added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git] / src / libgame / zip / ioapi.h
1 /* ioapi.h -- IO base function header for compress/uncompress .zip
2    part of the MiniZip project
3
4    Copyright (C) 2012-2017 Nathan Moinvaziri
5      https://github.com/nmoinvaz/minizip
6    Copyright (C) 2009-2010 Mathias Svensson
7      Modifications for Zip64 support
8      http://result42.com
9    Copyright (C) 1998-2010 Gilles Vollant
10      http://www.winimage.com/zLibDll/minizip.html
11
12    This program is distributed under the terms of the same license as zlib.
13    See the accompanying LICENSE file for the full text of the license.
14 */
15
16 #ifndef _ZLIBIOAPI64_H
17 #define _ZLIBIOAPI64_H
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <stdint.h>
22
23 #include "zlib.h"
24
25 #ifdef __GNUC__
26 #  define ZIP_UNUSED __attribute__((__unused__))
27 #else
28 #  define ZIP_UNUSED
29 #endif
30
31 #if defined(USE_FILE32API)
32 #  define fopen64 fopen
33 #  define ftello64 ftell
34 #  define fseeko64 fseek
35 #else
36 #  if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__ANDROID__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__OS2__)
37 #    define fopen64 fopen
38 #    define ftello64 ftello
39 #    define fseeko64 fseeko
40 #  endif
41 #  ifdef _MSC_VER
42 #    define fopen64 fopen
43 #    if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
44 #      define ftello64 _ftelli64
45 #      define fseeko64 _fseeki64
46 #    else /* old MSC */
47 #      define ftello64 ftell
48 #      define fseeko64 fseek
49 #    endif
50 #  endif
51 #endif
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 #define ZLIB_FILEFUNC_SEEK_CUR (1)
58 #define ZLIB_FILEFUNC_SEEK_END (2)
59 #define ZLIB_FILEFUNC_SEEK_SET (0)
60
61 #define ZLIB_FILEFUNC_MODE_READ             (1)
62 #define ZLIB_FILEFUNC_MODE_WRITE            (2)
63 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER  (3)
64 #define ZLIB_FILEFUNC_MODE_EXISTING         (4)
65 #define ZLIB_FILEFUNC_MODE_CREATE           (8)
66
67 #ifndef ZCALLBACK
68 #  if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || \
69        defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
70 #    define ZCALLBACK CALLBACK
71 #  else
72 #    define ZCALLBACK
73 #  endif
74 #endif
75
76 typedef voidpf   (ZCALLBACK *open_file_func)     (voidpf opaque, const char *filename, int mode);
77 typedef voidpf   (ZCALLBACK *opendisk_file_func) (voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
78 typedef uint32_t (ZCALLBACK *read_file_func)     (voidpf opaque, voidpf stream, void* buf, uint32_t size);
79 typedef uint32_t (ZCALLBACK *write_file_func)    (voidpf opaque, voidpf stream, const void *buf, uint32_t size);
80 typedef int      (ZCALLBACK *close_file_func)    (voidpf opaque, voidpf stream);
81 typedef int      (ZCALLBACK *error_file_func)    (voidpf opaque, voidpf stream);
82
83 typedef long     (ZCALLBACK *tell_file_func)     (voidpf opaque, voidpf stream);
84 typedef long     (ZCALLBACK *seek_file_func)     (voidpf opaque, voidpf stream, uint32_t offset, int origin);
85
86 /* here is the "old" 32 bits structure structure */
87 typedef struct zlib_filefunc_def_s
88 {
89     open_file_func      zopen_file;
90     opendisk_file_func  zopendisk_file;
91     read_file_func      zread_file;
92     write_file_func     zwrite_file;
93     tell_file_func      ztell_file;
94     seek_file_func      zseek_file;
95     close_file_func     zclose_file;
96     error_file_func     zerror_file;
97     voidpf              opaque;
98 } zlib_filefunc_def;
99
100 typedef uint64_t (ZCALLBACK *tell64_file_func)    (voidpf opaque, voidpf stream);
101 typedef long     (ZCALLBACK *seek64_file_func)    (voidpf opaque, voidpf stream, uint64_t offset, int origin);
102 typedef voidpf   (ZCALLBACK *open64_file_func)    (voidpf opaque, const void *filename, int mode);
103 typedef voidpf   (ZCALLBACK *opendisk64_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
104
105 typedef struct zlib_filefunc64_def_s
106 {
107     open64_file_func     zopen64_file;
108     opendisk64_file_func zopendisk64_file;
109     read_file_func       zread_file;
110     write_file_func      zwrite_file;
111     tell64_file_func     ztell64_file;
112     seek64_file_func     zseek64_file;
113     close_file_func      zclose_file;
114     error_file_func      zerror_file;
115     voidpf               opaque;
116 } zlib_filefunc64_def;
117
118 void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
119
120 /* now internal definition, only for zip.c and unzip.h */
121 typedef struct zlib_filefunc64_32_def_s
122 {
123     zlib_filefunc64_def zfile_func64;
124     open_file_func      zopen32_file;
125     opendisk_file_func  zopendisk32_file;
126     tell_file_func      ztell32_file;
127     seek_file_func      zseek32_file;
128 } zlib_filefunc64_32_def;
129
130 #define ZREAD64(filefunc, filestream, buf, size)       ((*((filefunc).zfile_func64.zread_file))        ((filefunc).zfile_func64.opaque, filestream, buf, size))
131 #define ZWRITE64(filefunc, filestream, buf, size)      ((*((filefunc).zfile_func64.zwrite_file))       ((filefunc).zfile_func64.opaque, filestream, buf, size))
132 /*#define ZTELL64(filefunc, filestream)                ((*((filefunc).ztell64_file))                   ((filefunc).opaque, filestream))*/
133 /*#define ZSEEK64(filefunc, filestream, pos, mode)       ((*((filefunc).zseek64_file))                   ((filefunc).opaque, filestream, pos, mode))*/
134 #define ZCLOSE64(filefunc, filestream)               ((*((filefunc).zfile_func64.zclose_file))       ((filefunc).zfile_func64.opaque, filestream))
135 #define ZERROR64(filefunc, filestream)               ((*((filefunc).zfile_func64.zerror_file))       ((filefunc).zfile_func64.opaque, filestream))
136
137 voidpf   call_zopen64(const zlib_filefunc64_32_def *pfilefunc, const void *filename, int mode);
138 voidpf   call_zopendisk64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint32_t number_disk, int mode);
139 long     call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint64_t offset, int origin);
140 uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream);
141
142 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32);
143
144 #define ZOPEN64(filefunc, filename, mode)              (call_zopen64((&(filefunc)), (filename), (mode)))
145 #define ZOPENDISK64(filefunc, filestream, diskn, mode) (call_zopendisk64((&(filefunc)), (filestream), (diskn), (mode)))
146 #define ZTELL64(filefunc, filestream)                  (call_ztell64((&(filefunc)), (filestream)))
147 #define ZSEEK64(filefunc, filestream, pos, mode)       (call_zseek64((&(filefunc)), (filestream), (pos), (mode)))
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif