blob: 57f5cae6c627e9bf2991f4ef3e7bf869edf7732a [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 Ayusod9d7be32016-05-10 18:43:12 +02003 * generated by GNU Gengetopt version 2.22.6
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 Ayusod9d7be32016-05-10 18:43:12 +020098 int gtp_linux_flag; /**< @brief GTP linux kernel support (default=off). */
99 const char *gtp_linux_help; /**< @brief GTP linux kernel support help description. */
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100100
101 unsigned int help_given ; /**< @brief Whether help was given. */
102 unsigned int version_given ; /**< @brief Whether version was given. */
103 unsigned int fg_given ; /**< @brief Whether fg was given. */
104 unsigned int debug_given ; /**< @brief Whether debug was given. */
105 unsigned int conf_given ; /**< @brief Whether conf was given. */
106 unsigned int pidfile_given ; /**< @brief Whether pidfile was given. */
107 unsigned int statedir_given ; /**< @brief Whether statedir was given. */
108 unsigned int listen_given ; /**< @brief Whether listen was given. */
109 unsigned int net_given ; /**< @brief Whether net was given. */
110 unsigned int ipup_given ; /**< @brief Whether ipup was given. */
111 unsigned int ipdown_given ; /**< @brief Whether ipdown was given. */
112 unsigned int dynip_given ; /**< @brief Whether dynip was given. */
113 unsigned int statip_given ; /**< @brief Whether statip was given. */
114 unsigned int pcodns1_given ; /**< @brief Whether pcodns1 was given. */
115 unsigned int pcodns2_given ; /**< @brief Whether pcodns2 was given. */
116 unsigned int timelimit_given ; /**< @brief Whether timelimit was given. */
117 unsigned int apn_given ; /**< @brief Whether apn was given. */
118 unsigned int qos_given ; /**< @brief Whether qos was given. */
Holger Hans Peter Freyther9c0ff4f2014-03-23 10:07:26 +0100119 unsigned int logfile_given ; /**< @brief Whether logfile was given. */
Holger Hans Peter Freytherc38bf642014-12-04 18:54:58 +0100120 unsigned int loglevel_given ; /**< @brief Whether loglevel was given. */
Pablo Neira Ayusod9d7be32016-05-10 18:43:12 +0200121 unsigned int gtp_linux_given ; /**< @brief Whether gtp-linux was given. */
jjako52c24142002-12-16 13:33:51 +0000122
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100123} ;
jjako52c24142002-12-16 13:33:51 +0000124
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100125/** @brief The additional parameters to pass to parser functions */
126struct cmdline_parser_params
127{
128 int override; /**< @brief whether to override possibly already present options (default 0) */
129 int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
130 int check_required; /**< @brief whether to check that all required options were provided (default 1) */
131 int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
132 int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
133} ;
Harald Welte1b3e5772010-05-04 11:13:56 +0200134
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100135/** @brief the purpose string of the program */
136extern const char *gengetopt_args_info_purpose;
137/** @brief the usage string of the program */
138extern const char *gengetopt_args_info_usage;
Pablo Neira Ayusod9d7be32016-05-10 18:43:12 +0200139/** @brief the description string of the program */
140extern const char *gengetopt_args_info_description;
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100141/** @brief all the lines making the help output */
142extern const char *gengetopt_args_info_help[];
jjako52c24142002-12-16 13:33:51 +0000143
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100144/**
145 * The command line parser
146 * @param argc the number of command line options
147 * @param argv the command line options
148 * @param args_info the structure where option information will be stored
149 * @return 0 if everything went fine, NON 0 if an error took place
150 */
151int cmdline_parser (int argc, char **argv,
152 struct gengetopt_args_info *args_info);
jjako52c24142002-12-16 13:33:51 +0000153
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100154/**
155 * The command line parser (version with additional parameters - deprecated)
156 * @param argc the number of command line options
157 * @param argv the command line options
158 * @param args_info the structure where option information will be stored
159 * @param override whether to override possibly already present options
160 * @param initialize whether to initialize the option structure my_args_info
161 * @param check_required whether to check that all required options were provided
162 * @return 0 if everything went fine, NON 0 if an error took place
163 * @deprecated use cmdline_parser_ext() instead
164 */
165int cmdline_parser2 (int argc, char **argv,
166 struct gengetopt_args_info *args_info,
167 int override, int initialize, int check_required);
Harald Welte1b3e5772010-05-04 11:13:56 +0200168
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100169/**
170 * The command line parser (version with additional parameters)
171 * @param argc the number of command line options
172 * @param argv the command line options
173 * @param args_info the structure where option information will be stored
174 * @param params additional parameters for the parser
175 * @return 0 if everything went fine, NON 0 if an error took place
176 */
177int cmdline_parser_ext (int argc, char **argv,
178 struct gengetopt_args_info *args_info,
179 struct cmdline_parser_params *params);
Harald Welte1b3e5772010-05-04 11:13:56 +0200180
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100181/**
182 * Save the contents of the option struct into an already open FILE stream.
183 * @param outfile the stream where to dump options
184 * @param args_info the option struct to dump
185 * @return 0 if everything went fine, NON 0 if an error took place
186 */
187int cmdline_parser_dump(FILE *outfile,
188 struct gengetopt_args_info *args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +0200189
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100190/**
191 * Save the contents of the option struct into a (text) file.
192 * This file can be read by the config file parser (if generated by gengetopt)
193 * @param filename the file where to save
194 * @param args_info the option struct to save
195 * @return 0 if everything went fine, NON 0 if an error took place
196 */
197int cmdline_parser_file_save(const char *filename,
198 struct gengetopt_args_info *args_info);
199
200/**
201 * Print the help
202 */
203void cmdline_parser_print_help(void);
204/**
205 * Print the version
206 */
207void cmdline_parser_print_version(void);
208
209/**
210 * Initializes all the fields a cmdline_parser_params structure
211 * to their default values
212 * @param params the structure to initialize
213 */
214void cmdline_parser_params_init(struct cmdline_parser_params *params);
215
216/**
217 * Allocates dynamically a cmdline_parser_params structure and initializes
218 * all its fields to their default values
219 * @return the created and initialized cmdline_parser_params structure
220 */
221struct cmdline_parser_params *cmdline_parser_params_create(void);
222
223/**
224 * Initializes the passed gengetopt_args_info structure's fields
225 * (also set default values for options that have a default)
226 * @param args_info the structure to initialize
227 */
228void cmdline_parser_init (struct gengetopt_args_info *args_info);
229/**
230 * Deallocates the string fields of the gengetopt_args_info structure
231 * (but does not deallocate the structure itself)
232 * @param args_info the structure to deallocate
233 */
234void cmdline_parser_free (struct gengetopt_args_info *args_info);
235
236/**
237 * The config file parser (deprecated version)
238 * @param filename the name of the config file
239 * @param args_info the structure where option information will be stored
240 * @param override whether to override possibly already present options
241 * @param initialize whether to initialize the option structure my_args_info
242 * @param check_required whether to check that all required options were provided
243 * @return 0 if everything went fine, NON 0 if an error took place
244 * @deprecated use cmdline_parser_config_file() instead
245 */
246int cmdline_parser_configfile (const char *filename,
247 struct gengetopt_args_info *args_info,
248 int override, int initialize, int check_required);
249
250/**
251 * The config file parser
252 * @param filename the name of the config file
253 * @param args_info the structure where option information will be stored
254 * @param params additional parameters for the parser
255 * @return 0 if everything went fine, NON 0 if an error took place
256 */
257int cmdline_parser_config_file (const char *filename,
258 struct gengetopt_args_info *args_info,
259 struct cmdline_parser_params *params);
260
261/**
262 * Checks that all the required options were specified
263 * @param args_info the structure to check
264 * @param prog_name the name of the program that will be used to print
265 * possible errors
266 * @return
267 */
268int cmdline_parser_required (struct gengetopt_args_info *args_info,
269 const char *prog_name);
270
jjako52c24142002-12-16 13:33:51 +0000271
272#ifdef __cplusplus
273}
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100274#endif /* __cplusplus */
275#endif /* CMDLINE_H */