aboutsummaryrefslogtreecommitdiffstats
path: root/captype.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-12-26 13:45:59 +0000
committerGuy Harris <guy@alum.mit.edu>2013-12-26 13:45:59 +0000
commit67527befa6ca1ee78bdab50c2fb4a76e12f9be33 (patch)
treea640fd0fcac6fab238ed51784d02ba625c9cb3b8 /captype.c
parente3d4fe8aae92e1edff06724e3541c963601c66ec (diff)
Report files not recognized as capture files as type "unknown" rather
than as open errors. svn path=/trunk/; revision=54461
Diffstat (limited to 'captype.c')
-rw-r--r--captype.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/captype.c b/captype.c
index 4b54f99482..1aed705f02 100644
--- a/captype.c
+++ b/captype.c
@@ -145,10 +145,16 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
wth = wtap_open_offline(argv[i], &err, &err_info, FALSE);
- if (!wth) {
- fprintf(stderr, "captype: Can't open %s: %s\n", argv[i],
- wtap_strerror(err));
- switch (err) {
+ if(wth) {
+ printf("%s: %s\n", argv[i], wtap_file_type_subtype_short_string(wtap_file_type_subtype(wth)));
+ wtap_close(wth);
+ } else {
+ if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT)
+ printf("%s: unknown\n", argv[i]);
+ else {
+ fprintf(stderr, "captype: Can't open %s: %s\n", argv[i],
+ wtap_strerror(err));
+ switch (err) {
case WTAP_ERR_UNSUPPORTED:
case WTAP_ERR_UNSUPPORTED_ENCAP:
@@ -156,14 +162,11 @@ main(int argc, char *argv[])
fprintf(stderr, "(%s)\n", err_info);
g_free(err_info);
break;
+ }
+ overall_error_status = 1; /* remember that an error has occurred */
}
- overall_error_status = 1; /* remember that an error has occurred */
}
- if(wth) {
- printf("%s: %s\n", argv[i], wtap_file_type_subtype_short_string(wtap_file_type_subtype(wth)));
- wtap_close(wth);
- }
}
return overall_error_status;