blob: f6f044fd7c5eb6a3d76812885a0ef56865ee6f7e [file] [log] [blame]
jjako52c24142002-12-16 13:33:51 +00001/*
jjakoa7cd2492003-04-11 09:40:12 +00002 File autogenerated by gengetopt version 2.8
jjako52c24142002-12-16 13:33:51 +00003 generated with the following command:
jjakoa7cd2492003-04-11 09:40:12 +00004 gengetopt --conf-parser
jjako52c24142002-12-16 13:33:51 +00005
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
33void
34cmdline_parser_print_version (void)
35{
36 printf ("%s %s\n", PACKAGE, VERSION);
37}
38
39void
40cmdline_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");
jjako52c24142002-12-16 13:33:51 +000047 printf(" -d --debug Run in debug mode (default=off)\n");
48 printf(" -cSTRING --conf=STRING Read configuration file\n");
49 printf(" --pidfile=STRING Filename of process id file (default='./sgsnemu.pid')\n");
50 printf(" --statedir=STRING Directory of nonvolatile data (default='./')\n");
51 printf(" --dns=STRING DNS Server to use\n");
52 printf(" -lSTRING --listen=STRING Local interface\n");
53 printf(" -rSTRING --remote=STRING Remote host\n");
jjako52c24142002-12-16 13:33:51 +000054 printf(" --contexts=INT Number of contexts (default='1')\n");
jjako52c24142002-12-16 13:33:51 +000055 printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n");
56 printf(" -aSTRING --apn=STRING Access point name (default='internet')\n");
57 printf(" -iSTRING --imsi=STRING IMSI (default='240010123456789')\n");
58 printf(" -mSTRING --msisdn=STRING Mobile Station ISDN number (default='46702123456')\n");
59 printf(" -qINT --qos=INT Requested quality of service (default='0x0b921f')\n");
60 printf(" -uSTRING --uid=STRING Login user ID (default='mig')\n");
61 printf(" -pSTRING --pwd=STRING Login password (default='hemmelig')\n");
jjako5da68452003-01-28 16:08:47 +000062 printf(" --createif Create local network interface (default=off)\n");
jjakoa7cd2492003-04-11 09:40:12 +000063 printf(" --defaultroute Create default route (default=off)\n");
jjako5da68452003-01-28 16:08:47 +000064 printf(" --ipup=STRING Script to run after link-up\n");
65 printf(" --ipdown=STRING Script to run after link-down\n");
jjako5da68452003-01-28 16:08:47 +000066 printf(" --pinghost=STRING Ping remote host\n");
67 printf(" --pingrate=INT Number of ping req per second (default='1')\n");
68 printf(" --pingsize=INT Number of ping data bytes (default='56')\n");
69 printf(" --pingcount=INT Number of ping req to send (default='0')\n");
70 printf(" --pingquiet Do not print ping packet info (default=off)\n");
jjako52c24142002-12-16 13:33:51 +000071}
72
73
74#ifndef HAVE_STRDUP
75/* gengetopt_strdup(): automatically generated from strdup.c. */
76/* strdup.c replacement of strdup, which is not standard */
77static char *
78gengetopt_strdup (const char *s)
79{
80 char *result = (char*)malloc(strlen(s) + 1);
81 if (result == (char*)0)
82 return (char*)0;
83 strcpy(result, s);
84 return result;
85}
86#endif /* HAVE_STRDUP */
87
88int
89cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
90{
91 int c; /* Character of the parsed option. */
92 int missing_required_options = 0;
93
94 args_info->help_given = 0 ;
95 args_info->version_given = 0 ;
jjako52c24142002-12-16 13:33:51 +000096 args_info->debug_given = 0 ;
97 args_info->conf_given = 0 ;
98 args_info->pidfile_given = 0 ;
99 args_info->statedir_given = 0 ;
100 args_info->dns_given = 0 ;
101 args_info->listen_given = 0 ;
102 args_info->remote_given = 0 ;
jjako52c24142002-12-16 13:33:51 +0000103 args_info->contexts_given = 0 ;
jjako52c24142002-12-16 13:33:51 +0000104 args_info->timelimit_given = 0 ;
105 args_info->apn_given = 0 ;
106 args_info->imsi_given = 0 ;
107 args_info->msisdn_given = 0 ;
108 args_info->qos_given = 0 ;
109 args_info->uid_given = 0 ;
110 args_info->pwd_given = 0 ;
jjako5da68452003-01-28 16:08:47 +0000111 args_info->createif_given = 0 ;
jjakoa7cd2492003-04-11 09:40:12 +0000112 args_info->defaultroute_given = 0 ;
jjako5da68452003-01-28 16:08:47 +0000113 args_info->ipup_given = 0 ;
114 args_info->ipdown_given = 0 ;
jjako5da68452003-01-28 16:08:47 +0000115 args_info->pinghost_given = 0 ;
116 args_info->pingrate_given = 0 ;
117 args_info->pingsize_given = 0 ;
118 args_info->pingcount_given = 0 ;
119 args_info->pingquiet_given = 0 ;
jjako52c24142002-12-16 13:33:51 +0000120#define clear_args() { \
jjako52c24142002-12-16 13:33:51 +0000121 args_info->debug_flag = 0;\
122 args_info->conf_arg = NULL; \
123 args_info->pidfile_arg = strdup("./sgsnemu.pid") ;\
124 args_info->statedir_arg = strdup("./") ;\
125 args_info->dns_arg = NULL; \
126 args_info->listen_arg = NULL; \
127 args_info->remote_arg = NULL; \
jjako52c24142002-12-16 13:33:51 +0000128 args_info->contexts_arg = 1 ;\
jjako52c24142002-12-16 13:33:51 +0000129 args_info->timelimit_arg = 0 ;\
130 args_info->apn_arg = strdup("internet") ;\
131 args_info->imsi_arg = strdup("240010123456789") ;\
132 args_info->msisdn_arg = strdup("46702123456") ;\
133 args_info->qos_arg = 0x0b921f ;\
134 args_info->uid_arg = strdup("mig") ;\
135 args_info->pwd_arg = strdup("hemmelig") ;\
jjako5da68452003-01-28 16:08:47 +0000136 args_info->createif_flag = 0;\
jjakoa7cd2492003-04-11 09:40:12 +0000137 args_info->defaultroute_flag = 0;\
jjako5da68452003-01-28 16:08:47 +0000138 args_info->ipup_arg = NULL; \
139 args_info->ipdown_arg = NULL; \
jjako5da68452003-01-28 16:08:47 +0000140 args_info->pinghost_arg = NULL; \
141 args_info->pingrate_arg = 1 ;\
142 args_info->pingsize_arg = 56 ;\
143 args_info->pingcount_arg = 0 ;\
144 args_info->pingquiet_flag = 0;\
jjako52c24142002-12-16 13:33:51 +0000145}
146
147 clear_args();
148
149 optarg = 0;
150 optind = 1;
151 opterr = 1;
152 optopt = '?';
153
154 while (1)
155 {
156 int option_index = 0;
157 char *stop_char;
158 static struct option long_options[] = {
159 { "help", 0, NULL, 'h' },
160 { "version", 0, NULL, 'V' },
jjako52c24142002-12-16 13:33:51 +0000161 { "debug", 0, NULL, 'd' },
162 { "conf", 1, NULL, 'c' },
163 { "pidfile", 1, NULL, 0 },
164 { "statedir", 1, NULL, 0 },
165 { "dns", 1, NULL, 0 },
166 { "listen", 1, NULL, 'l' },
167 { "remote", 1, NULL, 'r' },
jjako52c24142002-12-16 13:33:51 +0000168 { "contexts", 1, NULL, 0 },
jjako52c24142002-12-16 13:33:51 +0000169 { "timelimit", 1, NULL, 0 },
170 { "apn", 1, NULL, 'a' },
171 { "imsi", 1, NULL, 'i' },
172 { "msisdn", 1, NULL, 'm' },
173 { "qos", 1, NULL, 'q' },
174 { "uid", 1, NULL, 'u' },
175 { "pwd", 1, NULL, 'p' },
jjako5da68452003-01-28 16:08:47 +0000176 { "createif", 0, NULL, 0 },
jjakoa7cd2492003-04-11 09:40:12 +0000177 { "defaultroute", 0, NULL, 0 },
jjako5da68452003-01-28 16:08:47 +0000178 { "ipup", 1, NULL, 0 },
179 { "ipdown", 1, NULL, 0 },
jjako5da68452003-01-28 16:08:47 +0000180 { "pinghost", 1, NULL, 0 },
181 { "pingrate", 1, NULL, 0 },
182 { "pingsize", 1, NULL, 0 },
183 { "pingcount", 1, NULL, 0 },
184 { "pingquiet", 0, NULL, 0 },
jjako52c24142002-12-16 13:33:51 +0000185 { NULL, 0, NULL, 0 }
186 };
187
jjakoe607f742003-07-06 21:21:30 +0000188 c = getopt_long (argc, argv, "hVdc:l:r:a:i:m:q:u:p:", long_options, &option_index);
jjako52c24142002-12-16 13:33:51 +0000189
190 if (c == -1) break; /* Exit from `while (1)' loop. */
191
192 switch (c)
193 {
194 case 'h': /* Print help and exit. */
195 clear_args ();
196 cmdline_parser_print_help ();
197 exit (EXIT_SUCCESS);
198
199 case 'V': /* Print version and exit. */
200 clear_args ();
201 cmdline_parser_print_version ();
202 exit (EXIT_SUCCESS);
203
jjako52c24142002-12-16 13:33:51 +0000204 case 'd': /* Run in debug mode. */
205 if (args_info->debug_given)
206 {
207 fprintf (stderr, "%s: `--debug' (`-d') option given more than once\n", PACKAGE);
208 clear_args ();
209 exit (EXIT_FAILURE);
210 }
211 args_info->debug_given = 1;
212 args_info->debug_flag = !(args_info->debug_flag);
213 break;
214
215 case 'c': /* Read configuration file. */
216 if (args_info->conf_given)
217 {
218 fprintf (stderr, "%s: `--conf' (`-c') option given more than once\n", PACKAGE);
219 clear_args ();
220 exit (EXIT_FAILURE);
221 }
222 args_info->conf_given = 1;
223 args_info->conf_arg = strdup (optarg);
224 break;
225
226 case 'l': /* Local interface. */
227 if (args_info->listen_given)
228 {
229 fprintf (stderr, "%s: `--listen' (`-l') option given more than once\n", PACKAGE);
230 clear_args ();
231 exit (EXIT_FAILURE);
232 }
233 args_info->listen_given = 1;
234 args_info->listen_arg = strdup (optarg);
235 break;
236
237 case 'r': /* Remote host. */
238 if (args_info->remote_given)
239 {
240 fprintf (stderr, "%s: `--remote' (`-r') option given more than once\n", PACKAGE);
241 clear_args ();
242 exit (EXIT_FAILURE);
243 }
244 args_info->remote_given = 1;
245 args_info->remote_arg = strdup (optarg);
246 break;
247
jjako52c24142002-12-16 13:33:51 +0000248 case 'a': /* Access point name. */
249 if (args_info->apn_given)
250 {
251 fprintf (stderr, "%s: `--apn' (`-a') option given more than once\n", PACKAGE);
252 clear_args ();
253 exit (EXIT_FAILURE);
254 }
255 args_info->apn_given = 1;
256 args_info->apn_arg = strdup (optarg);
257 break;
258
259 case 'i': /* IMSI. */
260 if (args_info->imsi_given)
261 {
262 fprintf (stderr, "%s: `--imsi' (`-i') option given more than once\n", PACKAGE);
263 clear_args ();
264 exit (EXIT_FAILURE);
265 }
266 args_info->imsi_given = 1;
267 args_info->imsi_arg = strdup (optarg);
268 break;
269
270 case 'm': /* Mobile Station ISDN number. */
271 if (args_info->msisdn_given)
272 {
273 fprintf (stderr, "%s: `--msisdn' (`-m') option given more than once\n", PACKAGE);
274 clear_args ();
275 exit (EXIT_FAILURE);
276 }
277 args_info->msisdn_given = 1;
278 args_info->msisdn_arg = strdup (optarg);
279 break;
280
281 case 'q': /* Requested quality of service. */
282 if (args_info->qos_given)
283 {
284 fprintf (stderr, "%s: `--qos' (`-q') option given more than once\n", PACKAGE);
285 clear_args ();
286 exit (EXIT_FAILURE);
287 }
288 args_info->qos_given = 1;
289 args_info->qos_arg = strtol (optarg,&stop_char,0);
290 break;
291
292 case 'u': /* Login user ID. */
293 if (args_info->uid_given)
294 {
295 fprintf (stderr, "%s: `--uid' (`-u') option given more than once\n", PACKAGE);
296 clear_args ();
297 exit (EXIT_FAILURE);
298 }
299 args_info->uid_given = 1;
300 args_info->uid_arg = strdup (optarg);
301 break;
302
303 case 'p': /* Login password. */
304 if (args_info->pwd_given)
305 {
306 fprintf (stderr, "%s: `--pwd' (`-p') option given more than once\n", PACKAGE);
307 clear_args ();
308 exit (EXIT_FAILURE);
309 }
310 args_info->pwd_given = 1;
311 args_info->pwd_arg = strdup (optarg);
312 break;
313
314
315 case 0: /* Long option with no short option */
316 /* Filename of process id file. */
317 if (strcmp (long_options[option_index].name, "pidfile") == 0)
318 {
319 if (args_info->pidfile_given)
320 {
321 fprintf (stderr, "%s: `--pidfile' option given more than once\n", PACKAGE);
322 clear_args ();
323 exit (EXIT_FAILURE);
324 }
325 args_info->pidfile_given = 1;
326 args_info->pidfile_arg = strdup (optarg);
327 break;
328 }
329 /* Directory of nonvolatile data. */
330 else if (strcmp (long_options[option_index].name, "statedir") == 0)
331 {
332 if (args_info->statedir_given)
333 {
334 fprintf (stderr, "%s: `--statedir' option given more than once\n", PACKAGE);
335 clear_args ();
336 exit (EXIT_FAILURE);
337 }
338 args_info->statedir_given = 1;
339 args_info->statedir_arg = strdup (optarg);
340 break;
341 }
342 /* DNS Server to use. */
343 else if (strcmp (long_options[option_index].name, "dns") == 0)
344 {
345 if (args_info->dns_given)
346 {
347 fprintf (stderr, "%s: `--dns' option given more than once\n", PACKAGE);
348 clear_args ();
349 exit (EXIT_FAILURE);
350 }
351 args_info->dns_given = 1;
352 args_info->dns_arg = strdup (optarg);
353 break;
354 }
jjako52c24142002-12-16 13:33:51 +0000355 /* Number of contexts. */
356 else if (strcmp (long_options[option_index].name, "contexts") == 0)
357 {
358 if (args_info->contexts_given)
359 {
360 fprintf (stderr, "%s: `--contexts' option given more than once\n", PACKAGE);
361 clear_args ();
362 exit (EXIT_FAILURE);
363 }
364 args_info->contexts_given = 1;
365 args_info->contexts_arg = strtol (optarg,&stop_char,0);
366 break;
367 }
jjako52c24142002-12-16 13:33:51 +0000368 /* Exit after timelimit seconds. */
369 else if (strcmp (long_options[option_index].name, "timelimit") == 0)
370 {
371 if (args_info->timelimit_given)
372 {
373 fprintf (stderr, "%s: `--timelimit' option given more than once\n", PACKAGE);
374 clear_args ();
375 exit (EXIT_FAILURE);
376 }
377 args_info->timelimit_given = 1;
378 args_info->timelimit_arg = strtol (optarg,&stop_char,0);
379 break;
380 }
jjako5da68452003-01-28 16:08:47 +0000381 /* Create local network interface. */
382 else if (strcmp (long_options[option_index].name, "createif") == 0)
383 {
384 if (args_info->createif_given)
385 {
386 fprintf (stderr, "%s: `--createif' option given more than once\n", PACKAGE);
387 clear_args ();
388 exit (EXIT_FAILURE);
389 }
390 args_info->createif_given = 1;
391 args_info->createif_flag = !(args_info->createif_flag);
392 break;
393 }
jjakoa7cd2492003-04-11 09:40:12 +0000394 /* Create default route. */
395 else if (strcmp (long_options[option_index].name, "defaultroute") == 0)
396 {
397 if (args_info->defaultroute_given)
398 {
399 fprintf (stderr, "%s: `--defaultroute' option given more than once\n", PACKAGE);
400 clear_args ();
401 exit (EXIT_FAILURE);
402 }
403 args_info->defaultroute_given = 1;
404 args_info->defaultroute_flag = !(args_info->defaultroute_flag);
405 break;
406 }
jjako5da68452003-01-28 16:08:47 +0000407 /* Script to run after link-up. */
408 else if (strcmp (long_options[option_index].name, "ipup") == 0)
409 {
410 if (args_info->ipup_given)
411 {
412 fprintf (stderr, "%s: `--ipup' option given more than once\n", PACKAGE);
413 clear_args ();
414 exit (EXIT_FAILURE);
415 }
416 args_info->ipup_given = 1;
417 args_info->ipup_arg = strdup (optarg);
418 break;
419 }
420 /* Script to run after link-down. */
421 else if (strcmp (long_options[option_index].name, "ipdown") == 0)
422 {
423 if (args_info->ipdown_given)
424 {
425 fprintf (stderr, "%s: `--ipdown' option given more than once\n", PACKAGE);
426 clear_args ();
427 exit (EXIT_FAILURE);
428 }
429 args_info->ipdown_given = 1;
430 args_info->ipdown_arg = strdup (optarg);
431 break;
432 }
jjako5da68452003-01-28 16:08:47 +0000433 /* Ping remote host. */
434 else if (strcmp (long_options[option_index].name, "pinghost") == 0)
435 {
436 if (args_info->pinghost_given)
437 {
438 fprintf (stderr, "%s: `--pinghost' option given more than once\n", PACKAGE);
439 clear_args ();
440 exit (EXIT_FAILURE);
441 }
442 args_info->pinghost_given = 1;
443 args_info->pinghost_arg = strdup (optarg);
444 break;
445 }
446 /* Number of ping req per second. */
447 else if (strcmp (long_options[option_index].name, "pingrate") == 0)
448 {
449 if (args_info->pingrate_given)
450 {
451 fprintf (stderr, "%s: `--pingrate' option given more than once\n", PACKAGE);
452 clear_args ();
453 exit (EXIT_FAILURE);
454 }
455 args_info->pingrate_given = 1;
456 args_info->pingrate_arg = strtol (optarg,&stop_char,0);
457 break;
458 }
459 /* Number of ping data bytes. */
460 else if (strcmp (long_options[option_index].name, "pingsize") == 0)
461 {
462 if (args_info->pingsize_given)
463 {
464 fprintf (stderr, "%s: `--pingsize' option given more than once\n", PACKAGE);
465 clear_args ();
466 exit (EXIT_FAILURE);
467 }
468 args_info->pingsize_given = 1;
469 args_info->pingsize_arg = strtol (optarg,&stop_char,0);
470 break;
471 }
472 /* Number of ping req to send. */
473 else if (strcmp (long_options[option_index].name, "pingcount") == 0)
474 {
475 if (args_info->pingcount_given)
476 {
477 fprintf (stderr, "%s: `--pingcount' option given more than once\n", PACKAGE);
478 clear_args ();
479 exit (EXIT_FAILURE);
480 }
481 args_info->pingcount_given = 1;
482 args_info->pingcount_arg = strtol (optarg,&stop_char,0);
483 break;
484 }
485 /* Do not print ping packet info. */
486 else if (strcmp (long_options[option_index].name, "pingquiet") == 0)
487 {
488 if (args_info->pingquiet_given)
489 {
490 fprintf (stderr, "%s: `--pingquiet' option given more than once\n", PACKAGE);
491 clear_args ();
492 exit (EXIT_FAILURE);
493 }
494 args_info->pingquiet_given = 1;
495 args_info->pingquiet_flag = !(args_info->pingquiet_flag);
496 break;
497 }
jjako52c24142002-12-16 13:33:51 +0000498
499 case '?': /* Invalid option. */
500 /* `getopt_long' already printed an error message. */
501 exit (EXIT_FAILURE);
502
503 default: /* bug: option not considered. */
504 fprintf (stderr, "%s: option unknown: %c\n", PACKAGE, c);
505 abort ();
506 } /* switch */
507 } /* while */
508
509
510 if ( missing_required_options )
511 exit (EXIT_FAILURE);
512
513 return 0;
514}
515
516#define CONFIGPARSERBUFSIZE 1024
517
518int
519cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override)
520{
521 FILE* file;
522 char linebuf[CONFIGPARSERBUFSIZE];
523 int line_num = 0;
524 int len;
525 int fnum;
526 char fopt[CONFIGPARSERBUFSIZE], farg[CONFIGPARSERBUFSIZE];
527 char *stop_char;
528
529 if ((file = fopen(filename, "r")) == NULL)
530 {
531 fprintf (stderr, "%s: Error opening configuration file '%s'\n",
532 PACKAGE, filename);
533 exit (EXIT_FAILURE);
534 }
535
536 while ((fgets(linebuf, CONFIGPARSERBUFSIZE, file)) != NULL)
537 {
538 ++line_num;
539 len = strlen(linebuf);
540 if (len == CONFIGPARSERBUFSIZE-1)
541 {
542 fprintf (stderr, "%s: Line longer than %d characters found in configuration file '%s'\n",
543 PACKAGE, CONFIGPARSERBUFSIZE, filename);
544 exit (EXIT_FAILURE);
545 }
546
547 if (linebuf[0] == '#')
548 continue; /* Line was a comment */
549
550 /* Get the option */
551 if ((fnum = sscanf(linebuf, "%s %s", fopt, farg)) > 0)
552 {
553 if (!strcmp(fopt, "help"))
554 {
555 if (override || !args_info->help_given)
556 {
557 args_info->help_given = 1;
558
559 }
560 continue;
561 }
562 if (!strcmp(fopt, "version"))
563 {
564 if (override || !args_info->version_given)
565 {
566 args_info->version_given = 1;
567
568 }
569 continue;
570 }
jjako52c24142002-12-16 13:33:51 +0000571 if (!strcmp(fopt, "debug"))
572 {
573 if (override || !args_info->debug_given)
574 {
575 args_info->debug_given = 1;
576 args_info->debug_flag = !(args_info->debug_flag);
577 }
578 continue;
579 }
580 if (!strcmp(fopt, "conf"))
581 {
582 if (override || !args_info->conf_given)
583 {
584 args_info->conf_given = 1;
585 if (fnum == 2)
586 args_info->conf_arg = strdup (farg);
587 else
588 {
589 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
590 filename, line_num);
591 exit (EXIT_FAILURE);
592 }
593 }
594 continue;
595 }
596 if (!strcmp(fopt, "pidfile"))
597 {
598 if (override || !args_info->pidfile_given)
599 {
600 args_info->pidfile_given = 1;
601 if (fnum == 2)
602 args_info->pidfile_arg = strdup (farg);
603 else
604 {
605 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
606 filename, line_num);
607 exit (EXIT_FAILURE);
608 }
609 }
610 continue;
611 }
612 if (!strcmp(fopt, "statedir"))
613 {
614 if (override || !args_info->statedir_given)
615 {
616 args_info->statedir_given = 1;
617 if (fnum == 2)
618 args_info->statedir_arg = strdup (farg);
619 else
620 {
621 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
622 filename, line_num);
623 exit (EXIT_FAILURE);
624 }
625 }
626 continue;
627 }
628 if (!strcmp(fopt, "dns"))
629 {
630 if (override || !args_info->dns_given)
631 {
632 args_info->dns_given = 1;
633 if (fnum == 2)
634 args_info->dns_arg = strdup (farg);
635 else
636 {
637 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
638 filename, line_num);
639 exit (EXIT_FAILURE);
640 }
641 }
642 continue;
643 }
644 if (!strcmp(fopt, "listen"))
645 {
646 if (override || !args_info->listen_given)
647 {
648 args_info->listen_given = 1;
649 if (fnum == 2)
650 args_info->listen_arg = strdup (farg);
651 else
652 {
653 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
654 filename, line_num);
655 exit (EXIT_FAILURE);
656 }
657 }
658 continue;
659 }
660 if (!strcmp(fopt, "remote"))
661 {
662 if (override || !args_info->remote_given)
663 {
664 args_info->remote_given = 1;
665 if (fnum == 2)
666 args_info->remote_arg = strdup (farg);
667 else
668 {
669 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
670 filename, line_num);
671 exit (EXIT_FAILURE);
672 }
673 }
674 continue;
675 }
jjako52c24142002-12-16 13:33:51 +0000676 if (!strcmp(fopt, "contexts"))
677 {
678 if (override || !args_info->contexts_given)
679 {
680 args_info->contexts_given = 1;
681 if (fnum == 2)
682 args_info->contexts_arg = strtol (farg,&stop_char,0);
683 else
684 {
685 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
686 filename, line_num);
687 exit (EXIT_FAILURE);
688 }
689 }
690 continue;
691 }
jjako52c24142002-12-16 13:33:51 +0000692 if (!strcmp(fopt, "timelimit"))
693 {
694 if (override || !args_info->timelimit_given)
695 {
696 args_info->timelimit_given = 1;
697 if (fnum == 2)
698 args_info->timelimit_arg = strtol (farg,&stop_char,0);
699 else
700 {
701 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
702 filename, line_num);
703 exit (EXIT_FAILURE);
704 }
705 }
706 continue;
707 }
708 if (!strcmp(fopt, "apn"))
709 {
710 if (override || !args_info->apn_given)
711 {
712 args_info->apn_given = 1;
713 if (fnum == 2)
714 args_info->apn_arg = strdup (farg);
715 else
716 {
717 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
718 filename, line_num);
719 exit (EXIT_FAILURE);
720 }
721 }
722 continue;
723 }
724 if (!strcmp(fopt, "imsi"))
725 {
726 if (override || !args_info->imsi_given)
727 {
728 args_info->imsi_given = 1;
729 if (fnum == 2)
730 args_info->imsi_arg = strdup (farg);
731 else
732 {
733 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
734 filename, line_num);
735 exit (EXIT_FAILURE);
736 }
737 }
738 continue;
739 }
740 if (!strcmp(fopt, "msisdn"))
741 {
742 if (override || !args_info->msisdn_given)
743 {
744 args_info->msisdn_given = 1;
745 if (fnum == 2)
746 args_info->msisdn_arg = strdup (farg);
747 else
748 {
749 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
750 filename, line_num);
751 exit (EXIT_FAILURE);
752 }
753 }
754 continue;
755 }
756 if (!strcmp(fopt, "qos"))
757 {
758 if (override || !args_info->qos_given)
759 {
760 args_info->qos_given = 1;
761 if (fnum == 2)
762 args_info->qos_arg = strtol (farg,&stop_char,0);
763 else
764 {
765 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
766 filename, line_num);
767 exit (EXIT_FAILURE);
768 }
769 }
770 continue;
771 }
772 if (!strcmp(fopt, "uid"))
773 {
774 if (override || !args_info->uid_given)
775 {
776 args_info->uid_given = 1;
777 if (fnum == 2)
778 args_info->uid_arg = strdup (farg);
779 else
780 {
781 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
782 filename, line_num);
783 exit (EXIT_FAILURE);
784 }
785 }
786 continue;
787 }
788 if (!strcmp(fopt, "pwd"))
789 {
790 if (override || !args_info->pwd_given)
791 {
792 args_info->pwd_given = 1;
793 if (fnum == 2)
794 args_info->pwd_arg = strdup (farg);
795 else
796 {
797 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
798 filename, line_num);
799 exit (EXIT_FAILURE);
800 }
801 }
802 continue;
803 }
jjako5da68452003-01-28 16:08:47 +0000804 if (!strcmp(fopt, "createif"))
805 {
806 if (override || !args_info->createif_given)
807 {
808 args_info->createif_given = 1;
809 args_info->createif_flag = !(args_info->createif_flag);
810 }
811 continue;
812 }
jjakoa7cd2492003-04-11 09:40:12 +0000813 if (!strcmp(fopt, "defaultroute"))
814 {
815 if (override || !args_info->defaultroute_given)
816 {
817 args_info->defaultroute_given = 1;
818 args_info->defaultroute_flag = !(args_info->defaultroute_flag);
819 }
820 continue;
821 }
jjako5da68452003-01-28 16:08:47 +0000822 if (!strcmp(fopt, "ipup"))
823 {
824 if (override || !args_info->ipup_given)
825 {
826 args_info->ipup_given = 1;
827 if (fnum == 2)
828 args_info->ipup_arg = strdup (farg);
829 else
830 {
831 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
832 filename, line_num);
833 exit (EXIT_FAILURE);
834 }
835 }
836 continue;
837 }
838 if (!strcmp(fopt, "ipdown"))
839 {
840 if (override || !args_info->ipdown_given)
841 {
842 args_info->ipdown_given = 1;
843 if (fnum == 2)
844 args_info->ipdown_arg = strdup (farg);
845 else
846 {
847 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
848 filename, line_num);
849 exit (EXIT_FAILURE);
850 }
851 }
852 continue;
853 }
jjako5da68452003-01-28 16:08:47 +0000854 if (!strcmp(fopt, "pinghost"))
855 {
856 if (override || !args_info->pinghost_given)
857 {
858 args_info->pinghost_given = 1;
859 if (fnum == 2)
860 args_info->pinghost_arg = strdup (farg);
861 else
862 {
863 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
864 filename, line_num);
865 exit (EXIT_FAILURE);
866 }
867 }
868 continue;
869 }
870 if (!strcmp(fopt, "pingrate"))
871 {
872 if (override || !args_info->pingrate_given)
873 {
874 args_info->pingrate_given = 1;
875 if (fnum == 2)
876 args_info->pingrate_arg = strtol (farg,&stop_char,0);
877 else
878 {
879 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
880 filename, line_num);
881 exit (EXIT_FAILURE);
882 }
883 }
884 continue;
885 }
886 if (!strcmp(fopt, "pingsize"))
887 {
888 if (override || !args_info->pingsize_given)
889 {
890 args_info->pingsize_given = 1;
891 if (fnum == 2)
892 args_info->pingsize_arg = strtol (farg,&stop_char,0);
893 else
894 {
895 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
896 filename, line_num);
897 exit (EXIT_FAILURE);
898 }
899 }
900 continue;
901 }
902 if (!strcmp(fopt, "pingcount"))
903 {
904 if (override || !args_info->pingcount_given)
905 {
906 args_info->pingcount_given = 1;
907 if (fnum == 2)
908 args_info->pingcount_arg = strtol (farg,&stop_char,0);
909 else
910 {
911 fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
912 filename, line_num);
913 exit (EXIT_FAILURE);
914 }
915 }
916 continue;
917 }
918 if (!strcmp(fopt, "pingquiet"))
919 {
920 if (override || !args_info->pingquiet_given)
921 {
922 args_info->pingquiet_given = 1;
923 args_info->pingquiet_flag = !(args_info->pingquiet_flag);
924 }
925 continue;
926 }
jjako52c24142002-12-16 13:33:51 +0000927
928
929 /* Tried all known options. This one is unknown! */
930 fprintf (stderr, "%s: Unknown option '%s' found in %s\n",
931 PACKAGE, fopt, filename);
932 exit (EXIT_FAILURE);
933 }
934 } /* while */
935 fclose(file); /* No error checking on close */
936
937 return 0;
938}