2.9
[glibc/nacl-glibc.git] / manual / examples / argp-ex2.c
blob313c6819a2ec107c2568cf81aaf647df73281bbe
1 /* Argp example #2 -- a pretty minimal program using argp */
3 /* This program doesn't use any options or arguments, but uses
4 argp to be compliant with the GNU standard command line
5 format.
7 In addition to making sure no arguments are given, and
8 implementing a --help option, this example will have a
9 --version option, and will put the given documentation string
10 and bug address in the --help output, as per GNU standards.
12 The variable ARGP contains the argument parser specification;
13 adding fields to this structure is the way most parameters are
14 passed to argp_parse (the first three fields are usually used,
15 but not in this small program). There are also two global
16 variables that argp knows about defined here,
17 ARGP_PROGRAM_VERSION and ARGP_PROGRAM_BUG_ADDRESS (they are
18 global variables because they will almost always be constant
19 for a given program, even if it uses different argument
20 parsers for various tasks). */
22 #include <argp.h>
24 const char *argp_program_version =
25 "argp-ex2 1.0";
26 const char *argp_program_bug_address =
27 "<bug-gnu-utils@@gnu.org>";
29 /* Program documentation. */
30 static char doc[] =
31 "Argp example #2 -- a pretty minimal program using argp";
33 /* Our argument parser. The @code{options}, @code{parser}, and
34 @code{args_doc} fields are zero because we have neither options or
35 arguments; @code{doc} and @code{argp_program_bug_address} will be
36 used in the output for @samp{--help}, and the @samp{--version}
37 option will print out @code{argp_program_version}. */
38 static struct argp argp = { 0, 0, 0, doc };
40 int main (int argc, char **argv)
42 argp_parse (&argp, argc, argv, 0, 0, 0);
43 exit (0);