Path: utzoo!mnetor!uunet!husc6!cca!mirror!datacube!ftw From: ftw@datacube.UUCP Newsgroups: comp.unix.wizards Subject: Re: Command interfaces Message-ID: <106600027@datacube> Date: 29 Dec 87 22:37:00 GMT References: <432@cresswell.quintus.UUCP> Lines: 58 Nf-ID: #R:cresswell.quintus.UUCP:432:datacube:106600027:000:2334 Nf-From: datacube.UUCP!ftw Dec 29 17:37:00 1987 robf2@pyuxf.UUCP writes: > In article <106600024@datacube>, ftw@datacube.UUCP writes: > + > + aglew@ccvaxa.UUCP writers: > + > + > + > Well, in the days before I came to UNIX (using Whitesmith's on a PDP with ^^^^^^^^^^^^ > + > RT-11, if I remember correctly), I used to do: > + > + > + > + Gee, why didn't you use getflags() ? > + > Well, I guess I'm stupid because never heard of getflags(). Nor has my > Unix (V.2) manual. So, gee, why don't you enlighten us all ? Whitesmiths wrote a function called getflags() which they include in the libraries that they ship along with their compilers. It's much like a very specialized version of sscanf(): It takes the addresses of argc and argv, a format string, and the addresses of variables to fill. The format string can specify booleans, numeric fields, single characters, and strings. getflags() will rattle through argv collecting the flags and filling the variables (flags may be specified in any order when a program is invoked; they need not be in the order given in the format string), and update argc and argv accoring to the number of items matched. It also does things like automatic conversion of hex and octal numbers. It is not super picky about whitespace between a flag and its value. getflags() has advantages over getopt() in my opinion: You don't have to write a loop around it, you don't have to declare a couple of externs, and it provides a more uniform way of reporting mal-formed command line args (it issues it's own message regarding usage in this case). Whitesmiths is pushing (I don't know exctly how hard) to have getflags() become more of a standard. They may also release a copy of that function into the Public Domain if they can get it to become a standard. It would be nice to see a getflags() or something similar to it become standard. I think that getopt() was a good first step, but it's kind of clunky to use. > Rob Fair Feel more enlightened, Rob? ;-) ;-) > ihnp4!pyuxww!pyuxf!robf2 Farrell T. Woods Datacube Inc. Systems / Software Group 4 Dearborn Rd. Peabody, Ma 01960 VOICE: 617-535-6644; FAX: (617) 535-5643; TWX: (710) 347-0125 INTERNET: ftw@datacube.COM UUCP: {rutgers, ihnp4, mirror}!datacube!ftw "OS/2 -- Half an operating system"