| www.delorie.com/gnu/docs/glibc/libc_537.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Argp provides a number of functions available to the user of argp (see section 25.3.5 Argp Parser Functions), mostly for producing error messages. These take as their first argument the state argument to the parser function. See section 25.3.5.3 Argp Parsing State.
state->err_stream and terminate the program
with exit (argp_err_exit_status). See section 25.3.2 Argp Global Variables.
argp_err_exit_status. See section 25.3.2 Argp Global Variables.
error, this
prints the program name and `:', the printf format string
fmt, and the appropriate following args. If it is non-zero, the
standard unix error text for errnum is printed. If status is
non-zero, it terminates the program with that value as its exit status.
The difference between argp_failure 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 are
passed to argp_parse. See section 25.3.7 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, and for the case where the program doesn't terminate, calls to any of these functions should be followed by code that returns the appropriate error code:
if (bad argument syntax)
{
argp_usage (state);
return EINVAL;
}
|
If a parser function will only be used when ARGP_NO_EXIT
is not set, the return may be omitted.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |