1 | /* cmdline.h |
---|
2 | * Wrapper for GNU getopt which deals with standard options |
---|
3 | * Copyright (C) 1998-2001 Olly Betts |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU General Public License as published by |
---|
7 | * the Free Software Foundation; either version 2 of the License, or |
---|
8 | * (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License |
---|
16 | * along with this program; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef CMDLINE_H |
---|
21 | # define CMDLINE_H |
---|
22 | |
---|
23 | #ifdef __cplusplus |
---|
24 | extern "C" { |
---|
25 | #endif |
---|
26 | |
---|
27 | #include "getopt.h" |
---|
28 | |
---|
29 | struct help_msg { |
---|
30 | int opt; |
---|
31 | const char *msg; |
---|
32 | }; |
---|
33 | |
---|
34 | /* give -1 for max_args_ if there's no limit */ |
---|
35 | void cmdline_init(int argc_, char *const *argv_, const char *shortopts_, |
---|
36 | const struct option *longopts_, int *longind_, |
---|
37 | const struct help_msg *help_, |
---|
38 | int min_args_, int max_args_); |
---|
39 | /* if args not NULL, use instead of auto-generated FILE args */ |
---|
40 | /* if extra not NULL, display as extra blurb at end */ |
---|
41 | void cmdline_set_syntax_message(const char *args, const char *extra); |
---|
42 | int cmdline_getopt(void); |
---|
43 | void cmdline_help(void); |
---|
44 | void cmdline_version(void); |
---|
45 | void cmdline_syntax(void); |
---|
46 | void cmdline_too_few_args(void); |
---|
47 | void cmdline_too_many_args(void); |
---|
48 | int cmdline_int_arg(void); |
---|
49 | double cmdline_double_arg(void); |
---|
50 | |
---|
51 | #define HLP_ENCODELONG(N) (-(N + 1)) |
---|
52 | #define HLP_DECODELONG(N) (-(N + 1)) |
---|
53 | #define HLP_ISLONG(N) ((N) <= 0) |
---|
54 | #define HLP_HELP 30000 |
---|
55 | #define HLP_VERSION 30001 |
---|
56 | |
---|
57 | #ifdef __cplusplus |
---|
58 | } |
---|
59 | #endif |
---|
60 | |
---|
61 | #endif |
---|