packio-simple
diff src/minizip/ioapi.h @ 0:d81c3ae262a0
initial commit
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Sun, 09 Sep 2012 06:05:11 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/minizip/ioapi.h Sun Sep 09 06:05:11 2012 +0300 1.3 @@ -0,0 +1,208 @@ 1.4 +/* ioapi.h -- IO base function header for compress/uncompress .zip 1.5 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 1.6 + 1.7 + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 1.8 + 1.9 + Modifications for Zip64 support 1.10 + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 1.11 + 1.12 + For more info read MiniZip_info.txt 1.13 + 1.14 + Changes 1.15 + 1.16 + 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) 1.17 + Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. 1.18 + More if/def section may be needed to support other platforms 1.19 + Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. 1.20 + (but you should use iowin32.c for windows instead) 1.21 + 1.22 +*/ 1.23 + 1.24 +#ifndef _ZLIBIOAPI64_H 1.25 +#define _ZLIBIOAPI64_H 1.26 + 1.27 +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) 1.28 + 1.29 + // Linux needs this to support file operation on files larger then 4+GB 1.30 + // But might need better if/def to select just the platforms that needs them. 1.31 + 1.32 + #ifndef __USE_FILE_OFFSET64 1.33 + #define __USE_FILE_OFFSET64 1.34 + #endif 1.35 + #ifndef __USE_LARGEFILE64 1.36 + #define __USE_LARGEFILE64 1.37 + #endif 1.38 + #ifndef _LARGEFILE64_SOURCE 1.39 + #define _LARGEFILE64_SOURCE 1.40 + #endif 1.41 + #ifndef _FILE_OFFSET_BIT 1.42 + #define _FILE_OFFSET_BIT 64 1.43 + #endif 1.44 + 1.45 +#endif 1.46 + 1.47 +#include <stdio.h> 1.48 +#include <stdlib.h> 1.49 +#include "zlib.h" 1.50 + 1.51 +#if defined(USE_FILE32API) 1.52 +#define fopen64 fopen 1.53 +#define ftello64 ftell 1.54 +#define fseeko64 fseek 1.55 +#else 1.56 +#ifdef __FreeBSD__ 1.57 +#define fopen64 fopen 1.58 +#define ftello64 ftello 1.59 +#define fseeko64 fseeko 1.60 +#endif 1.61 +#ifdef _MSC_VER 1.62 + #define fopen64 fopen 1.63 + #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) 1.64 + #define ftello64 _ftelli64 1.65 + #define fseeko64 _fseeki64 1.66 + #else // old MSC 1.67 + #define ftello64 ftell 1.68 + #define fseeko64 fseek 1.69 + #endif 1.70 +#endif 1.71 +#endif 1.72 + 1.73 +/* 1.74 +#ifndef ZPOS64_T 1.75 + #ifdef _WIN32 1.76 + #define ZPOS64_T fpos_t 1.77 + #else 1.78 + #include <stdint.h> 1.79 + #define ZPOS64_T uint64_t 1.80 + #endif 1.81 +#endif 1.82 +*/ 1.83 + 1.84 +#ifdef HAVE_MINIZIP64_CONF_H 1.85 +#include "mz64conf.h" 1.86 +#endif 1.87 + 1.88 +/* a type choosen by DEFINE */ 1.89 +#ifdef HAVE_64BIT_INT_CUSTOM 1.90 +typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; 1.91 +#else 1.92 +#ifdef HAS_STDINT_H 1.93 +#include "stdint.h" 1.94 +typedef uint64_t ZPOS64_T; 1.95 +#else 1.96 + 1.97 +/* Maximum unsigned 32-bit value used as placeholder for zip64 */ 1.98 +#define MAXU32 0xffffffff 1.99 + 1.100 +#if defined(_MSC_VER) || defined(__BORLANDC__) 1.101 +typedef unsigned __int64 ZPOS64_T; 1.102 +#else 1.103 +typedef unsigned long long int ZPOS64_T; 1.104 +#endif 1.105 +#endif 1.106 +#endif 1.107 + 1.108 + 1.109 + 1.110 +#ifdef __cplusplus 1.111 +extern "C" { 1.112 +#endif 1.113 + 1.114 + 1.115 +#define ZLIB_FILEFUNC_SEEK_CUR (1) 1.116 +#define ZLIB_FILEFUNC_SEEK_END (2) 1.117 +#define ZLIB_FILEFUNC_SEEK_SET (0) 1.118 + 1.119 +#define ZLIB_FILEFUNC_MODE_READ (1) 1.120 +#define ZLIB_FILEFUNC_MODE_WRITE (2) 1.121 +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 1.122 + 1.123 +#define ZLIB_FILEFUNC_MODE_EXISTING (4) 1.124 +#define ZLIB_FILEFUNC_MODE_CREATE (8) 1.125 + 1.126 + 1.127 +#ifndef ZCALLBACK 1.128 + #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 1.129 + #define ZCALLBACK CALLBACK 1.130 + #else 1.131 + #define ZCALLBACK 1.132 + #endif 1.133 +#endif 1.134 + 1.135 + 1.136 + 1.137 + 1.138 +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 1.139 +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 1.140 +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 1.141 +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 1.142 +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 1.143 + 1.144 +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 1.145 +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 1.146 + 1.147 + 1.148 +/* here is the "old" 32 bits structure structure */ 1.149 +typedef struct zlib_filefunc_def_s 1.150 +{ 1.151 + open_file_func zopen_file; 1.152 + read_file_func zread_file; 1.153 + write_file_func zwrite_file; 1.154 + tell_file_func ztell_file; 1.155 + seek_file_func zseek_file; 1.156 + close_file_func zclose_file; 1.157 + testerror_file_func zerror_file; 1.158 + voidpf opaque; 1.159 +} zlib_filefunc_def; 1.160 + 1.161 +typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); 1.162 +typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); 1.163 +typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); 1.164 + 1.165 +typedef struct zlib_filefunc64_def_s 1.166 +{ 1.167 + open64_file_func zopen64_file; 1.168 + read_file_func zread_file; 1.169 + write_file_func zwrite_file; 1.170 + tell64_file_func ztell64_file; 1.171 + seek64_file_func zseek64_file; 1.172 + close_file_func zclose_file; 1.173 + testerror_file_func zerror_file; 1.174 + voidpf opaque; 1.175 +} zlib_filefunc64_def; 1.176 + 1.177 +void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); 1.178 +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 1.179 + 1.180 +/* now internal definition, only for zip.c and unzip.h */ 1.181 +typedef struct zlib_filefunc64_32_def_s 1.182 +{ 1.183 + zlib_filefunc64_def zfile_func64; 1.184 + open_file_func zopen32_file; 1.185 + tell_file_func ztell32_file; 1.186 + seek_file_func zseek32_file; 1.187 +} zlib_filefunc64_32_def; 1.188 + 1.189 + 1.190 +#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 1.191 +#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) 1.192 +//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) 1.193 +//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) 1.194 +#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) 1.195 +#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) 1.196 + 1.197 +voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); 1.198 +long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); 1.199 +ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); 1.200 + 1.201 +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); 1.202 + 1.203 +#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) 1.204 +#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) 1.205 +#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) 1.206 + 1.207 +#ifdef __cplusplus 1.208 +} 1.209 +#endif 1.210 + 1.211 +#endif