diff options
author | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-06-02 23:14:19 +0000 |
---|---|---|
committer | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-06-02 23:14:19 +0000 |
commit | 994a4331ff61cb5fb95abc3cd5ffc5952e7f707d (patch) | |
tree | 1e4f67c7082e851cd1b94430908e6c164818ef0b /editcap.c | |
parent | 2aea08ae058c93e5f4794e1f3fd6c7e4bfeec709 (diff) |
If no valid packages was found in the input file we write an empty
header in the output file. This way we at least create a file.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28617 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'editcap.c')
-rw-r--r-- | editcap.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -1230,7 +1230,6 @@ main(int argc, char *argv[]) count++; } - g_free(filename); g_free(fprefix); g_free(fsuffix); @@ -1250,13 +1249,28 @@ main(int argc, char *argv[]) } } - if (pdh && !wtap_dump_close(pdh, &err)) { + if (!pdh) { + /* No valid packages found, open the outfile so we can write an empty header */ + g_free (filename); + filename = g_strdup(argv[optind+1]); + + pdh = wtap_dump_open(filename, out_file_type, + out_frame_type, wtap_snapshot_length(wth), FALSE /* compressed */, &err); + if (pdh == NULL) { + fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename, + wtap_strerror(err)); + exit(2); + } + } - fprintf(stderr, "editcap: Error closing %s: %s\n", filename, + if (!wtap_dump_close(pdh, &err)) { + + fprintf(stderr, "editcap: Error writing to %s: %s\n", filename, wtap_strerror(err)); exit(2); } + g_free(filename); } if (dup_detect) { |