aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture.c26
-rw-r--r--file.c21
-rw-r--r--gtk/file_dlg.c7
-rw-r--r--gtk/main.c3
-rw-r--r--gtk/menu.c3
-rw-r--r--gtk/simple_dialog.c14
-rw-r--r--simple_dialog.h5
7 files changed, 60 insertions, 19 deletions
diff --git a/capture.c b/capture.c
index 781e26c6c0..1d970cb855 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.232 2004/01/31 03:22:37 guy Exp $
+ * $Id: capture.c,v 1.233 2004/02/03 17:59:00 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1533,18 +1533,27 @@ capture(gboolean *stats_known, struct pcap_stat *stats)
}
if (pcap_compile(pch, &fcode, cfile.cfilter, 1, netmask) < 0) {
dfilter_t *rfcode = NULL;
+ /* filter string invalid, did the user tried a display filter? */
if (dfilter_compile(cfile.cfilter, &rfcode) && rfcode != NULL) {
snprintf(errmsg, sizeof errmsg,
- "Unable to parse capture filter string (%s).\n"
+ "%sInvalid capture filter: \"%s\"!%s\n"
"\n"
- " That string looks like a valid display filter; note that display filters\n"
- " and capture filters don't have the same syntax, so you can't use\n"
- " most display filter expressions as capture filters.",
+ "That string looks like a valid display filter.\n"
+ "\n"
+ "Note that display filters and capture filters don't have the same syntax,\n"
+ "so you can't use most display filter expressions as capture filters.\n"
+ "\n"
+ "See help for correct capture filter syntax.",
+ simple_dialog_primary_start(), cfile.cfilter, simple_dialog_primary_end(),
pcap_geterr(pch));
dfilter_free(rfcode);
} else {
snprintf(errmsg, sizeof errmsg,
- "Unable to parse capture filter string (%s).",
+ "%sInvalid capture filter: \"%s\"!%s\n"
+ "\n"
+ "Unable to parse capture filter string (%s),\n"
+ "see help for correct capture filter syntax.",
+ simple_dialog_primary_start(), cfile.cfilter, simple_dialog_primary_end(),
pcap_geterr(pch));
}
goto error;
@@ -2059,11 +2068,10 @@ gpointer callback_data)
void
capture_stop(void)
{
+ if (fork_child != -1) {
#ifndef _WIN32
- if (fork_child != -1)
kill(fork_child, SIGUSR1);
#else
- if (fork_child != -1) {
/* XXX: this is not the preferred method of closing a process!
* the clean way would be getting the process id of the child process,
* then getting window handle hWnd of that process (using EnumChildWindows),
@@ -2077,8 +2085,8 @@ capture_stop(void)
* And this also will require to have the process id
*/
TerminateProcess((HANDLE) fork_child, 0);
- }
#endif
+ }
}
void
diff --git a/file.c b/file.c
index 12b979119f..49ad7278c2 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.356 2004/02/03 00:30:50 guy Exp $
+ * $Id: file.c,v 1.357 2004/02/03 17:59:00 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -667,8 +667,17 @@ cf_finish_tail(capture_file *cf, int *err)
/* We got an error reading the capture file.
XXX - pop up a dialog box? */
return (READ_ERROR);
- } else
+ } else {
+ if(cf->count == 0) {
+ simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
+ "%sNo packets captured!%s\n\n"
+ "As no data was captured, closing the %scapture file!",
+ simple_dialog_primary_start(), simple_dialog_primary_end(),
+ (cf->is_tempfile) ? "temporary " : "");
+ cf_close(cf);
+ }
return (READ_SUCCESS);
+ }
}
#endif /* HAVE_LIBPCAP */
@@ -984,7 +993,13 @@ filter_packets(capture_file *cf, gchar *dftext)
dftext = g_strdup(dftext);
if (!dfilter_compile(dftext, &dfcode)) {
/* The attempt failed; report an error. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, dfilter_error_msg);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "%sInvalid display filter: \"%s\"!%s\n"
+ "\n"
+ "Unable to parse display filter string (%s),\n"
+ "see help for correct display filter syntax.",
+ simple_dialog_primary_start(), dftext, simple_dialog_primary_end(),
+ dfilter_error_msg);
g_free(dftext);
return 0;
}
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index ffb45b152f..06ec93e1b6 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.91 2004/02/01 20:28:11 ulfl Exp $
+ * $Id: file_dlg.c,v 1.92 2004/02/03 17:59:01 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -347,6 +347,7 @@ void file_open_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
file_save_as_cmd(after_save_open_dialog, data);
break;
case(ESD_BTN_NO):
+ cf_close(&cfile);
file_open_cmd(data);
break;
case(ESD_BTN_CANCEL):
@@ -465,7 +466,7 @@ file_open_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
file_open_w = NULL;
}
-void file_close_confirmed_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
+void file_close_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
{
switch(btn) {
case(ESD_BTN_YES):
@@ -494,7 +495,7 @@ file_close_cmd_cb(GtkWidget *widget _U_, gpointer data _U_) {
PRIMARY_TEXT_START "Save capture file before closing it?" PRIMARY_TEXT_END "\n\n"
"If you close without saving, your capture data will be discarded.");
- simple_dialog_set_cb(dialog, file_close_confirmed_cb, NULL);
+ simple_dialog_set_cb(dialog, file_close_answered_cb, NULL);
} else {
/* unchanged file, just close it */
cf_close(&cfile);
diff --git a/gtk/main.c b/gtk/main.c
index 6c69c8b8f1..d0602e452f 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.388 2004/02/03 00:16:58 ulfl Exp $
+ * $Id: main.c,v 1.389 2004/02/03 17:59:01 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1644,6 +1644,7 @@ dnd_open_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
file_save_as_cmd(after_save_open_dnd_file, data);
break;
case(ESD_BTN_NO):
+ cf_close(&cfile);
dnd_open_file_cmd(data);
break;
case(ESD_BTN_CANCEL):
diff --git a/gtk/menu.c b/gtk/menu.c
index cb9956646f..f633db7084 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.156 2004/02/03 00:16:59 ulfl Exp $
+ * $Id: menu.c,v 1.157 2004/02/03 17:59:01 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -822,6 +822,7 @@ static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpo
file_save_as_cmd(after_save_open_recent_file, data);
break;
case(ESD_BTN_NO):
+ cf_close(&cfile);
menu_open_recent_file_cmd(data);
break;
case(ESD_BTN_CANCEL):
diff --git a/gtk/simple_dialog.c b/gtk/simple_dialog.c
index 780cd30a2f..574979f1e6 100644
--- a/gtk/simple_dialog.c
+++ b/gtk/simple_dialog.c
@@ -1,7 +1,7 @@
/* simple_dialog.c
* Simple message dialog box routines.
*
- * $Id: simple_dialog.c,v 1.22 2004/01/31 12:49:54 ulfl Exp $
+ * $Id: simple_dialog.c,v 1.23 2004/02/03 17:59:01 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -227,3 +227,15 @@ void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpoi
OBJECT_SET_DATA(GTK_WIDGET(dialog), CALLBACK_FCT_KEY, callback_fct);
OBJECT_SET_DATA(GTK_WIDGET(dialog), CALLBACK_DATA_KEY, data);
}
+
+char *
+simple_dialog_primary_start(void) {
+ return PRIMARY_TEXT_START;
+}
+
+char *
+simple_dialog_primary_end(void) {
+ return PRIMARY_TEXT_END;
+}
+
+
diff --git a/simple_dialog.h b/simple_dialog.h
index b37a44a558..29ced367ca 100644
--- a/simple_dialog.h
+++ b/simple_dialog.h
@@ -2,7 +2,7 @@
* Definitions for dialog box routines with toolkit-independent APIs but
* toolkit-dependent implementations.
*
- * $Id: simple_dialog.h,v 1.7 2004/01/31 12:13:21 ulfl Exp $
+ * $Id: simple_dialog.h,v 1.8 2004/02/03 17:59:00 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -62,6 +62,9 @@ typedef void (* simple_dialog_cb_t) (gpointer dialog, gint btn, gpointer data);
/* set the callback function, which has to be called when a button was pressed */
extern void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data);
+extern char *simple_dialog_primary_start(void);
+extern char *simple_dialog_primary_end(void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */