diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-01-25 00:58:13 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-01-25 00:58:13 +0000 |
commit | 7502ac216ad7dcef048f1418eb8e34edb953ddac (patch) | |
tree | 6285e0506f94a9c4dfbf986131dd1b0f316d19bd /tethereal.c | |
parent | 064d5e5e07127d79d1bb02b3c11ff4a5e2ef7939 (diff) |
There's no need to keep a "FILE *" for the file being printed to in a
"capture_file" structure. Keep it locally, instead.
Check for errors when printing packets.
Report failure to open a print destination and failure to write to a
print destination differently.
Don't have the "print preamble" and "print final" routines return
success/failure indications - revert to the old scheme where they
didn't, and have the callers use "ferror()" to check for errors.
Report write errors when printing dissections in Tethereal.
Report print errors as errors, not warnings.
svn path=/trunk/; revision=9828
Diffstat (limited to 'tethereal.c')
-rw-r--r-- | tethereal.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/tethereal.c b/tethereal.c index 3ae5cb8071..e997df7f39 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.224 2004/01/24 01:44:28 guy Exp $ + * $Id: tethereal.c,v 1.225 2004/01/25 00:58:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -172,6 +172,7 @@ static void wtap_dispatch_cb_write(guchar *, const struct wtap_pkthdr *, long, static void show_capture_file_io_error(const char *, int, gboolean); static void wtap_dispatch_cb_print(guchar *, const struct wtap_pkthdr *, long, union wtap_pseudo_header *, const guchar *); +static void show_print_file_io_error(int err); static char *cf_open_error_message(int err, gboolean for_writing, int file_type); #ifdef HAVE_LIBPCAP @@ -2269,11 +2270,23 @@ load_cap_file(capture_file *cf, int out_file_type) args.cf = cf; args.pdh = NULL; print_preamble(stdout, print_format); + if (ferror(stdout)) { + err = errno; + show_print_file_io_error(err); + goto out; + } success = wtap_loop(cf->wth, 0, wtap_dispatch_cb_print, (guchar *) &args, &err); - print_finale(stdout, print_format); } - if (!success) { + if (success) { + if (cf->save_file == NULL) { + print_finale(stdout, print_format); + if (ferror(stdout)) { + err = errno; + show_print_file_io_error(err); + } + } + } else { /* Print up a message box noting that the read failed somewhere along the line. */ switch (err) { @@ -2816,6 +2829,33 @@ wtap_dispatch_cb_print(guchar *user, const struct wtap_pkthdr *phdr, clear_fdata(&fdata); } +static void +show_print_file_io_error(int err) +{ + switch (err) { + + case ENOSPC: + fprintf(stderr, +"tethereal: Not all the packets could be printed because there is " +"no space left on the file system.\n"); + break; + +#ifdef EDQUOT + case EDQUOT: + fprintf(stderr, +"tethereal: Not all the packets could be printed because you are " +"too close to, or over your disk quota.\n"); + break; +#endif + + default: + fprintf(stderr, +"tethereal: An error occurred while printing packets: %s.\n", + strerror(err)); + break; + } +} + static char * cf_open_error_message(int err, gboolean for_writing, int file_type) { |