3 * This is an unpublished work copyright (c) 1998 HELIOS Software GmbH
4 * 30827 Garbsen, Germany
19 static int suboptind
= 1;
21 int getopt(int argc
, char *const argv
[], const char * optstring
)
27 if (suboptind
== optind
-1 && argv
[suboptind
][subopt
] != '\0') {
28 curopt
= (char *)argv
[suboptind
];
30 curopt
= (char *)argv
[optind
];
31 if (curopt
== NULL
|| curopt
[0] != '-' || strcmp(curopt
, "-") == 0)
36 if (strcmp(curopt
, "--") == 0)
40 if ((p
= strchr(optstring
, curopt
[cursubopt
])) == NULL
) {
41 optopt
= curopt
[cursubopt
];
43 fprintf(stderr
, "%s: illegal option -- %c\n", argv
[0], optopt
);
47 if (curopt
[cursubopt
+1] != '\0') {
48 optarg
= curopt
+cursubopt
+1;
52 if (argv
[optind
] == NULL
) {
55 fprintf(stderr
, "%s: option requires an argument -- %c\n", argv
[0], optopt
);
56 if (*optstring
== ':')
60 optarg
= argv
[optind
++];