2007-10-31 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / jnlib / argparse.h
blob7972438b88fd65c3a370f6a2c003c97b1ee9e766
1 /* argparse.h
2 * Copyright (C) 1998,1999,2000,2001,2006 Free Software Foundation, Inc.
4 * This file is part of JNLIB.
6 * JNLIB is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * JNLIB is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIBJNLIB_ARGPARSE_H
21 #define LIBJNLIB_ARGPARSE_H
23 #include <stdio.h>
24 #include "types.h"
26 typedef struct {
27 int *argc; /* pointer to argc (value subject to change) */
28 char ***argv; /* pointer to argv (value subject to change) */
29 unsigned flags; /* Global flags (DO NOT CHANGE) */
30 int err; /* print error about last option */
31 /* 1 = warning, 2 = abort */
32 int r_opt; /* return option */
33 int r_type; /* type of return value (0 = no argument found)*/
34 union {
35 int ret_int;
36 long ret_long;
37 unsigned long ret_ulong;
38 char *ret_str;
39 } r; /* Return values */
40 struct {
41 int idx;
42 int inarg;
43 int stopped;
44 const char *last;
45 void *aliases;
46 const void *cur_alias;
47 } internal; /* DO NOT CHANGE */
48 } ARGPARSE_ARGS;
50 typedef struct {
51 int short_opt;
52 const char *long_opt;
53 unsigned flags;
54 const char *description; /* optional option description */
55 } ARGPARSE_OPTS;
59 int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
60 int optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
61 ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
62 void usage( int level );
63 const char *strusage( int level );
64 void set_strusage( const char *(*f)( int ) );
66 #endif /*LIBJNLIB_ARGPARSE_H*/