#ifndef WINGETOPT_H
#define WINGETOPT_H

#ifdef __cplusplus
extern "C" {
#endif

/* Globals shared between getopt() and getopt_long() */
extern char *optarg;
extern int   optind;
extern int   opterr;
extern int   optopt;

/* has_arg values for struct option */
#define no_argument        0
#define required_argument  1
#define optional_argument  2

/* Long-option descriptor passed to getopt_long() */
struct option {
    const char *name;       /* long option name (without "--") */
    int         has_arg;    /* no_argument / required_argument / optional_argument */
    int        *flag;       /* if non-NULL, set *flag = val and return 0 */
    int         val;        /* value to return (or store in *flag) */
};

int getopt(int argc, char *argv[], const char *optstring);

int getopt_long(int argc, char * const argv[], const char *optstring,
                const struct option *longopts, int *longindex);

#ifdef __cplusplus
}
#endif

#endif /* WINGETOPT_H */
