File indexing completed on 2025-01-26 04:24:52
0001 /* ioapi.h -- IO base function header for compress/uncompress .zip 0002 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 0003 0004 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 0005 0006 Modifications for Zip64 support 0007 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 0008 0009 Modified by Sergey A. Tachenov to allow QIODevice API usage. 0010 0011 For more info read MiniZip_info.txt 0012 0013 Changes 0014 0015 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) 0016 Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. 0017 More if/def section may be needed to support other platforms 0018 Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. 0019 (but you should use iowin32.c for windows instead) 0020 0021 */ 0022 0023 #ifndef _ZLIBIOAPI64_H 0024 #define _ZLIBIOAPI64_H 0025 0026 #if (!defined(_WIN32)) && (!defined(WIN32)) 0027 0028 // Linux needs this to support file operation on files larger then 4+GB 0029 // But might need better if/def to select just the platforms that needs them. 0030 0031 #ifndef __USE_FILE_OFFSET64 0032 #define __USE_FILE_OFFSET64 0033 #endif 0034 #ifndef __USE_LARGEFILE64 0035 #define __USE_LARGEFILE64 0036 #endif 0037 #ifndef _LARGEFILE64_SOURCE 0038 #define _LARGEFILE64_SOURCE 0039 #endif 0040 #ifndef _FILE_OFFSET_BIT 0041 #define _FILE_OFFSET_BIT 64 0042 #endif 0043 #endif 0044 0045 #include <stdio.h> 0046 #include <stdlib.h> 0047 #include "zlib.h" 0048 0049 #if defined(USE_FILE32API) 0050 #define fopen64 fopen 0051 #define ftello64 ftell 0052 #define fseeko64 fseek 0053 #else 0054 #ifdef _MSC_VER 0055 #define fopen64 fopen 0056 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) 0057 #define ftello64 _ftelli64 0058 #define fseeko64 _fseeki64 0059 #else // old MSC 0060 #define ftello64 ftell 0061 #define fseeko64 fseek 0062 #endif 0063 #endif 0064 #endif 0065 0066 /* 0067 #ifndef ZPOS64_T 0068 #ifdef _WIN32 0069 #define ZPOS64_T fpos_t 0070 #else 0071 #include <stdint.h> 0072 #define ZPOS64_T uint64_t 0073 #endif 0074 #endif 0075 */ 0076 0077 #ifdef HAVE_MINIZIP64_CONF_H 0078 #include "mz64conf.h" 0079 #endif 0080 0081 /* a type choosen by DEFINE */ 0082 #ifdef HAVE_64BIT_INT_CUSTOM 0083 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; 0084 #else 0085 #ifdef HAS_STDINT_H 0086 #include "stdint.h" 0087 typedef uint64_t ZPOS64_T; 0088 #else 0089 0090 0091 #if defined(_MSC_VER) || defined(__BORLANDC__) 0092 typedef unsigned __int64 ZPOS64_T; 0093 #else 0094 typedef unsigned long long int ZPOS64_T; 0095 #endif 0096 #endif 0097 #endif 0098 0099 0100 0101 #ifdef __cplusplus 0102 extern "C" { 0103 #endif 0104 0105 #ifndef OF 0106 #define OF _Z_OF 0107 #endif 0108 0109 #define ZLIB_FILEFUNC_SEEK_CUR (1) 0110 #define ZLIB_FILEFUNC_SEEK_END (2) 0111 #define ZLIB_FILEFUNC_SEEK_SET (0) 0112 0113 #define ZLIB_FILEFUNC_MODE_READ (1) 0114 #define ZLIB_FILEFUNC_MODE_WRITE (2) 0115 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 0116 0117 #define ZLIB_FILEFUNC_MODE_EXISTING (4) 0118 #define ZLIB_FILEFUNC_MODE_CREATE (8) 0119 0120 0121 #ifndef ZCALLBACK 0122 #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 0123 #define ZCALLBACK CALLBACK 0124 #else 0125 #define ZCALLBACK 0126 #endif 0127 #endif 0128 0129 0130 0131 0132 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, voidpf file, int mode)); 0133 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 0134 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 0135 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 0136 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 0137 0138 typedef uLong (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 0139 typedef int (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 0140 0141 0142 /* here is the "old" 32 bits structure structure */ 0143 typedef struct zlib_filefunc_def_s 0144 { 0145 open_file_func zopen_file; 0146 read_file_func zread_file; 0147 write_file_func zwrite_file; 0148 tell_file_func ztell_file; 0149 seek_file_func zseek_file; 0150 close_file_func zclose_file; 0151 testerror_file_func zerror_file; 0152 voidpf opaque; 0153 } zlib_filefunc_def; 0154 0155 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); 0156 typedef int (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); 0157 typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, voidpf file, int mode)); 0158 0159 typedef struct zlib_filefunc64_def_s 0160 { 0161 open64_file_func zopen64_file; 0162 read_file_func zread_file; 0163 write_file_func zwrite_file; 0164 tell64_file_func ztell64_file; 0165 seek64_file_func zseek64_file; 0166 close_file_func zclose_file; 0167 testerror_file_func zerror_file; 0168 voidpf opaque; 0169 close_file_func zfakeclose_file; // for no-auto-close flag 0170 } zlib_filefunc64_def; 0171 0172 void fill_qiodevice64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); 0173 void fill_qiodevice_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 0174 0175 /* now internal definition, only for zip.c and unzip.h */ 0176 typedef struct zlib_filefunc64_32_def_s 0177 { 0178 zlib_filefunc64_def zfile_func64; 0179 open_file_func zopen32_file; 0180 tell_file_func ztell32_file; 0181 seek_file_func zseek32_file; 0182 } zlib_filefunc64_32_def; 0183 0184 0185 #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 0186 #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 0187 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) 0188 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) 0189 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) 0190 #define ZFAKECLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zfakeclose_file)) ((filefunc).zfile_func64.opaque,filestream)) 0191 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) 0192 0193 voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf file,int mode)); 0194 int call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); 0195 ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); 0196 0197 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); 0198 0199 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) 0200 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) 0201 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) 0202 0203 #ifdef __cplusplus 0204 } 0205 #endif 0206 0207 #endif