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