Free the buffer
[obnox/wireshark/wip.git] / wiretap / file_wrappers.c
index 31c70f7638c648b8803cd477a5a05e9a25bc8eea..a5f4739f15f953fb3df7d8a2669c45ed5efc3414 100644 (file)
 #include "file_wrappers.h"
 #include <wsutil/file_util.h>
 
+#ifdef HAVE_LIBZ
+#include <zlib.h>
+#endif /* HAVE_LIBZ */
+
 /*
  * See RFC 1952 for a description of the gzip file format.
  *
  *     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
 
@@ -91,7 +126,7 @@ struct wtap_reader {
        int seek;               /* true if seek request pending */
        /* error information */
        int err;                /* error code */
-       char *err_info;         /* additional error information string for some errors */
+       const char *err_info;   /* additional error information string for some errors */
 
        unsigned int  avail_in;  /* number of bytes available at next_in */
        unsigned char *next_in;  /* next input byte */
@@ -978,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 */