Ruby: ext/zlib/zlib-1.2.13/contrib/minizip/ioapi.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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