1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/zlib/gzguts.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,132 @@ 1.4 +/* gzguts.h -- zlib internal header definitions for gz* operations 1.5 + * Copyright (C) 2004, 2005, 2010 Mark Adler 1.6 + * For conditions of distribution and use, see copyright notice in zlib.h 1.7 + */ 1.8 + 1.9 +#ifdef _LARGEFILE64_SOURCE 1.10 +# ifndef _LARGEFILE_SOURCE 1.11 +# define _LARGEFILE_SOURCE 1 1.12 +# endif 1.13 +# ifdef _FILE_OFFSET_BITS 1.14 +# undef _FILE_OFFSET_BITS 1.15 +# endif 1.16 +#endif 1.17 + 1.18 +#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) 1.19 +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 1.20 +#else 1.21 +# define ZLIB_INTERNAL 1.22 +#endif 1.23 + 1.24 +#include <stdio.h> 1.25 +#include "zlib.h" 1.26 +#ifdef STDC 1.27 +# include <string.h> 1.28 +# include <stdlib.h> 1.29 +# include <limits.h> 1.30 +#endif 1.31 +#include <fcntl.h> 1.32 + 1.33 +#ifdef NO_DEFLATE /* for compatibility with old definition */ 1.34 +# define NO_GZCOMPRESS 1.35 +#endif 1.36 + 1.37 +#ifdef _MSC_VER 1.38 +# include <io.h> 1.39 +# define vsnprintf _vsnprintf 1.40 +#endif 1.41 + 1.42 +#ifndef local 1.43 +# define local static 1.44 +#endif 1.45 +/* compile with -Dlocal if your debugger can't find static symbols */ 1.46 + 1.47 +/* gz* functions always use library allocation functions */ 1.48 +#ifndef STDC 1.49 + extern voidp malloc OF((uInt size)); 1.50 + extern void free OF((voidpf ptr)); 1.51 +#endif 1.52 + 1.53 +/* get errno and strerror definition */ 1.54 +#if defined UNDER_CE 1.55 +# include <windows.h> 1.56 +# define zstrerror() gz_strwinerror((DWORD)GetLastError()) 1.57 +#else 1.58 +# ifdef STDC 1.59 +# include <errno.h> 1.60 +# define zstrerror() strerror(errno) 1.61 +# else 1.62 +# define zstrerror() "stdio error (consult errno)" 1.63 +# endif 1.64 +#endif 1.65 + 1.66 +/* provide prototypes for these when building zlib without LFS */ 1.67 +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 1.68 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 1.69 + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); 1.70 + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); 1.71 + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); 1.72 +#endif 1.73 + 1.74 +/* default i/o buffer size -- double this for output when reading */ 1.75 +#define GZBUFSIZE 8192 1.76 + 1.77 +/* gzip modes, also provide a little integrity check on the passed structure */ 1.78 +#define GZ_NONE 0 1.79 +#define GZ_READ 7247 1.80 +#define GZ_WRITE 31153 1.81 +#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ 1.82 + 1.83 +/* values for gz_state how */ 1.84 +#define LOOK 0 /* look for a gzip header */ 1.85 +#define COPY 1 /* copy input directly */ 1.86 +#define GZIP 2 /* decompress a gzip stream */ 1.87 + 1.88 +/* internal gzip file state data structure */ 1.89 +typedef struct { 1.90 + /* used for both reading and writing */ 1.91 + int mode; /* see gzip modes above */ 1.92 + int fd; /* file descriptor */ 1.93 + char *path; /* path or fd for error messages */ 1.94 + z_off64_t pos; /* current position in uncompressed data */ 1.95 + unsigned size; /* buffer size, zero if not allocated yet */ 1.96 + unsigned want; /* requested buffer size, default is GZBUFSIZE */ 1.97 + unsigned char *in; /* input buffer */ 1.98 + unsigned char *out; /* output buffer (double-sized when reading) */ 1.99 + unsigned char *next; /* next output data to deliver or write */ 1.100 + /* just for reading */ 1.101 + unsigned have; /* amount of output data unused at next */ 1.102 + int eof; /* true if end of input file reached */ 1.103 + z_off64_t start; /* where the gzip data started, for rewinding */ 1.104 + z_off64_t raw; /* where the raw data started, for seeking */ 1.105 + int how; /* 0: get header, 1: copy, 2: decompress */ 1.106 + int direct; /* true if last read direct, false if gzip */ 1.107 + /* just for writing */ 1.108 + int level; /* compression level */ 1.109 + int strategy; /* compression strategy */ 1.110 + /* seek request */ 1.111 + z_off64_t skip; /* amount to skip (already rewound if backwards) */ 1.112 + int seek; /* true if seek request pending */ 1.113 + /* error information */ 1.114 + int err; /* error code */ 1.115 + char *msg; /* error message */ 1.116 + /* zlib inflate or deflate stream */ 1.117 + z_stream strm; /* stream structure in-place (not a pointer) */ 1.118 +} gz_state; 1.119 +typedef gz_state FAR *gz_statep; 1.120 + 1.121 +/* shared functions */ 1.122 +void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 1.123 +#if defined UNDER_CE 1.124 +char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 1.125 +#endif 1.126 + 1.127 +/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t 1.128 + value -- needed when comparing unsigned to z_off64_t, which is signed 1.129 + (possible z_off64_t types off_t, off64_t, and long are all signed) */ 1.130 +#ifdef INT_MAX 1.131 +# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) 1.132 +#else 1.133 +unsigned ZLIB_INTERNAL gz_intmax OF((void)); 1.134 +# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) 1.135 +#endif