aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tshark.c3
-rw-r--r--ui/commandline.c3
-rw-r--r--ui/dissect_opts.c9
-rw-r--r--ui/dissect_opts.h10
4 files changed, 16 insertions, 9 deletions
diff --git a/tshark.c b/tshark.c
index 12452ecb3b..8f838726a6 100644
--- a/tshark.c
+++ b/tshark.c
@@ -1315,7 +1315,8 @@ main(int argc, char *argv[])
case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
- dissect_opts_add_opt(opt, optarg);
+ if (!dissect_opts_handle_opt(opt, optarg))
+ return 1;
break;
default:
diff --git a/ui/commandline.c b/ui/commandline.c
index 39f0da54e2..85f8375442 100644
--- a/ui/commandline.c
+++ b/ui/commandline.c
@@ -580,7 +580,8 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
- dissect_opts_add_opt(opt, optarg);
+ if (!dissect_opts_handle_opt(opt, optarg))
+ exit(1);
break;
case LONGOPT_FULL_SCREEN:
global_commandline_info.full_screen = TRUE;
diff --git a/ui/dissect_opts.c b/ui/dissect_opts.c
index aa9691f58f..471f0467fd 100644
--- a/ui/dissect_opts.c
+++ b/ui/dissect_opts.c
@@ -52,13 +52,13 @@ dissect_opts_init(void)
global_dissect_options.disable_heur_slist = NULL;
}
-void
-dissect_opts_add_opt(int opt, char *optarg_str_p)
+gboolean
+dissect_opts_handle_opt(int opt, char *optarg_str_p)
{
switch(opt) {
case 'd': /* Decode as rule */
if (!decode_as_command_option(optarg_str_p))
- exit(1);
+ return FALSE;
break;
case 't': /* Time stamp type */
if (strcmp(optarg_str_p, "r") == 0)
@@ -93,7 +93,7 @@ dissect_opts_add_opt(int opt, char *optarg_str_p)
"\t\"u\" for absolute UTC\n"
"\t\"ud\" for absolute UTC with YYYY-MM-DD date\n"
"\t\"udoy\" for absolute UTC with YYYY/DOY date");
- exit(1);
+ return FALSE;
}
break;
case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
@@ -109,6 +109,7 @@ dissect_opts_add_opt(int opt, char *optarg_str_p)
/* the caller is responsible to send us only the right opt's */
g_assert_not_reached();
}
+ return TRUE;
}
/*
diff --git a/ui/dissect_opts.h b/ui/dissect_opts.h
index ad049b8160..629136e131 100644
--- a/ui/dissect_opts.h
+++ b/ui/dissect_opts.h
@@ -82,9 +82,13 @@ extern dissect_options global_dissect_options;
extern void
dissect_opts_init(void);
-/* set a command line option value */
-extern void
-dissect_opts_add_opt(int opt, char *optarg_str_p);
+/*
+ * Handle a command line option.
+ * Returns TRUE if the option is valid, FALSE if not; an error message
+ * is reported with cmdarg_err() if it's not valid.
+ */
+extern gboolean
+dissect_opts_handle_opt(int opt, char *optarg_str_p);
#ifdef __cplusplus
}