aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alert_box.c19
-rw-r--r--alert_box.h8
-rw-r--r--file.c9
-rw-r--r--gtk/follow_dlg.c25
-rw-r--r--gtk/print_dlg.c5
-rw-r--r--gtk/proto_draw.c9
-rw-r--r--gtk/rtp_analysis.c26
-rw-r--r--gtk/rtp_stream.c13
8 files changed, 56 insertions, 58 deletions
diff --git a/alert_box.c b/alert_box.c
index ecd0f734d7..4df5296f9c 100644
--- a/alert_box.c
+++ b/alert_box.c
@@ -2,7 +2,7 @@
* Routines to put up various "standard" alert boxes used in multiple
* places
*
- * $Id: alert_box.c,v 1.2 2004/02/11 01:23:23 guy Exp $
+ * $Id: alert_box.c,v 1.3 2004/02/11 01:37:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -56,6 +56,23 @@ open_failure_alert_box(const char *filename, int err, gboolean for_writing)
}
/*
+ * Alert box for a failed attempt to write to a file.
+ * "err" is assumed to be a UNIX-style errno.
+ *
+ * XXX - add explanatory secondary text for at least some of the errors;
+ * various HIGs suggest that you should, for example, suggest that the
+ * user remove files if the file system is full. Perhaps that's because
+ * they're providing guidelines for people less sophisticated than the
+ * typical Ethereal user is, but....
+ */
+void
+write_failure_alert_box(const char *filename, int err)
+{
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ file_write_error_message(err), filename);
+}
+
+/*
* Alert box for an invalid display filter expression.
* Assumes "dfilter_error_msg" has been set by "dfilter_compile()" to the
* error message for the filter.
diff --git a/alert_box.h b/alert_box.h
index 249d6aaafa..667b8101ed 100644
--- a/alert_box.h
+++ b/alert_box.h
@@ -2,7 +2,7 @@
* Routines to put up various "standard" alert boxes used in multiple
* places
*
- * $Id: alert_box.h,v 1.2 2004/02/11 01:23:23 guy Exp $
+ * $Id: alert_box.h,v 1.3 2004/02/11 01:37:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,6 +40,12 @@ extern void open_failure_alert_box(const char *filename, int err,
gboolean for_writing);
/*
+ * Alert box for a failed attempt to write to a file.
+ * "err" is assumed to be a UNIX-style errno.
+ */
+extern void write_failure_alert_box(const char *filename, int err);
+
+/*
* Alert box for an invalid display filter expression.
* Assumes "dfilter_error_msg" has been set by "dfilter_compile()" to the
* error message for the filter.
diff --git a/file.c b/file.c
index d91bdb599a..e98cb66949 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.359 2004/02/11 01:23:24 guy Exp $
+ * $Id: file.c,v 1.360 2004/02/11 01:37:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -3003,8 +3003,7 @@ copy_binary_file(char *from_filename, char *to_filename)
err = errno;
else
err = WTAP_ERR_SHORT_WRITE;
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(err), to_filename);
+ write_failure_alert_box(to_filename, err);
close(from_fd);
close(to_fd);
goto done;
@@ -3021,9 +3020,7 @@ copy_binary_file(char *from_filename, char *to_filename)
}
close(from_fd);
if (close(to_fd) < 0) {
- err = errno;
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(err), to_filename);
+ write_failure_alert_box(to_filename, errno);
goto done;
}
diff --git a/gtk/follow_dlg.c b/gtk/follow_dlg.c
index e31218f70a..ebb55a577a 100644
--- a/gtk/follow_dlg.c
+++ b/gtk/follow_dlg.c
@@ -1,6 +1,6 @@
/* follow_dlg.c
*
- * $Id: follow_dlg.c,v 1.44 2004/02/11 01:23:24 guy Exp $
+ * $Id: follow_dlg.c,v 1.45 2004/02/11 01:37:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -796,10 +796,9 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
if (ferror(fh))
goto print_error;
if (!close_print_dest(to_file, fh)) {
- if (to_file) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), prefs.pr_file);
- } else {
+ if (to_file)
+ write_failure_alert_box(prefs.pr_file, errno);
+ else {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Error closing print destination.");
}
@@ -807,10 +806,9 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
return;
print_error:
- if (to_file) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), prefs.pr_file);
- } else {
+ if (to_file)
+ write_failure_alert_box(prefs.pr_file, errno);
+ else {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Error writing to print command: %s", strerror(errno));
}
@@ -989,10 +987,8 @@ follow_save_as_ok_cb(GtkWidget * w _U_, GtkFileSelection * fs)
switch (follow_read_stream(follow_info, follow_print_text, fh)) {
case FRS_OK:
- if (fclose(fh) == EOF) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), to_name);
- }
+ if (fclose(fh) == EOF)
+ write_failure_alert_box(to_name, errno);
break;
case FRS_OPEN_ERROR:
@@ -1001,8 +997,7 @@ follow_save_as_ok_cb(GtkWidget * w _U_, GtkFileSelection * fs)
break;
case FRS_PRINT_ERROR:
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), to_name);
+ write_failure_alert_box(to_name, errno);
fclose(fh);
break;
}
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index 5955a36c82..1c6fe9e699 100644
--- a/gtk/print_dlg.c
+++ b/gtk/print_dlg.c
@@ -1,7 +1,7 @@
/* print_dlg.c
* Dialog boxes for printing
*
- * $Id: print_dlg.c,v 1.61 2004/02/11 01:23:24 guy Exp $
+ * $Id: print_dlg.c,v 1.62 2004/02/11 01:37:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -855,8 +855,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
case PP_WRITE_ERROR:
if (print_args.to_file)
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), print_args.dest);
+ write_failure_alert_box(print_args.dest, errno);
else
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Error writing to print command: %s", strerror(errno));
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index ea5b52b340..cd05f8788e 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -1,7 +1,7 @@
/* proto_draw.c
* Routines for GTK+ packet display
*
- * $Id: proto_draw.c,v 1.87 2004/02/11 01:23:24 guy Exp $
+ * $Id: proto_draw.c,v 1.88 2004/02/11 01:37:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -61,7 +61,6 @@
#include "ui_util.h"
#include "gtkglobals.h"
#include "compat_macros.h"
-#include <epan/filesystem.h>
#include "alert_box.h"
#include "simple_dialog.h"
@@ -923,14 +922,12 @@ savehex_save_clicked_cb(GtkWidget * w _U_, gpointer data _U_)
return;
}
if (write(fd, data_p + start, end - start) < 0) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), file);
+ write_failure_alert_box(file, errno);
close(fd);
return;
}
if (close(fd) < 0) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), file);
+ write_failure_alert_box(file, errno);
return;
}
diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c
index 1d85416720..d6c8ae74a8 100644
--- a/gtk/rtp_analysis.c
+++ b/gtk/rtp_analysis.c
@@ -1,7 +1,7 @@
/* rtp_analysis.c
* RTP analysis addition for ethereal
*
- * $Id: rtp_analysis.c,v 1.33 2004/02/11 01:23:25 guy Exp $
+ * $Id: rtp_analysis.c,v 1.34 2004/02/11 01:37:13 guy Exp $
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <lars.ruoff@gmx.net>
@@ -994,8 +994,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
if (GTK_TOGGLE_BUTTON(both)->active) {
fprintf(fp, "Forward\n");
if (ferror(fp)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
fclose(fp);
return;
}
@@ -1010,8 +1009,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
}
fprintf(fp,"\n");
if (ferror(fp)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
fclose(fp);
return;
}
@@ -1026,16 +1024,14 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
}
fprintf(fp,"\n");
if (ferror(fp)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
fclose(fp);
return;
}
}
if (fclose(fp) == EOF) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
return;
}
}
@@ -1050,8 +1046,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
}
fprintf(fp, "\nReverse\n");
if (ferror(fp)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
fclose(fp);
return;
}
@@ -1071,8 +1066,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
}
fprintf(fp,"\n");
if (ferror(fp)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
fclose(fp);
return;
}
@@ -1087,15 +1081,13 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
}
fprintf(fp,"\n");
if (ferror(fp)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
fclose(fp);
return;
}
}
if (fclose(fp) == EOF) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), g_dest);
+ write_failure_alert_box(g_dest, errno);
return;
}
}
diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c
index 029ed1c1ac..2c2a9300e7 100644
--- a/gtk/rtp_stream.c
+++ b/gtk/rtp_stream.c
@@ -1,7 +1,7 @@
/* rtp_stream.c
* RTP streams summary addition for ethereal
*
- * $Id: rtp_stream.c,v 1.12 2004/02/11 01:23:25 guy Exp $
+ * $Id: rtp_stream.c,v 1.13 2004/02/11 01:37:13 guy Exp $
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <lars.ruoff@gmx.net>
@@ -38,8 +38,6 @@
#include "register.h"
#include "packet-rtp.h"
-#include <epan/filesystem.h>
-
#include "alert_box.h"
#include "simple_dialog.h"
@@ -292,8 +290,7 @@ gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
rtp_write_header(stream, the_tapinfo_struct.save_file);
if (ferror(the_tapinfo_struct.save_file)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), filename);
+ write_failure_alert_box(filename, errno);
fclose(the_tapinfo_struct.save_file);
return FALSE;
}
@@ -310,15 +307,13 @@ gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
remove_tap_listener_rtp_stream();
if (ferror(the_tapinfo_struct.save_file)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), filename);
+ write_failure_alert_box(filename, errno);
fclose(the_tapinfo_struct.save_file);
return FALSE;
}
if (fclose(the_tapinfo_struct.save_file) == EOF) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(errno), filename);
+ write_failure_alert_box(filename, errno);
return FALSE;
}
return TRUE;