1 /* ioapi.h -- IO base function header for compress/uncompress .zip 2 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 3 4 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 5 6 Modifications for Zip64 support 7 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 8 9 For more info read MiniZip_info.txt 10 11 Changes 12 13 Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) 14 Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. 15 More if/def section may be needed to support other platforms 16 Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. 17 (but you should use iowin32.c for windows instead) 18 19 */ 20 21 #ifndef _ZLIBIOAPI64_H 22 #define _ZLIBIOAPI64_H 23 24 #include "config.h" // Must be first to include things like _FILE_OFFSET_BITS 25 26 #include <stdio.h> 27 #include <stdlib.h> 28 #include "zlib.h" 29 30 #ifdef HAVE_MINIZIP64_CONF_H 31 #include "mz64conf.h" 32 #endif 33 34 #ifdef HAVE_STDINT_H 35 #include "stdint.h" 36 typedef uint64_t ZPOS64_T; 37 #else 38 #if defined(HAVE__FSEEKI64) 39 typedef unsigned __int64 ZPOS64_T; 40 #else 41 typedef unsigned long long int ZPOS64_T; 42 #endif 43 #endif 44 45 /* Maximum unsigned 32-bit value used as placeholder for zip64 */ 46 #define MAXU32 0xffffffff 47 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 54 #define ZLIB_FILEFUNC_SEEK_CUR (1) 55 #define ZLIB_FILEFUNC_SEEK_END (2) 56 #define ZLIB_FILEFUNC_SEEK_SET (0) 57 58 #define ZLIB_FILEFUNC_MODE_READ (1) 59 #define ZLIB_FILEFUNC_MODE_WRITE (2) 60 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 61 62 #define ZLIB_FILEFUNC_MODE_EXISTING (4) 63 #define ZLIB_FILEFUNC_MODE_CREATE (8) 64 65 66 #ifndef ZCALLBACK 67 #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 68 #define ZCALLBACK CALLBACK 69 #else 70 #define ZCALLBACK 71 #endif 72 #endif 73 74 #ifndef OF 75 #define OF(x) x 76 #endif 77 78 79 80 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 81 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 82 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 83 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 84 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 85 86 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 87 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 88 89 typedef voidpf (ZCALLBACK *clone_file_func) OF((voidpf opaque, voidpf stream)); 90 91 /* here is the "old" 32 bits structure structure */ 92 typedef struct zlib_filefunc_def_s 93 { 94 open_file_func zopen_file; 95 read_file_func zread_file; 96 write_file_func zwrite_file; 97 tell_file_func ztell_file; 98 seek_file_func zseek_file; 99 close_file_func zclose_file; 100 testerror_file_func zerror_file; 101 voidpf opaque; 102 clone_file_func zclone_file; 103 } zlib_filefunc_def; 104 105 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); 106 typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); 107 typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); 108 109 typedef struct zlib_filefunc64_def_s 110 { 111 open64_file_func zopen64_file; 112 read_file_func zread_file; 113 write_file_func zwrite_file; 114 tell64_file_func ztell64_file; 115 seek64_file_func zseek64_file; 116 close_file_func zclose_file; 117 testerror_file_func zerror_file; 118 voidpf opaque; 119 clone_file_func zclone_file; 120 } zlib_filefunc64_def; 121 122 void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); 123 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 124 125 /* now internal definition, only for zip.c and unzip.h */ 126 typedef struct zlib_filefunc64_32_def_s 127 { 128 zlib_filefunc64_def zfile_func64; 129 open_file_func zopen32_file; 130 tell_file_func ztell32_file; 131 seek_file_func zseek32_file; 132 clone_file_func zclone_file; 133 } zlib_filefunc64_32_def; 134 135 136 #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 137 #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 138 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) 139 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) 140 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) 141 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) 142 #define ZCLONE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclone_file)) ((filefunc).zfile_func64.opaque,filestream)) 143 144 voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); 145 long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); 146 ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); 147 148 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); 149 150 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) 151 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) 152 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) 153 154 #ifdef __cplusplus 155 } 156 #endif 157 158 #endif 159