Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!crdgw1!sungod!davidsen From: davidsen@sungod.crd.ge.com (William Davidsen) Newsgroups: comp.lang.c Subject: getopt Message-ID: <782@crdgw1.crd.ge.com> Date: 14 Jun 89 17:16:41 GMT Sender: news@crdgw1.crd.ge.com Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric Corp. R&D, Schenectady, NY Lines: 22 References: 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@crdos1.crd.GE.COM) {uunet | philabs}!crdgw1!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me