1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 *************************************************************************/
28 /* ioapi.c -- IO base function header for compress/uncompress .zip
29 files using zlib + zip or unzip API
31 Version 1.01e, February 12th, 2005
33 Copyright (C) 1998-2005 Gilles Vollant
45 /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
59 voidpf ZCALLBACK fopen_file_func OF((
64 uLong ZCALLBACK fread_file_func OF((
70 uLong ZCALLBACK fwrite_file_func OF((
76 long ZCALLBACK ftell_file_func OF((
80 long ZCALLBACK fseek_file_func OF((
86 int ZCALLBACK fclose_file_func OF((
90 int ZCALLBACK ferror_file_func OF((
95 voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
101 const char* mode_fopen = NULL;
102 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
105 if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
108 if (mode & ZLIB_FILEFUNC_MODE_CREATE)
111 if ((filename!=NULL) && (mode_fopen != NULL))
112 file = fopen(filename, mode_fopen);
117 uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
124 ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
129 uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
136 ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
140 long ZCALLBACK ftell_file_func (opaque, stream)
145 ret = ftell((FILE *)stream);
149 long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
159 case ZLIB_FILEFUNC_SEEK_CUR :
160 fseek_origin = SEEK_CUR;
162 case ZLIB_FILEFUNC_SEEK_END :
163 fseek_origin = SEEK_END;
165 case ZLIB_FILEFUNC_SEEK_SET :
166 fseek_origin = SEEK_SET;
171 fseek((FILE *)stream, offset, fseek_origin);
175 int ZCALLBACK fclose_file_func (opaque, stream)
180 ret = fclose((FILE *)stream);
184 int ZCALLBACK ferror_file_func (opaque, stream)
189 ret = ferror((FILE *)stream);
193 void fill_fopen_filefunc (pzlib_filefunc_def)
194 zlib_filefunc_def* pzlib_filefunc_def;
196 pzlib_filefunc_def->zopen_file = fopen_file_func;
197 pzlib_filefunc_def->zread_file = fread_file_func;
198 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
199 pzlib_filefunc_def->ztell_file = ftell_file_func;
200 pzlib_filefunc_def->zseek_file = fseek_file_func;
201 pzlib_filefunc_def->zclose_file = fclose_file_func;
202 pzlib_filefunc_def->zerror_file = ferror_file_func;
203 pzlib_filefunc_def->opaque = NULL;