1 | #ifndef GETOPT_H_ 2 | #define GETOPT_H_ 3 | 4 | typedef struct { 5 | int optind; /* index into parent argv vector */ 6 | int optopt; /* character checked for validity */ 7 | int optreset; /* reset getopt */ 8 | char *optarg; /* argument associated with option */ 9 | char *place; /* option letter processing */ 10 | } getopt_state_t; 11 | 12 | #define BADCH (int)'?' 13 | #define BADARG (int)':' 14 | #define EMSG "" 15 | 16 | 17 | getopt_state_t *mg_new(int optind); 18 | int mg_getopt( int nargc, 19 | char * const *nargv, 20 | const char *ostr, 21 | getopt_state_t *state); 22 | 23 | #endif /* GETOPT_H_ */