annotate src/zlib-1.2.8/contrib/minizip/ioapi.h @ 128:5b4145a0d408

Current zlib source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 14:33:52 +0100
parents
children
rev   line source
cannam@128 1 /* ioapi.h -- IO base function header for compress/uncompress .zip
cannam@128 2 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
cannam@128 3
cannam@128 4 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
cannam@128 5
cannam@128 6 Modifications for Zip64 support
cannam@128 7 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
cannam@128 8
cannam@128 9 For more info read MiniZip_info.txt
cannam@128 10
cannam@128 11 Changes
cannam@128 12
cannam@128 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)
cannam@128 14 Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
cannam@128 15 More if/def section may be needed to support other platforms
cannam@128 16 Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
cannam@128 17 (but you should use iowin32.c for windows instead)
cannam@128 18
cannam@128 19 */
cannam@128 20
cannam@128 21 #ifndef _ZLIBIOAPI64_H
cannam@128 22 #define _ZLIBIOAPI64_H
cannam@128 23
cannam@128 24 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
cannam@128 25
cannam@128 26 // Linux needs this to support file operation on files larger then 4+GB
cannam@128 27 // But might need better if/def to select just the platforms that needs them.
cannam@128 28
cannam@128 29 #ifndef __USE_FILE_OFFSET64
cannam@128 30 #define __USE_FILE_OFFSET64
cannam@128 31 #endif
cannam@128 32 #ifndef __USE_LARGEFILE64
cannam@128 33 #define __USE_LARGEFILE64
cannam@128 34 #endif
cannam@128 35 #ifndef _LARGEFILE64_SOURCE
cannam@128 36 #define _LARGEFILE64_SOURCE
cannam@128 37 #endif
cannam@128 38 #ifndef _FILE_OFFSET_BIT
cannam@128 39 #define _FILE_OFFSET_BIT 64
cannam@128 40 #endif
cannam@128 41
cannam@128 42 #endif
cannam@128 43
cannam@128 44 #include <stdio.h>
cannam@128 45 #include <stdlib.h>
cannam@128 46 #include "zlib.h"
cannam@128 47
cannam@128 48 #if defined(USE_FILE32API)
cannam@128 49 #define fopen64 fopen
cannam@128 50 #define ftello64 ftell
cannam@128 51 #define fseeko64 fseek
cannam@128 52 #else
cannam@128 53 #ifdef __FreeBSD__
cannam@128 54 #define fopen64 fopen
cannam@128 55 #define ftello64 ftello
cannam@128 56 #define fseeko64 fseeko
cannam@128 57 #endif
cannam@128 58 #ifdef _MSC_VER
cannam@128 59 #define fopen64 fopen
cannam@128 60 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
cannam@128 61 #define ftello64 _ftelli64
cannam@128 62 #define fseeko64 _fseeki64
cannam@128 63 #else // old MSC
cannam@128 64 #define ftello64 ftell
cannam@128 65 #define fseeko64 fseek
cannam@128 66 #endif
cannam@128 67 #endif
cannam@128 68 #endif
cannam@128 69
cannam@128 70 /*
cannam@128 71 #ifndef ZPOS64_T
cannam@128 72 #ifdef _WIN32
cannam@128 73 #define ZPOS64_T fpos_t
cannam@128 74 #else
cannam@128 75 #include <stdint.h>
cannam@128 76 #define ZPOS64_T uint64_t
cannam@128 77 #endif
cannam@128 78 #endif
cannam@128 79 */
cannam@128 80
cannam@128 81 #ifdef HAVE_MINIZIP64_CONF_H
cannam@128 82 #include "mz64conf.h"
cannam@128 83 #endif
cannam@128 84
cannam@128 85 /* a type choosen by DEFINE */
cannam@128 86 #ifdef HAVE_64BIT_INT_CUSTOM
cannam@128 87 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
cannam@128 88 #else
cannam@128 89 #ifdef HAS_STDINT_H
cannam@128 90 #include "stdint.h"
cannam@128 91 typedef uint64_t ZPOS64_T;
cannam@128 92 #else
cannam@128 93
cannam@128 94 /* Maximum unsigned 32-bit value used as placeholder for zip64 */
cannam@128 95 #define MAXU32 0xffffffff
cannam@128 96
cannam@128 97 #if defined(_MSC_VER) || defined(__BORLANDC__)
cannam@128 98 typedef unsigned __int64 ZPOS64_T;
cannam@128 99 #else
cannam@128 100 typedef unsigned long long int ZPOS64_T;
cannam@128 101 #endif
cannam@128 102 #endif
cannam@128 103 #endif
cannam@128 104
cannam@128 105
cannam@128 106
cannam@128 107 #ifdef __cplusplus
cannam@128 108 extern "C" {
cannam@128 109 #endif
cannam@128 110
cannam@128 111
cannam@128 112 #define ZLIB_FILEFUNC_SEEK_CUR (1)
cannam@128 113 #define ZLIB_FILEFUNC_SEEK_END (2)
cannam@128 114 #define ZLIB_FILEFUNC_SEEK_SET (0)
cannam@128 115
cannam@128 116 #define ZLIB_FILEFUNC_MODE_READ (1)
cannam@128 117 #define ZLIB_FILEFUNC_MODE_WRITE (2)
cannam@128 118 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
cannam@128 119
cannam@128 120 #define ZLIB_FILEFUNC_MODE_EXISTING (4)
cannam@128 121 #define ZLIB_FILEFUNC_MODE_CREATE (8)
cannam@128 122
cannam@128 123
cannam@128 124 #ifndef ZCALLBACK
cannam@128 125 #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
cannam@128 126 #define ZCALLBACK CALLBACK
cannam@128 127 #else
cannam@128 128 #define ZCALLBACK
cannam@128 129 #endif
cannam@128 130 #endif
cannam@128 131
cannam@128 132
cannam@128 133
cannam@128 134
cannam@128 135 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
cannam@128 136 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
cannam@128 137 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
cannam@128 138 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
cannam@128 139 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
cannam@128 140
cannam@128 141 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
cannam@128 142 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
cannam@128 143
cannam@128 144
cannam@128 145 /* here is the "old" 32 bits structure structure */
cannam@128 146 typedef struct zlib_filefunc_def_s
cannam@128 147 {
cannam@128 148 open_file_func zopen_file;
cannam@128 149 read_file_func zread_file;
cannam@128 150 write_file_func zwrite_file;
cannam@128 151 tell_file_func ztell_file;
cannam@128 152 seek_file_func zseek_file;
cannam@128 153 close_file_func zclose_file;
cannam@128 154 testerror_file_func zerror_file;
cannam@128 155 voidpf opaque;
cannam@128 156 } zlib_filefunc_def;
cannam@128 157
cannam@128 158 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
cannam@128 159 typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
cannam@128 160 typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
cannam@128 161
cannam@128 162 typedef struct zlib_filefunc64_def_s
cannam@128 163 {
cannam@128 164 open64_file_func zopen64_file;
cannam@128 165 read_file_func zread_file;
cannam@128 166 write_file_func zwrite_file;
cannam@128 167 tell64_file_func ztell64_file;
cannam@128 168 seek64_file_func zseek64_file;
cannam@128 169 close_file_func zclose_file;
cannam@128 170 testerror_file_func zerror_file;
cannam@128 171 voidpf opaque;
cannam@128 172 } zlib_filefunc64_def;
cannam@128 173
cannam@128 174 void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
cannam@128 175 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
cannam@128 176
cannam@128 177 /* now internal definition, only for zip.c and unzip.h */
cannam@128 178 typedef struct zlib_filefunc64_32_def_s
cannam@128 179 {
cannam@128 180 zlib_filefunc64_def zfile_func64;
cannam@128 181 open_file_func zopen32_file;
cannam@128 182 tell_file_func ztell32_file;
cannam@128 183 seek_file_func zseek32_file;
cannam@128 184 } zlib_filefunc64_32_def;
cannam@128 185
cannam@128 186
cannam@128 187 #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
cannam@128 188 #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
cannam@128 189 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
cannam@128 190 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
cannam@128 191 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
cannam@128 192 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
cannam@128 193
cannam@128 194 voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
cannam@128 195 long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
cannam@128 196 ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
cannam@128 197
cannam@128 198 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
cannam@128 199
cannam@128 200 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
cannam@128 201 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
cannam@128 202 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
cannam@128 203
cannam@128 204 #ifdef __cplusplus
cannam@128 205 }
cannam@128 206 #endif
cannam@128 207
cannam@128 208 #endif