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
57extern "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
79typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char *filename, int mode);
80typedef voidpf (ZCALLBACK *opendisk_file_func) (voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
81typedef uint32_t (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uint32_t size);
82typedef uint32_t (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void *buf, uint32_t size);
83typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
84typedef int (ZCALLBACK *error_file_func) (voidpf opaque, voidpf stream);
85
86typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
87typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uint32_t offset, int origin);
88
89/* here is the "old" 32 bits structure structure */
90typedef struct zlib_filefunc_def_s
91{
100 voidpf opaque;
102
103typedef uint64_t (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
104typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, uint64_t offset, int origin);
105typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void *filename, int mode);
106typedef voidpf (ZCALLBACK *opendisk64_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
107
109{
118 voidpf opaque;
120
121void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def);
122void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
123
124/* now internal definition, only for zip.c and unzip.h */
126{
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);
143long 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
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
uint32_t(ZCALLBACK * write_file_func)(voidpf opaque, voidpf stream, const void *buf, uint32_t size)
Definition: ioapi.h:82
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
voidpf call_zopendisk64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint32_t number_disk, int mode)
Definition: ioapi.c:38
long(ZCALLBACK * seek_file_func)(voidpf opaque, voidpf stream, uint32_t offset, int origin)
Definition: ioapi.h:87
struct zlib_filefunc64_def_s zlib_filefunc64_def
uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
Definition: ioapi.c:56
uint32_t(ZCALLBACK * read_file_func)(voidpf opaque, voidpf stream, void *buf, uint32_t size)
Definition: ioapi.h:81
voidpf(ZCALLBACK * open64_file_func)(voidpf opaque, const void *filename, int mode)
Definition: ioapi.h:105
long call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint64_t offset, int origin)
Definition: ioapi.c:45
long(ZCALLBACK * tell_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:86
voidpf(ZCALLBACK * open_file_func)(voidpf opaque, const char *filename, int mode)
Definition: ioapi.h:79
struct zlib_filefunc_def_s zlib_filefunc_def
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: ioapi.c:343
long(ZCALLBACK * seek64_file_func)(voidpf opaque, voidpf stream, uint64_t offset, int origin)
Definition: ioapi.h:104
struct zlib_filefunc64_32_def_s zlib_filefunc64_32_def
#define ZCALLBACK
Definition: ioapi.h:75
int(ZCALLBACK * close_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:83
void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
Definition: ioapi.c:330
voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc, const void *filename, int mode)
Definition: ioapi.c:31
voidpf(ZCALLBACK * opendisk64_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode)
Definition: ioapi.h:106
uint64_t(ZCALLBACK * tell64_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:103
voidpf(ZCALLBACK * opendisk_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode)
Definition: ioapi.h:80
int(ZCALLBACK * error_file_func)(voidpf opaque, voidpf stream)
Definition: ioapi.h:84
Definition: ioapi.h:126
seek_file_func zseek32_file
Definition: ioapi.h:131
zlib_filefunc64_def zfile_func64
Definition: ioapi.h:127
open_file_func zopen32_file
Definition: ioapi.h:128
tell_file_func ztell32_file
Definition: ioapi.h:130
opendisk_file_func zopendisk32_file
Definition: ioapi.h:129
Definition: ioapi.h:109
write_file_func zwrite_file
Definition: ioapi.h:113
error_file_func zerror_file
Definition: ioapi.h:117
opendisk64_file_func zopendisk64_file
Definition: ioapi.h:111
open64_file_func zopen64_file
Definition: ioapi.h:110
voidpf opaque
Definition: ioapi.h:118
read_file_func zread_file
Definition: ioapi.h:112
tell64_file_func ztell64_file
Definition: ioapi.h:114
close_file_func zclose_file
Definition: ioapi.h:116
seek64_file_func zseek64_file
Definition: ioapi.h:115
Definition: ioapi.h:91
opendisk_file_func zopendisk_file
Definition: ioapi.h:93
seek_file_func zseek_file
Definition: ioapi.h:97
voidpf opaque
Definition: ioapi.h:100
open_file_func zopen_file
Definition: ioapi.h:92
write_file_func zwrite_file
Definition: ioapi.h:95
error_file_func zerror_file
Definition: ioapi.h:99
read_file_func zread_file
Definition: ioapi.h:94
close_file_func zclose_file
Definition: ioapi.h:98
tell_file_func ztell_file
Definition: ioapi.h:96