GDAL

cpl_minizip_ioapi.h
1 /* $Id$ */
2
3 /* Modified version by Even Rouault. :
4 - change fill_fopen_filefunc to cpl_fill_fopen_filefunc
5 - Add support for ZIP64
6
7 * Copyright (c) 2008-2012, Even Rouault <even dot rouault at spatialys.com>
8
9 Original licence available in port/LICENCE_minizip
10 */
11
12 /* ioapi.h -- IO base function header for compress/uncompress .zip
13 files using zlib + zip or unzip API
14
15 Version 1.01e, February 12th, 2005
16
17 Copyright (C) 1998-2005 Gilles Vollant
18 */
19
20 #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
21 #define CPL_MINIZIP_IOAPI_H_INCLUDED
22
23 #ifndef DOXYGEN_SKIP
24
25 #include "cpl_vsi.h"
26 #include "zlib.h"
27
28 #define uLong64 vsi_l_offset
29
30 #define ZLIB_FILEFUNC_SEEK_CUR (1)
31 #define ZLIB_FILEFUNC_SEEK_END (2)
32 #define ZLIB_FILEFUNC_SEEK_SET (0)
33
34 #define ZLIB_FILEFUNC_MODE_READ (1)
35 #define ZLIB_FILEFUNC_MODE_WRITE (2)
36 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
37
38 #define ZLIB_FILEFUNC_MODE_EXISTING (4)
39 #define ZLIB_FILEFUNC_MODE_CREATE (8)
40
41 #ifndef ZCALLBACK
42
43 #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
44 #define ZCALLBACK CALLBACK
45 #else
46 #define ZCALLBACK
47 #endif
48 #endif
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
55 typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
56 typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
57 typedef uLong64 (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
58 typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong64 offset, int origin);
59 typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
60 typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
61
62 typedef struct zlib_filefunc_def_s
63 {
64 open_file_func zopen_file;
65 read_file_func zread_file;
66 write_file_func zwrite_file;
67 tell_file_func ztell_file;
68 seek_file_func zseek_file;
69 close_file_func zclose_file;
70 testerror_file_func zerror_file;
71 voidpf opaque;
72 } zlib_filefunc_def;
73
74 void cpl_fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def);
75
76 #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
77 #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
78 #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
79 #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
80 #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
81 #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
82
83 #define ZREAD64 ZREAD
84 #define ZWRITE64 ZWRITE
85 #define ZTELL64 ZTELL
86 #define ZSEEK64 ZSEEK
87 #define ZCLOSE64 ZCLOSE
88 #define ZERROR64 ZERROR
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* #ifndef DOXYGEN_SKIP */
95
96 #endif /* CPL_MINIZIP_IOAPI_H_INCLUDED */
cpl_vsi.h