2 ** This is part of a changed public domain getopt implementation that
3 ** had the following text on top:
5 ** I got this off net.sources from Henry Spencer.
6 ** It is a public domain getopt(3) like in System V.
7 ** I have made the following modifications:
9 ** A test main program was added, ifdeffed by GETOPT.
10 ** This main program is a public domain implementation
11 ** of the getopt(1) program like in System V. The getopt
12 ** program can be used to standardize shell option handling.
13 ** e.g. cc -DGETOPT getopt.c -o getopt
25 int main (int argc, char **argv)
27 char *optstring = argv[1];
29 char *argv0 = argv[0];
38 fprintf (stderr, "Usage: %s optstring args\n", argv0);
44 while ((C = getopt (argc, argv, optstring)) != EOF) {
48 opi = strchr (optstring, C);
49 if (opi && opi[1] == ARGCH)
51 printf ("\"%s\" ", optarg);
55 printf ("%s", ENDARGS);
57 printf (" \"%s\"", argv[optind++]);