Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 1 | /** @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 */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 7 | |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 8 | #ifndef CMDLINE_H |
| 9 | #define CMDLINE_H |
| 10 | |
| 11 | /* If we use autoconf. */ |
| 12 | #ifdef HAVE_CONFIG_H |
| 13 | #include "config.h" |
| 14 | #endif |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 15 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 16 | #include <stdio.h> /* for FILE */ |
| 17 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 20 | #endif /* __cplusplus */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 21 | |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 22 | #ifndef CMDLINE_PARSER_PACKAGE |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 23 | /** @brief the program name (used for printing errors) */ |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 24 | #define CMDLINE_PARSER_PACKAGE PACKAGE |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 25 | #endif |
| 26 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 27 | #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 Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 36 | #ifndef CMDLINE_PARSER_VERSION |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 37 | /** @brief the program version */ |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 38 | #define CMDLINE_PARSER_VERSION VERSION |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 39 | #endif |
| 40 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 41 | /** @brief Where the command line options are stored */ |
| 42 | struct 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 Freyther | 9c0ff4f | 2014-03-23 10:07:26 +0100 | [diff] [blame] | 92 | 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 Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 95 | |
| 96 | unsigned int help_given ; /**< @brief Whether help was given. */ |
| 97 | unsigned int version_given ; /**< @brief Whether version was given. */ |
| 98 | unsigned int fg_given ; /**< @brief Whether fg was given. */ |
| 99 | unsigned int debug_given ; /**< @brief Whether debug was given. */ |
| 100 | unsigned int conf_given ; /**< @brief Whether conf was given. */ |
| 101 | unsigned int pidfile_given ; /**< @brief Whether pidfile was given. */ |
| 102 | unsigned int statedir_given ; /**< @brief Whether statedir was given. */ |
| 103 | unsigned int listen_given ; /**< @brief Whether listen was given. */ |
| 104 | unsigned int net_given ; /**< @brief Whether net was given. */ |
| 105 | unsigned int ipup_given ; /**< @brief Whether ipup was given. */ |
| 106 | unsigned int ipdown_given ; /**< @brief Whether ipdown was given. */ |
| 107 | unsigned int dynip_given ; /**< @brief Whether dynip was given. */ |
| 108 | unsigned int statip_given ; /**< @brief Whether statip was given. */ |
| 109 | unsigned int pcodns1_given ; /**< @brief Whether pcodns1 was given. */ |
| 110 | unsigned int pcodns2_given ; /**< @brief Whether pcodns2 was given. */ |
| 111 | unsigned int timelimit_given ; /**< @brief Whether timelimit was given. */ |
| 112 | unsigned int apn_given ; /**< @brief Whether apn was given. */ |
| 113 | unsigned int qos_given ; /**< @brief Whether qos was given. */ |
Holger Hans Peter Freyther | 9c0ff4f | 2014-03-23 10:07:26 +0100 | [diff] [blame] | 114 | unsigned int logfile_given ; /**< @brief Whether logfile was given. */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 115 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 116 | } ; |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 117 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 118 | /** @brief The additional parameters to pass to parser functions */ |
| 119 | struct cmdline_parser_params |
| 120 | { |
| 121 | int override; /**< @brief whether to override possibly already present options (default 0) */ |
| 122 | int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ |
| 123 | int check_required; /**< @brief whether to check that all required options were provided (default 1) */ |
| 124 | int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ |
| 125 | int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ |
| 126 | } ; |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 127 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 128 | /** @brief the purpose string of the program */ |
| 129 | extern const char *gengetopt_args_info_purpose; |
| 130 | /** @brief the usage string of the program */ |
| 131 | extern const char *gengetopt_args_info_usage; |
| 132 | /** @brief the description string of the program */ |
| 133 | extern const char *gengetopt_args_info_description; |
| 134 | /** @brief all the lines making the help output */ |
| 135 | extern const char *gengetopt_args_info_help[]; |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 136 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 137 | /** |
| 138 | * The command line parser |
| 139 | * @param argc the number of command line options |
| 140 | * @param argv the command line options |
| 141 | * @param args_info the structure where option information will be stored |
| 142 | * @return 0 if everything went fine, NON 0 if an error took place |
| 143 | */ |
| 144 | int cmdline_parser (int argc, char **argv, |
| 145 | struct gengetopt_args_info *args_info); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 146 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 147 | /** |
| 148 | * The command line parser (version with additional parameters - deprecated) |
| 149 | * @param argc the number of command line options |
| 150 | * @param argv the command line options |
| 151 | * @param args_info the structure where option information will be stored |
| 152 | * @param override whether to override possibly already present options |
| 153 | * @param initialize whether to initialize the option structure my_args_info |
| 154 | * @param check_required whether to check that all required options were provided |
| 155 | * @return 0 if everything went fine, NON 0 if an error took place |
| 156 | * @deprecated use cmdline_parser_ext() instead |
| 157 | */ |
| 158 | int cmdline_parser2 (int argc, char **argv, |
| 159 | struct gengetopt_args_info *args_info, |
| 160 | int override, int initialize, int check_required); |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 161 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 162 | /** |
| 163 | * The command line parser (version with additional parameters) |
| 164 | * @param argc the number of command line options |
| 165 | * @param argv the command line options |
| 166 | * @param args_info the structure where option information will be stored |
| 167 | * @param params additional parameters for the parser |
| 168 | * @return 0 if everything went fine, NON 0 if an error took place |
| 169 | */ |
| 170 | int cmdline_parser_ext (int argc, char **argv, |
| 171 | struct gengetopt_args_info *args_info, |
| 172 | struct cmdline_parser_params *params); |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 173 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 174 | /** |
| 175 | * Save the contents of the option struct into an already open FILE stream. |
| 176 | * @param outfile the stream where to dump options |
| 177 | * @param args_info the option struct to dump |
| 178 | * @return 0 if everything went fine, NON 0 if an error took place |
| 179 | */ |
| 180 | int cmdline_parser_dump(FILE *outfile, |
| 181 | struct gengetopt_args_info *args_info); |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 182 | |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 183 | /** |
| 184 | * Save the contents of the option struct into a (text) file. |
| 185 | * This file can be read by the config file parser (if generated by gengetopt) |
| 186 | * @param filename the file where to save |
| 187 | * @param args_info the option struct to save |
| 188 | * @return 0 if everything went fine, NON 0 if an error took place |
| 189 | */ |
| 190 | int cmdline_parser_file_save(const char *filename, |
| 191 | struct gengetopt_args_info *args_info); |
| 192 | |
| 193 | /** |
| 194 | * Print the help |
| 195 | */ |
| 196 | void cmdline_parser_print_help(void); |
| 197 | /** |
| 198 | * Print the version |
| 199 | */ |
| 200 | void cmdline_parser_print_version(void); |
| 201 | |
| 202 | /** |
| 203 | * Initializes all the fields a cmdline_parser_params structure |
| 204 | * to their default values |
| 205 | * @param params the structure to initialize |
| 206 | */ |
| 207 | void cmdline_parser_params_init(struct cmdline_parser_params *params); |
| 208 | |
| 209 | /** |
| 210 | * Allocates dynamically a cmdline_parser_params structure and initializes |
| 211 | * all its fields to their default values |
| 212 | * @return the created and initialized cmdline_parser_params structure |
| 213 | */ |
| 214 | struct cmdline_parser_params *cmdline_parser_params_create(void); |
| 215 | |
| 216 | /** |
| 217 | * Initializes the passed gengetopt_args_info structure's fields |
| 218 | * (also set default values for options that have a default) |
| 219 | * @param args_info the structure to initialize |
| 220 | */ |
| 221 | void cmdline_parser_init (struct gengetopt_args_info *args_info); |
| 222 | /** |
| 223 | * Deallocates the string fields of the gengetopt_args_info structure |
| 224 | * (but does not deallocate the structure itself) |
| 225 | * @param args_info the structure to deallocate |
| 226 | */ |
| 227 | void cmdline_parser_free (struct gengetopt_args_info *args_info); |
| 228 | |
| 229 | /** |
| 230 | * The config file parser (deprecated version) |
| 231 | * @param filename the name of the config file |
| 232 | * @param args_info the structure where option information will be stored |
| 233 | * @param override whether to override possibly already present options |
| 234 | * @param initialize whether to initialize the option structure my_args_info |
| 235 | * @param check_required whether to check that all required options were provided |
| 236 | * @return 0 if everything went fine, NON 0 if an error took place |
| 237 | * @deprecated use cmdline_parser_config_file() instead |
| 238 | */ |
| 239 | int cmdline_parser_configfile (const char *filename, |
| 240 | struct gengetopt_args_info *args_info, |
| 241 | int override, int initialize, int check_required); |
| 242 | |
| 243 | /** |
| 244 | * The config file parser |
| 245 | * @param filename the name of the config file |
| 246 | * @param args_info the structure where option information will be stored |
| 247 | * @param params additional parameters for the parser |
| 248 | * @return 0 if everything went fine, NON 0 if an error took place |
| 249 | */ |
| 250 | int cmdline_parser_config_file (const char *filename, |
| 251 | struct gengetopt_args_info *args_info, |
| 252 | struct cmdline_parser_params *params); |
| 253 | |
| 254 | /** |
| 255 | * Checks that all the required options were specified |
| 256 | * @param args_info the structure to check |
| 257 | * @param prog_name the name of the program that will be used to print |
| 258 | * possible errors |
| 259 | * @return |
| 260 | */ |
| 261 | int cmdline_parser_required (struct gengetopt_args_info *args_info, |
| 262 | const char *prog_name); |
| 263 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 264 | |
| 265 | #ifdef __cplusplus |
| 266 | } |
Holger Hans Peter Freyther | 6c0b9c2 | 2014-03-23 10:02:14 +0100 | [diff] [blame] | 267 | #endif /* __cplusplus */ |
| 268 | #endif /* CMDLINE_H */ |