Няма описание

ioapi.h 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* ioapi.h -- IO base function header for compress/uncompress .zip
  2. part of the MiniZip project
  3. Copyright (C) 1998-2010 Gilles Vollant
  4. http://www.winimage.com/zLibDll/minizip.html
  5. Modifications for Zip64 support
  6. Copyright (C) 2009-2010 Mathias Svensson
  7. http://result42.com
  8. This program is distributed under the terms of the same license as zlib.
  9. See the accompanying LICENSE file for the full text of the license.
  10. */
  11. #ifndef _ZLIBIOAPI64_H
  12. #define _ZLIBIOAPI64_H
  13. #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
  14. # ifndef __USE_FILE_OFFSET64
  15. # define __USE_FILE_OFFSET64
  16. # endif
  17. # ifndef __USE_LARGEFILE64
  18. # define __USE_LARGEFILE64
  19. # endif
  20. # ifndef _LARGEFILE64_SOURCE
  21. # define _LARGEFILE64_SOURCE
  22. # endif
  23. # ifndef _FILE_OFFSET_BIT
  24. # define _FILE_OFFSET_BIT 64
  25. # endif
  26. #endif
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include "zlib.h"
  30. #if defined(USE_FILE32API)
  31. # define fopen64 fopen
  32. # define ftello64 ftell
  33. # define fseeko64 fseek
  34. #else
  35. # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
  36. # define fopen64 fopen
  37. # define ftello64 ftello
  38. # define fseeko64 fseeko
  39. # endif
  40. # ifdef _MSC_VER
  41. # define fopen64 fopen
  42. # if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
  43. # define ftello64 _ftelli64
  44. # define fseeko64 _fseeki64
  45. # else /* old MSC */
  46. # define ftello64 ftell
  47. # define fseeko64 fseek
  48. # endif
  49. # endif
  50. #endif
  51. /* a type choosen by DEFINE */
  52. #ifdef HAVE_64BIT_INT_CUSTOM
  53. typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
  54. #else
  55. # ifdef HAS_STDINT_H
  56. # include "stdint.h"
  57. typedef uint64_t ZPOS64_T;
  58. # else
  59. # if defined(_MSC_VER) || defined(__BORLANDC__)
  60. typedef unsigned __int64 ZPOS64_T;
  61. # else
  62. typedef unsigned long long int ZPOS64_T;
  63. # endif
  64. # endif
  65. #endif
  66. #ifdef __cplusplus
  67. extern "C" {
  68. #endif
  69. #define ZLIB_FILEFUNC_SEEK_CUR (1)
  70. #define ZLIB_FILEFUNC_SEEK_END (2)
  71. #define ZLIB_FILEFUNC_SEEK_SET (0)
  72. #define ZLIB_FILEFUNC_MODE_READ (1)
  73. #define ZLIB_FILEFUNC_MODE_WRITE (2)
  74. #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
  75. #define ZLIB_FILEFUNC_MODE_EXISTING (4)
  76. #define ZLIB_FILEFUNC_MODE_CREATE (8)
  77. #ifndef ZCALLBACK
  78. # if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || \
  79. defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
  80. # define ZCALLBACK CALLBACK
  81. # else
  82. # define ZCALLBACK
  83. # endif
  84. #endif
  85. typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
  86. typedef voidpf (ZCALLBACK *opendisk_file_func) OF((voidpf opaque, voidpf stream, int number_disk, int mode));
  87. typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
  88. typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
  89. typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
  90. typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
  91. typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
  92. typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
  93. /* here is the "old" 32 bits structure structure */
  94. typedef struct zlib_filefunc_def_s
  95. {
  96. open_file_func zopen_file;
  97. opendisk_file_func zopendisk_file;
  98. read_file_func zread_file;
  99. write_file_func zwrite_file;
  100. tell_file_func ztell_file;
  101. seek_file_func zseek_file;
  102. close_file_func zclose_file;
  103. testerror_file_func zerror_file;
  104. voidpf opaque;
  105. } zlib_filefunc_def;
  106. typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
  107. typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
  108. typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
  109. typedef voidpf (ZCALLBACK *opendisk64_file_func)OF((voidpf opaque, voidpf stream, int number_disk, int mode));
  110. typedef struct zlib_filefunc64_def_s
  111. {
  112. open64_file_func zopen64_file;
  113. opendisk64_file_func zopendisk64_file;
  114. read_file_func zread_file;
  115. write_file_func zwrite_file;
  116. tell64_file_func ztell64_file;
  117. seek64_file_func zseek64_file;
  118. close_file_func zclose_file;
  119. testerror_file_func zerror_file;
  120. voidpf opaque;
  121. } zlib_filefunc64_def;
  122. void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
  123. void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
  124. /* now internal definition, only for zip.c and unzip.h */
  125. typedef struct zlib_filefunc64_32_def_s
  126. {
  127. zlib_filefunc64_def zfile_func64;
  128. open_file_func zopen32_file;
  129. opendisk_file_func zopendisk32_file;
  130. tell_file_func ztell32_file;
  131. seek_file_func zseek32_file;
  132. } zlib_filefunc64_32_def;
  133. #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
  134. #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
  135. /*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))*/
  136. /*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))*/
  137. #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
  138. #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
  139. voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
  140. voidpf call_zopendisk64 OF((const zlib_filefunc64_32_def* pfilefunc, voidpf filestream, int number_disk, int mode));
  141. long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
  142. ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
  143. void fill_zlib_filefunc64_32_def_from_filefunc32 OF((zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32));
  144. #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
  145. #define ZOPENDISK64(filefunc,filestream,diskn,mode) (call_zopendisk64((&(filefunc)),(filestream),(diskn),(mode)))
  146. #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
  147. #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151. #endif