aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-01-25 21:55:17 +0000
committerGuy Harris <guy@alum.mit.edu>2004-01-25 21:55:17 +0000
commitd6cd61061efe7207b298b5ac40a92e7b86b00b3e (patch)
tree392720e018248f9cf2b46db00a4a9740ff7d1fca /editcap.c
parent34bddb3c1a932632fd0515f7999ed96ef9974611 (diff)
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with "g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed strings returned as the error info string, and change the callers of those routines to, for those errors, put the info string into the printed message or alert box for the error. Add messages for cases where those errors were returned without printing an additional message. Nobody uses the error code from "cf_read()" - "cf_read()" puts up the alert box itself for failures; get rid of the error code, so it just returns a success/failure indication. Rename "file_read_error_message()" to "cf_read_error_message()", as it handles read errors from Wiretap, and have it take an error info string as an argument. (That handles a lot of the work of putting the info string into the error message.) Make some variables in "ascend-grammar.y" static. Check the return value of "erf_read_header()" in "erf_seek_read()". Get rid of an unused #define in "i4btrace.c". svn path=/trunk/; revision=9852
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/editcap.c b/editcap.c
index e846f5ba7e..6fb6d1593e 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1,7 +1,7 @@
/* Edit capture files. We can delete records, adjust timestamps, or
* simply convert from one format to another format.
*
- * $Id: editcap.c,v 1.27 2004/01/18 16:21:12 jmayer Exp $
+ * $Id: editcap.c,v 1.28 2004/01/25 21:55:09 guy Exp $
*
* Originally written by Richard Sharpe.
* Improved by Guy Harris.
@@ -307,6 +307,7 @@ int main(int argc, char *argv[])
{
wtap *wth;
int i, err;
+ gchar *err_info;
callback_arg args;
extern char *optarg;
extern int optind;
@@ -384,12 +385,19 @@ int main(int argc, char *argv[])
}
- wth = wtap_open_offline(argv[optind], &err, FALSE);
+ wth = wtap_open_offline(argv[optind], &err, &err_info, FALSE);
if (!wth) {
-
fprintf(stderr, "editcap: Can't open %s: %s\n", argv[optind],
wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ fprintf(stderr, "(%s)\n", err_info);
+ break;
+ }
exit(1);
}
@@ -430,7 +438,20 @@ int main(int argc, char *argv[])
for (i = optind + 2; i < argc; i++)
add_selection(argv[i]);
- wtap_loop(wth, 0, edit_callback, (char *)&args, &err);
+ if (!wtap_loop(wth, 0, edit_callback, (char *)&args, &err, &err_info)) {
+ /* Print a message noting that the read failed somewhere along the line. */
+ fprintf(stderr,
+ "editcap: An error occurred while reading \"%s\": %s.\n",
+ argv[optind], wtap_strerror(err));
+ switch (err) {
+
+ case WTAP_ERR_UNSUPPORTED:
+ case WTAP_ERR_UNSUPPORTED_ENCAP:
+ case WTAP_ERR_BAD_RECORD:
+ fprintf(stderr, "(%s)\n", err_info);
+ break;
+ }
+ }
if (!wtap_dump_close(args.pdh, &err)) {