Add "write_failure_alert_box()" to put up an alert box for a failed
attempt to write to a file (or close a file opened for writing). Get rid of no-longer-needed #includes of <epan/filesystem.h>. svn path=/trunk/; revision=10027
This commit is contained in:
parent
727b913bbd
commit
3a4e71a724
19
alert_box.c
19
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>
|
||||
|
@ -55,6 +55,23 @@ open_failure_alert_box(const char *filename, int err, gboolean for_writing)
|
|||
file_open_error_message(err, for_writing), filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
|
@ -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>
|
||||
|
@ -39,6 +39,12 @@ extern "C" {
|
|||
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
|
||||
|
|
9
file.c
9
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue