X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=argpar%2Fargpar.h;h=1fb8835f67f6df274c1f1d799f1ad2133f3f0ba0;hb=2af370d0a1dd610f66232e2bacc75e4b40ffca0d;hp=c6f79cf64f6e5ad445464ab7dd1cb02b5c52d9d4;hpb=37bb2b1fe8e07b4c2cb9c31d4f2c4ffdb56e3e10;p=argpar.git diff --git a/argpar/argpar.h b/argpar/argpar.h index c6f79cf..1fb8835 100644 --- a/argpar/argpar.h +++ b/argpar/argpar.h @@ -18,8 +18,8 @@ * * Iterator API: * Create a parsing iterator with argpar_iter_create(), then - * repeatedly call argpar_iter_parse_next() to access the parsing - * results, until one of: + * repeatedly call argpar_iter_next() to access the parsing results, + * until one of: * * * There are no more arguments. * @@ -144,7 +144,7 @@ enum argpar_item_type { ARGPAR_ITEM_TYPE_NON_OPT, }; -/* Parsing item, as created by argpar_parse() and argpar_iter_parse_next() */ +/* Parsing item, as created by argpar_parse() and argpar_iter_next() */ struct argpar_item; /* @@ -286,8 +286,8 @@ void argpar_parse_ret_fini(struct argpar_parse_ret *ret); * `*argv` and `*descrs` must NOT change for the lifetime of the * returned iterator (until you call argpar_iter_destroy()). * - * Call argpar_iter_parse_next() with the returned iterator to obtain - * the next parsing result (item). + * Call argpar_iter_next() with the returned iterator to obtain the next + * parsing result (item). */ ARGPAR_HIDDEN struct argpar_iter *argpar_iter_create(unsigned int argc, @@ -301,35 +301,58 @@ ARGPAR_HIDDEN void argpar_iter_destroy(struct argpar_iter *iter); /* - * Return type of argpar_iter_parse_next(). + * Return type of argpar_iter_next(). */ -enum argpar_iter_parse_next_status { - ARGPAR_ITER_PARSE_NEXT_STATUS_OK, - ARGPAR_ITER_PARSE_NEXT_STATUS_END, - ARGPAR_ITER_PARSE_NEXT_STATUS_ERROR_UNKNOWN_OPT, - ARGPAR_ITER_PARSE_NEXT_STATUS_ERROR, +enum argpar_iter_next_status { + ARGPAR_ITER_NEXT_STATUS_OK, + ARGPAR_ITER_NEXT_STATUS_END, + ARGPAR_ITER_NEXT_STATUS_ERROR_UNKNOWN_OPT, + ARGPAR_ITER_NEXT_STATUS_ERROR_MISSING_OPT_ARG, + ARGPAR_ITER_NEXT_STATUS_ERROR_INVALID_ARG, + ARGPAR_ITER_NEXT_STATUS_ERROR_UNEXPECTED_OPT_ARG, + ARGPAR_ITER_NEXT_STATUS_ERROR_MEMORY, }; /* * Parses and returns the next item from `iter`. * - * On success, this function sets `*item` to an item which describes the - * next option or non-option argument and returns - * `ARGPAR_ITER_PARSE_NEXT_STATUS_OK`. Destroy `*item` with - * argpar_item_destroy(). + * On success, this function: + * + * * Sets `*item` to a parsing item which describes the next option + * or non-option argument. + * + * Destroy `*item` with argpar_item_destroy(). + * + * * Returns `ARGPAR_ITER_NEXT_STATUS_OK`. * * If there are no more items to return, this function returns - * `ARGPAR_ITER_PARSE_NEXT_STATUS_END`. + * `ARGPAR_ITER_NEXT_STATUS_END`. + * + * On failure, this function: + * + * * Returns one of: + * + * `ARGPAR_ITER_NEXT_STATUS_ERROR_UNKNOWN_OPT`: + * Unknown option (not found in `descrs` as passed to + * argpar_iter_create() to create `iter`). + * + * `ARGPAR_ITER_NEXT_STATUS_ERROR_MISSING_OPT_ARG`: + * Missing option argument. + * + * `ARGPAR_ITER_NEXT_STATUS_ERROR_INVALID_ARG`: + * Invalid argument. + * + * `ARGPAR_ITER_NEXT_STATUS_ERROR_UNEXPECTED_OPT_ARG`: + * Unexpected option argument. * - * On failure (status codes - * `ARGPAR_ITER_PARSE_NEXT_STATUS_ERROR_UNKNOWN_OPT` and - * `ARGPAR_ITER_PARSE_NEXT_STATUS_ERROR`), this function sets `*error`, - * if not `NULL`, to a descriptive error string. Free `*error` with - * free(). + * `ARGPAR_ITER_NEXT_STATUS_ERROR_MEMORY`: + * Memory error. * - * Create an argument parsing iterator with argpar_iter_create(). + * * Except for the `ARGPAR_ITER_NEXT_STATUS_ERROR_MEMORY` status, + * sets `*error`, if not `NULL`, to a descriptive error string. + * Free `*error` with free(). */ -enum argpar_iter_parse_next_status argpar_iter_parse_next( +enum argpar_iter_next_status argpar_iter_next( struct argpar_iter *iter, const struct argpar_item **item, char **error); @@ -342,7 +365,7 @@ ARGPAR_HIDDEN unsigned int argpar_iter_get_ingested_orig_args(const struct argpar_iter *iter); /* - * Destroys `item`, as created by argpar_iter_parse_next(). + * Destroys `item`, as created by argpar_iter_next(). */ ARGPAR_HIDDEN void argpar_item_destroy(const struct argpar_item *item);