diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-01-25 02:24:44 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-01-25 02:24:44 +0000 |
commit | a0528c5f826f480d51ecf90f7422c5c085549d58 (patch) | |
tree | 54d822bca91ed7c53e6dbcce05da0cd25f0cd4eb /gtk | |
parent | 557d5430af928c648083f7c1a8984751648b2619 (diff) |
Report open errors when saving the contents of an RTP stream. Check for
and report write errors as well.
svn path=/trunk/; revision=9833
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/rtp_stream.c | 31 | ||||
-rw-r--r-- | gtk/rtp_stream.h | 4 | ||||
-rw-r--r-- | gtk/rtp_stream_dlg.c | 8 |
3 files changed, 34 insertions, 9 deletions
diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c index f021dcb668..452853c584 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.6 2004/01/18 16:08:21 jmayer Exp $ + * $Id: rtp_stream.c,v 1.7 2004/01/25 02:24:44 guy Exp $ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> @@ -38,6 +38,8 @@ #include "register.h" #include "packet-rtp.h" +#include <epan/filesystem.h> + #include "simple_dialog.h" #ifdef HAVE_SYS_TYPES_H @@ -275,16 +277,24 @@ void rtpstream_scan(void) /****************************************************************************/ /* save rtp dump of stream_fwd */ -void rtpstream_save(rtp_stream_info_t* stream, const gchar *filename) +gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename) { gboolean was_registered = the_tapinfo_struct.is_registered; /* open file for saving */ the_tapinfo_struct.save_file = fopen(filename, "wb"); if (the_tapinfo_struct.save_file==NULL) { - return; + simple_dialog(ESD_TYPE_CRIT, NULL, + file_open_error_message(errno, TRUE), filename); + return FALSE; } rtp_write_header(stream, the_tapinfo_struct.save_file); + if (ferror(the_tapinfo_struct.save_file)) { + simple_dialog(ESD_TYPE_CRIT, NULL, + file_write_error_message(errno), filename); + fclose(the_tapinfo_struct.save_file); + return FALSE; + } if (!the_tapinfo_struct.is_registered) register_tap_listener_rtp_stream(); @@ -297,8 +307,19 @@ void rtpstream_save(rtp_stream_info_t* stream, const gchar *filename) if (!was_registered) remove_tap_listener_rtp_stream(); - /* XXX check for error at fclose? */ - fclose(the_tapinfo_struct.save_file); + if (ferror(the_tapinfo_struct.save_file)) { + simple_dialog(ESD_TYPE_CRIT, NULL, + file_write_error_message(errno), filename); + fclose(the_tapinfo_struct.save_file); + return FALSE; + } + + if (fclose(the_tapinfo_struct.save_file) == EOF) { + simple_dialog(ESD_TYPE_CRIT, NULL, + file_write_error_message(errno), filename); + return FALSE; + } + return TRUE; } diff --git a/gtk/rtp_stream.h b/gtk/rtp_stream.h index 2d2da12a18..bbc8848f2e 100644 --- a/gtk/rtp_stream.h +++ b/gtk/rtp_stream.h @@ -1,7 +1,7 @@ /* rtp_stream.h * RTP streams summary addition for ethereal * - * $Id: rtp_stream.h,v 1.3 2004/01/18 16:08:21 jmayer Exp $ + * $Id: rtp_stream.h,v 1.4 2004/01/25 02:24:44 guy Exp $ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> @@ -132,7 +132,7 @@ void rtpstream_scan(void); * Saves an RTP stream as raw data stream with timestamp information for later RTP playback. * (redissects all packets) */ -void rtpstream_save(rtp_stream_info_t* stream, const gchar *filename); +gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename); /* * Marks all packets belonging to either of stream_fwd or stream_rev. diff --git a/gtk/rtp_stream_dlg.c b/gtk/rtp_stream_dlg.c index 3ee28ec518..89cafc0fa8 100644 --- a/gtk/rtp_stream_dlg.c +++ b/gtk/rtp_stream_dlg.c @@ -1,7 +1,7 @@ /* rtp_stream_dlg.c * RTP streams summary addition for ethereal * - * $Id: rtp_stream_dlg.c,v 1.9 2004/01/21 03:54:31 ulfl Exp $ + * $Id: rtp_stream_dlg.c,v 1.10 2004/01/25 02:24:44 guy Exp $ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff <lars.ruoff@gmx.net> @@ -162,7 +162,11 @@ static void save_stream_ok_cb(GtkWidget *ok_bt _U_, gpointer user_data _U_) return; } - rtpstream_save(selected_stream_fwd, g_dest); + /* + * Don't dismiss the dialog box if the save operation fails. + */ + if (!rtpstream_save(selected_stream_fwd, g_dest)) + return; gtk_widget_destroy(GTK_WIDGET(rtpstream_save_dlg)); } |