2 * This is an unpublished work copyright (c) 1998 HELIOS Software GmbH
3 * 30827 Garbsen, Germany
18 static int suboptind
= 1;
20 int getopt(int argc
, char *const argv
[], const char * optstring
)
26 if (suboptind
== optind
-1 && argv
[suboptind
][subopt
] != '\0') {
27 curopt
= (char *)argv
[suboptind
];
29 curopt
= (char *)argv
[optind
];
30 if (curopt
== NULL
|| curopt
[0] != '-' || strcmp(curopt
, "-") == 0)
35 if (strcmp(curopt
, "--") == 0)
39 if ((p
= strchr(optstring
, curopt
[cursubopt
])) == NULL
) {
40 optopt
= curopt
[cursubopt
];
42 fprintf(stderr
, "%s: illegal option -- %c\n", argv
[0], optopt
);
46 if (curopt
[cursubopt
+1] != '\0') {
47 optarg
= curopt
+cursubopt
+1;
51 if (argv
[optind
] == NULL
) {
54 fprintf(stderr
, "%s: option requires an argument -- %c\n", argv
[0], optopt
);
55 if (*optstring
== ':')
59 optarg
= argv
[optind
++];