Add an "open_failure_alert_box()" routine to pop up an alert box for a
failed attempt to open/create a file. Fix one call to pass the right value for the "for_writing" flag. svn path=/trunk/; revision=10026
This commit is contained in:
parent
c7fd1b2b13
commit
727b913bbd
22
alert_box.c
22
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.1 2004/02/11 00:55:26 guy Exp $
|
||||
* $Id: alert_box.c,v 1.2 2004/02/11 01:23:23 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -29,12 +29,32 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include <epan/filesystem.h>
|
||||
#include <epan/dfilter/dfilter.h>
|
||||
|
||||
#include "alert_box.h"
|
||||
|
||||
#include "simple_dialog.h"
|
||||
|
||||
/*
|
||||
* Alert box for a failed attempt to open or create a file.
|
||||
* "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if
|
||||
* the file is being opened for writing and FALSE if it's being opened
|
||||
* for reading.
|
||||
*
|
||||
* 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
|
||||
open_failure_alert_box(const char *filename, int err, gboolean for_writing)
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(err, for_writing), filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Alert box for an invalid display filter expression.
|
||||
* Assumes "dfilter_error_msg" has been set by "dfilter_compile()" to the
|
||||
|
|
11
alert_box.h
11
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.1 2004/02/11 00:55:27 guy Exp $
|
||||
* $Id: alert_box.h,v 1.2 2004/02/11 01:23:23 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -30,6 +30,15 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Alert box for a failed attempt to open or create a file.
|
||||
* "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if
|
||||
* the file is being opened for writing and FALSE if it's being opened
|
||||
* for reading.
|
||||
*/
|
||||
extern void open_failure_alert_box(const char *filename, int err,
|
||||
gboolean for_writing);
|
||||
|
||||
/*
|
||||
* Alert box for an invalid display filter expression.
|
||||
* Assumes "dfilter_error_msg" has been set by "dfilter_compile()" to the
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* capture.c
|
||||
* Routines for packet capture windows
|
||||
*
|
||||
* $Id: capture.c,v 1.237 2004/02/09 19:19:19 ulfl Exp $
|
||||
* $Id: capture.c,v 1.238 2004/02/11 01:23:23 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -130,11 +130,11 @@
|
|||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/dfilter/dfilter.h>
|
||||
#include <epan/filesystem.h>
|
||||
#include "file.h"
|
||||
#include "capture.h"
|
||||
#include "util.h"
|
||||
#include "pcap-util.h"
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
#include "prefs.h"
|
||||
#include "globals.h"
|
||||
|
@ -322,8 +322,7 @@ do_capture(const char *save_file)
|
|||
if (capture_opts.ringbuffer_on) {
|
||||
ringbuf_error_cleanup();
|
||||
}
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), capfile_name);
|
||||
open_failure_alert_box(capfile_name, errno, TRUE);
|
||||
}
|
||||
g_free(capfile_name);
|
||||
return FALSE;
|
||||
|
|
11
file.c
11
file.c
|
@ -1,7 +1,7 @@
|
|||
/* file.c
|
||||
* File I/O routines
|
||||
*
|
||||
* $Id: file.c,v 1.358 2004/02/11 00:55:27 guy Exp $
|
||||
* $Id: file.c,v 1.359 2004/02/11 01:23:24 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -70,6 +70,7 @@
|
|||
#include "file.h"
|
||||
#include "menu.h"
|
||||
#include "util.h"
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
#include "progress_dlg.h"
|
||||
#include "ui_util.h"
|
||||
|
@ -2979,9 +2980,7 @@ copy_binary_file(char *from_filename, char *to_filename)
|
|||
/* Copy the raw bytes of the file. */
|
||||
from_fd = open(from_filename, O_RDONLY | O_BINARY);
|
||||
if (from_fd < 0) {
|
||||
err = errno;
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(err, TRUE), from_filename);
|
||||
open_failure_alert_box(from_filename, errno, FALSE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -2992,9 +2991,7 @@ copy_binary_file(char *from_filename, char *to_filename)
|
|||
to be open in binary mode. */
|
||||
to_fd = open(to_filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
|
||||
if (to_fd < 0) {
|
||||
err = errno;
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(err, TRUE), to_filename);
|
||||
open_failure_alert_box(to_filename, errno, TRUE);
|
||||
close(from_fd);
|
||||
goto done;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* follow_dlg.c
|
||||
*
|
||||
* $Id: follow_dlg.c,v 1.43 2004/02/06 19:19:10 ulfl Exp $
|
||||
* $Id: follow_dlg.c,v 1.44 2004/02/11 01:23:24 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -54,6 +54,7 @@
|
|||
#include "globals.h"
|
||||
#include "gtkglobals.h"
|
||||
#include "main.h"
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
#include "packet-ipv6.h"
|
||||
#include "prefs.h"
|
||||
|
@ -765,10 +766,9 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
|
|||
|
||||
fh = open_print_dest(to_file, print_dest);
|
||||
if (fh == NULL) {
|
||||
if (to_file) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), prefs.pr_file);
|
||||
} else {
|
||||
if (to_file)
|
||||
open_failure_alert_box(prefs.pr_file, errno, TRUE);
|
||||
else {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Couldn't run print command %s.", prefs.pr_cmd);
|
||||
}
|
||||
|
@ -977,8 +977,7 @@ follow_save_as_ok_cb(GtkWidget * w _U_, GtkFileSelection * fs)
|
|||
|
||||
fh = fopen(to_name, "wb");
|
||||
if (fh == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), to_name);
|
||||
open_failure_alert_box(to_name, errno, TRUE);
|
||||
g_free(to_name);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* print_dlg.c
|
||||
* Dialog boxes for printing
|
||||
*
|
||||
* $Id: print_dlg.c,v 1.60 2004/01/31 20:31:20 ulfl Exp $
|
||||
* $Id: print_dlg.c,v 1.61 2004/02/11 01:23:24 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -34,6 +34,7 @@
|
|||
#include "keys.h"
|
||||
#include "print.h"
|
||||
#include "prefs.h"
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
#include "file_dlg.h"
|
||||
#include "ui_util.h"
|
||||
|
@ -846,8 +847,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
|
|||
|
||||
case PP_OPEN_ERROR:
|
||||
if (print_args.to_file)
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), print_args.dest);
|
||||
open_failure_alert_box(print_args.dest, errno, TRUE);
|
||||
else
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Couldn't run print command %s.",
|
||||
print_args.dest);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* proto_draw.c
|
||||
* Routines for GTK+ packet display
|
||||
*
|
||||
* $Id: proto_draw.c,v 1.86 2004/02/06 19:19:10 ulfl Exp $
|
||||
* $Id: proto_draw.c,v 1.87 2004/02/11 01:23:24 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -62,6 +62,7 @@
|
|||
#include "gtkglobals.h"
|
||||
#include "compat_macros.h"
|
||||
#include <epan/filesystem.h>
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
|
||||
#define BYTE_VIEW_WIDTH 16
|
||||
|
@ -918,8 +919,7 @@ savehex_save_clicked_cb(GtkWidget * w _U_, gpointer data _U_)
|
|||
|
||||
fd = open(file, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||
if (fd == -1) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), file);
|
||||
open_failure_alert_box(file, errno, TRUE);
|
||||
return;
|
||||
}
|
||||
if (write(fd, data_p + start, end - start) < 0) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* rtp_analysis.c
|
||||
* RTP analysis addition for ethereal
|
||||
*
|
||||
* $Id: rtp_analysis.c,v 1.32 2004/02/06 19:19:10 ulfl Exp $
|
||||
* $Id: rtp_analysis.c,v 1.33 2004/02/11 01:23:25 guy Exp $
|
||||
*
|
||||
* Copyright 2003, Alcatel Business Systems
|
||||
* By Lars Ruoff <lars.ruoff@gmx.net>
|
||||
|
@ -60,6 +60,7 @@
|
|||
/* in /gtk ... */
|
||||
#include "dlg_utils.h"
|
||||
#include "ui_util.h"
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
#include "menu.h"
|
||||
#include "main.h"
|
||||
|
@ -986,8 +987,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
|
|||
if (GTK_TOGGLE_BUTTON(forw)->active || GTK_TOGGLE_BUTTON(both)->active) {
|
||||
fp = fopen(g_dest, "w");
|
||||
if (fp == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), g_dest);
|
||||
open_failure_alert_box(g_dest, errno, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1045,9 +1045,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
|
|||
if (GTK_TOGGLE_BUTTON(both)->active) {
|
||||
fp = fopen(g_dest, "a");
|
||||
if (fp == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE),
|
||||
g_dest);
|
||||
open_failure_alert_box(g_dest, errno, TRUE);
|
||||
return;
|
||||
}
|
||||
fprintf(fp, "\nReverse\n");
|
||||
|
@ -1060,9 +1058,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
|
|||
} else {
|
||||
fp = fopen(g_dest, "w");
|
||||
if (fp == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE),
|
||||
g_dest);
|
||||
open_failure_alert_box(g_dest, errno, TRUE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* rtp_stream.c
|
||||
* RTP streams summary addition for ethereal
|
||||
*
|
||||
* $Id: rtp_stream.c,v 1.11 2004/01/31 09:48:26 guy Exp $
|
||||
* $Id: rtp_stream.c,v 1.12 2004/02/11 01:23:25 guy Exp $
|
||||
*
|
||||
* Copyright 2003, Alcatel Business Systems
|
||||
* By Lars Ruoff <lars.ruoff@gmx.net>
|
||||
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include <epan/filesystem.h>
|
||||
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
|
@ -285,8 +286,7 @@ gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
|
|||
/* open file for saving */
|
||||
the_tapinfo_struct.save_file = fopen(filename, "wb");
|
||||
if (the_tapinfo_struct.save_file==NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
file_open_error_message(errno, TRUE), filename);
|
||||
open_failure_alert_box(filename, errno, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue