aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-04-01 05:45:08 +0000
committerGuy Harris <guy@alum.mit.edu>2005-04-01 05:45:08 +0000
commit910ad32b3bc8c58d930b116ddbc3f89575c5652c (patch)
treeca8af38f93c01c7a47a992411b19b4f6cdef3969
parent31954877ca5ea16d2b6e1e7f5d217580e18aab52 (diff)
Don't assume only one "-z" argument will be given on the command line;
add information for each tap to a list, and set up all the taps in the list. svn path=/trunk/; revision=13991
-rw-r--r--gtk/main.c52
-rw-r--r--tethereal.c39
2 files changed, 66 insertions, 25 deletions
diff --git a/gtk/main.c b/gtk/main.c
index c2b4ac908b..0a2544e450 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1478,6 +1478,11 @@ void main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
}
}
+typedef struct {
+ ethereal_tap_list *tli;
+ char *arg;
+} tap_to_run_t;
+
/* And now our feature presentation... [ fade to music ] */
int
main(int argc, char *argv[])
@@ -1525,8 +1530,9 @@ main(int argc, char *argv[])
gboolean rfilter_parse_failed = FALSE;
e_prefs *prefs;
char badopt;
- ethereal_tap_list *tli = NULL;
- gchar *tap_opt = NULL;
+ ethereal_tap_list *tli;
+ tap_to_run_t *tap_to_run;
+ GSList *taps_to_run = NULL;
GtkWidget *splash_win = NULL;
gboolean capture_child; /* True if this is the child for "-S" */
@@ -1968,7 +1974,15 @@ main(int argc, char *argv[])
case 'z':
for(tli=tap_list;tli;tli=tli->next){
if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){
- tap_opt = g_strdup(optarg);
+ /* We won't call the init function for the tap this soon
+ as it would disallow MATE's fields (which are registered
+ by the preferences set callback) from being used as
+ part of a tap filter. Instead, we just add the argument
+ to a list of tap arguments. */
+ tap_to_run = g_malloc(sizeof (tap_to_run_t));
+ tap_to_run->tli = tli;
+ tap_to_run->arg = g_strdup(optarg);
+ taps_to_run = g_slist_append(taps_to_run, tap_to_run);
break;
}
}
@@ -2319,10 +2333,17 @@ main(int argc, char *argv[])
cfile.rfcode = rfcode;
/* Open tap windows; we do so after creating the main window,
to avoid GTK warnings, and after successfully opening the
- capture file, so we know we have something to tap. */
- if (tap_opt && tli) {
- (*tli->func)(tap_opt);
- g_free(tap_opt);
+ capture file, so we know we have something to tap, and
+ after registering all dissectors, so that MATE will have
+ registered its field array and we can have a filter with
+ one of MATE's late-registered fields as part of the tap's
+ filter. */
+ while (taps_to_run != NULL) {
+ tap_to_run = taps_to_run->data;
+ (*tap_to_run->tli->func)(tap_to_run->arg);
+ g_free(tap_to_run->arg);
+ g_free(tap_to_run);
+ taps_to_run = g_slist_remove(taps_to_run, tap_to_run);
}
/* Read the capture file. */
@@ -2371,11 +2392,18 @@ main(int argc, char *argv[])
show_main_window(TRUE);
if (capture_start(capture_opts)) {
/* The capture started. Open tap windows; we do so after creating
- the main window, to avoid GTK warnings, and after starting the
- capture, so we know we have something to tap. */
- if (tap_opt && tli) {
- (*tli->func)(tap_opt);
- g_free(tap_opt);
+ the main window, to avoid GTK warnings, and after successfully
+ opening the capture file, so we know we have something to tap,
+ and after registering all dissectors, so that MATE will have
+ registered its field array and we can have a filter with
+ one of MATE's late-registered fields as part of the tap's
+ filter. */
+ while (taps_to_run != NULL) {
+ tap_to_run = taps_to_run->data;
+ (*tap_to_run->tli->func)(tap_to_run->arg);
+ g_free(tap_to_run->arg);
+ g_free(tap_to_run);
+ taps_to_run = g_slist_remove(taps_to_run, tap_to_run);
}
}
}
diff --git a/tethereal.c b/tethereal.c
index 1bdf2e48e3..5027bb59ca 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -634,6 +634,11 @@ add_decode_as(const gchar *cl_param)
return TRUE;
}
+typedef struct {
+ ethereal_tap_list *tli;
+ char *arg;
+} tap_to_run_t;
+
int
main(int argc, char *argv[])
{
@@ -680,8 +685,9 @@ main(int argc, char *argv[])
dfilter_t *rfcode = NULL;
e_prefs *prefs;
char badopt;
- ethereal_tap_list *tli = NULL;
- guint8* tli_optarg = NULL;
+ ethereal_tap_list *tli;
+ tap_to_run_t *tap_to_run;
+ GSList *taps_to_run = NULL;
#ifdef HAVE_LIBPCAP
capture_opts_init(&capture_opts, NULL /* cfile */);
@@ -1045,11 +1051,15 @@ main(int argc, char *argv[])
case 'z':
for(tli=tap_list;tli;tli=tli->next){
if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){
- /* we won't call the init function for the tap this soon
- as it would disallow mate's fields (which are registered
- by the preferences set callback) from being used as
- part of a tap filter */
- tli_optarg = g_strdup(optarg);
+ /* We won't call the init function for the tap this soon
+ as it would disallow MATE's fields (which are registered
+ by the preferences set callback) from being used as
+ part of a tap filter. Instead, we just add the argument
+ to a list of tap arguments. */
+ tap_to_run = g_malloc(sizeof (tap_to_run_t));
+ tap_to_run->tli = tli;
+ tap_to_run->arg = g_strdup(optarg);
+ taps_to_run = g_slist_append(taps_to_run, tap_to_run);
break;
}
}
@@ -1236,12 +1246,15 @@ main(int argc, char *argv[])
line that their preferences have changed. */
prefs_apply_all();
- /* At this point mate will have registered its field array so we can
- have a filter with one of mate's late registered fields as part
- of the tap's filter */
- if (tli_optarg != NULL) {
- (*tli->func)(tli_optarg);
- g_free(tli_optarg);
+ /* At this point MATE will have registered its field array so we can
+ have a filter with one of MATE's late-registered fields as part
+ of the tap's filter. We can now process all the "-z" arguments. */
+ while (taps_to_run != NULL) {
+ tap_to_run = taps_to_run->data;
+ (*tap_to_run->tli->func)(tap_to_run->arg);
+ g_free(tap_to_run->arg);
+ g_free(tap_to_run);
+ taps_to_run = g_slist_remove(taps_to_run, tap_to_run);
}
/* disabled protocols as per configuration file */