gzguts.h
上传用户:shengde
上传日期:2021-02-21
资源大小:638k
文件大小:4k
源码类别:

压缩解压

开发平台:

Visual C++

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