Update copyright notices with scripts/update-copyrights
[glibc.git] / manual / examples / argp-ex2.c
blob6f77638e595c7d948f1ffcd918341da06f1230b1
1 /* Argp example #2 -- a pretty minimal program using argp
2 Copyright (C) 1991-2014 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, if not, see <http://www.gnu.org/licenses/>.
18 /* This program doesn't use any options or arguments, but uses
19 argp to be compliant with the GNU standard command line
20 format.
22 In addition to making sure no arguments are given, and
23 implementing a --help option, this example will have a
24 --version option, and will put the given documentation string
25 and bug address in the --help output, as per GNU standards.
27 The variable ARGP contains the argument parser specification;
28 adding fields to this structure is the way most parameters are
29 passed to argp_parse (the first three fields are usually used,
30 but not in this small program). There are also two global
31 variables that argp knows about defined here,
32 ARGP_PROGRAM_VERSION and ARGP_PROGRAM_BUG_ADDRESS (they are
33 global variables because they will almost always be constant
34 for a given program, even if it uses different argument
35 parsers for various tasks). */
37 #include <stdlib.h>
38 #include <argp.h>
40 const char *argp_program_version =
41 "argp-ex2 1.0";
42 const char *argp_program_bug_address =
43 "<bug-gnu-utils@@gnu.org>";
45 /* Program documentation. */
46 static char doc[] =
47 "Argp example #2 -- a pretty minimal program using argp";
49 /* Our argument parser. The @code{options}, @code{parser}, and
50 @code{args_doc} fields are zero because we have neither options or
51 arguments; @code{doc} and @code{argp_program_bug_address} will be
52 used in the output for @samp{--help}, and the @samp{--version}
53 option will print out @code{argp_program_version}. */
54 static struct argp argp = { 0, 0, 0, doc };
56 int
57 main (int argc, char **argv)
59 argp_parse (&argp, argc, argv, 0, 0, 0);
60 exit (0);