| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
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
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#ifdef __linux
17# define _GNU_SOURCE // // Defines _LARGEFILE64_SOURCE if using GNU libc.
18#endif
19
20#ifndef _ZLIBIOAPI64_H
21#define _ZLIBIOAPI64_H
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <stdint.h>
26
27#include "zlib.h"
28
29#ifdef __GNUC__
30# define ZIP_UNUSED __attribute__((__unused__))
31#else
32# define ZIP_UNUSED
33#endif
34
35#if defined(USE_FILE32API)
36# define fopen64 fopen
37# define ftello64 ftell
38# define fseeko64 fseek
39#else
40# if defined(_MSC_VER)
41# define fopen64 fopen
42# if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
43# define ftello64 _ftelli64
44# define fseeko64 _fseeki64
45# else /* old MSC */
46# define ftello64 ftell
47# define fseeko64 fseek
48# endif
49# else
50# define fopen64 fopen
51# define ftello64 ftello
52# define fseeko64 fseeko
53# endif
54#endif
55
56#ifdef __cplusplus
57 extern "C" {
58#endif
59
60#define ZLIB_FILEFUNC_SEEK_CUR (1)
61#define ZLIB_FILEFUNC_SEEK_END (2)
62#define ZLIB_FILEFUNC_SEEK_SET (0)
63
64#define ZLIB_FILEFUNC_MODE_READ (1)
65#define ZLIB_FILEFUNC_MODE_WRITE (2)
66#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
67#define ZLIB_FILEFUNC_MODE_EXISTING (4)
68#define ZLIB_FILEFUNC_MODE_CREATE (8)
69
70#ifndef ZCALLBACK
71# if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || \
72 defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
73# define ZCALLBACK CALLBACK
74# else
75# define ZCALLBACK
76# endif
77#endif
78
79 typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char *filename, int mode);
80 typedef voidpf (ZCALLBACK *opendisk_file_func) (voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
81 typedef uint32_t (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uint32_t size);
82 typedef uint32_t (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void *buf, uint32_t size);
83 typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
84 typedef int (ZCALLBACK *error_file_func) (voidpf opaque, voidpf stream);
85
86 typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
87 typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uint32_t offset, int origin);
88
89/* here is the "old" 32 bits structure structure */
90 typedef struct zlib_filefunc_def_s
91{
92 open_file_func zopen_file;
93 opendisk_file_func zopendisk_file;
94 read_file_func zread_file;
95 write_file_func zwrite_file;
96 tell_file_func ztell_file;
97 seek_file_func zseek_file;
98 close_file_func zclose_file;
99 error_file_func zerror_file;
100 voidpf opaque;
101} zlib_filefunc_def;
102
103 typedef uint64_t (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
104 typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, uint64_t offset, int origin);
105 typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void *filename, int mode);
106 typedef voidpf (ZCALLBACK *opendisk64_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
107
108 typedef struct zlib_filefunc64_def_s
109{
110 open64_file_func zopen64_file;
111 opendisk64_file_func zopendisk64_file;
112 read_file_func zread_file;
113 write_file_func zwrite_file;
114 tell64_file_func ztell64_file;
115 seek64_file_func zseek64_file;
116 close_file_func zclose_file;
117 error_file_func zerror_file;
118 voidpf opaque;
119} zlib_filefunc64_def;
120
121 void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def);
122 void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
123
124/* now internal definition, only for zip.c and unzip.h */
125 typedef struct zlib_filefunc64_32_def_s
126{
127 zlib_filefunc64_def zfile_func64;
128 open_file_func zopen32_file;
129 opendisk_file_func zopendisk32_file;
130 tell_file_func ztell32_file;
131 seek_file_func zseek32_file;
132} zlib_filefunc64_32_def;
133
134#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
135#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
136/*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))*/
137/*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))*/
138#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
139#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
140
141voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc,const void*filename, int mode);
142voidpf call_zopendisk64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint32_t number_disk, int mode);
143 long call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint64_t offset, int origin);
144uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream);
145
146 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32);
147
148#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
149#define ZOPENDISK64(filefunc,filestream,diskn,mode) (call_zopendisk64((&(filefunc)),(filestream),(diskn),(mode)))
150#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
151#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif
write_file_func
uint32_t(ZCALLBACK * write_file_func)(voidpf opaque, voidpf stream, const void *buf, uint32_t size)
Definition: ioapi.h:82
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:67
call_zopendisk64
voidpf call_zopendisk64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint32_t number_disk, int mode)
Definition: ioapi.c:38
seek_file_func
long(ZCALLBACK * seek_file_func)(voidpf opaque, voidpf stream, uint32_t offset, int origin)
Definition: ioapi.h:87
zlib_filefunc64_def
struct zlib_filefunc64_def_s zlib_filefunc64_def
call_ztell64
uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
Definition: ioapi.c:56
read_file_func
uint32_t(ZCALLBACK * read_file_func)(voidpf opaque, voidpf stream, void *buf, uint32_t size)
Definition: ioapi.h:81
open64_file_func
voidpf(ZCALLBACK * open64_file_func)(voidpf opaque, const void *filename, int mode)
Definition: ioapi.h:105
call_zseek64
long call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint64_t offset, int origin)
Definition: ioapi.c:45
tell_file_func
long(ZCALLBACK * tell_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:86
open_file_func
voidpf(ZCALLBACK * open_file_func)(voidpf opaque, const char *filename, int mode)
Definition: ioapi.h:79
zlib_filefunc_def
struct zlib_filefunc_def_s zlib_filefunc_def
fill_fopen64_filefunc
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: ioapi.c:343
seek64_file_func
long(ZCALLBACK * seek64_file_func)(voidpf opaque, voidpf stream, uint64_t offset, int origin)
Definition: ioapi.h:104
zlib_filefunc64_32_def
struct zlib_filefunc64_32_def_s zlib_filefunc64_32_def
ZCALLBACK
#define ZCALLBACK
Definition: ioapi.h:75
close_file_func
int(ZCALLBACK * close_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:83
fill_fopen_filefunc
void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
Definition: ioapi.c:330
call_zopen64
voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc, const void *filename, int mode)
Definition: ioapi.c:31
opendisk64_file_func
voidpf(ZCALLBACK * opendisk64_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode)
Definition: ioapi.h:106
tell64_file_func
uint64_t(ZCALLBACK * tell64_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:103
opendisk_file_func
voidpf(ZCALLBACK * opendisk_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode)
Definition: ioapi.h:80
error_file_func
int(ZCALLBACK * error_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:84
zlib_filefunc64_32_def_s
Definition: ioapi.h:126
zlib_filefunc64_32_def_s::zseek32_file
seek_file_func zseek32_file
Definition: ioapi.h:131
zlib_filefunc64_32_def_s::zfile_func64
zlib_filefunc64_def zfile_func64
Definition: ioapi.h:127
zlib_filefunc64_32_def_s::zopen32_file
open_file_func zopen32_file
Definition: ioapi.h:128
zlib_filefunc64_32_def_s::ztell32_file
tell_file_func ztell32_file
Definition: ioapi.h:130
zlib_filefunc64_32_def_s::zopendisk32_file
opendisk_file_func zopendisk32_file
Definition: ioapi.h:129
zlib_filefunc64_def_s
Definition: ioapi.h:109
zlib_filefunc64_def_s::zwrite_file
write_file_func zwrite_file
Definition: ioapi.h:113
zlib_filefunc64_def_s::zerror_file
error_file_func zerror_file
Definition: ioapi.h:117
zlib_filefunc64_def_s::zopendisk64_file
opendisk64_file_func zopendisk64_file
Definition: ioapi.h:111
zlib_filefunc64_def_s::zopen64_file
open64_file_func zopen64_file
Definition: ioapi.h:110
zlib_filefunc64_def_s::opaque
voidpf opaque
Definition: ioapi.h:118
zlib_filefunc64_def_s::zread_file
read_file_func zread_file
Definition: ioapi.h:112
zlib_filefunc64_def_s::ztell64_file
tell64_file_func ztell64_file
Definition: ioapi.h:114
zlib_filefunc64_def_s::zclose_file
close_file_func zclose_file
Definition: ioapi.h:116
zlib_filefunc64_def_s::zseek64_file
seek64_file_func zseek64_file
Definition: ioapi.h:115
zlib_filefunc_def_s
Definition: ioapi.h:91
zlib_filefunc_def_s::zopendisk_file
opendisk_file_func zopendisk_file
Definition: ioapi.h:93
zlib_filefunc_def_s::zseek_file
seek_file_func zseek_file
Definition: ioapi.h:97
zlib_filefunc_def_s::opaque
voidpf opaque
Definition: ioapi.h:100
zlib_filefunc_def_s::zopen_file
open_file_func zopen_file
Definition: ioapi.h:92
zlib_filefunc_def_s::zwrite_file
write_file_func zwrite_file
Definition: ioapi.h:95
zlib_filefunc_def_s::zerror_file
error_file_func zerror_file
Definition: ioapi.h:99
zlib_filefunc_def_s::zread_file
read_file_func zread_file
Definition: ioapi.h:94
zlib_filefunc_def_s::zclose_file
close_file_func zclose_file
Definition: ioapi.h:98
zlib_filefunc_def_s::ztell_file
tell_file_func ztell_file
Definition: ioapi.h:96