1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 /* ioapi.h -- IO base function header for compress/uncompress .zip
25    files using zlib + zip or unzip API
26 
27    Version 1.01e, February 12th, 2005
28 
29    Copyright (C) 1998-2005 Gilles Vollant
30 */
31 
32 #ifndef _ZLIBIOAPI_H
33 #define _ZLIBIOAPI_H
34 
35 #include <zlib.h>
36 
37 #define ZLIB_FILEFUNC_SEEK_CUR (1)
38 #define ZLIB_FILEFUNC_SEEK_END (2)
39 #define ZLIB_FILEFUNC_SEEK_SET (0)
40 
41 #define ZLIB_FILEFUNC_MODE_READ      (1)
42 #define ZLIB_FILEFUNC_MODE_WRITE     (2)
43 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
44 
45 #define ZLIB_FILEFUNC_MODE_EXISTING (4)
46 #define ZLIB_FILEFUNC_MODE_CREATE   (8)
47 
48 
49 #ifndef ZCALLBACK
50 #define ZCALLBACK
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
58 typedef uLong  (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
59 typedef uLong  (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
60 typedef long   (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
61 typedef long   (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
62 typedef int    (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
63 typedef int    (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
64 
65 typedef struct zlib_filefunc_def_s
66 {
67     open_file_func      zopen_file;
68     read_file_func      zread_file;
69     write_file_func     zwrite_file;
70     tell_file_func      ztell_file;
71     seek_file_func      zseek_file;
72     close_file_func     zclose_file;
73     testerror_file_func zerror_file;
74     voidpf              opaque;
75 } zlib_filefunc_def;
76 
77 
78 
79 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
80 
81 #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
82 #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
83 #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
84 #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
85 #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
86 #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
87 
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif
94 
95