blob: 1ce222e973d00e7ff15e8db7c5ec8f103f7df854 [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. */
92
93 unsigned int help_given ; /**< @brief Whether help was given. */
94 unsigned int version_given ; /**< @brief Whether version was given. */
95 unsigned int fg_given ; /**< @brief Whether fg was given. */
96 unsigned int debug_given ; /**< @brief Whether debug was given. */
97 unsigned int conf_given ; /**< @brief Whether conf was given. */
98 unsigned int pidfile_given ; /**< @brief Whether pidfile was given. */
99 unsigned int statedir_given ; /**< @brief Whether statedir was given. */
100 unsigned int listen_given ; /**< @brief Whether listen was given. */
101 unsigned int net_given ; /**< @brief Whether net was given. */
102 unsigned int ipup_given ; /**< @brief Whether ipup was given. */
103 unsigned int ipdown_given ; /**< @brief Whether ipdown was given. */
104 unsigned int dynip_given ; /**< @brief Whether dynip was given. */
105 unsigned int statip_given ; /**< @brief Whether statip was given. */
106 unsigned int pcodns1_given ; /**< @brief Whether pcodns1 was given. */
107 unsigned int pcodns2_given ; /**< @brief Whether pcodns2 was given. */
108 unsigned int timelimit_given ; /**< @brief Whether timelimit was given. */
109 unsigned int apn_given ; /**< @brief Whether apn was given. */
110 unsigned int qos_given ; /**< @brief Whether qos was given. */
jjako52c24142002-12-16 13:33:51 +0000111
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100112} ;
jjako52c24142002-12-16 13:33:51 +0000113
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100114/** @brief The additional parameters to pass to parser functions */
115struct cmdline_parser_params
116{
117 int override; /**< @brief whether to override possibly already present options (default 0) */
118 int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
119 int check_required; /**< @brief whether to check that all required options were provided (default 1) */
120 int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
121 int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
122} ;
Harald Welte1b3e5772010-05-04 11:13:56 +0200123
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100124/** @brief the purpose string of the program */
125extern const char *gengetopt_args_info_purpose;
126/** @brief the usage string of the program */
127extern const char *gengetopt_args_info_usage;
128/** @brief the description string of the program */
129extern const char *gengetopt_args_info_description;
130/** @brief all the lines making the help output */
131extern const char *gengetopt_args_info_help[];
jjako52c24142002-12-16 13:33:51 +0000132
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100133/**
134 * The command line parser
135 * @param argc the number of command line options
136 * @param argv the command line options
137 * @param args_info the structure where option information will be stored
138 * @return 0 if everything went fine, NON 0 if an error took place
139 */
140int cmdline_parser (int argc, char **argv,
141 struct gengetopt_args_info *args_info);
jjako52c24142002-12-16 13:33:51 +0000142
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100143/**
144 * The command line parser (version with additional parameters - deprecated)
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 * @param override whether to override possibly already present options
149 * @param initialize whether to initialize the option structure my_args_info
150 * @param check_required whether to check that all required options were provided
151 * @return 0 if everything went fine, NON 0 if an error took place
152 * @deprecated use cmdline_parser_ext() instead
153 */
154int cmdline_parser2 (int argc, char **argv,
155 struct gengetopt_args_info *args_info,
156 int override, int initialize, int check_required);
Harald Welte1b3e5772010-05-04 11:13:56 +0200157
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100158/**
159 * The command line parser (version with additional parameters)
160 * @param argc the number of command line options
161 * @param argv the command line options
162 * @param args_info the structure where option information will be stored
163 * @param params additional parameters for the parser
164 * @return 0 if everything went fine, NON 0 if an error took place
165 */
166int cmdline_parser_ext (int argc, char **argv,
167 struct gengetopt_args_info *args_info,
168 struct cmdline_parser_params *params);
Harald Welte1b3e5772010-05-04 11:13:56 +0200169
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100170/**
171 * Save the contents of the option struct into an already open FILE stream.
172 * @param outfile the stream where to dump options
173 * @param args_info the option struct to dump
174 * @return 0 if everything went fine, NON 0 if an error took place
175 */
176int cmdline_parser_dump(FILE *outfile,
177 struct gengetopt_args_info *args_info);
Harald Welte1b3e5772010-05-04 11:13:56 +0200178
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100179/**
180 * Save the contents of the option struct into a (text) file.
181 * This file can be read by the config file parser (if generated by gengetopt)
182 * @param filename the file where to save
183 * @param args_info the option struct to save
184 * @return 0 if everything went fine, NON 0 if an error took place
185 */
186int cmdline_parser_file_save(const char *filename,
187 struct gengetopt_args_info *args_info);
188
189/**
190 * Print the help
191 */
192void cmdline_parser_print_help(void);
193/**
194 * Print the version
195 */
196void cmdline_parser_print_version(void);
197
198/**
199 * Initializes all the fields a cmdline_parser_params structure
200 * to their default values
201 * @param params the structure to initialize
202 */
203void cmdline_parser_params_init(struct cmdline_parser_params *params);
204
205/**
206 * Allocates dynamically a cmdline_parser_params structure and initializes
207 * all its fields to their default values
208 * @return the created and initialized cmdline_parser_params structure
209 */
210struct cmdline_parser_params *cmdline_parser_params_create(void);
211
212/**
213 * Initializes the passed gengetopt_args_info structure's fields
214 * (also set default values for options that have a default)
215 * @param args_info the structure to initialize
216 */
217void cmdline_parser_init (struct gengetopt_args_info *args_info);
218/**
219 * Deallocates the string fields of the gengetopt_args_info structure
220 * (but does not deallocate the structure itself)
221 * @param args_info the structure to deallocate
222 */
223void cmdline_parser_free (struct gengetopt_args_info *args_info);
224
225/**
226 * The config file parser (deprecated version)
227 * @param filename the name of the config file
228 * @param args_info the structure where option information will be stored
229 * @param override whether to override possibly already present options
230 * @param initialize whether to initialize the option structure my_args_info
231 * @param check_required whether to check that all required options were provided
232 * @return 0 if everything went fine, NON 0 if an error took place
233 * @deprecated use cmdline_parser_config_file() instead
234 */
235int cmdline_parser_configfile (const char *filename,
236 struct gengetopt_args_info *args_info,
237 int override, int initialize, int check_required);
238
239/**
240 * The config file parser
241 * @param filename the name of the config file
242 * @param args_info the structure where option information will be stored
243 * @param params additional parameters for the parser
244 * @return 0 if everything went fine, NON 0 if an error took place
245 */
246int cmdline_parser_config_file (const char *filename,
247 struct gengetopt_args_info *args_info,
248 struct cmdline_parser_params *params);
249
250/**
251 * Checks that all the required options were specified
252 * @param args_info the structure to check
253 * @param prog_name the name of the program that will be used to print
254 * possible errors
255 * @return
256 */
257int cmdline_parser_required (struct gengetopt_args_info *args_info,
258 const char *prog_name);
259
jjako52c24142002-12-16 13:33:51 +0000260
261#ifdef __cplusplus
262}
Holger Hans Peter Freyther6c0b9c22014-03-23 10:02:14 +0100263#endif /* __cplusplus */
264#endif /* CMDLINE_H */