| <html lang="en"> |
| <head> |
| <title>Argp Parsing State - The GNU C Library</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="The GNU C Library"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Argp-Parser-Functions.html#Argp-Parser-Functions" title="Argp Parser Functions"> |
| <link rel="prev" href="Argp-Special-Keys.html#Argp-Special-Keys" title="Argp Special Keys"> |
| <link rel="next" href="Argp-Helper-Functions.html#Argp-Helper-Functions" title="Argp Helper Functions"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| This file documents the GNU C library. |
| |
| This is Edition 0.12, last updated 2007-10-27, |
| of `The GNU C Library Reference Manual', for version |
| 2.8 (Sourcery G++ Lite 2011.03-41). |
| |
| Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, |
| 2003, 2007, 2008, 2010 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Free Software Needs Free Documentation'' |
| and ``GNU Lesser General Public License'', the Front-Cover texts being |
| ``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A |
| copy of the license is included in the section entitled "GNU Free |
| Documentation License". |
| |
| (a) The FSF's Back-Cover Text is: ``You have the freedom to |
| copy and modify this GNU manual. Buying copies from the FSF |
| supports it in developing GNU and promoting software freedom.''--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| <link rel="stylesheet" type="text/css" href="../cs.css"> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Argp-Parsing-State"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Argp-Helper-Functions.html#Argp-Helper-Functions">Argp Helper Functions</a>, |
| Previous: <a rel="previous" accesskey="p" href="Argp-Special-Keys.html#Argp-Special-Keys">Argp Special Keys</a>, |
| Up: <a rel="up" accesskey="u" href="Argp-Parser-Functions.html#Argp-Parser-Functions">Argp Parser Functions</a> |
| <hr> |
| </div> |
| |
| <h5 class="subsubsection">25.3.5.3 Argp Parsing State</h5> |
| |
| <p>The third argument to argp parser functions (see <a href="Argp-Parser-Functions.html#Argp-Parser-Functions">Argp Parser Functions</a>) is a pointer to a <code>struct argp_state</code>, which contains |
| information about the state of the option parsing. |
| |
| <!-- argp.h --> |
| <!-- GNU --> |
| <div class="defun"> |
| — Data Type: <b>struct argp_state</b><var><a name="index-struct-argp_005fstate-3065"></a></var><br> |
| <blockquote><p>This structure has the following fields, which may be modified as noted: |
| |
| <dl> |
| <dt><code>const struct argp *const root_argp</code><dd>The top level argp parser being parsed. Note that this is often |
| <em>not</em> the same <code>struct argp</code> passed into <code>argp_parse</code> by |
| the invoking program. See <a href="Argp.html#Argp">Argp</a>. It is an internal argp parser that |
| contains options implemented by <code>argp_parse</code> itself, such as |
| ‘<samp><span class="samp">--help</span></samp>’. |
| |
| <br><dt><code>int argc</code><dt><code>char **argv</code><dd>The argument vector being parsed. This may be modified. |
| |
| <br><dt><code>int next</code><dd>The index in <code>argv</code> of the next argument to be parsed. This may be |
| modified. |
| |
| <p>One way to consume all remaining arguments in the input is to set |
| <var>state</var><code>->next = </code><var>state</var><code>->argc</code>, perhaps after recording |
| the value of the <code>next</code> field to find the consumed arguments. The |
| current option can be re-parsed immediately by decrementing this field, |
| then modifying <var>state</var><code>->argv[</code><var>state</var><code>->next]</code> to reflect |
| the option that should be reexamined. |
| |
| <br><dt><code>unsigned flags</code><dd>The flags supplied to <code>argp_parse</code>. These may be modified, although |
| some flags may only take effect when <code>argp_parse</code> is first |
| invoked. See <a href="Argp-Flags.html#Argp-Flags">Argp Flags</a>. |
| |
| <br><dt><code>unsigned arg_num</code><dd>While calling a parsing function with the <var>key</var> argument |
| <code>ARGP_KEY_ARG</code>, this represents the number of the current arg, |
| starting at 0. It is incremented after each <code>ARGP_KEY_ARG</code> call |
| returns. At all other times, this is the number of <code>ARGP_KEY_ARG</code> |
| arguments that have been processed. |
| |
| <br><dt><code>int quoted</code><dd>If non-zero, the index in <code>argv</code> of the first argument following a |
| special ‘<samp><span class="samp">--</span></samp>’ argument. This prevents anything that follows from |
| being interpreted as an option. It is only set after argument parsing |
| has proceeded past this point. |
| |
| <br><dt><code>void *input</code><dd>An arbitrary pointer passed in from the caller of <code>argp_parse</code>, in |
| the <var>input</var> argument. |
| |
| <br><dt><code>void **child_inputs</code><dd>These are values that will be passed to child parsers. This vector will |
| be the same length as the number of children in the current parser. Each |
| child parser will be given the value of |
| <var>state</var><code>->child_inputs[</code><var>i</var><code>]</code> as <em>its</em> |
| <var>state</var><code>->input</code> field, where <var>i</var> is the index of the child |
| in the this parser's <code>children</code> field. See <a href="Argp-Children.html#Argp-Children">Argp Children</a>. |
| |
| <br><dt><code>void *hook</code><dd>For the parser function's use. Initialized to 0, but otherwise ignored |
| by argp. |
| |
| <br><dt><code>char *name</code><dd>The name used when printing messages. This is initialized to |
| <code>argv[0]</code>, or <code>program_invocation_name</code> if <code>argv[0]</code> is |
| unavailable. |
| |
| <br><dt><code>FILE *err_stream</code><dt><code>FILE *out_stream</code><dd>The stdio streams used when argp prints. Error messages are printed to |
| <code>err_stream</code>, all other output, such as ‘<samp><span class="samp">--help</span></samp>’ output) to |
| <code>out_stream</code>. These are initialized to <code>stderr</code> and |
| <code>stdout</code> respectively. See <a href="Standard-Streams.html#Standard-Streams">Standard Streams</a>. |
| |
| <br><dt><code>void *pstate</code><dd>Private, for use by the argp implementation. |
| </dl> |
| </p></blockquote></div> |
| |
| </body></html> |
| |