Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [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 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [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" { |
Harald Welte | bed35df | 2011-11-02 13:06:18 +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 |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 23 | /** @brief the program name (used for printing errors) */ |
Harald Welte | 7e1175f | 2017-09-24 10:53:53 +0800 | [diff] [blame] | 24 | #define CMDLINE_PARSER_PACKAGE "sgsnemu" |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 25 | #endif |
| 26 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 27 | #ifndef CMDLINE_PARSER_PACKAGE_NAME |
| 28 | /** @brief the complete program name (used for help and version) */ |
Harald Welte | 7e1175f | 2017-09-24 10:53:53 +0800 | [diff] [blame] | 29 | #define CMDLINE_PARSER_PACKAGE_NAME "sgsnemu" |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 30 | #endif |
| 31 | |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 32 | #ifndef CMDLINE_PARSER_VERSION |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 33 | /** @brief the program version */ |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 34 | #define CMDLINE_PARSER_VERSION VERSION |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 35 | #endif |
| 36 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 37 | /** @brief Where the command line options are stored */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 38 | struct gengetopt_args_info { |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 39 | const char *help_help; |
| 40 | /**< @brief Print help and exit help description. */ |
| 41 | const char *version_help; |
| 42 | /**< @brief Print version and exit help description. */ |
| 43 | int debug_flag; |
| 44 | /**< @brief Run in debug mode (default=off). */ |
| 45 | const char *debug_help; |
| 46 | /**< @brief Run in debug mode help description. */ |
| 47 | char *conf_arg; |
| 48 | /**< @brief Read configuration file. */ |
| 49 | char *conf_orig; |
| 50 | /**< @brief Read configuration file original value given at command line. */ |
| 51 | const char *conf_help; |
| 52 | /**< @brief Read configuration file help description. */ |
| 53 | char *pidfile_arg; |
| 54 | /**< @brief Filename of process id file (default='./sgsnemu.pid'). */ |
| 55 | char *pidfile_orig; |
| 56 | /**< @brief Filename of process id file original value given at command line. */ |
| 57 | const char *pidfile_help; |
| 58 | /**< @brief Filename of process id file help description. */ |
| 59 | char *statedir_arg; |
| 60 | /**< @brief Directory of nonvolatile data (default='./'). */ |
| 61 | char *statedir_orig; |
| 62 | /**< @brief Directory of nonvolatile data original value given at command line. */ |
| 63 | const char *statedir_help; |
| 64 | /**< @brief Directory of nonvolatile data help description. */ |
| 65 | char *dns_arg; |
| 66 | /**< @brief DNS Server to use. */ |
| 67 | char *dns_orig; |
| 68 | /**< @brief DNS Server to use original value given at command line. */ |
| 69 | const char *dns_help; |
| 70 | /**< @brief DNS Server to use help description. */ |
| 71 | char *listen_arg; |
Pau Espin Pedrol | 5fdda13 | 2018-02-12 18:03:09 +0100 | [diff] [blame] | 72 | /**< @brief Local host. */ |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 73 | char *listen_orig; |
Pau Espin Pedrol | 5fdda13 | 2018-02-12 18:03:09 +0100 | [diff] [blame] | 74 | /**< @brief Local host original value given at command line. */ |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 75 | const char *listen_help; |
Pau Espin Pedrol | 5fdda13 | 2018-02-12 18:03:09 +0100 | [diff] [blame] | 76 | /**< @brief Local host help description. */ |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 77 | char *remote_arg; |
| 78 | /**< @brief Remote host. */ |
| 79 | char *remote_orig; |
| 80 | /**< @brief Remote host original value given at command line. */ |
| 81 | const char *remote_help; |
| 82 | /**< @brief Remote host help description. */ |
| 83 | int contexts_arg; |
| 84 | /**< @brief Number of contexts (default='1'). */ |
| 85 | char *contexts_orig; |
| 86 | /**< @brief Number of contexts original value given at command line. */ |
| 87 | const char *contexts_help; |
| 88 | /**< @brief Number of contexts help description. */ |
| 89 | int timelimit_arg; |
| 90 | /**< @brief Exit after timelimit seconds (default='0'). */ |
| 91 | char *timelimit_orig; |
| 92 | /**< @brief Exit after timelimit seconds original value given at command line. */ |
| 93 | const char *timelimit_help; |
| 94 | /**< @brief Exit after timelimit seconds help description. */ |
| 95 | int gtpversion_arg; |
| 96 | /**< @brief GTP version to use (default='1'). */ |
| 97 | char *gtpversion_orig; |
| 98 | /**< @brief GTP version to use original value given at command line. */ |
| 99 | const char *gtpversion_help; |
| 100 | /**< @brief GTP version to use help description. */ |
| 101 | char *apn_arg; |
| 102 | /**< @brief Access point name (default='internet'). */ |
| 103 | char *apn_orig; |
| 104 | /**< @brief Access point name original value given at command line. */ |
| 105 | const char *apn_help; |
| 106 | /**< @brief Access point name help description. */ |
| 107 | int selmode_arg; |
| 108 | /**< @brief Selection mode (default='0x01'). */ |
| 109 | char *selmode_orig; |
| 110 | /**< @brief Selection mode original value given at command line. */ |
| 111 | const char *selmode_help; |
| 112 | /**< @brief Selection mode help description. */ |
| 113 | int rattype_arg; |
| 114 | /**< @brief Radio Access Technology Type (default='1'). */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 115 | char *rattype_orig; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 116 | /**< @brief Radio Access Technology Type original value given at command line. */ |
| 117 | const char *rattype_help; |
| 118 | /**< @brief Radio Access Technology Type help description. */ |
| 119 | char *userloc_arg; |
| 120 | /**< @brief User Location Information (default='02509946241207'). */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 121 | char *userloc_orig; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 122 | /**< @brief User Location Information original value given at command line. */ |
| 123 | const char *userloc_help; |
| 124 | /**< @brief User Location Information help description. */ |
| 125 | char *rai_arg; |
| 126 | /**< @brief Routing Area Information (default='02509946241207'). */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 127 | char *rai_orig; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 128 | /**< @brief Routing Area Information original value given at command line. */ |
| 129 | const char *rai_help; |
| 130 | /**< @brief Routing Area Information help description. */ |
| 131 | char *mstz_arg; |
| 132 | /**< @brief MS Time Zone (default='0'). */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 133 | char *mstz_orig; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 134 | /**< @brief MS Time Zone original value given at command line. */ |
| 135 | const char *mstz_help; |
| 136 | /**< @brief MS Time Zone help description. */ |
| 137 | char *imeisv_arg; |
| 138 | /**< @brief IMEI(SV) International Mobile Equipment Identity (and Software Version) (default='2143658709214365'). */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 139 | char *imeisv_orig; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 140 | /**< @brief IMEI(SV) International Mobile Equipment Identity (and Software Version) original value given at command line. */ |
| 141 | const char *imeisv_help; |
| 142 | /**< @brief IMEI(SV) International Mobile Equipment Identity (and Software Version) help description. */ |
| 143 | int norecovery_flag; |
| 144 | /**< @brief Do not send recovery (default=off). */ |
| 145 | const char *norecovery_help; |
| 146 | /**< @brief Do not send recovery help description. */ |
| 147 | char *imsi_arg; |
| 148 | /**< @brief IMSI (default='240010123456789'). */ |
| 149 | char *imsi_orig; |
| 150 | /**< @brief IMSI original value given at command line. */ |
| 151 | const char *imsi_help; |
| 152 | /**< @brief IMSI help description. */ |
| 153 | int nsapi_arg; |
| 154 | /**< @brief NSAPI (default='0'). */ |
| 155 | char *nsapi_orig; |
| 156 | /**< @brief NSAPI original value given at command line. */ |
| 157 | const char *nsapi_help; |
| 158 | /**< @brief NSAPI help description. */ |
| 159 | char *msisdn_arg; |
| 160 | /**< @brief Mobile Station ISDN number (default='46702123456'). */ |
| 161 | char *msisdn_orig; |
| 162 | /**< @brief Mobile Station ISDN number original value given at command line. */ |
| 163 | const char *msisdn_help; |
| 164 | /**< @brief Mobile Station ISDN number help description. */ |
| 165 | int qos_arg; |
| 166 | /**< @brief Requested quality of service (default='0x000b921f'). */ |
| 167 | char *qos_orig; |
| 168 | /**< @brief Requested quality of service original value given at command line. */ |
| 169 | const char *qos_help; |
| 170 | /**< @brief Requested quality of service help description. */ |
| 171 | unsigned long long int qose1_arg; |
| 172 | /**< @brief Requested quality of service Extension 1 (default='0x9396404074f9ffff'). */ |
| 173 | char *qose1_orig; |
| 174 | /**< @brief Requested quality of service Extension 1 original value given at command line. */ |
| 175 | const char *qose1_help; |
| 176 | /**< @brief Requested quality of service Extension 1 help description. */ |
| 177 | int qose2_arg; |
| 178 | /**< @brief Requested quality of service Extension 2 (default='0x11'). */ |
| 179 | char *qose2_orig; |
| 180 | /**< @brief Requested quality of service Extension 2 original value given at command line. */ |
| 181 | const char *qose2_help; |
| 182 | /**< @brief Requested quality of service Extension 2 help description. */ |
| 183 | int qose3_arg; |
| 184 | /**< @brief Requested quality of service Extension 3 (default='0x0101'). */ |
| 185 | char *qose3_orig; |
| 186 | /**< @brief Requested quality of service Extension 3 original value given at command line. */ |
| 187 | const char *qose3_help; |
| 188 | /**< @brief Requested quality of service Extension 3 help description. */ |
| 189 | int qose4_arg; |
| 190 | /**< @brief Requested quality of service Extension 4 (default='0x4040'). */ |
| 191 | char *qose4_orig; |
| 192 | /**< @brief Requested quality of service Extension 4 original value given at command line. */ |
| 193 | const char *qose4_help; |
| 194 | /**< @brief Requested quality of service Extension 4 help description. */ |
| 195 | int charging_arg; |
| 196 | /**< @brief Charging characteristics (default='0x0800'). */ |
| 197 | char *charging_orig; |
| 198 | /**< @brief Charging characteristics original value given at command line. */ |
| 199 | const char *charging_help; |
| 200 | /**< @brief Charging characteristics help description. */ |
| 201 | char *uid_arg; |
| 202 | /**< @brief Login user ID (default='mig'). */ |
| 203 | char *uid_orig; |
| 204 | /**< @brief Login user ID original value given at command line. */ |
| 205 | const char *uid_help; |
| 206 | /**< @brief Login user ID help description. */ |
| 207 | char *pwd_arg; |
| 208 | /**< @brief Login password (default='hemmelig'). */ |
| 209 | char *pwd_orig; |
| 210 | /**< @brief Login password original value given at command line. */ |
| 211 | const char *pwd_help; |
| 212 | /**< @brief Login password help description. */ |
| 213 | int createif_flag; |
| 214 | /**< @brief Create local network interface (default=off). */ |
| 215 | const char *createif_help; |
| 216 | /**< @brief Create local network interface help description. */ |
| 217 | char *net_arg; |
| 218 | /**< @brief Network address for local interface. */ |
| 219 | char *net_orig; |
| 220 | /**< @brief Network address for local interface original value given at command line. */ |
| 221 | const char *net_help; |
| 222 | /**< @brief Network address for local interface help description. */ |
| 223 | int defaultroute_flag; |
| 224 | /**< @brief Create default route (default=off). */ |
| 225 | const char *defaultroute_help; |
| 226 | /**< @brief Create default route help description. */ |
| 227 | char *ipup_arg; |
| 228 | /**< @brief Script to run after link-up. */ |
| 229 | char *ipup_orig; |
| 230 | /**< @brief Script to run after link-up original value given at command line. */ |
| 231 | const char *ipup_help; |
| 232 | /**< @brief Script to run after link-up help description. */ |
| 233 | char *ipdown_arg; |
| 234 | /**< @brief Script to run after link-down. */ |
| 235 | char *ipdown_orig; |
| 236 | /**< @brief Script to run after link-down original value given at command line. */ |
| 237 | const char *ipdown_help; |
| 238 | /**< @brief Script to run after link-down help description. */ |
Harald Welte | 73abc38 | 2017-10-10 08:50:11 +0800 | [diff] [blame] | 239 | char *tun_device_arg; |
| 240 | /**< @brief Name of the local network interface. */ |
| 241 | char *tun_device_orig; |
| 242 | /**< @brief Name of the local network interface original value given at command line. */ |
| 243 | const char *tun_device_help; |
| 244 | /**< @brief Name of the local network interface help description. */ |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 245 | char *pinghost_arg; |
| 246 | /**< @brief Ping remote host. */ |
| 247 | char *pinghost_orig; |
| 248 | /**< @brief Ping remote host original value given at command line. */ |
| 249 | const char *pinghost_help; |
| 250 | /**< @brief Ping remote host help description. */ |
| 251 | int pingrate_arg; |
| 252 | /**< @brief Number of ping req per second (default='1'). */ |
| 253 | char *pingrate_orig; |
| 254 | /**< @brief Number of ping req per second original value given at command line. */ |
| 255 | const char *pingrate_help; |
| 256 | /**< @brief Number of ping req per second help description. */ |
| 257 | int pingsize_arg; |
| 258 | /**< @brief Number of ping data bytes (default='56'). */ |
| 259 | char *pingsize_orig; |
| 260 | /**< @brief Number of ping data bytes original value given at command line. */ |
| 261 | const char *pingsize_help; |
| 262 | /**< @brief Number of ping data bytes help description. */ |
| 263 | int pingcount_arg; |
| 264 | /**< @brief Number of ping req to send (default='0'). */ |
| 265 | char *pingcount_orig; |
| 266 | /**< @brief Number of ping req to send original value given at command line. */ |
| 267 | const char *pingcount_help; |
| 268 | /**< @brief Number of ping req to send help description. */ |
| 269 | int pingquiet_flag; |
| 270 | /**< @brief Do not print ping packet info (default=off). */ |
| 271 | const char *pingquiet_help; |
| 272 | /**< @brief Do not print ping packet info help description. */ |
Harald Welte | fbb9c7f | 2017-09-24 11:50:20 +0800 | [diff] [blame] | 273 | int no_tx_gpdu_seq_flag; |
| 274 | /**< @brief Don't transmit G-PDU sequence nums (default=off). */ |
| 275 | const char *no_tx_gpdu_seq_help; |
| 276 | /**< @brief Don't transmit G-PDU sequence nums help description. */ |
Harald Welte | 840a8e9 | 2017-09-24 18:12:40 +0800 | [diff] [blame] | 277 | char *pdp_type_arg; |
| 278 | /**< @brief PDP Type (default='v4'). */ |
| 279 | char *pdp_type_orig; |
| 280 | /**< @brief PDP Type original value given at command line. */ |
| 281 | const char *pdp_type_help; |
| 282 | /**< @brief PDP Type help description. */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 283 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 284 | unsigned int help_given; |
| 285 | /**< @brief Whether help was given. */ |
| 286 | unsigned int version_given; |
| 287 | /**< @brief Whether version was given. */ |
| 288 | unsigned int debug_given; |
| 289 | /**< @brief Whether debug was given. */ |
| 290 | unsigned int conf_given; |
| 291 | /**< @brief Whether conf was given. */ |
| 292 | unsigned int pidfile_given; |
| 293 | /**< @brief Whether pidfile was given. */ |
| 294 | unsigned int statedir_given; |
| 295 | /**< @brief Whether statedir was given. */ |
| 296 | unsigned int dns_given; |
| 297 | /**< @brief Whether dns was given. */ |
| 298 | unsigned int listen_given; |
| 299 | /**< @brief Whether listen was given. */ |
| 300 | unsigned int remote_given; |
| 301 | /**< @brief Whether remote was given. */ |
| 302 | unsigned int contexts_given; |
| 303 | /**< @brief Whether contexts was given. */ |
| 304 | unsigned int timelimit_given; |
| 305 | /**< @brief Whether timelimit was given. */ |
| 306 | unsigned int gtpversion_given; |
| 307 | /**< @brief Whether gtpversion was given. */ |
| 308 | unsigned int apn_given; |
| 309 | /**< @brief Whether apn was given. */ |
| 310 | unsigned int selmode_given; |
| 311 | /**< @brief Whether selmode was given. */ |
| 312 | unsigned int rattype_given; |
| 313 | /**< @brief Whether rattype was given. */ |
| 314 | unsigned int userloc_given; |
| 315 | /**< @brief Whether userloc was given. */ |
| 316 | unsigned int rai_given; |
| 317 | /**< @brief Whether rai was given. */ |
| 318 | unsigned int mstz_given; |
| 319 | /**< @brief Whether mstz was given. */ |
| 320 | unsigned int imeisv_given; |
| 321 | /**< @brief Whether imeisv was given. */ |
| 322 | unsigned int norecovery_given; |
| 323 | /**< @brief Whether norecovery was given. */ |
| 324 | unsigned int imsi_given; |
| 325 | /**< @brief Whether imsi was given. */ |
| 326 | unsigned int nsapi_given; |
| 327 | /**< @brief Whether nsapi was given. */ |
| 328 | unsigned int msisdn_given; |
| 329 | /**< @brief Whether msisdn was given. */ |
| 330 | unsigned int qos_given; |
| 331 | /**< @brief Whether qos was given. */ |
| 332 | unsigned int qose1_given; |
| 333 | /**< @brief Whether qose1 was given. */ |
| 334 | unsigned int qose2_given; |
| 335 | /**< @brief Whether qose2 was given. */ |
| 336 | unsigned int qose3_given; |
| 337 | /**< @brief Whether qose3 was given. */ |
| 338 | unsigned int qose4_given; |
| 339 | /**< @brief Whether qose4 was given. */ |
| 340 | unsigned int charging_given; |
| 341 | /**< @brief Whether charging was given. */ |
| 342 | unsigned int uid_given; |
| 343 | /**< @brief Whether uid was given. */ |
| 344 | unsigned int pwd_given; |
| 345 | /**< @brief Whether pwd was given. */ |
| 346 | unsigned int createif_given; |
| 347 | /**< @brief Whether createif was given. */ |
| 348 | unsigned int net_given; |
| 349 | /**< @brief Whether net was given. */ |
| 350 | unsigned int defaultroute_given; |
| 351 | /**< @brief Whether defaultroute was given. */ |
| 352 | unsigned int ipup_given; |
| 353 | /**< @brief Whether ipup was given. */ |
| 354 | unsigned int ipdown_given; |
| 355 | /**< @brief Whether ipdown was given. */ |
Harald Welte | 73abc38 | 2017-10-10 08:50:11 +0800 | [diff] [blame] | 356 | unsigned int tun_device_given; |
| 357 | /**< @brief Whether tun-device was given. */ |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 358 | unsigned int pinghost_given; |
| 359 | /**< @brief Whether pinghost was given. */ |
| 360 | unsigned int pingrate_given; |
| 361 | /**< @brief Whether pingrate was given. */ |
| 362 | unsigned int pingsize_given; |
| 363 | /**< @brief Whether pingsize was given. */ |
| 364 | unsigned int pingcount_given; |
| 365 | /**< @brief Whether pingcount was given. */ |
| 366 | unsigned int pingquiet_given; |
| 367 | /**< @brief Whether pingquiet was given. */ |
Harald Welte | fbb9c7f | 2017-09-24 11:50:20 +0800 | [diff] [blame] | 368 | unsigned int no_tx_gpdu_seq_given; |
| 369 | /**< @brief Whether no-tx-gpdu-seq was given. */ |
Harald Welte | 840a8e9 | 2017-09-24 18:12:40 +0800 | [diff] [blame] | 370 | unsigned int pdp_type_given; |
| 371 | /**< @brief Whether pdp-type was given. */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 372 | |
Viktor Tsymbalyuk | ab4db10 | 2018-01-30 14:40:12 +0200 | [diff] [blame] | 373 | int createif_mode_counter; |
| 374 | /**< @brief Counter for mode createif */ |
| 375 | int pinghost_mode_counter; |
| 376 | /**< @brief Counter for mode pinghost */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 377 | }; |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 378 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 379 | /** @brief The additional parameters to pass to parser functions */ |
| 380 | struct cmdline_parser_params { |
| 381 | int override; |
| 382 | /**< @brief whether to override possibly already present options (default 0) */ |
| 383 | int initialize; |
| 384 | /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ |
| 385 | int check_required; |
| 386 | /**< @brief whether to check that all required options were provided (default 1) */ |
| 387 | int check_ambiguity; |
| 388 | /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ |
| 389 | int print_errors; |
| 390 | /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ |
| 391 | }; |
| 392 | |
| 393 | /** @brief the purpose string of the program */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 394 | extern const char *gengetopt_args_info_purpose; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 395 | /** @brief the usage string of the program */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 396 | extern const char *gengetopt_args_info_usage; |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 397 | /** @brief the description string of the program */ |
| 398 | extern const char *gengetopt_args_info_description; |
| 399 | /** @brief all the lines making the help output */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 400 | extern const char *gengetopt_args_info_help[]; |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 401 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 402 | /** |
| 403 | * The command line parser |
| 404 | * @param argc the number of command line options |
| 405 | * @param argv the command line options |
| 406 | * @param args_info the structure where option information will be stored |
| 407 | * @return 0 if everything went fine, NON 0 if an error took place |
| 408 | */ |
| 409 | int cmdline_parser(int argc, char **argv, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 410 | struct gengetopt_args_info *args_info); |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 411 | |
| 412 | /** |
| 413 | * The command line parser (version with additional parameters - deprecated) |
| 414 | * @param argc the number of command line options |
| 415 | * @param argv the command line options |
| 416 | * @param args_info the structure where option information will be stored |
| 417 | * @param override whether to override possibly already present options |
| 418 | * @param initialize whether to initialize the option structure my_args_info |
| 419 | * @param check_required whether to check that all required options were provided |
| 420 | * @return 0 if everything went fine, NON 0 if an error took place |
| 421 | * @deprecated use cmdline_parser_ext() instead |
| 422 | */ |
| 423 | int cmdline_parser2(int argc, char **argv, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 424 | struct gengetopt_args_info *args_info, |
| 425 | int override, int initialize, int check_required); |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 426 | |
| 427 | /** |
| 428 | * The command line parser (version with additional parameters) |
| 429 | * @param argc the number of command line options |
| 430 | * @param argv the command line options |
| 431 | * @param args_info the structure where option information will be stored |
| 432 | * @param params additional parameters for the parser |
| 433 | * @return 0 if everything went fine, NON 0 if an error took place |
| 434 | */ |
| 435 | int cmdline_parser_ext(int argc, char **argv, |
| 436 | struct gengetopt_args_info *args_info, |
| 437 | struct cmdline_parser_params *params); |
| 438 | |
| 439 | /** |
| 440 | * Save the contents of the option struct into an already open FILE stream. |
| 441 | * @param outfile the stream where to dump options |
| 442 | * @param args_info the option struct to dump |
| 443 | * @return 0 if everything went fine, NON 0 if an error took place |
| 444 | */ |
| 445 | int cmdline_parser_dump(FILE * outfile, |
| 446 | struct gengetopt_args_info *args_info); |
| 447 | |
| 448 | /** |
| 449 | * Save the contents of the option struct into a (text) file. |
| 450 | * This file can be read by the config file parser (if generated by gengetopt) |
| 451 | * @param filename the file where to save |
| 452 | * @param args_info the option struct to save |
| 453 | * @return 0 if everything went fine, NON 0 if an error took place |
| 454 | */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 455 | int cmdline_parser_file_save(const char *filename, |
| 456 | struct gengetopt_args_info *args_info); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 457 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 458 | /** |
| 459 | * Print the help |
| 460 | */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 461 | void cmdline_parser_print_help(void); |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 462 | /** |
| 463 | * Print the version |
| 464 | */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 465 | void cmdline_parser_print_version(void); |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 466 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 467 | /** |
| 468 | * Initializes all the fields a cmdline_parser_params structure |
| 469 | * to their default values |
| 470 | * @param params the structure to initialize |
| 471 | */ |
| 472 | void cmdline_parser_params_init(struct cmdline_parser_params *params); |
| 473 | |
| 474 | /** |
| 475 | * Allocates dynamically a cmdline_parser_params structure and initializes |
| 476 | * all its fields to their default values |
| 477 | * @return the created and initialized cmdline_parser_params structure |
| 478 | */ |
| 479 | struct cmdline_parser_params *cmdline_parser_params_create(void); |
| 480 | |
| 481 | /** |
| 482 | * Initializes the passed gengetopt_args_info structure's fields |
| 483 | * (also set default values for options that have a default) |
| 484 | * @param args_info the structure to initialize |
| 485 | */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 486 | void cmdline_parser_init(struct gengetopt_args_info *args_info); |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 487 | /** |
| 488 | * Deallocates the string fields of the gengetopt_args_info structure |
| 489 | * (but does not deallocate the structure itself) |
| 490 | * @param args_info the structure to deallocate |
| 491 | */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 492 | void cmdline_parser_free(struct gengetopt_args_info *args_info); |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 493 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 494 | /** |
| 495 | * The config file parser (deprecated version) |
| 496 | * @param filename the name of the config file |
| 497 | * @param args_info the structure where option information will be stored |
| 498 | * @param override whether to override possibly already present options |
| 499 | * @param initialize whether to initialize the option structure my_args_info |
| 500 | * @param check_required whether to check that all required options were provided |
| 501 | * @return 0 if everything went fine, NON 0 if an error took place |
| 502 | * @deprecated use cmdline_parser_config_file() instead |
| 503 | */ |
| 504 | int cmdline_parser_configfile(const char *filename, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 505 | struct gengetopt_args_info *args_info, |
| 506 | int override, int initialize, |
| 507 | int check_required); |
Harald Welte | 1b3e577 | 2010-05-04 11:13:56 +0200 | [diff] [blame] | 508 | |
Harald Welte | f621498 | 2017-09-24 10:23:24 +0800 | [diff] [blame] | 509 | /** |
| 510 | * The config file parser |
| 511 | * @param filename the name of the config file |
| 512 | * @param args_info the structure where option information will be stored |
| 513 | * @param params additional parameters for the parser |
| 514 | * @return 0 if everything went fine, NON 0 if an error took place |
| 515 | */ |
| 516 | int cmdline_parser_config_file(const char *filename, |
| 517 | struct gengetopt_args_info *args_info, |
| 518 | struct cmdline_parser_params *params); |
| 519 | |
| 520 | /** |
| 521 | * Checks that all the required options were specified |
| 522 | * @param args_info the structure to check |
| 523 | * @param prog_name the name of the program that will be used to print |
| 524 | * possible errors |
| 525 | * @return |
| 526 | */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 527 | int cmdline_parser_required(struct gengetopt_args_info *args_info, |
| 528 | const char *prog_name); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 529 | |
| 530 | #ifdef __cplusplus |
| 531 | } |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 532 | #endif /* __cplusplus */ |
| 533 | #endif /* CMDLINE_H */ |