]> git.lizzy.rs Git - zlib.git/blobdiff - gzguts.h
Add assertions to fill_window() in deflate.c to match comments.
[zlib.git] / gzguts.h
index 429c21b23498fa3de111727805cd7bd5f76f0b47..0f8fb79f87d4f65e7f5667129c763e3a361199f2 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
@@ -5,26 +5,33 @@
 
 #ifdef _LARGEFILE64_SOURCE
 #  ifndef _LARGEFILE_SOURCE
-#    define _LARGEFILE_SOURCE
+#    define _LARGEFILE_SOURCE 1
 #  endif
 #  ifdef _FILE_OFFSET_BITS
 #    undef _FILE_OFFSET_BITS
 #  endif
 #endif
 
-#define ZLIB_INTERNAL
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
+#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+#else
+#  define ZLIB_INTERNAL
+#endif
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
 #include "zlib.h"
+#ifdef STDC
+#  include <string.h>
+#  include <stdlib.h>
+#  include <limits.h>
+#endif
+#include <fcntl.h>
 
 #ifdef NO_DEFLATE       /* for compatibility with old definition */
 #  define NO_GZCOMPRESS
 #endif
 
-#ifdef WIN32
+#ifdef _MSC_VER
 #  include <io.h>
 #  define vsnprintf _vsnprintf
 #endif
@@ -41,8 +48,9 @@
 #endif
 
 /* get errno and strerror definition */
-#if defined UNDER_CE && defined NO_ERRNO_H
-#  define zstrerror(errnum) strwinerror((DWORD)errnum)
+#if defined UNDER_CE
+#  include <windows.h>
+#  define zstrerror() gz_strwinerror((DWORD)GetLastError())
 #else
 #  ifdef STDC
 #    include <errno.h>
 #  endif
 #endif
 
-/* MVS fdopen() */
-#ifdef __MVS__
-#  pragma map (fdopen , "\174\174FDOPEN")
-   FILE *fdopen(int, const char *);
-#endif
-
-#ifdef _LARGEFILE64_SOURCE
-#  define z_off64_t off64_t
-#else
-#  define z_off64_t z_off_t
+/* provide prototypes for these when building zlib without LFS */
+#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+    ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+    ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+    ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
 #endif
 
 /* default i/o buffer size -- double this for output when reading */
 #define GZ_WRITE 31153
 #define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */
 
+/* values for gz_state how */
+#define LOOK 0      /* look for a gzip header */
+#define COPY 1      /* copy input directly */
+#define GZIP 2      /* decompress a gzip stream */
+
 /* internal gzip file state data structure */
 typedef struct {
         /* used for both reading and writing */
@@ -86,17 +95,18 @@ typedef struct {
     unsigned char *out;     /* output buffer (double-sized when reading) */
     unsigned char *next;    /* next output data to deliver or write */
         /* just for reading */
-    int how;                /* 0: get header, 1: copy, 2: decompress */
-    unsigned have;          /* amount of output data unused */
+    unsigned have;          /* amount of output data unused at next */
+    int eof;                /* true if end of input file reached */
     z_off64_t start;        /* where the gzip data started, for rewinding */
     z_off64_t raw;          /* where the raw data started, for seeking */
-    int eof;                /* true if end of input file reached */
+    int how;                /* 0: get header, 1: copy, 2: decompress */
+    int direct;             /* true if last read direct, false if gzip */
         /* just for writing */
     int level;              /* compression level */
     int strategy;           /* compression strategy */
         /* seek request */
-    int seek;               /* true if seek request pending */
     z_off64_t skip;         /* amount to skip (already rewound if backwards) */
+    int seek;               /* true if seek request pending */
         /* error information */
     int err;                /* error code */
     char *msg;              /* error message */
@@ -106,4 +116,17 @@ typedef struct {
 typedef gz_state FAR *gz_statep;
 
 /* shared functions */
-ZEXTERN void ZEXPORT gz_error OF((gz_statep, int, char *));
+void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
+#if defined UNDER_CE
+char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
+#endif
+
+/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
+   value -- needed when comparing unsigned to z_off64_t, which is signed
+   (possible z_off64_t types off_t, off64_t, and long are all signed) */
+#ifdef INT_MAX
+#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
+#else
+unsigned ZLIB_INTERNAL gz_intmax OF((void));
+#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
+#endif