www.delorie.com/gnu/docs/glibc/libc_530.html   search  
 
Buy the book!


The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25.3.1 The argp_parse Function

The main interface to argp is the argp_parse function. In many cases, calling argp_parse is the only argument-parsing code needed in main. See section 25.1 Program Arguments.

Function: error_t argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags, int *arg_index, void *input)
The argp_parse function parses the arguments in argv, of length argc, using the argp parser argp. See section 25.3.3 Specifying Argp Parsers.

A value of zero is the same as a struct argpcontaining all zeros. flags is a set of flag bits that modify the parsing behavior. See section 25.3.7 Flags for argp_parse. input is passed through to the argp parser argp, and has meaning defined by argp. A typical usage is to pass a pointer to a structure which is used for specifying parameters to the parser and passing back the results.

Unless the ARGP_NO_EXIT or ARGP_NO_HELP flags are included in flags, calling argp_parse may result in the program exiting. This behavior is true if an error is detected, or when an unknown option is encountered. See section 25.6 Program Termination.

If arg_index is non-null, the index of the first unparsed option in argv is returned as a value.

The return value is zero for successful parsing, or an error code (see section 2.2 Error Codes) if an error is detected. Different argp parsers may return arbitrary error codes, but the standard error codes are: ENOMEM if a memory allocation error occurred, or EINVAL if an unknown option or option argument is encountered.

25.3.2 Argp Global Variables  Global argp parameters.
25.3.3 Specifying Argp Parsers  Defining parsers for use with argp_parse.
25.3.7 Flags for argp_parse  Flags that modify the behavior of argp_parse.
25.3.9 The argp_help Function  Printing help messages when not parsing.
25.3.11 Argp Examples  Simple examples of programs using argp.
25.3.12 Argp User Customization  Users may control the `--help' output format.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003