| 1 | |
| 2 | #ifndef ZLIBIOAPI64_H |
| 3 | #define ZLIBIOAPI64_H |
| 4 | |
| 5 | #include <stdint.h> |
| 6 | |
| 7 | typedef uint64_t ZPOS64_T; |
| 8 | |
| 9 | #ifndef ZEXPORT |
| 10 | # define ZEXPORT |
| 11 | #endif |
| 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /***************************************************************************/ |
| 18 | |
| 19 | #define ZLIB_FILEFUNC_SEEK_SET (0) |
| 20 | #define ZLIB_FILEFUNC_SEEK_CUR (1) |
| 21 | #define ZLIB_FILEFUNC_SEEK_END (2) |
| 22 | |
| 23 | #define ZLIB_FILEFUNC_MODE_READ (1) |
| 24 | #define ZLIB_FILEFUNC_MODE_WRITE (2) |
| 25 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) |
| 26 | |
| 27 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) |
| 28 | #define ZLIB_FILEFUNC_MODE_CREATE (8) |
| 29 | |
| 30 | #ifndef ZCALLBACK |
| 31 | # define ZCALLBACK |
| 32 | #endif |
| 33 | |
| 34 | /***************************************************************************/ |
| 35 | |
| 36 | typedef void *(ZCALLBACK *open_file_func)(void *opaque, const char *filename, int mode); |
| 37 | typedef void *(ZCALLBACK *open64_file_func)(void *opaque, const void *filename, int mode); |
| 38 | typedef unsigned long(ZCALLBACK *read_file_func)(void *opaque, void *stream, void *buf, unsigned long size); |
| 39 | typedef unsigned long(ZCALLBACK *write_file_func)(void *opaque, void *stream, const void *buf, unsigned long size); |
| 40 | typedef int(ZCALLBACK *close_file_func)(void *opaque, void *stream); |
| 41 | typedef int(ZCALLBACK *testerror_file_func)(void *opaque, void *stream); |
| 42 | typedef long(ZCALLBACK *tell_file_func)(void *opaque, void *stream); |
| 43 | typedef ZPOS64_T(ZCALLBACK *tell64_file_func)(void *opaque, void *stream); |
| 44 | typedef long(ZCALLBACK *seek_file_func)(void *opaque, void *stream, unsigned long offset, int origin); |
| 45 | typedef long(ZCALLBACK *seek64_file_func)(void *opaque, void *stream, ZPOS64_T offset, int origin); |
| 46 | |
| 47 | /***************************************************************************/ |
| 48 | |
| 49 | typedef struct zlib_filefunc_def_s { |
| 50 | open_file_func zopen_file; |
| 51 | read_file_func zread_file; |
| 52 | write_file_func zwrite_file; |
| 53 | tell_file_func ztell_file; |
| 54 | seek_file_func zseek_file; |
| 55 | close_file_func zclose_file; |
| 56 | testerror_file_func zerror_file; |
| 57 | void *opaque; |
| 58 | } zlib_filefunc_def; |
| 59 | |
| 60 | typedef struct zlib_filefunc64_def_s { |
| 61 | open64_file_func zopen64_file; |
| 62 | read_file_func zread_file; |
| 63 | write_file_func zwrite_file; |
| 64 | tell64_file_func ztell64_file; |
| 65 | seek64_file_func zseek64_file; |
| 66 | close_file_func zclose_file; |
| 67 | testerror_file_func zerror_file; |
| 68 | void *opaque; |
| 69 | } zlib_filefunc64_def; |
| 70 | |
| 71 | /***************************************************************************/ |
| 72 | |
| 73 | /* Compatibility layer with the original minizip library (ioapi.h and iowin32.h). */ |
| 74 | ZEXPORT void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def); |
| 75 | ZEXPORT void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def); |
| 76 | ZEXPORT void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def); |
| 77 | ZEXPORT void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def); |
| 78 | ZEXPORT void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def); |
| 79 | |
| 80 | /* Compatibility layer with older minizip-ng (ioapi_mem.h). */ |
| 81 | ZEXPORT void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def); |
| 82 | |
| 83 | /***************************************************************************/ |
| 84 | |
| 85 | int32_t mz_stream_ioapi_set_filefunc(void *stream, zlib_filefunc_def *filefunc); |
| 86 | int32_t mz_stream_ioapi_set_filefunc64(void *stream, zlib_filefunc64_def *filefunc); |
| 87 | |
| 88 | void *mz_stream_ioapi_create(void); |
| 89 | void mz_stream_ioapi_delete(void **stream); |
| 90 | |
| 91 | /***************************************************************************/ |
| 92 | |
| 93 | #ifdef __cplusplus |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | #endif |