NAME ^

longopt.c - Command-line option parsing

DESCRIPTION ^

This is used by parrot.

Functions ^

PARROT_API int longopt_get(PARROT_INTERP, int argc, NOTNULL(char *argv[]), ARGIN(const struct longopt_opt_decl options[]), NOTNULL(struct longopt_opt_info *info_buf))

Gets long or short options, specified in options[] (see docs/dev/longopt.dev).

Call it iteratively with the same info_buf until it returns 0 or -1.

0 means you have reached the end of options.

-1 means a parse error, with error put in info_buf->opt_error.

Any other value is a valid option identifier.

static int longopt_get_longopt(PARROT_INTERP, int argc, NOTNULL(char *argv[]), ARGIN(const struct longopt_opt_decl options[]), NOTNULL(struct longopt_opt_info *info_buf))

Find the option identifier of a long option.

Fill info_buf appropriately, and return the option identifier.

argv[info_buf-opt_index]> is guaranteed to have at least three characters and start with --.

static int longopt_get_shortopt(PARROT_INTERP, int argc, NOTNULL(char *argv[]), ARGIN(const struct longopt_opt_decl options[]), NOTNULL(struct longopt_opt_info *info_buf))

Find the option identifier of the next short option.

This next short option may be in the middle of a bundle (-abcd), and info_buf->_shortopt_pos maintains a pointer into that bundle.

argv[info_buf->opt_index] is guaranteed to be at least two characters long and start with a dash.

SEE ALSO ^

include/parrot/longopt.h and docs/dev/longopt.dev.


parrot