Remove hacks which are not anymore needed since we now require Libgcrypt 1.4
[gnupg.git] / jnlib / argparse.h
bloba0ce43a43ca50865ce0936fe4ad02cfbcd0702b0
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;
58 /* Error values. */
59 #define ARGPARSE_IS_ARG (-1)
60 #define ARGPARSE_INVALID_OPTION (-2)
61 #define ARGPARSE_MISSING_ARG (-3)
62 #define ARGPARSE_KEYWORD_TOO_LONG (-4)
63 #define ARGPARSE_READ_ERROR (-5)
64 #define ARGPARSE_UNEXPECTED_ARG (-6)
65 #define ARGPARSE_INVALID_COMMAND (-7)
66 #define ARGPARSE_AMBIGUOUS_OPTION (-8)
67 #define ARGPARSE_AMBIGUOUS_COMMAND (-9)
68 #define ARGPARSE_INVALID_ALIAS (-10)
69 #define ARGPARSE_OUT_OF_CORE (-11)
72 int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
73 int optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
74 ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
75 void usage( int level );
76 const char *strusage( int level );
77 void set_strusage( const char *(*f)( int ) );
79 #endif /*LIBJNLIB_ARGPARSE_H*/