diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-02-17 03:05:54 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-02-17 03:05:54 +0000 |
commit | 2a67272100db8b206dec54a1c35bb28310f6fad0 (patch) | |
tree | 42adc7ae815b3fa17187af437c07eee04de224ce /file.c | |
parent | 8f46bd354bca3c418c49365fe703f8d7124ea32f (diff) |
Have "cf_merge_files()" take a pointer-to-pointer-to-char as the output
file name argument; if the pointed-to pointer is null, it opens a
temporary file, and sets that pointer to a mallocated copy of the
pathname of the temporary file. It no longer needs a file descriptor as
an argument.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13419 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -939,11 +939,14 @@ read_packet(capture_file *cf, long offset) } cf_status_t -cf_merge_files(const char *out_filename, int out_fd, int in_file_count, +cf_merge_files(char **out_filenamep, int in_file_count, char *const *in_filenames, int file_type, gboolean do_append) { merge_in_file_t *in_files; wtap *wth; + char *out_filename; + char tmpname[128+1]; + int out_fd; wtap_dumper *pdh; int open_err, read_err, write_err, close_err; gchar *err_info; @@ -977,6 +980,26 @@ cf_merge_files(const char *out_filename, int out_fd, int in_file_count, return CF_ERROR; } + if (*out_filenamep != NULL) { + out_filename = *out_filenamep; + out_fd = open(out_filename, O_CREAT|O_TRUNC|O_BINARY, 0600); + if (out_fd == -1) + open_err = errno; + } else { + out_fd = create_tempfile(tmpname, sizeof tmpname, "ether"); + if (out_fd == -1) + open_err = errno; + out_filename = g_strdup(tmpname); + *out_filenamep = out_filename; + } + if (out_fd == -1) { + err_info = NULL; + merge_close_in_files(in_file_count, in_files); + free(in_files); + cf_open_failure_alert_box(out_filename, open_err, NULL, TRUE, file_type); + return CF_ERROR; + } + pdh = wtap_dump_fdopen(out_fd, file_type, merge_select_frame_type(in_file_count, in_files), merge_max_snapshot_length(in_file_count, in_files), &open_err); |