2007-05-19 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / jnlib / argparse.h
blob3528d815694a2663e4e5bbc81a76cf32dc6b58dc
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 2.1 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
22 #ifndef LIBJNLIB_ARGPARSE_H
23 #define LIBJNLIB_ARGPARSE_H
25 #include <stdio.h>
26 #include "types.h"
28 typedef struct {
29 int *argc; /* pointer to argc (value subject to change) */
30 char ***argv; /* pointer to argv (value subject to change) */
31 unsigned flags; /* Global flags (DO NOT CHANGE) */
32 int err; /* print error about last option */
33 /* 1 = warning, 2 = abort */
34 int r_opt; /* return option */
35 int r_type; /* type of return value (0 = no argument found)*/
36 union {
37 int ret_int;
38 long ret_long;
39 unsigned long ret_ulong;
40 char *ret_str;
41 } r; /* Return values */
42 struct {
43 int idx;
44 int inarg;
45 int stopped;
46 const char *last;
47 void *aliases;
48 const void *cur_alias;
49 } internal; /* DO NOT CHANGE */
50 } ARGPARSE_ARGS;
52 typedef struct {
53 int short_opt;
54 const char *long_opt;
55 unsigned flags;
56 const char *description; /* optional option description */
57 } ARGPARSE_OPTS;
61 int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
62 int optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
63 ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
64 void usage( int level );
65 const char *strusage( int level );
66 void set_strusage( const char *(*f)( int ) );
68 #endif /*LIBJNLIB_ARGPARSE_H*/