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