aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2009-05-23 20:29:12 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2009-05-23 20:29:12 +0000
commit1c8625dac4b7eddef50e86efc997ce83dcc7a3d1 (patch)
tree09202e232bbe214fbc7a0d05ea5ff5c6e5a75f39 /editcap.c
parent1a959823616f75165de902a2d5cd77a0ec26faea (diff)
Have fileset_extract_prefix_suffix() print an error message if it fails,
so we don't just exit silently. Don't bother checking the validity of arguments - it shouldn't be passed NULL fprefix or fsuffix arguments in the first place, and isn't passed them. Exit with an exit status of 1 for command-line syntax errors and 2 for file open/close/IO errors. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28458 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/editcap.c b/editcap.c
index ac9a4a2561..d5ad41f97a 100644
--- a/editcap.c
+++ b/editcap.c
@@ -186,9 +186,10 @@ fileset_extract_prefix_suffix(const char *fname, gchar **fprefix, gchar **fsuffi
gchar *save_file;
save_file = g_strdup(fname);
-
- if (!fprefix || !fsuffix || !save_file)
- return FALSE;
+ if (save_file == NULL) {
+ fprintf(stderr, "editcap: Out of memory\n");
+ return FALSE;
+ }
last_pathsep = strrchr(save_file, G_DIR_SEPARATOR);
pfx = strrchr(save_file,'.');
@@ -936,7 +937,7 @@ main(int argc, char *argv[])
g_free(err_info);
break;
}
- exit(1);
+ exit(2);
}
@@ -976,7 +977,7 @@ main(int argc, char *argv[])
if (split_packet_count > 0 || secs_per_block > 0) {
if (!fileset_extract_prefix_suffix(argv[optind+1], &fprefix, &fsuffix))
- exit(5);
+ exit(2);
filename = fileset_get_filename_by_pattern(block_cnt++, &phdr->ts, fprefix, fsuffix);
} else
@@ -988,7 +989,7 @@ main(int argc, char *argv[])
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
wtap_strerror(err));
- exit(1);
+ exit(2);
}
}
@@ -1002,7 +1003,7 @@ main(int argc, char *argv[])
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
wtap_strerror(err));
- exit(1);
+ exit(2);
}
block_start.secs = block_start.secs + secs_per_block; /* reset for next interval */
g_free(filename);
@@ -1019,7 +1020,7 @@ main(int argc, char *argv[])
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
wtap_strerror(err));
- exit(1);
+ exit(2);
}
}
}
@@ -1032,7 +1033,7 @@ main(int argc, char *argv[])
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
wtap_strerror(err));
- exit(1);
+ exit(2);
}
g_free(filename);
@@ -1048,7 +1049,7 @@ main(int argc, char *argv[])
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
wtap_strerror(err));
- exit(1);
+ exit(2);
}
}
}
@@ -1222,7 +1223,7 @@ main(int argc, char *argv[])
&err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));
- exit(1);
+ exit(2);
}
written_count++;
}
@@ -1253,7 +1254,7 @@ main(int argc, char *argv[])
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
wtap_strerror(err));
- exit(1);
+ exit(2);
}
}