X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Fargpar-utils%2Fargpar-utils.h;h=b56ce4b1b1ccf6aa0afa75a57693495252e3ae89;hb=f618151398055a753d5c5fb519d98a166ddde09f;hp=358c5f64bff21101f8acea35a310210d559c76fe;hpb=ea76a8bbde6896bddfa656627e8f12e0b9f55a5e;p=lttng-tools.git diff --git a/src/common/argpar-utils/argpar-utils.h b/src/common/argpar-utils/argpar-utils.h index 358c5f64b..b56ce4b1b 100644 --- a/src/common/argpar-utils/argpar-utils.h +++ b/src/common/argpar-utils/argpar-utils.h @@ -14,11 +14,14 @@ #include #include +#define WHILE_PARSING_ARG_N_ARG_FMT "While parsing argument #%d (`%s`): " + enum parse_next_item_status { PARSE_NEXT_ITEM_STATUS_OK = 0, PARSE_NEXT_ITEM_STATUS_END = 1, PARSE_NEXT_ITEM_STATUS_ERROR = -1, + PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY = -2, }; /* @@ -35,13 +38,20 @@ enum parse_next_item_status * On error, print a descriptive error message and return * PARSE_NEXT_ITEM_STATUS_ERROR. If `context_fmt` is non-NULL, it is formatted * using the following arguments and prepended to the error message. + * Add `argc_offset` to the argument index mentioned in the error message. * * If `unknown_opt_is_error` is true, an unknown option is considered an error. * Otherwise, it is considered as the end of the argument list. + * + * If `error_out` is given and PARSE_NEXT_ITEM_STATUS_ERROR is returned, set + * `*error_out` to the argpar_error object corresponding to the error. The + * caller must free the object with `argpar_error_destroy`. */ -LTTNG_HIDDEN ATTR_FORMAT_PRINTF(5, 6) +LTTNG_HIDDEN enum parse_next_item_status parse_next_item(struct argpar_iter *iter, - const struct argpar_item **item, const char **argv, - bool unknown_opt_is_error, const char *context_fmt, ...); + const struct argpar_item **item, int argc_offset, + const char **argv, bool unknown_opt_is_error, + const struct argpar_error **error_out, + const char *context_fmt, ...); #endif