1 /*************************************************************************
2 *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26 *************************************************************************/
27 
28 /* ioapi.h -- IO base function header for compress/uncompress .zip
29    files using zlib + zip or unzip API
30 
31    Version 1.01e, February 12th, 2005
32 
33    Copyright (C) 1998-2005 Gilles Vollant
34 */
35 
36 #ifndef _ZLIBIOAPI_H
37 #define _ZLIBIOAPI_H
38 
39 #include <zlib.h>
40 
41 #define ZLIB_FILEFUNC_SEEK_CUR (1)
42 #define ZLIB_FILEFUNC_SEEK_END (2)
43 #define ZLIB_FILEFUNC_SEEK_SET (0)
44 
45 #define ZLIB_FILEFUNC_MODE_READ      (1)
46 #define ZLIB_FILEFUNC_MODE_WRITE     (2)
47 #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
48 
49 #define ZLIB_FILEFUNC_MODE_EXISTING (4)
50 #define ZLIB_FILEFUNC_MODE_CREATE   (8)
51 
52 
53 #ifndef ZCALLBACK
54 #define ZCALLBACK
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
62 typedef uLong  (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
63 typedef uLong  (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
64 typedef long   (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
65 typedef long   (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
66 typedef int    (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
67 typedef int    (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
68 
69 typedef struct zlib_filefunc_def_s
70 {
71     open_file_func      zopen_file;
72     read_file_func      zread_file;
73     write_file_func     zwrite_file;
74     tell_file_func      ztell_file;
75     seek_file_func      zseek_file;
76     close_file_func     zclose_file;
77     testerror_file_func zerror_file;
78     voidpf              opaque;
79 } zlib_filefunc_def;
80 
81 
82 
83 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
84 
85 #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
86 #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
87 #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
88 #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
89 #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
90 #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
91 
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif
98 
99