diff options
author | cmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-11-16 15:37:37 +0000 |
---|---|---|
committer | cmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-11-16 15:37:37 +0000 |
commit | 0057b3b18ebb2c71be8e93b92cf4deccda6d2cf7 (patch) | |
tree | b13d90d4dbeeaefe11d7f3f390e4aab271035a2c /dumpcap.c | |
parent | c4bb2eb817073c4db2ceb7b33cf88a3fb5df4822 (diff) |
Use more meaningful temp file name. Fixes bug 1882.
Template chosen is: wireshark_<iface>_YYYYmmddHHMMSS_XXXXXX ... where
<iface> is the interface name (or UUID part of the interface if applicable)
YYYYmmddHHMMSS are as described in "man strftime".
XXXXXX is a template filled in with random characters. See "man mkstemp".
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@34902 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'dumpcap.c')
-rw-r--r-- | dumpcap.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -2633,6 +2633,29 @@ capture_loop_dispatch(capture_options *capture_opts _U_, loop_data *ld, return ld->packet_count - packet_count_before; } +#ifdef _WIN32 +/* Isolate the Universally Unique Identifier from the interface. Basically, we + * want to grab only the characters between the '{' and '}' delimiters. + * + * Returns a GString that must be freed with g_string_free(). */ +static GString *isolate_uuid(const char *iface) +{ + gchar *ptr; + GString *gstr; + + ptr = strchr(iface, '{'); + if (ptr == NULL) + return g_string_new(iface); + gstr = g_string_new(ptr + 1); + + ptr = strchr(gstr->str, '}'); + if (ptr == NULL) + return gstr; + + gstr = g_string_truncate(gstr, ptr - gstr->str); + return gstr; +} +#endif /* open the output file (temporary/specified name/ringbuffer/named pipe/stdout) */ /* Returns TRUE if the file opened successfully, FALSE otherwise. */ @@ -2642,6 +2665,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, char *tmpname; gchar *capfile_name; + gchar *prefix; gboolean is_tempfile; #ifndef _WIN32 int ret; @@ -2696,7 +2720,17 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, is_tempfile = FALSE; } else { /* Choose a random name for the temporary capture buffer */ - *save_file_fd = create_tempfile(&tmpname, "wireshark"); +#ifdef _WIN32 + GString *iface; + + iface = isolate_uuid(capture_opts->iface); + prefix = g_strconcat("wireshark_", g_basename(iface->str), NULL); + g_string_free(iface, TRUE); +#else + prefix = g_strconcat("wireshark_", g_basename(capture_opts->iface), NULL); +#endif + *save_file_fd = create_tempfile(&tmpname, prefix); + g_free(prefix); capfile_name = g_strdup(tmpname); is_tempfile = TRUE; } |