diff options
author | jjako <jjako> | 2003-01-28 16:13:57 +0000 |
---|---|---|
committer | jjako <jjako> | 2003-01-28 16:13:57 +0000 |
commit | 4b26b51bf090e9b81fff0a7336800fab37abc88d (patch) | |
tree | 0c7d9160108fab1576176e63c80e5c2319a1d3bb /ggsn/cmdline.c | |
parent | 0511e22c9eff9b5f75c5bb57f5592816ac390171 (diff) |
Support for external ipup script
Diffstat (limited to 'ggsn/cmdline.c')
-rw-r--r-- | ggsn/cmdline.c | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/ggsn/cmdline.c b/ggsn/cmdline.c index ef50f7c..3c5d7e2 100644 --- a/ggsn/cmdline.c +++ b/ggsn/cmdline.c @@ -1,7 +1,7 @@ /* - File autogenerated by gengetopt version 2.8 + File autogenerated by gengetopt version 2.8rc generated with the following command: - gengetopt --conf-parser + ../../gengetopt-2.8rc/src/gengetopt --conf-parser The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -55,6 +55,8 @@ cmdline_parser_print_help (void) printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n"); printf(" -aSTRING --apn=STRING Access point name (default='internet')\n"); printf(" -qINT --qos=INT Requested quality of service (default='0x0b921f')\n"); + printf(" --ipup=STRING Script to run after link-up\n"); + printf(" --ipdown=STRING Script to run after link-down\n"); } @@ -91,6 +93,8 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i args_info->timelimit_given = 0 ; args_info->apn_given = 0 ; args_info->qos_given = 0 ; + args_info->ipup_given = 0 ; + args_info->ipdown_given = 0 ; #define clear_args() { \ args_info->fg_flag = 0;\ args_info->debug_flag = 0;\ @@ -103,6 +107,8 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i args_info->timelimit_arg = 0 ;\ args_info->apn_arg = strdup("internet") ;\ args_info->qos_arg = 0x0b921f ;\ + args_info->ipup_arg = NULL; \ + args_info->ipdown_arg = NULL; \ } clear_args(); @@ -130,6 +136,8 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i { "timelimit", 1, NULL, 0 }, { "apn", 1, NULL, 'a' }, { "qos", 1, NULL, 'q' }, + { "ipup", 1, NULL, 0 }, + { "ipdown", 1, NULL, 0 }, { NULL, 0, NULL, 0 } }; @@ -280,6 +288,32 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i args_info->timelimit_arg = strtol (optarg,&stop_char,0); break; } + /* Script to run after link-up. */ + else if (strcmp (long_options[option_index].name, "ipup") == 0) + { + if (args_info->ipup_given) + { + fprintf (stderr, "%s: `--ipup' option given more than once\n", PACKAGE); + clear_args (); + exit (EXIT_FAILURE); + } + args_info->ipup_given = 1; + args_info->ipup_arg = strdup (optarg); + break; + } + /* Script to run after link-down. */ + else if (strcmp (long_options[option_index].name, "ipdown") == 0) + { + if (args_info->ipdown_given) + { + fprintf (stderr, "%s: `--ipdown' option given more than once\n", PACKAGE); + clear_args (); + exit (EXIT_FAILURE); + } + args_info->ipdown_given = 1; + args_info->ipdown_arg = strdup (optarg); + break; + } case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ @@ -515,6 +549,38 @@ cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *ar } continue; } + if (!strcmp(fopt, "ipup")) + { + if (override || !args_info->ipup_given) + { + args_info->ipup_given = 1; + if (fnum == 2) + args_info->ipup_arg = strdup (farg); + else + { + fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", + filename, line_num); + exit (EXIT_FAILURE); + } + } + continue; + } + if (!strcmp(fopt, "ipdown")) + { + if (override || !args_info->ipdown_given) + { + args_info->ipdown_given = 1; + if (fnum == 2) + args_info->ipdown_arg = strdup (farg); + else + { + fprintf (stderr, "%s:%d: required <option_name> <option_val>\n", + filename, line_num); + exit (EXIT_FAILURE); + } + } + continue; + } /* Tried all known options. This one is unknown! */ |