DOSBox-X
|
00001 /* ioapi.h -- IO base function header for compress/uncompress .zip 00002 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 00003 00004 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 00005 00006 Modifications for Zip64 support 00007 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 00008 00009 For more info read MiniZip_info.txt 00010 00011 Changes 00012 00013 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) 00014 Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. 00015 More if/def section may be needed to support other platforms 00016 Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. 00017 (but you should use iowin32.c for windows instead) 00018 00019 */ 00020 00021 #ifndef _ZLIBIOAPI64_H 00022 #define _ZLIBIOAPI64_H 00023 00024 #if (!defined(_WIN32)) && (!defined(WIN32)) 00025 00026 // Linux needs this to support file operation on files larger then 4+GB 00027 // But might need better if/def to select just the platforms that needs them. 00028 00029 #ifndef __USE_FILE_OFFSET64 00030 #define __USE_FILE_OFFSET64 00031 #endif 00032 #ifndef __USE_LARGEFILE64 00033 #define __USE_LARGEFILE64 00034 #endif 00035 #ifndef _LARGEFILE64_SOURCE 00036 #define _LARGEFILE64_SOURCE 00037 #endif 00038 #ifndef _FILE_OFFSET_BIT 00039 #define _FILE_OFFSET_BIT 64 00040 #endif 00041 #endif 00042 00043 #include <stdio.h> 00044 #include <stdlib.h> 00045 #include "zlib.h" 00046 00047 #if defined(__APPLE__) || defined(USE_FILE32API) 00048 #define fopen64 fopen 00049 #define ftello64 ftell 00050 #define fseeko64 fseek 00051 #define fseek_ofs_t off_t 00052 #else 00053 #ifdef _MSC_VER 00054 #define fopen64 fopen 00055 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) 00056 #define ftello64 _ftelli64 00057 #define fseeko64 _fseeki64 00058 #define fseek_ofs_t __int64 00059 #else // old MSC 00060 #define ftello64 ftell 00061 #define fseeko64 fseek 00062 #define fseek_ofs_t long 00063 #endif 00064 #else 00065 #define fseek_ofs_t long 00066 #endif 00067 #endif 00068 00069 /* 00070 #ifndef ZPOS64_T 00071 #ifdef _WIN32 00072 #define ZPOS64_T fpos_t 00073 #else 00074 #include <stdint.h> 00075 #define ZPOS64_T uint64_t 00076 #endif 00077 #endif 00078 */ 00079 00080 #ifdef HAVE_MINIZIP64_CONF_H 00081 #include "mz64conf.h" 00082 #endif 00083 00084 /* a type choosen by DEFINE */ 00085 #ifdef HAVE_64BIT_INT_CUSTOM 00086 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; 00087 #else 00088 #ifdef HAS_STDINT_H 00089 #include "stdint.h" 00090 typedef uint64_t ZPOS64_T; 00091 #else 00092 00093 00094 #if defined(_MSC_VER) || defined(__BORLANDC__) 00095 typedef unsigned __int64 ZPOS64_T; 00096 #else 00097 typedef unsigned long long int ZPOS64_T; 00098 #endif 00099 #endif 00100 #endif 00101 00102 00103 00104 #ifdef __cplusplus 00105 extern "C" { 00106 #endif 00107 00108 00109 #define ZLIB_FILEFUNC_SEEK_CUR (1) 00110 #define ZLIB_FILEFUNC_SEEK_END (2) 00111 #define ZLIB_FILEFUNC_SEEK_SET (0) 00112 00113 #define ZLIB_FILEFUNC_MODE_READ (1) 00114 #define ZLIB_FILEFUNC_MODE_WRITE (2) 00115 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 00116 00117 #define ZLIB_FILEFUNC_MODE_EXISTING (4) 00118 #define ZLIB_FILEFUNC_MODE_CREATE (8) 00119 00120 00121 #ifndef ZCALLBACK 00122 #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 00123 #define ZCALLBACK CALLBACK 00124 #else 00125 #define ZCALLBACK 00126 #endif 00127 #endif 00128 00129 00130 00131 00132 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 00133 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 00134 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 00135 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 00136 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 00137 00138 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 00139 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 00140 00141 00142 /* here is the "old" 32 bits structure structure */ 00143 typedef struct zlib_filefunc_def_s 00144 { 00145 open_file_func zopen_file; 00146 read_file_func zread_file; 00147 write_file_func zwrite_file; 00148 tell_file_func ztell_file; 00149 seek_file_func zseek_file; 00150 close_file_func zclose_file; 00151 testerror_file_func zerror_file; 00152 voidpf opaque; 00153 } zlib_filefunc_def; 00154 00155 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); 00156 typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); 00157 typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); 00158 00159 typedef struct zlib_filefunc64_def_s 00160 { 00161 open64_file_func zopen64_file; 00162 read_file_func zread_file; 00163 write_file_func zwrite_file; 00164 tell64_file_func ztell64_file; 00165 seek64_file_func zseek64_file; 00166 close_file_func zclose_file; 00167 testerror_file_func zerror_file; 00168 voidpf opaque; 00169 } zlib_filefunc64_def; 00170 00171 void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); 00172 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 00173 00174 /* now internal definition, only for zip.c and unzip.h */ 00175 typedef struct zlib_filefunc64_32_def_s 00176 { 00177 zlib_filefunc64_def zfile_func64; 00178 open_file_func zopen32_file; 00179 tell_file_func ztell32_file; 00180 seek_file_func zseek32_file; 00181 } zlib_filefunc64_32_def; 00182 00183 00184 #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 00185 #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 00186 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) 00187 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) 00188 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) 00189 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) 00190 00191 voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); 00192 long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); 00193 ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); 00194 00195 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); 00196 00197 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) 00198 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) 00199 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) 00200 00201 #ifdef __cplusplus 00202 } 00203 #endif 00204 00205 #endif