security/nss/lib/zlib/gzguts.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* gzguts.h -- zlib internal header definitions for gz* operations
michael@0 2 * Copyright (C) 2004, 2005, 2010 Mark Adler
michael@0 3 * For conditions of distribution and use, see copyright notice in zlib.h
michael@0 4 */
michael@0 5
michael@0 6 #ifdef _LARGEFILE64_SOURCE
michael@0 7 # ifndef _LARGEFILE_SOURCE
michael@0 8 # define _LARGEFILE_SOURCE 1
michael@0 9 # endif
michael@0 10 # ifdef _FILE_OFFSET_BITS
michael@0 11 # undef _FILE_OFFSET_BITS
michael@0 12 # endif
michael@0 13 #endif
michael@0 14
michael@0 15 #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
michael@0 16 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
michael@0 17 #else
michael@0 18 # define ZLIB_INTERNAL
michael@0 19 #endif
michael@0 20
michael@0 21 #include <stdio.h>
michael@0 22 #include "zlib.h"
michael@0 23 #ifdef STDC
michael@0 24 # include <string.h>
michael@0 25 # include <stdlib.h>
michael@0 26 # include <limits.h>
michael@0 27 #endif
michael@0 28 #include <fcntl.h>
michael@0 29
michael@0 30 #ifdef NO_DEFLATE /* for compatibility with old definition */
michael@0 31 # define NO_GZCOMPRESS
michael@0 32 #endif
michael@0 33
michael@0 34 #ifdef _MSC_VER
michael@0 35 # include <io.h>
michael@0 36 # define vsnprintf _vsnprintf
michael@0 37 #endif
michael@0 38
michael@0 39 #ifndef local
michael@0 40 # define local static
michael@0 41 #endif
michael@0 42 /* compile with -Dlocal if your debugger can't find static symbols */
michael@0 43
michael@0 44 /* gz* functions always use library allocation functions */
michael@0 45 #ifndef STDC
michael@0 46 extern voidp malloc OF((uInt size));
michael@0 47 extern void free OF((voidpf ptr));
michael@0 48 #endif
michael@0 49
michael@0 50 /* get errno and strerror definition */
michael@0 51 #if defined UNDER_CE
michael@0 52 # include <windows.h>
michael@0 53 # define zstrerror() gz_strwinerror((DWORD)GetLastError())
michael@0 54 #else
michael@0 55 # ifdef STDC
michael@0 56 # include <errno.h>
michael@0 57 # define zstrerror() strerror(errno)
michael@0 58 # else
michael@0 59 # define zstrerror() "stdio error (consult errno)"
michael@0 60 # endif
michael@0 61 #endif
michael@0 62
michael@0 63 /* provide prototypes for these when building zlib without LFS */
michael@0 64 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
michael@0 65 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
michael@0 66 ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
michael@0 67 ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
michael@0 68 ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
michael@0 69 #endif
michael@0 70
michael@0 71 /* default i/o buffer size -- double this for output when reading */
michael@0 72 #define GZBUFSIZE 8192
michael@0 73
michael@0 74 /* gzip modes, also provide a little integrity check on the passed structure */
michael@0 75 #define GZ_NONE 0
michael@0 76 #define GZ_READ 7247
michael@0 77 #define GZ_WRITE 31153
michael@0 78 #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
michael@0 79
michael@0 80 /* values for gz_state how */
michael@0 81 #define LOOK 0 /* look for a gzip header */
michael@0 82 #define COPY 1 /* copy input directly */
michael@0 83 #define GZIP 2 /* decompress a gzip stream */
michael@0 84
michael@0 85 /* internal gzip file state data structure */
michael@0 86 typedef struct {
michael@0 87 /* used for both reading and writing */
michael@0 88 int mode; /* see gzip modes above */
michael@0 89 int fd; /* file descriptor */
michael@0 90 char *path; /* path or fd for error messages */
michael@0 91 z_off64_t pos; /* current position in uncompressed data */
michael@0 92 unsigned size; /* buffer size, zero if not allocated yet */
michael@0 93 unsigned want; /* requested buffer size, default is GZBUFSIZE */
michael@0 94 unsigned char *in; /* input buffer */
michael@0 95 unsigned char *out; /* output buffer (double-sized when reading) */
michael@0 96 unsigned char *next; /* next output data to deliver or write */
michael@0 97 /* just for reading */
michael@0 98 unsigned have; /* amount of output data unused at next */
michael@0 99 int eof; /* true if end of input file reached */
michael@0 100 z_off64_t start; /* where the gzip data started, for rewinding */
michael@0 101 z_off64_t raw; /* where the raw data started, for seeking */
michael@0 102 int how; /* 0: get header, 1: copy, 2: decompress */
michael@0 103 int direct; /* true if last read direct, false if gzip */
michael@0 104 /* just for writing */
michael@0 105 int level; /* compression level */
michael@0 106 int strategy; /* compression strategy */
michael@0 107 /* seek request */
michael@0 108 z_off64_t skip; /* amount to skip (already rewound if backwards) */
michael@0 109 int seek; /* true if seek request pending */
michael@0 110 /* error information */
michael@0 111 int err; /* error code */
michael@0 112 char *msg; /* error message */
michael@0 113 /* zlib inflate or deflate stream */
michael@0 114 z_stream strm; /* stream structure in-place (not a pointer) */
michael@0 115 } gz_state;
michael@0 116 typedef gz_state FAR *gz_statep;
michael@0 117
michael@0 118 /* shared functions */
michael@0 119 void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
michael@0 120 #if defined UNDER_CE
michael@0 121 char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
michael@0 122 #endif
michael@0 123
michael@0 124 /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
michael@0 125 value -- needed when comparing unsigned to z_off64_t, which is signed
michael@0 126 (possible z_off64_t types off_t, off64_t, and long are all signed) */
michael@0 127 #ifdef INT_MAX
michael@0 128 # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
michael@0 129 #else
michael@0 130 unsigned ZLIB_INTERNAL gz_intmax OF((void));
michael@0 131 # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
michael@0 132 #endif

mercurial