jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 1 | /* |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 2 | File autogenerated by gengetopt version 2.8 |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 3 | generated with the following command: |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 4 | gengetopt --conf-parser |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 5 | |
| 6 | The developers of gengetopt consider the fixed text that goes in all |
| 7 | gengetopt output files to be in the public domain: |
| 8 | we make no copyright claims on it. |
| 9 | */ |
| 10 | |
| 11 | |
| 12 | #include <stdio.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
| 15 | /* If we use autoconf. */ |
| 16 | #ifdef HAVE_CONFIG_H |
| 17 | #include "config.h" |
| 18 | #endif |
| 19 | /* Check for configure's getopt check result. */ |
| 20 | #ifndef HAVE_GETOPT_LONG |
| 21 | #include "getopt.h" |
| 22 | #else |
| 23 | #include <getopt.h> |
| 24 | #endif |
| 25 | |
| 26 | #ifndef HAVE_STRDUP |
| 27 | #define strdup gengetopt_strdup |
| 28 | #endif /* HAVE_STRDUP */ |
| 29 | |
| 30 | #include "cmdline.h" |
| 31 | |
| 32 | |
| 33 | void |
| 34 | cmdline_parser_print_version (void) |
| 35 | { |
| 36 | printf ("%s %s\n", PACKAGE, VERSION); |
| 37 | } |
| 38 | |
| 39 | void |
| 40 | cmdline_parser_print_help (void) |
| 41 | { |
| 42 | cmdline_parser_print_version (); |
| 43 | printf("\n" |
| 44 | "Usage: %s [OPTIONS]...\n", PACKAGE); |
| 45 | printf(" -h --help Print help and exit\n"); |
| 46 | printf(" -V --version Print version and exit\n"); |
| 47 | printf(" -f --fg Run in foreground (default=off)\n"); |
| 48 | printf(" -d --debug Run in debug mode (default=off)\n"); |
| 49 | printf(" -cSTRING --conf=STRING Read configuration file (default='/etc/ggsn.conf')\n"); |
| 50 | printf(" --pidfile=STRING Filename of process id file (default='/var/run/ggsn.pid')\n"); |
| 51 | printf(" --statedir=STRING Directory of nonvolatile data (default='/var/lib/ggsn/')\n"); |
| 52 | printf(" -lSTRING --listen=STRING Local interface\n"); |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 53 | printf(" -nSTRING --net=STRING Network (default='192.168.0.0/24')\n"); |
| 54 | printf(" --ipup=STRING Script to run after link-up\n"); |
| 55 | printf(" --ipdown=STRING Script to run after link-down\n"); |
jjako | a7c3381 | 2003-04-11 11:51:39 +0000 | [diff] [blame] | 56 | printf(" --dynip=STRING Dynamic IP address pool\n"); |
| 57 | printf(" --statip=STRING Static IP address pool\n"); |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 58 | printf(" --pcodns1=STRING PCO DNS Server 1 (default='0.0.0.0')\n"); |
| 59 | printf(" --pcodns2=STRING PCO DNS Server 2 (default='0.0.0.0')\n"); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 60 | printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n"); |
| 61 | printf(" -aSTRING --apn=STRING Access point name (default='internet')\n"); |
| 62 | printf(" -qINT --qos=INT Requested quality of service (default='0x0b921f')\n"); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | #ifndef HAVE_STRDUP |
| 67 | /* gengetopt_strdup(): automatically generated from strdup.c. */ |
| 68 | /* strdup.c replacement of strdup, which is not standard */ |
| 69 | static char * |
| 70 | gengetopt_strdup (const char *s) |
| 71 | { |
| 72 | char *result = (char*)malloc(strlen(s) + 1); |
| 73 | if (result == (char*)0) |
| 74 | return (char*)0; |
| 75 | strcpy(result, s); |
| 76 | return result; |
| 77 | } |
| 78 | #endif /* HAVE_STRDUP */ |
| 79 | |
| 80 | int |
| 81 | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 82 | { |
| 83 | int c; /* Character of the parsed option. */ |
| 84 | int missing_required_options = 0; |
| 85 | |
| 86 | args_info->help_given = 0 ; |
| 87 | args_info->version_given = 0 ; |
| 88 | args_info->fg_given = 0 ; |
| 89 | args_info->debug_given = 0 ; |
| 90 | args_info->conf_given = 0 ; |
| 91 | args_info->pidfile_given = 0 ; |
| 92 | args_info->statedir_given = 0 ; |
| 93 | args_info->listen_given = 0 ; |
| 94 | args_info->net_given = 0 ; |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 95 | args_info->ipup_given = 0 ; |
| 96 | args_info->ipdown_given = 0 ; |
| 97 | args_info->dynip_given = 0 ; |
| 98 | args_info->statip_given = 0 ; |
| 99 | args_info->pcodns1_given = 0 ; |
| 100 | args_info->pcodns2_given = 0 ; |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 101 | args_info->timelimit_given = 0 ; |
| 102 | args_info->apn_given = 0 ; |
| 103 | args_info->qos_given = 0 ; |
| 104 | #define clear_args() { \ |
| 105 | args_info->fg_flag = 0;\ |
| 106 | args_info->debug_flag = 0;\ |
| 107 | args_info->conf_arg = strdup("/etc/ggsn.conf") ;\ |
| 108 | args_info->pidfile_arg = strdup("/var/run/ggsn.pid") ;\ |
| 109 | args_info->statedir_arg = strdup("/var/lib/ggsn/") ;\ |
| 110 | args_info->listen_arg = NULL; \ |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 111 | args_info->net_arg = strdup("192.168.0.0/24") ;\ |
| 112 | args_info->ipup_arg = NULL; \ |
| 113 | args_info->ipdown_arg = NULL; \ |
jjako | a7c3381 | 2003-04-11 11:51:39 +0000 | [diff] [blame] | 114 | args_info->dynip_arg = NULL; \ |
| 115 | args_info->statip_arg = NULL; \ |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 116 | args_info->pcodns1_arg = strdup("0.0.0.0") ;\ |
| 117 | args_info->pcodns2_arg = strdup("0.0.0.0") ;\ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 118 | args_info->timelimit_arg = 0 ;\ |
| 119 | args_info->apn_arg = strdup("internet") ;\ |
| 120 | args_info->qos_arg = 0x0b921f ;\ |
| 121 | } |
| 122 | |
| 123 | clear_args(); |
| 124 | |
| 125 | optarg = 0; |
| 126 | optind = 1; |
| 127 | opterr = 1; |
| 128 | optopt = '?'; |
| 129 | |
| 130 | while (1) |
| 131 | { |
| 132 | int option_index = 0; |
| 133 | char *stop_char; |
| 134 | static struct option long_options[] = { |
| 135 | { "help", 0, NULL, 'h' }, |
| 136 | { "version", 0, NULL, 'V' }, |
| 137 | { "fg", 0, NULL, 'f' }, |
| 138 | { "debug", 0, NULL, 'd' }, |
| 139 | { "conf", 1, NULL, 'c' }, |
| 140 | { "pidfile", 1, NULL, 0 }, |
| 141 | { "statedir", 1, NULL, 0 }, |
| 142 | { "listen", 1, NULL, 'l' }, |
| 143 | { "net", 1, NULL, 'n' }, |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 144 | { "ipup", 1, NULL, 0 }, |
| 145 | { "ipdown", 1, NULL, 0 }, |
| 146 | { "dynip", 1, NULL, 0 }, |
| 147 | { "statip", 1, NULL, 0 }, |
| 148 | { "pcodns1", 1, NULL, 0 }, |
| 149 | { "pcodns2", 1, NULL, 0 }, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 150 | { "timelimit", 1, NULL, 0 }, |
| 151 | { "apn", 1, NULL, 'a' }, |
| 152 | { "qos", 1, NULL, 'q' }, |
| 153 | { NULL, 0, NULL, 0 } |
| 154 | }; |
| 155 | |
| 156 | c = getopt_long (argc, argv, "hVfdc:l:n:a:q:", long_options, &option_index); |
| 157 | |
| 158 | if (c == -1) break; /* Exit from `while (1)' loop. */ |
| 159 | |
| 160 | switch (c) |
| 161 | { |
| 162 | case 'h': /* Print help and exit. */ |
| 163 | clear_args (); |
| 164 | cmdline_parser_print_help (); |
| 165 | exit (EXIT_SUCCESS); |
| 166 | |
| 167 | case 'V': /* Print version and exit. */ |
| 168 | clear_args (); |
| 169 | cmdline_parser_print_version (); |
| 170 | exit (EXIT_SUCCESS); |
| 171 | |
| 172 | case 'f': /* Run in foreground. */ |
| 173 | if (args_info->fg_given) |
| 174 | { |
| 175 | fprintf (stderr, "%s: `--fg' (`-f') option given more than once\n", PACKAGE); |
| 176 | clear_args (); |
| 177 | exit (EXIT_FAILURE); |
| 178 | } |
| 179 | args_info->fg_given = 1; |
| 180 | args_info->fg_flag = !(args_info->fg_flag); |
| 181 | break; |
| 182 | |
| 183 | case 'd': /* Run in debug mode. */ |
| 184 | if (args_info->debug_given) |
| 185 | { |
| 186 | fprintf (stderr, "%s: `--debug' (`-d') option given more than once\n", PACKAGE); |
| 187 | clear_args (); |
| 188 | exit (EXIT_FAILURE); |
| 189 | } |
| 190 | args_info->debug_given = 1; |
| 191 | args_info->debug_flag = !(args_info->debug_flag); |
| 192 | break; |
| 193 | |
| 194 | case 'c': /* Read configuration file. */ |
| 195 | if (args_info->conf_given) |
| 196 | { |
| 197 | fprintf (stderr, "%s: `--conf' (`-c') option given more than once\n", PACKAGE); |
| 198 | clear_args (); |
| 199 | exit (EXIT_FAILURE); |
| 200 | } |
| 201 | args_info->conf_given = 1; |
| 202 | args_info->conf_arg = strdup (optarg); |
| 203 | break; |
| 204 | |
| 205 | case 'l': /* Local interface. */ |
| 206 | if (args_info->listen_given) |
| 207 | { |
| 208 | fprintf (stderr, "%s: `--listen' (`-l') option given more than once\n", PACKAGE); |
| 209 | clear_args (); |
| 210 | exit (EXIT_FAILURE); |
| 211 | } |
| 212 | args_info->listen_given = 1; |
| 213 | args_info->listen_arg = strdup (optarg); |
| 214 | break; |
| 215 | |
| 216 | case 'n': /* Network. */ |
| 217 | if (args_info->net_given) |
| 218 | { |
| 219 | fprintf (stderr, "%s: `--net' (`-n') option given more than once\n", PACKAGE); |
| 220 | clear_args (); |
| 221 | exit (EXIT_FAILURE); |
| 222 | } |
| 223 | args_info->net_given = 1; |
| 224 | args_info->net_arg = strdup (optarg); |
| 225 | break; |
| 226 | |
| 227 | case 'a': /* Access point name. */ |
| 228 | if (args_info->apn_given) |
| 229 | { |
| 230 | fprintf (stderr, "%s: `--apn' (`-a') option given more than once\n", PACKAGE); |
| 231 | clear_args (); |
| 232 | exit (EXIT_FAILURE); |
| 233 | } |
| 234 | args_info->apn_given = 1; |
| 235 | args_info->apn_arg = strdup (optarg); |
| 236 | break; |
| 237 | |
| 238 | case 'q': /* Requested quality of service. */ |
| 239 | if (args_info->qos_given) |
| 240 | { |
| 241 | fprintf (stderr, "%s: `--qos' (`-q') option given more than once\n", PACKAGE); |
| 242 | clear_args (); |
| 243 | exit (EXIT_FAILURE); |
| 244 | } |
| 245 | args_info->qos_given = 1; |
| 246 | args_info->qos_arg = strtol (optarg,&stop_char,0); |
| 247 | break; |
| 248 | |
| 249 | |
| 250 | case 0: /* Long option with no short option */ |
| 251 | /* Filename of process id file. */ |
| 252 | if (strcmp (long_options[option_index].name, "pidfile") == 0) |
| 253 | { |
| 254 | if (args_info->pidfile_given) |
| 255 | { |
| 256 | fprintf (stderr, "%s: `--pidfile' option given more than once\n", PACKAGE); |
| 257 | clear_args (); |
| 258 | exit (EXIT_FAILURE); |
| 259 | } |
| 260 | args_info->pidfile_given = 1; |
| 261 | args_info->pidfile_arg = strdup (optarg); |
| 262 | break; |
| 263 | } |
| 264 | /* Directory of nonvolatile data. */ |
| 265 | else if (strcmp (long_options[option_index].name, "statedir") == 0) |
| 266 | { |
| 267 | if (args_info->statedir_given) |
| 268 | { |
| 269 | fprintf (stderr, "%s: `--statedir' option given more than once\n", PACKAGE); |
| 270 | clear_args (); |
| 271 | exit (EXIT_FAILURE); |
| 272 | } |
| 273 | args_info->statedir_given = 1; |
| 274 | args_info->statedir_arg = strdup (optarg); |
| 275 | break; |
| 276 | } |
jjako | 4b26b51 | 2003-01-28 16:13:57 +0000 | [diff] [blame] | 277 | /* Script to run after link-up. */ |
| 278 | else if (strcmp (long_options[option_index].name, "ipup") == 0) |
| 279 | { |
| 280 | if (args_info->ipup_given) |
| 281 | { |
| 282 | fprintf (stderr, "%s: `--ipup' option given more than once\n", PACKAGE); |
| 283 | clear_args (); |
| 284 | exit (EXIT_FAILURE); |
| 285 | } |
| 286 | args_info->ipup_given = 1; |
| 287 | args_info->ipup_arg = strdup (optarg); |
| 288 | break; |
| 289 | } |
| 290 | /* Script to run after link-down. */ |
| 291 | else if (strcmp (long_options[option_index].name, "ipdown") == 0) |
| 292 | { |
| 293 | if (args_info->ipdown_given) |
| 294 | { |
| 295 | fprintf (stderr, "%s: `--ipdown' option given more than once\n", PACKAGE); |
| 296 | clear_args (); |
| 297 | exit (EXIT_FAILURE); |
| 298 | } |
| 299 | args_info->ipdown_given = 1; |
| 300 | args_info->ipdown_arg = strdup (optarg); |
| 301 | break; |
| 302 | } |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 303 | /* Dynamic IP address pool. */ |
| 304 | else if (strcmp (long_options[option_index].name, "dynip") == 0) |
| 305 | { |
| 306 | if (args_info->dynip_given) |
| 307 | { |
| 308 | fprintf (stderr, "%s: `--dynip' option given more than once\n", PACKAGE); |
| 309 | clear_args (); |
| 310 | exit (EXIT_FAILURE); |
| 311 | } |
| 312 | args_info->dynip_given = 1; |
| 313 | args_info->dynip_arg = strdup (optarg); |
| 314 | break; |
| 315 | } |
| 316 | /* Static IP address pool. */ |
| 317 | else if (strcmp (long_options[option_index].name, "statip") == 0) |
| 318 | { |
| 319 | if (args_info->statip_given) |
| 320 | { |
| 321 | fprintf (stderr, "%s: `--statip' option given more than once\n", PACKAGE); |
| 322 | clear_args (); |
| 323 | exit (EXIT_FAILURE); |
| 324 | } |
| 325 | args_info->statip_given = 1; |
| 326 | args_info->statip_arg = strdup (optarg); |
| 327 | break; |
| 328 | } |
| 329 | /* PCO DNS Server 1. */ |
| 330 | else if (strcmp (long_options[option_index].name, "pcodns1") == 0) |
| 331 | { |
| 332 | if (args_info->pcodns1_given) |
| 333 | { |
| 334 | fprintf (stderr, "%s: `--pcodns1' option given more than once\n", PACKAGE); |
| 335 | clear_args (); |
| 336 | exit (EXIT_FAILURE); |
| 337 | } |
| 338 | args_info->pcodns1_given = 1; |
| 339 | args_info->pcodns1_arg = strdup (optarg); |
| 340 | break; |
| 341 | } |
| 342 | /* PCO DNS Server 2. */ |
| 343 | else if (strcmp (long_options[option_index].name, "pcodns2") == 0) |
| 344 | { |
| 345 | if (args_info->pcodns2_given) |
| 346 | { |
| 347 | fprintf (stderr, "%s: `--pcodns2' option given more than once\n", PACKAGE); |
| 348 | clear_args (); |
| 349 | exit (EXIT_FAILURE); |
| 350 | } |
| 351 | args_info->pcodns2_given = 1; |
| 352 | args_info->pcodns2_arg = strdup (optarg); |
| 353 | break; |
| 354 | } |
| 355 | /* Exit after timelimit seconds. */ |
| 356 | else if (strcmp (long_options[option_index].name, "timelimit") == 0) |
| 357 | { |
| 358 | if (args_info->timelimit_given) |
| 359 | { |
| 360 | fprintf (stderr, "%s: `--timelimit' option given more than once\n", PACKAGE); |
| 361 | clear_args (); |
| 362 | exit (EXIT_FAILURE); |
| 363 | } |
| 364 | args_info->timelimit_given = 1; |
| 365 | args_info->timelimit_arg = strtol (optarg,&stop_char,0); |
| 366 | break; |
| 367 | } |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 368 | |
| 369 | case '?': /* Invalid option. */ |
| 370 | /* `getopt_long' already printed an error message. */ |
| 371 | exit (EXIT_FAILURE); |
| 372 | |
| 373 | default: /* bug: option not considered. */ |
| 374 | fprintf (stderr, "%s: option unknown: %c\n", PACKAGE, c); |
| 375 | abort (); |
| 376 | } /* switch */ |
| 377 | } /* while */ |
| 378 | |
| 379 | |
| 380 | if ( missing_required_options ) |
| 381 | exit (EXIT_FAILURE); |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | #define CONFIGPARSERBUFSIZE 1024 |
| 387 | |
| 388 | int |
| 389 | cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override) |
| 390 | { |
| 391 | FILE* file; |
| 392 | char linebuf[CONFIGPARSERBUFSIZE]; |
| 393 | int line_num = 0; |
| 394 | int len; |
| 395 | int fnum; |
| 396 | char fopt[CONFIGPARSERBUFSIZE], farg[CONFIGPARSERBUFSIZE]; |
| 397 | char *stop_char; |
| 398 | |
| 399 | if ((file = fopen(filename, "r")) == NULL) |
| 400 | { |
| 401 | fprintf (stderr, "%s: Error opening configuration file '%s'\n", |
| 402 | PACKAGE, filename); |
| 403 | exit (EXIT_FAILURE); |
| 404 | } |
| 405 | |
| 406 | while ((fgets(linebuf, CONFIGPARSERBUFSIZE, file)) != NULL) |
| 407 | { |
| 408 | ++line_num; |
| 409 | len = strlen(linebuf); |
| 410 | if (len == CONFIGPARSERBUFSIZE-1) |
| 411 | { |
| 412 | fprintf (stderr, "%s: Line longer than %d characters found in configuration file '%s'\n", |
| 413 | PACKAGE, CONFIGPARSERBUFSIZE, filename); |
| 414 | exit (EXIT_FAILURE); |
| 415 | } |
| 416 | |
| 417 | if (linebuf[0] == '#') |
| 418 | continue; /* Line was a comment */ |
| 419 | |
| 420 | /* Get the option */ |
| 421 | if ((fnum = sscanf(linebuf, "%s %s", fopt, farg)) > 0) |
| 422 | { |
| 423 | if (!strcmp(fopt, "help")) |
| 424 | { |
| 425 | if (override || !args_info->help_given) |
| 426 | { |
| 427 | args_info->help_given = 1; |
| 428 | |
| 429 | } |
| 430 | continue; |
| 431 | } |
| 432 | if (!strcmp(fopt, "version")) |
| 433 | { |
| 434 | if (override || !args_info->version_given) |
| 435 | { |
| 436 | args_info->version_given = 1; |
| 437 | |
| 438 | } |
| 439 | continue; |
| 440 | } |
| 441 | if (!strcmp(fopt, "fg")) |
| 442 | { |
| 443 | if (override || !args_info->fg_given) |
| 444 | { |
| 445 | args_info->fg_given = 1; |
| 446 | args_info->fg_flag = !(args_info->fg_flag); |
| 447 | } |
| 448 | continue; |
| 449 | } |
| 450 | if (!strcmp(fopt, "debug")) |
| 451 | { |
| 452 | if (override || !args_info->debug_given) |
| 453 | { |
| 454 | args_info->debug_given = 1; |
| 455 | args_info->debug_flag = !(args_info->debug_flag); |
| 456 | } |
| 457 | continue; |
| 458 | } |
| 459 | if (!strcmp(fopt, "conf")) |
| 460 | { |
| 461 | if (override || !args_info->conf_given) |
| 462 | { |
| 463 | args_info->conf_given = 1; |
| 464 | if (fnum == 2) |
| 465 | args_info->conf_arg = strdup (farg); |
| 466 | else |
| 467 | { |
| 468 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 469 | filename, line_num); |
| 470 | exit (EXIT_FAILURE); |
| 471 | } |
| 472 | } |
| 473 | continue; |
| 474 | } |
| 475 | if (!strcmp(fopt, "pidfile")) |
| 476 | { |
| 477 | if (override || !args_info->pidfile_given) |
| 478 | { |
| 479 | args_info->pidfile_given = 1; |
| 480 | if (fnum == 2) |
| 481 | args_info->pidfile_arg = strdup (farg); |
| 482 | else |
| 483 | { |
| 484 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 485 | filename, line_num); |
| 486 | exit (EXIT_FAILURE); |
| 487 | } |
| 488 | } |
| 489 | continue; |
| 490 | } |
| 491 | if (!strcmp(fopt, "statedir")) |
| 492 | { |
| 493 | if (override || !args_info->statedir_given) |
| 494 | { |
| 495 | args_info->statedir_given = 1; |
| 496 | if (fnum == 2) |
| 497 | args_info->statedir_arg = strdup (farg); |
| 498 | else |
| 499 | { |
| 500 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 501 | filename, line_num); |
| 502 | exit (EXIT_FAILURE); |
| 503 | } |
| 504 | } |
| 505 | continue; |
| 506 | } |
| 507 | if (!strcmp(fopt, "listen")) |
| 508 | { |
| 509 | if (override || !args_info->listen_given) |
| 510 | { |
| 511 | args_info->listen_given = 1; |
| 512 | if (fnum == 2) |
| 513 | args_info->listen_arg = strdup (farg); |
| 514 | else |
| 515 | { |
| 516 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 517 | filename, line_num); |
| 518 | exit (EXIT_FAILURE); |
| 519 | } |
| 520 | } |
| 521 | continue; |
| 522 | } |
| 523 | if (!strcmp(fopt, "net")) |
| 524 | { |
| 525 | if (override || !args_info->net_given) |
| 526 | { |
| 527 | args_info->net_given = 1; |
| 528 | if (fnum == 2) |
| 529 | args_info->net_arg = strdup (farg); |
| 530 | else |
| 531 | { |
| 532 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 533 | filename, line_num); |
| 534 | exit (EXIT_FAILURE); |
| 535 | } |
| 536 | } |
| 537 | continue; |
| 538 | } |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 539 | if (!strcmp(fopt, "ipup")) |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 540 | { |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 541 | if (override || !args_info->ipup_given) |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 542 | { |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 543 | args_info->ipup_given = 1; |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 544 | if (fnum == 2) |
jjako | a7cd249 | 2003-04-11 09:40:12 +0000 | [diff] [blame] | 545 | args_info->ipup_arg = strdup (farg); |
| 546 | else |
| 547 | { |
| 548 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 549 | filename, line_num); |
| 550 | exit (EXIT_FAILURE); |
| 551 | } |
| 552 | } |
| 553 | continue; |
| 554 | } |
| 555 | if (!strcmp(fopt, "ipdown")) |
| 556 | { |
| 557 | if (override || !args_info->ipdown_given) |
| 558 | { |
| 559 | args_info->ipdown_given = 1; |
| 560 | if (fnum == 2) |
| 561 | args_info->ipdown_arg = strdup (farg); |
| 562 | else |
| 563 | { |
| 564 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 565 | filename, line_num); |
| 566 | exit (EXIT_FAILURE); |
| 567 | } |
| 568 | } |
| 569 | continue; |
| 570 | } |
| 571 | if (!strcmp(fopt, "dynip")) |
| 572 | { |
| 573 | if (override || !args_info->dynip_given) |
| 574 | { |
| 575 | args_info->dynip_given = 1; |
| 576 | if (fnum == 2) |
| 577 | args_info->dynip_arg = strdup (farg); |
| 578 | else |
| 579 | { |
| 580 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 581 | filename, line_num); |
| 582 | exit (EXIT_FAILURE); |
| 583 | } |
| 584 | } |
| 585 | continue; |
| 586 | } |
| 587 | if (!strcmp(fopt, "statip")) |
| 588 | { |
| 589 | if (override || !args_info->statip_given) |
| 590 | { |
| 591 | args_info->statip_given = 1; |
| 592 | if (fnum == 2) |
| 593 | args_info->statip_arg = strdup (farg); |
| 594 | else |
| 595 | { |
| 596 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 597 | filename, line_num); |
| 598 | exit (EXIT_FAILURE); |
| 599 | } |
| 600 | } |
| 601 | continue; |
| 602 | } |
| 603 | if (!strcmp(fopt, "pcodns1")) |
| 604 | { |
| 605 | if (override || !args_info->pcodns1_given) |
| 606 | { |
| 607 | args_info->pcodns1_given = 1; |
| 608 | if (fnum == 2) |
| 609 | args_info->pcodns1_arg = strdup (farg); |
| 610 | else |
| 611 | { |
| 612 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 613 | filename, line_num); |
| 614 | exit (EXIT_FAILURE); |
| 615 | } |
| 616 | } |
| 617 | continue; |
| 618 | } |
| 619 | if (!strcmp(fopt, "pcodns2")) |
| 620 | { |
| 621 | if (override || !args_info->pcodns2_given) |
| 622 | { |
| 623 | args_info->pcodns2_given = 1; |
| 624 | if (fnum == 2) |
| 625 | args_info->pcodns2_arg = strdup (farg); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 626 | else |
| 627 | { |
| 628 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 629 | filename, line_num); |
| 630 | exit (EXIT_FAILURE); |
| 631 | } |
| 632 | } |
| 633 | continue; |
| 634 | } |
| 635 | if (!strcmp(fopt, "timelimit")) |
| 636 | { |
| 637 | if (override || !args_info->timelimit_given) |
| 638 | { |
| 639 | args_info->timelimit_given = 1; |
| 640 | if (fnum == 2) |
| 641 | args_info->timelimit_arg = strtol (farg,&stop_char,0); |
| 642 | else |
| 643 | { |
| 644 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 645 | filename, line_num); |
| 646 | exit (EXIT_FAILURE); |
| 647 | } |
| 648 | } |
| 649 | continue; |
| 650 | } |
| 651 | if (!strcmp(fopt, "apn")) |
| 652 | { |
| 653 | if (override || !args_info->apn_given) |
| 654 | { |
| 655 | args_info->apn_given = 1; |
| 656 | if (fnum == 2) |
| 657 | args_info->apn_arg = strdup (farg); |
| 658 | else |
| 659 | { |
| 660 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 661 | filename, line_num); |
| 662 | exit (EXIT_FAILURE); |
| 663 | } |
| 664 | } |
| 665 | continue; |
| 666 | } |
| 667 | if (!strcmp(fopt, "qos")) |
| 668 | { |
| 669 | if (override || !args_info->qos_given) |
| 670 | { |
| 671 | args_info->qos_given = 1; |
| 672 | if (fnum == 2) |
| 673 | args_info->qos_arg = strtol (farg,&stop_char,0); |
| 674 | else |
| 675 | { |
| 676 | fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", |
| 677 | filename, line_num); |
| 678 | exit (EXIT_FAILURE); |
| 679 | } |
| 680 | } |
| 681 | continue; |
| 682 | } |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 683 | |
| 684 | |
| 685 | /* Tried all known options. This one is unknown! */ |
| 686 | fprintf (stderr, "%s: Unknown option '%s' found in %s\n", |
| 687 | PACKAGE, fopt, filename); |
| 688 | exit (EXIT_FAILURE); |
| 689 | } |
| 690 | } /* while */ |
| 691 | fclose(file); /* No error checking on close */ |
| 692 | |
| 693 | return 0; |
| 694 | } |