Free the buffer
[obnox/wireshark/wip.git] / wiretap / file_wrappers.c
index f8b9b8c8eb550c0d2572c9d8ed62e9d1e17b0624..a5f4739f15f953fb3df7d8a2669c45ed5efc3414 100644 (file)
  *     Bzip2 format: http://bzip.org/
  */
 
+/*
+ * List of extensions for compressed files.
+ * If we add support for more compressed file types, this table
+ * might be expanded to include routines to handle the various
+ * compression types.
+ */
+static const char *compressed_file_extensions[] = {
+#ifdef HAVE_LIBZ
+       "gz",
+#endif
+       NULL
+};
+
+/*
+ * Return a GSList of all the compressed file extensions.
+ * The data pointers all point to items in compressed_file_extensions[],
+ * so the GSList can just be freed with g_slist_free().
+ */
+GSList *
+wtap_get_compressed_file_extensions(void)
+{
+       const char **extension;
+       GSList *extensions;
+
+       extensions = NULL;
+       for (extension = &compressed_file_extensions[0]; *extension != NULL;
+           extension++)
+               extensions = g_slist_append(extensions, (gpointer)(*extension));
+       return extensions;
+}
+
 /* #define GZBUFSIZE 8192 */
 #define GZBUFSIZE 4096
 
@@ -982,7 +1013,7 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err)
        if (offset < 0) {
                offset += file->pos;
                if (offset < 0) {                    /* before start of file! */
-                       /* *err = ???; */
+                       *err = EINVAL;
                        return -1;
                }
                /* rewind, then skip to offset */