X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fconfig%2Fvlc_getopt.h;h=751f762319449fd90806f0f3c5f5139c2921c469;hb=12ade3e3bc975d5426ba4af155b7372c31093b31;hp=7229355dfa4d16fa85a94c066141ff7defa48fa9;hpb=2361280d58e8b8c52ff4b7afa9dded5bc112efea;p=vlc diff --git a/src/config/vlc_getopt.h b/src/config/vlc_getopt.h index 7229355dfa..751f762319 100644 --- a/src/config/vlc_getopt.h +++ b/src/config/vlc_getopt.h @@ -22,13 +22,13 @@ #ifndef VLC_GETOPT_H #define VLC_GETOPT_H 1 +typedef struct vlc_getopt_s +{ /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ + the argument value is returned here. */ - extern char *optarg; + char *arg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -42,16 +42,31 @@ Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ - extern int optind; + int ind; -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ +/* Set to an option character which was unrecognized. */ - extern int opterr; + int opt; -/* Set to an option character which was unrecognized. */ +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + + char *nextchar; + +/* Handle permutation of arguments. */ - extern int optopt; +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + + int first_nonopt; + int last_nonopt; + +} vlc_getopt_t; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector @@ -59,9 +74,8 @@ zero. The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. + false if the option does not take an argument, + true if the option requires an argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but @@ -74,23 +88,16 @@ one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ - struct option - { - const char *name; - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; - }; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - - extern int vlc_getopt_long(int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); +struct vlc_option +{ + const char *name; + bool has_arg; + int *flag; + int val; +}; + +extern int vlc_getopt_long(int argc, char *const *argv, const char *shortopts, + const struct vlc_option *longopts, int *longind, + vlc_getopt_t *restrict state); #endif /* VLC_GETOPT_H */