getopt

William Davidsen davidsen at sungod.crd.ge.com
Thu Jun 15 03:16:41 AEST 1989


I have a program which needs an option which may have either a default
value or a specific value. ie. "-c" or "-c4" would be typical. I would
like to use getopt to read the values.

The question: is there a tricky way to use the existing getopt, or
do I have to make an extended version? I would like to use the existing
interface if possible.

  In the meantime, I took a P.D. version and added another option
qualifier, #, indicating an optional numeric argument. The logic
requires that the numeric value follow the option inducer without a
space, as "-c2" but not "-c 2". I set optarg to NULL if no value is
specified. I renamed the procedure, obviously, to prevent calling the
common version if the software is ported. Since the character # could be
an option in some software, my new version is not a superset.

  I have seen references to "eoptarg" in this group, but can't find a
man entry for it on SunOS or Ultrix, so I assume it's either proprietary
or P.D. we don't have it.
	bill davidsen		(davidsen at crdos1.crd.GE.COM)
  {uunet | philabs}!crdgw1!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list