1 /* ioapi.h -- IO base function header for compress/uncompress .zip 2 files using zlib + zip or unzip API 3 4 Version 1.01h, December 28th, 2009 5 6 Copyright (C) 1998-2009 Gilles Vollant 7 */ 8 9 #ifndef _ZLIBIOAPI_H 10 #define _ZLIBIOAPI_H 11 12 // Needed for some zlib installations: 13 #ifndef OF 14 #define OF(x) x 15 #endif 16 17 18 #define ZLIB_FILEFUNC_SEEK_CUR (1) 19 #define ZLIB_FILEFUNC_SEEK_END (2) 20 #define ZLIB_FILEFUNC_SEEK_SET (0) 21 22 #define ZLIB_FILEFUNC_MODE_READ (1) 23 #define ZLIB_FILEFUNC_MODE_WRITE (2) 24 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 25 26 #define ZLIB_FILEFUNC_MODE_EXISTING (4) 27 #define ZLIB_FILEFUNC_MODE_CREATE (8) 28 29 30 #ifndef ZCALLBACK 31 32 #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 33 #define ZCALLBACK CALLBACK 34 #else 35 #define ZCALLBACK 36 #endif 37 #endif 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 44 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 45 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 46 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 47 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 48 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 49 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 50 51 typedef struct zlib_filefunc_def_s 52 { 53 open_file_func zopen_file; 54 read_file_func zread_file; 55 write_file_func zwrite_file; 56 tell_file_func ztell_file; 57 seek_file_func zseek_file; 58 close_file_func zclose_file; 59 testerror_file_func zerror_file; 60 voidpf opaque; 61 } zlib_filefunc_def; 62 63 64 65 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 66 67 #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 68 #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 69 #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 70 #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 71 #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 72 #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 73 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif 80 81