blob: 150fb4dc08bd2447216c290ab28702c7b1e4c47b [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
Pablo Neira Ayuso4b075b62015-11-17 12:22:42 +01003 * generated by GNU Gengetopt version 2.22.5
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +01004 * 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. */
Pablo Neira Ayuso4b075b62015-11-17 12:22:42 +010098 char * gtpnl_arg; /**< @brief GTP kernel support (default='eth0'). */
99 char * gtpnl_orig; /**< @brief GTP kernel support original value given at command line. */
100 const char *gtpnl_help; /**< @brief GTP kernel support help description. */
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100101
102 unsigned int help_given ; /**< @brief Whether help was given. */
103 unsigned int version_given ; /**< @brief Whether version was given. */
104 unsigned int fg_given ; /**< @brief Whether fg was given. */
105 unsigned int debug_given ; /**< @brief Whether debug was given. */
106 unsigned int conf_given ; /**< @brief Whether conf was given. */
107 unsigned int pidfile_given ; /**< @brief Whether pidfile was given. */
108 unsigned int statedir_given ; /**< @brief Whether statedir was given. */
109 unsigned int listen_given ; /**< @brief Whether listen was given. */
110 unsigned int net_given ; /**< @brief Whether net was given. */
111 unsigned int ipup_given ; /**< @brief Whether ipup was given. */
112 unsigned int ipdown_given ; /**< @brief Whether ipdown was given. */
113 unsigned int dynip_given ; /**< @brief Whether dynip was given. */
114 unsigned int statip_given ; /**< @brief Whether statip was given. */
115 unsigned int pcodns1_given ; /**< @brief Whether pcodns1 was given. */
116 unsigned int pcodns2_given ; /**< @brief Whether pcodns2 was given. */
117 unsigned int timelimit_given ; /**< @brief Whether timelimit was given. */
118 unsigned int apn_given ; /**< @brief Whether apn was given. */
119 unsigned int qos_given ; /**< @brief Whether qos was given. */
Holger Hans Peter Freyther9c0ff4f2014-03-23 10:07:26 +0100120 unsigned int logfile_given ; /**< @brief Whether logfile was given. */
Holger Hans Peter Freytherc38bf642014-12-04 18:54:58 +0100121 unsigned int loglevel_given ; /**< @brief Whether loglevel was given. */
Pablo Neira Ayuso4b075b62015-11-17 12:22:42 +0100122 unsigned int gtpnl_given ; /**< @brief Whether gtpnl was given. */
jjako52c24142002-12-16 13:33:51 +0000123
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100124} ;
jjako52c24142002-12-16 13:33:51 +0000125
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100126/** @brief The additional parameters to pass to parser functions */
127struct cmdline_parser_params
128{
129 int override; /**< @brief whether to override possibly already present options (default 0) */
130 int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
131 int check_required; /**< @brief whether to check that all required options were provided (default 1) */
132 int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
133 int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
134} ;
Harald Welte1b3e5772010-05-04 11:13:56 +0200135
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100136/** @brief the purpose string of the program */
137extern const char *gengetopt_args_info_purpose;
138/** @brief the usage string of the program */
139extern const char *gengetopt_args_info_usage;
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100140/** @brief all the lines making the help output */
141extern const char *gengetopt_args_info_help[];
jjako52c24142002-12-16 13:33:51 +0000142
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100143/**
144 * The command line parser
145 * @param argc the number of command line options
146 * @param argv the command line options
147 * @param args_info the structure where option information will be stored
148 * @return 0 if everything went fine, NON 0 if an error took place
149 */
150int cmdline_parser (int argc, char **argv,
151 struct gengetopt_args_info *args_info);
jjako52c24142002-12-16 13:33:51 +0000152
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100153/**
154 * The command line parser (version with additional parameters - deprecated)
155 * @param argc the number of command line options
156 * @param argv the command line options
157 * @param args_info the structure where option information will be stored
158 * @param override whether to override possibly already present options
159 * @param initialize whether to initialize the option structure my_args_info
160 * @param check_required whether to check that all required options were provided
161 * @return 0 if everything went fine, NON 0 if an error took place
162 * @deprecated use cmdline_parser_ext() instead
163 */
164int cmdline_parser2 (int argc, char **argv,
165 struct gengetopt_args_info *args_info,
166 int override, int initialize, int check_required);
Harald Welte1b3e5772010-05-04 11:13:56 +0200167
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100168/**
169 * The command line parser (version with additional parameters)
170 * @param argc the number of command line options
171 * @param argv the command line options
172 * @param args_info the structure where option information will be stored
173 * @param params additional parameters for the parser
174 * @return 0 if everything went fine, NON 0 if an error took place
175 */
176int cmdline_parser_ext (int argc, char **argv,
177 struct gengetopt_args_info *args_info,
178 struct cmdline_parser_params *params);
Harald Welte1b3e5772010-05-04 11:13:56 +0200179
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100180/**
181 * Save the contents of the option struct into an already open FILE stream.
182 * @param outfile the stream where to dump options
183 * @param args_info the option struct to dump
184 * @return 0 if everything went fine, NON 0 if an error took place
185 */
186int cmdline_parser_dump(FILE *outfile,
187 struct gengetopt_args_info *args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +0200188
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100189/**
190 * Save the contents of the option struct into a (text) file.
191 * This file can be read by the config file parser (if generated by gengetopt)
192 * @param filename the file where to save
193 * @param args_info the option struct to save
194 * @return 0 if everything went fine, NON 0 if an error took place
195 */
196int cmdline_parser_file_save(const char *filename,
197 struct gengetopt_args_info *args_info);
198
199/**
200 * Print the help
201 */
202void cmdline_parser_print_help(void);
203/**
204 * Print the version
205 */
206void cmdline_parser_print_version(void);
207
208/**
209 * Initializes all the fields a cmdline_parser_params structure
210 * to their default values
211 * @param params the structure to initialize
212 */
213void cmdline_parser_params_init(struct cmdline_parser_params *params);
214
215/**
216 * Allocates dynamically a cmdline_parser_params structure and initializes
217 * all its fields to their default values
218 * @return the created and initialized cmdline_parser_params structure
219 */
220struct cmdline_parser_params *cmdline_parser_params_create(void);
221
222/**
223 * Initializes the passed gengetopt_args_info structure's fields
224 * (also set default values for options that have a default)
225 * @param args_info the structure to initialize
226 */
227void cmdline_parser_init (struct gengetopt_args_info *args_info);
228/**
229 * Deallocates the string fields of the gengetopt_args_info structure
230 * (but does not deallocate the structure itself)
231 * @param args_info the structure to deallocate
232 */
233void cmdline_parser_free (struct gengetopt_args_info *args_info);
234
235/**
236 * The config file parser (deprecated version)
237 * @param filename the name of the config file
238 * @param args_info the structure where option information will be stored
239 * @param override whether to override possibly already present options
240 * @param initialize whether to initialize the option structure my_args_info
241 * @param check_required whether to check that all required options were provided
242 * @return 0 if everything went fine, NON 0 if an error took place
243 * @deprecated use cmdline_parser_config_file() instead
244 */
245int cmdline_parser_configfile (const char *filename,
246 struct gengetopt_args_info *args_info,
247 int override, int initialize, int check_required);
248
249/**
250 * The config file parser
251 * @param filename the name of the config file
252 * @param args_info the structure where option information will be stored
253 * @param params additional parameters for the parser
254 * @return 0 if everything went fine, NON 0 if an error took place
255 */
256int cmdline_parser_config_file (const char *filename,
257 struct gengetopt_args_info *args_info,
258 struct cmdline_parser_params *params);
259
260/**
261 * Checks that all the required options were specified
262 * @param args_info the structure to check
263 * @param prog_name the name of the program that will be used to print
264 * possible errors
265 * @return
266 */
267int cmdline_parser_required (struct gengetopt_args_info *args_info,
268 const char *prog_name);
269
jjako52c24142002-12-16 13:33:51 +0000270
271#ifdef __cplusplus
272}
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100273#endif /* __cplusplus */
274#endif /* CMDLINE_H */