blob: a87fa4a6c3f326b1c623ab48ef83a98bb740e5c6 [file] [log] [blame]
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01001/** @file cmdline.h
2 * @brief The header file for the command line option parser
3 * generated by GNU Gengetopt version 2.22.6
4 * http://www.gnu.org/software/gengetopt.
5 * DO NOT modify this file, since it can be overwritten
6 * @author GNU Gengetopt by Lorenzo Bettini */
jjako52c24142002-12-16 13:33:51 +00007
Harald Welte1b3e5772010-05-04 11:13:56 +02008#ifndef CMDLINE_H
9#define CMDLINE_H
10
11/* If we use autoconf. */
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
jjako52c24142002-12-16 13:33:51 +000015
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010016#include <stdio.h> /* for FILE */
17
jjako52c24142002-12-16 13:33:51 +000018#ifdef __cplusplus
19extern "C" {
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010020#endif /* __cplusplus */
jjako52c24142002-12-16 13:33:51 +000021
Harald Welte1b3e5772010-05-04 11:13:56 +020022#ifndef CMDLINE_PARSER_PACKAGE
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010023/** @brief the program name (used for printing errors) */
Harald Welte1b3e5772010-05-04 11:13:56 +020024#define CMDLINE_PARSER_PACKAGE PACKAGE
jjako52c24142002-12-16 13:33:51 +000025#endif
26
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010027#ifndef CMDLINE_PARSER_PACKAGE_NAME
28/** @brief the complete program name (used for help and version) */
29#ifdef PACKAGE_NAME
30#define CMDLINE_PARSER_PACKAGE_NAME PACKAGE_NAME
31#else
32#define CMDLINE_PARSER_PACKAGE_NAME PACKAGE
33#endif
34#endif
35
Harald Welte1b3e5772010-05-04 11:13:56 +020036#ifndef CMDLINE_PARSER_VERSION
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010037/** @brief the program version */
Harald Welte1b3e5772010-05-04 11:13:56 +020038#define CMDLINE_PARSER_VERSION VERSION
jjako52c24142002-12-16 13:33:51 +000039#endif
40
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010041/** @brief Where the command line options are stored */
42struct gengetopt_args_info
43{
44 const char *help_help; /**< @brief Print help and exit help description. */
45 const char *version_help; /**< @brief Print version and exit help description. */
46 int fg_flag; /**< @brief Run in foreground (default=off). */
47 const char *fg_help; /**< @brief Run in foreground help description. */
48 int debug_flag; /**< @brief Run in debug mode (default=off). */
49 const char *debug_help; /**< @brief Run in debug mode help description. */
50 char * conf_arg; /**< @brief Read configuration file (default='/etc/ggsn.conf'). */
51 char * conf_orig; /**< @brief Read configuration file original value given at command line. */
52 const char *conf_help; /**< @brief Read configuration file help description. */
53 char * pidfile_arg; /**< @brief Filename of process id file (default='/var/run/ggsn.pid'). */
54 char * pidfile_orig; /**< @brief Filename of process id file original value given at command line. */
55 const char *pidfile_help; /**< @brief Filename of process id file help description. */
56 char * statedir_arg; /**< @brief Directory of nonvolatile data (default='/var/lib/ggsn/'). */
57 char * statedir_orig; /**< @brief Directory of nonvolatile data original value given at command line. */
58 const char *statedir_help; /**< @brief Directory of nonvolatile data help description. */
59 char * listen_arg; /**< @brief Local interface. */
60 char * listen_orig; /**< @brief Local interface original value given at command line. */
61 const char *listen_help; /**< @brief Local interface help description. */
62 char * net_arg; /**< @brief Network (default='192.168.0.0/24'). */
63 char * net_orig; /**< @brief Network original value given at command line. */
64 const char *net_help; /**< @brief Network help description. */
65 char * ipup_arg; /**< @brief Script to run after link-up. */
66 char * ipup_orig; /**< @brief Script to run after link-up original value given at command line. */
67 const char *ipup_help; /**< @brief Script to run after link-up help description. */
68 char * ipdown_arg; /**< @brief Script to run after link-down. */
69 char * ipdown_orig; /**< @brief Script to run after link-down original value given at command line. */
70 const char *ipdown_help; /**< @brief Script to run after link-down help description. */
71 char * dynip_arg; /**< @brief Dynamic IP address pool. */
72 char * dynip_orig; /**< @brief Dynamic IP address pool original value given at command line. */
73 const char *dynip_help; /**< @brief Dynamic IP address pool help description. */
74 char * statip_arg; /**< @brief Static IP address pool. */
75 char * statip_orig; /**< @brief Static IP address pool original value given at command line. */
76 const char *statip_help; /**< @brief Static IP address pool help description. */
77 char * pcodns1_arg; /**< @brief PCO DNS Server 1 (default='0.0.0.0'). */
78 char * pcodns1_orig; /**< @brief PCO DNS Server 1 original value given at command line. */
79 const char *pcodns1_help; /**< @brief PCO DNS Server 1 help description. */
80 char * pcodns2_arg; /**< @brief PCO DNS Server 2 (default='0.0.0.0'). */
81 char * pcodns2_orig; /**< @brief PCO DNS Server 2 original value given at command line. */
82 const char *pcodns2_help; /**< @brief PCO DNS Server 2 help description. */
83 int timelimit_arg; /**< @brief Exit after timelimit seconds (default='0'). */
84 char * timelimit_orig; /**< @brief Exit after timelimit seconds original value given at command line. */
85 const char *timelimit_help; /**< @brief Exit after timelimit seconds help description. */
86 char * apn_arg; /**< @brief Access point name (default='internet'). */
87 char * apn_orig; /**< @brief Access point name original value given at command line. */
88 const char *apn_help; /**< @brief Access point name help description. */
89 int qos_arg; /**< @brief Requested quality of service (default='0x0b921f'). */
90 char * qos_orig; /**< @brief Requested quality of service original value given at command line. */
91 const char *qos_help; /**< @brief Requested quality of service help description. */
Holger Hans Peter Freyther9c0ff4f2014-03-23 10:07:26 +010092 char * logfile_arg; /**< @brief Logfile for errors. */
93 char * logfile_orig; /**< @brief Logfile for errors original value given at command line. */
94 const char *logfile_help; /**< @brief Logfile for errors help description. */
Holger Hans Peter Freytherc38bf642014-12-04 18:54:58 +010095 char * loglevel_arg; /**< @brief Global log ldevel (default='error'). */
96 char * loglevel_orig; /**< @brief Global log ldevel original value given at command line. */
97 const char *loglevel_help; /**< @brief Global log ldevel help description. */
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +010098
99 unsigned int help_given ; /**< @brief Whether help was given. */
100 unsigned int version_given ; /**< @brief Whether version was given. */
101 unsigned int fg_given ; /**< @brief Whether fg was given. */
102 unsigned int debug_given ; /**< @brief Whether debug was given. */
103 unsigned int conf_given ; /**< @brief Whether conf was given. */
104 unsigned int pidfile_given ; /**< @brief Whether pidfile was given. */
105 unsigned int statedir_given ; /**< @brief Whether statedir was given. */
106 unsigned int listen_given ; /**< @brief Whether listen was given. */
107 unsigned int net_given ; /**< @brief Whether net was given. */
108 unsigned int ipup_given ; /**< @brief Whether ipup was given. */
109 unsigned int ipdown_given ; /**< @brief Whether ipdown was given. */
110 unsigned int dynip_given ; /**< @brief Whether dynip was given. */
111 unsigned int statip_given ; /**< @brief Whether statip was given. */
112 unsigned int pcodns1_given ; /**< @brief Whether pcodns1 was given. */
113 unsigned int pcodns2_given ; /**< @brief Whether pcodns2 was given. */
114 unsigned int timelimit_given ; /**< @brief Whether timelimit was given. */
115 unsigned int apn_given ; /**< @brief Whether apn was given. */
116 unsigned int qos_given ; /**< @brief Whether qos was given. */
Holger Hans Peter Freyther9c0ff4f2014-03-23 10:07:26 +0100117 unsigned int logfile_given ; /**< @brief Whether logfile was given. */
Holger Hans Peter Freytherc38bf642014-12-04 18:54:58 +0100118 unsigned int loglevel_given ; /**< @brief Whether loglevel was given. */
jjako52c24142002-12-16 13:33:51 +0000119
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100120} ;
jjako52c24142002-12-16 13:33:51 +0000121
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100122/** @brief The additional parameters to pass to parser functions */
123struct cmdline_parser_params
124{
125 int override; /**< @brief whether to override possibly already present options (default 0) */
126 int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
127 int check_required; /**< @brief whether to check that all required options were provided (default 1) */
128 int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
129 int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
130} ;
Harald Welte1b3e5772010-05-04 11:13:56 +0200131
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100132/** @brief the purpose string of the program */
133extern const char *gengetopt_args_info_purpose;
134/** @brief the usage string of the program */
135extern const char *gengetopt_args_info_usage;
136/** @brief the description string of the program */
137extern const char *gengetopt_args_info_description;
138/** @brief all the lines making the help output */
139extern const char *gengetopt_args_info_help[];
jjako52c24142002-12-16 13:33:51 +0000140
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100141/**
142 * The command line parser
143 * @param argc the number of command line options
144 * @param argv the command line options
145 * @param args_info the structure where option information will be stored
146 * @return 0 if everything went fine, NON 0 if an error took place
147 */
148int cmdline_parser (int argc, char **argv,
149 struct gengetopt_args_info *args_info);
jjako52c24142002-12-16 13:33:51 +0000150
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100151/**
152 * The command line parser (version with additional parameters - deprecated)
153 * @param argc the number of command line options
154 * @param argv the command line options
155 * @param args_info the structure where option information will be stored
156 * @param override whether to override possibly already present options
157 * @param initialize whether to initialize the option structure my_args_info
158 * @param check_required whether to check that all required options were provided
159 * @return 0 if everything went fine, NON 0 if an error took place
160 * @deprecated use cmdline_parser_ext() instead
161 */
162int cmdline_parser2 (int argc, char **argv,
163 struct gengetopt_args_info *args_info,
164 int override, int initialize, int check_required);
Harald Welte1b3e5772010-05-04 11:13:56 +0200165
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100166/**
167 * The command line parser (version with additional parameters)
168 * @param argc the number of command line options
169 * @param argv the command line options
170 * @param args_info the structure where option information will be stored
171 * @param params additional parameters for the parser
172 * @return 0 if everything went fine, NON 0 if an error took place
173 */
174int cmdline_parser_ext (int argc, char **argv,
175 struct gengetopt_args_info *args_info,
176 struct cmdline_parser_params *params);
Harald Welte1b3e5772010-05-04 11:13:56 +0200177
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100178/**
179 * Save the contents of the option struct into an already open FILE stream.
180 * @param outfile the stream where to dump options
181 * @param args_info the option struct to dump
182 * @return 0 if everything went fine, NON 0 if an error took place
183 */
184int cmdline_parser_dump(FILE *outfile,
185 struct gengetopt_args_info *args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +0200186
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100187/**
188 * Save the contents of the option struct into a (text) file.
189 * This file can be read by the config file parser (if generated by gengetopt)
190 * @param filename the file where to save
191 * @param args_info the option struct to save
192 * @return 0 if everything went fine, NON 0 if an error took place
193 */
194int cmdline_parser_file_save(const char *filename,
195 struct gengetopt_args_info *args_info);
196
197/**
198 * Print the help
199 */
200void cmdline_parser_print_help(void);
201/**
202 * Print the version
203 */
204void cmdline_parser_print_version(void);
205
206/**
207 * Initializes all the fields a cmdline_parser_params structure
208 * to their default values
209 * @param params the structure to initialize
210 */
211void cmdline_parser_params_init(struct cmdline_parser_params *params);
212
213/**
214 * Allocates dynamically a cmdline_parser_params structure and initializes
215 * all its fields to their default values
216 * @return the created and initialized cmdline_parser_params structure
217 */
218struct cmdline_parser_params *cmdline_parser_params_create(void);
219
220/**
221 * Initializes the passed gengetopt_args_info structure's fields
222 * (also set default values for options that have a default)
223 * @param args_info the structure to initialize
224 */
225void cmdline_parser_init (struct gengetopt_args_info *args_info);
226/**
227 * Deallocates the string fields of the gengetopt_args_info structure
228 * (but does not deallocate the structure itself)
229 * @param args_info the structure to deallocate
230 */
231void cmdline_parser_free (struct gengetopt_args_info *args_info);
232
233/**
234 * The config file parser (deprecated version)
235 * @param filename the name of the config file
236 * @param args_info the structure where option information will be stored
237 * @param override whether to override possibly already present options
238 * @param initialize whether to initialize the option structure my_args_info
239 * @param check_required whether to check that all required options were provided
240 * @return 0 if everything went fine, NON 0 if an error took place
241 * @deprecated use cmdline_parser_config_file() instead
242 */
243int cmdline_parser_configfile (const char *filename,
244 struct gengetopt_args_info *args_info,
245 int override, int initialize, int check_required);
246
247/**
248 * The config file parser
249 * @param filename the name of the config file
250 * @param args_info the structure where option information will be stored
251 * @param params additional parameters for the parser
252 * @return 0 if everything went fine, NON 0 if an error took place
253 */
254int cmdline_parser_config_file (const char *filename,
255 struct gengetopt_args_info *args_info,
256 struct cmdline_parser_params *params);
257
258/**
259 * Checks that all the required options were specified
260 * @param args_info the structure to check
261 * @param prog_name the name of the program that will be used to print
262 * possible errors
263 * @return
264 */
265int cmdline_parser_required (struct gengetopt_args_info *args_info,
266 const char *prog_name);
267
jjako52c24142002-12-16 13:33:51 +0000268
269#ifdef __cplusplus
270}
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100271#endif /* __cplusplus */
272#endif /* CMDLINE_H */