X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=parse-options.h;h=5199950c006df4625355ce227970cc3e8a72ed41;hb=0bb3a0ba9e3cbb283a747e4736bcf7484d076a73;hp=4ee443dafe146f05d1fe2a46e7e39ca6fdd608f9;hpb=179c94b24ae87e28328f9b311489417b66bd62c9;p=git.git diff --git a/parse-options.h b/parse-options.h index 4ee443daf..5199950c0 100644 --- a/parse-options.h +++ b/parse-options.h @@ -20,6 +20,7 @@ enum parse_opt_type { enum parse_opt_flags { PARSE_OPT_KEEP_DASHDASH = 1, PARSE_OPT_STOP_AT_NON_OPTION = 2, + PARSE_OPT_KEEP_ARGV0 = 4, }; enum parse_opt_option_flags { @@ -27,6 +28,7 @@ enum parse_opt_option_flags { PARSE_OPT_NOARG = 2, PARSE_OPT_NONEG = 4, PARSE_OPT_HIDDEN = 8, + PARSE_OPT_LASTARG_DEFAULT = 16, }; struct option; @@ -111,6 +113,40 @@ extern int parse_options(int argc, const char **argv, extern NORETURN void usage_with_options(const char * const *usagestr, const struct option *options); +/*----- incremantal advanced APIs -----*/ + +enum { + PARSE_OPT_HELP = -1, + PARSE_OPT_DONE, + PARSE_OPT_UNKNOWN, +}; + +/* + * It's okay for the caller to consume argv/argc in the usual way. + * Other fields of that structure are private to parse-options and should not + * be modified in any way. + */ +struct parse_opt_ctx_t { + const char **argv; + const char **out; + int argc, cpidx; + const char *opt; + int flags; +}; + +extern int parse_options_usage(const char * const *usagestr, + const struct option *opts); + +extern void parse_options_start(struct parse_opt_ctx_t *ctx, + int argc, const char **argv, int flags); + +extern int parse_options_step(struct parse_opt_ctx_t *ctx, + const struct option *options, + const char * const usagestr[]); + +extern int parse_options_end(struct parse_opt_ctx_t *ctx); + + /*----- some often used options -----*/ extern int parse_opt_abbrev_cb(const struct option *, const char *, int); extern int parse_opt_approxidate_cb(const struct option *, const char *, int); @@ -123,4 +159,6 @@ extern int parse_opt_approxidate_cb(const struct option *, const char *, int); "use digits to display SHA-1s", \ PARSE_OPT_OPTARG, &parse_opt_abbrev_cb, 0 } +extern const char *parse_options_fix_filename(const char *prefix, const char *file); + #endif