aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2009-05-23 20:29:12 +0000
committerGuy Harris <guy@alum.mit.edu>2009-05-23 20:29:12 +0000
commit5e8e10cfa3bd4c29c6c29c3c609c56c99fbd20d9 (patch)
tree09202e232bbe214fbc7a0d05ea5ff5c6e5a75f39 /editcap.c
parentdc3b1136cc952e4c63a15744dd9d935c25e0eab3 (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. svn path=/trunk/; revision=28458
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);
}
}