Annotation of src/usr.bin/getopt/getopt.c, Revision 1.2
1.2 ! deraadt 1: /* $OpenBSD$ */
! 2:
1.1 deraadt 3: #ifndef lint
1.2 ! deraadt 4: static char rcsid[] = "$OpenBSD: getopt.c,v 1.1.1.1 1995/10/18 08:45:19 deraadt Exp $";
1.1 deraadt 5: #endif /* not lint */
6:
7: #include <stdio.h>
8:
9: main(argc, argv)
10: int argc;
11: char *argv[];
12: {
13: extern int optind;
14: extern char *optarg;
15: int c;
16: int status = 0;
17:
18: optind = 2; /* Past the program name and the option letters. */
19: while ((c = getopt(argc, argv, argv[1])) != EOF)
20: switch (c) {
21: case '?':
22: status = 1; /* getopt routine gave message */
23: break;
24: default:
25: if (optarg != NULL)
26: printf(" -%c %s", c, optarg);
27: else
28: printf(" -%c", c);
29: break;
30: }
31: printf(" --");
32: for (; optind < argc; optind++)
33: printf(" %s", argv[optind]);
34: printf("\n");
35: exit(status);
36: }