Argp provides a number of functions for the user of argp parser functions (see section Argp Parser Functions), mostly for producing error messages. These take as their first argument the state argument to the parser function (see section Argp Parsing State).
state->err_stream
and terminate the program
with exit (argp_err_exit_status)
(see section Argp Global Variables).
argp_err_exit_status
(see section Argp Global Variables).
error
,
print the printf format string fmt and following args, preceded by
the program name and `:', and followed by the standard unix error
text for errnum if it is non-zero; then if status is
non-zero, terminate the program with that as its exit status.
The difference between this function and argp_error
is that
argp_error
is for parsing errors, whereas
argp_failure
is for other problems that occur during parsing but
don't reflect a syntactic problem with the input--such as illegal
values for options, bad phase of the moon, etc.
argp_help
Function.
Error output is sent to state->err_stream
, and the program
name printed is state->name
.
The output or program termination behavior of these functions may be
suppressed if the ARGP_NO_EXIT
or ARGP_NO_ERRS
flags,
respectively, were passed to argp_parse
. See section Flags for argp_parse
.
This behavior is useful if an argp parser is exported for use by other programs (e.g., by a library), and may be used in a context where it is not desirable to terminate the program in response to parsing errors. In argp parsers intended for such general use, calls to any of these functions should be followed by code return of an appropriate error code for the case where the program doesn't terminate; for example:
if (bad argument syntax) { argp_usage (state); return EINVAL; }
If it's known that a parser function will only be used when
ARGP_NO_EXIT
is not set, the return may be omitted.
Go to the first, previous, next, last section, table of contents.