1 #define SUBGETOPTNOSHORT
4 #define sgopt subgetopt
5 #define optind subgetoptind
6 #define optpos subgetoptpos
7 #define optarg subgetoptarg
8 #define optproblem subgetoptproblem
9 #define optdone subgetoptdone
15 int optdone
= SUBGETOPTDONE
;
17 int sgopt(int argc
,char **argv
,const char *opts
)
23 if (!argv
|| (optind
>= argc
) || !argv
[optind
]) return optdone
;
24 if (optpos
&& !argv
[optind
][optpos
]) {
27 if ((optind
>= argc
) || !argv
[optind
]) return optdone
;
30 if (argv
[optind
][0] != '-') return optdone
;
33 if ((c
== '-') || (c
== 0)) {
38 /* otherwise c is reassigned below */
40 c
= argv
[optind
][optpos
];
46 optarg
= argv
[optind
] + optpos
;
50 optarg
= argv
[optind
];
51 if ((optind
>= argc
) || !optarg
) { /* argument past end */