aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-08-23 00:06:26 +0000
committerGuy Harris <guy@alum.mit.edu>2013-08-23 00:06:26 +0000
commit32e1523bb22a05b6595ac6451f02d9745d0376a5 (patch)
treed0adaefda6056ed8cd9a88f67864637b2fc914fe /wiretap
parent713012163c779528d8f2563f2444ccbf0d981eb7 (diff)
For the Windows Open dialog for capture files, get rid of the "(*.*)" in
the "All Files" entry (the current UI guidelines from Microsoft say to do so, and that's what Paint does, at least), and add an "All Capture Files" entry with all the file extensions for the file types we support (it'll pick up all text files, but there's not much we can do about that, and it won't pick up files with *no* extension or weird extensions, such as you might get from UN*X systems or from WinDump commands, but at least it'll filter out some other crud). Fix what appear to be memory leaks; that should be backported unless I've missed something and they aren't leaks. Fix an out-of-date comment, and add an additional comment. svn path=/trunk/; revision=51481
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_access.c108
-rw-r--r--wiretap/wtap.h2
2 files changed, 81 insertions, 29 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 356f8374f3..fc7620137f 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1117,37 +1117,12 @@ static GSList *add_extensions(GSList *extensions, const gchar *extension,
return extensions;
}
-/* Return a list of file extensions that are used by the specified file type.
-
- If include_compressed is TRUE, the list will include compressed
- extensions, e.g. not just "pcap" but also "pcap.gz" if we can read
- gzipped files.
-
- All strings in the list are allocated with g_malloc() and must be freed
- with g_free(). */
-GSList *wtap_get_file_extensions_list(int filetype, gboolean include_compressed)
+static GSList *
+add_extensions_for_filetype(int filetype, GSList *extensions,
+ GSList *compressed_file_extensions)
{
gchar **extensions_set, **extensionp;
gchar *extension;
- GSList *compressed_file_extensions;
- GSList *extensions;
-
- if (filetype < 0 || filetype >= wtap_num_file_types)
- return NULL; /* not a valid file type */
-
- if (dump_open_table[filetype].default_file_extension == NULL)
- return NULL; /* valid, but no extensions known */
-
- extensions = NULL; /* empty list, to start with */
-
- /*
- * If include_compressions is true, get the list of compressed-file
- * extensions.
- */
- if (include_compressed)
- compressed_file_extensions = wtap_get_compressed_file_extensions();
- else
- compressed_file_extensions = NULL;
/*
* Add the default extension, and all compressed variants of
@@ -1184,12 +1159,87 @@ GSList *wtap_get_file_extensions_list(int filetype, gboolean include_compressed)
g_strfreev(extensions_set);
}
+ return extensions;
+}
+
+/* Return a list of all extensions that are used by all file types,
+ including compressed extensions, e.g. not just "pcap" but also
+ "pcap.gz" if we can read gzipped files.
+
+ All strings in the list are allocated with g_malloc() and must be freed
+ with g_free(). */
+GSList *wtap_get_all_file_extensions_list(void)
+{
+ GSList *compressed_file_extensions;
+ GSList *extensions;
+ int filetype;
+
+ extensions = NULL; /* empty list, to start with */
+
+ /*
+ * Get the list of compressed-file extensions.
+ */
+ compressed_file_extensions = wtap_get_compressed_file_extensions();
+
+ for (filetype = 0; filetype < WTAP_NUM_FILE_TYPES; filetype++) {
+ if (dump_open_table[filetype].default_file_extension != NULL) {
+ /*
+ * This file type has at least one extension.
+ * Add all its extensions, with compressed
+ * variants.
+ */
+ extensions = add_extensions_for_filetype(filetype,
+ extensions, compressed_file_extensions);
+ }
+ }
+
+ g_slist_free(compressed_file_extensions);
+ return extensions;
+}
+
+/* Return a list of file extensions that are used by the specified file type.
+
+ If include_compressed is TRUE, the list will include compressed
+ extensions, e.g. not just "pcap" but also "pcap.gz" if we can read
+ gzipped files.
+
+ All strings in the list are allocated with g_malloc() and must be freed
+ with g_free(). */
+GSList *wtap_get_file_extensions_list(int filetype, gboolean include_compressed)
+{
+ GSList *compressed_file_extensions;
+ GSList *extensions;
+
+ if (filetype < 0 || filetype >= wtap_num_file_types)
+ return NULL; /* not a valid file type */
+
+ if (dump_open_table[filetype].default_file_extension == NULL)
+ return NULL; /* valid, but no extensions known */
+
+ extensions = NULL; /* empty list, to start with */
+
+ /*
+ * If include_compressions is true, get the list of compressed-file
+ * extensions.
+ */
+ if (include_compressed)
+ compressed_file_extensions = wtap_get_compressed_file_extensions();
+ else
+ compressed_file_extensions = NULL;
+
+ /*
+ * Add all this file type's extensions, with compressed
+ * variants.
+ */
+ extensions = add_extensions_for_filetype(filetype, extensions,
+ compressed_file_extensions);
+
g_slist_free(compressed_file_extensions);
return extensions;
}
/*
- * Free a list returned by wtap_file_extensions_list().
+ * Free a list returned by wtap_get_file_extensions_list().
*/
void wtap_free_file_extensions_list(GSList *extensions)
{
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 44001a870b..5d4c26a73e 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1331,6 +1331,8 @@ int wtap_short_string_to_file_type(const char *short_name);
/*** various file extension functions ***/
WS_DLL_PUBLIC
+GSList *wtap_get_all_file_extensions_list(void);
+WS_DLL_PUBLIC
const char *wtap_default_file_extension(int filetype);
WS_DLL_PUBLIC
GSList *wtap_get_file_extensions_list(int filetype, gboolean include_compressed);