mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Use a more modern implementation of minizip from ioquake3
This commit is contained in:
parent
4f99c0fa98
commit
085b72154f
5 changed files with 2758 additions and 4282 deletions
|
@ -55,6 +55,7 @@ set(SOURCES_COMMON
|
|||
"${CMAKE_SOURCE_DIR}/code/qcommon/crc.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/cvar.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/files.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/ioapi.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/huffman.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/md4.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/md5.c"
|
||||
|
@ -83,4 +84,22 @@ endif()
|
|||
|
||||
target_compile_features(qcommon_standalone INTERFACE cxx_nullptr)
|
||||
target_compile_features(qcommon_standalone INTERFACE c_variadic_macros)
|
||||
target_link_libraries(qcommon_standalone INTERFACE omohtiki omohskeletor)
|
||||
target_link_libraries(qcommon_standalone INTERFACE omohtiki omohskeletor)
|
||||
|
||||
#
|
||||
# FIXME: Opt-in for the using the system one rather than bundled one
|
||||
#
|
||||
add_library(zlib INTERFACE)
|
||||
|
||||
target_sources(zlib INTERFACE
|
||||
# zlib
|
||||
"${CMAKE_SOURCE_DIR}/code/zlib/adler32.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/zlib/crc32.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/zlib/inffast.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/zlib/inflate.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/zlib/inftrees.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/zlib/zutil.c"
|
||||
)
|
||||
|
||||
target_include_directories(zlib INTERFACE "${CMAKE_SOURCE_DIR}/code/zlib")
|
||||
target_link_libraries(qcommon_standalone INTERFACE zlib)
|
||||
|
|
|
@ -1711,106 +1711,10 @@ FS_Seek
|
|||
=================
|
||||
*/
|
||||
int FS_Seek( fileHandle_t f, long offset, fsOrigin_t origin ) {
|
||||
#if 0
|
||||
int _origin;
|
||||
|
||||
if ( !fs_searchpaths ) {
|
||||
Com_Error( ERR_FATAL, "Filesystem call made without initialization\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch( origin ) {
|
||||
case FS_SEEK_CUR:
|
||||
_origin = SEEK_CUR;
|
||||
break;
|
||||
case FS_SEEK_END:
|
||||
_origin = SEEK_END;
|
||||
break;
|
||||
case FS_SEEK_SET:
|
||||
_origin = SEEK_SET;
|
||||
break;
|
||||
default:
|
||||
Com_Error( ERR_FATAL, "Bad origin in FS_Seek\n" );
|
||||
_origin = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if( fsh[ f ].zipFile == qtrue ) {
|
||||
if( !unzIsCurrentFileOpen( fsh[ f ].handleFiles.file.o ) ) {
|
||||
Com_Error( ERR_FATAL, "Tried to read from a zip file %s that was not open\n", fsh[ f ].name );
|
||||
}
|
||||
return unzseek( fsh[ f ].handleFiles.file.o, offset, _origin );
|
||||
} else {
|
||||
return fseek( FS_FileForHandle( f ), offset, _origin );
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
if (fsh[f].streamed) {
|
||||
fsh[f].streamed = qfalse;
|
||||
FS_Seek( f, offset, origin );
|
||||
fsh[f].streamed = qtrue;
|
||||
}
|
||||
|
||||
if (fsh[f].zipFile == qtrue) {
|
||||
//FIXME: this is incomplete and really, really
|
||||
//crappy (but better than what was here before)
|
||||
byte buffer[PK3_SEEK_BUFFER_SIZE];
|
||||
int remainder = offset;
|
||||
|
||||
if( offset < 0 || origin == FS_SEEK_END ) {
|
||||
Com_Error( ERR_FATAL, "Negative offsets and FS_SEEK_END not implemented "
|
||||
"for FS_Seek on pk3 file contents\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch( origin ) {
|
||||
case FS_SEEK_SET:
|
||||
unzSetCurrentFileInfoPosition(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);
|
||||
unzOpenCurrentFile(fsh[f].handleFiles.file.z);
|
||||
//fallthrough
|
||||
|
||||
case FS_SEEK_CUR:
|
||||
while( remainder > PK3_SEEK_BUFFER_SIZE ) {
|
||||
FS_Read( buffer, PK3_SEEK_BUFFER_SIZE, f );
|
||||
remainder -= PK3_SEEK_BUFFER_SIZE;
|
||||
}
|
||||
FS_Read( buffer, remainder, f );
|
||||
return offset;
|
||||
break;
|
||||
|
||||
default:
|
||||
Com_Error( ERR_FATAL, "Bad origin in FS_Seek\n" );
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
FILE *file;
|
||||
file = FS_FileForHandle(f);
|
||||
switch( origin ) {
|
||||
case FS_SEEK_CUR:
|
||||
_origin = SEEK_CUR;
|
||||
break;
|
||||
case FS_SEEK_END:
|
||||
_origin = SEEK_END;
|
||||
break;
|
||||
case FS_SEEK_SET:
|
||||
_origin = SEEK_SET;
|
||||
break;
|
||||
default:
|
||||
_origin = SEEK_CUR;
|
||||
Com_Error( ERR_FATAL, "Bad origin in FS_Seek\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
return fseek( file, offset, _origin );
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
int _origin;
|
||||
|
||||
if (!fs_searchpaths) {
|
||||
Com_Error(ERR_FATAL, "Filesystem call made without initialization");
|
||||
Com_Error( ERR_FATAL, "Filesystem call made without initialization" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1819,67 +1723,64 @@ int FS_Seek( fileHandle_t f, long offset, fsOrigin_t origin ) {
|
|||
//(but better than what was here before)
|
||||
byte buffer[PK3_SEEK_BUFFER_SIZE];
|
||||
int remainder;
|
||||
int currentPosition = FS_FTell(f);
|
||||
int currentPosition = FS_FTell( f );
|
||||
|
||||
// change negative offsets into FS_SEEK_SET
|
||||
if (offset < 0) {
|
||||
switch (origin) {
|
||||
case FS_SEEK_END:
|
||||
remainder = fsh[f].zipFileLen + offset;
|
||||
break;
|
||||
if ( offset < 0 ) {
|
||||
switch( origin ) {
|
||||
case FS_SEEK_END:
|
||||
remainder = fsh[f].zipFileLen + offset;
|
||||
break;
|
||||
|
||||
case FS_SEEK_CUR:
|
||||
remainder = currentPosition + offset;
|
||||
break;
|
||||
case FS_SEEK_CUR:
|
||||
remainder = currentPosition + offset;
|
||||
break;
|
||||
|
||||
case FS_SEEK_SET:
|
||||
default:
|
||||
remainder = 0;
|
||||
break;
|
||||
case FS_SEEK_SET:
|
||||
default:
|
||||
remainder = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (remainder < 0) {
|
||||
if ( remainder < 0 ) {
|
||||
remainder = 0;
|
||||
}
|
||||
|
||||
origin = FS_SEEK_SET;
|
||||
}
|
||||
else {
|
||||
if (origin == FS_SEEK_END) {
|
||||
} else {
|
||||
if ( origin == FS_SEEK_END ) {
|
||||
remainder = fsh[f].zipFileLen - currentPosition + offset;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
remainder = offset;
|
||||
}
|
||||
}
|
||||
|
||||
switch (origin) {
|
||||
case FS_SEEK_SET:
|
||||
if (remainder == currentPosition) {
|
||||
switch( origin ) {
|
||||
case FS_SEEK_SET:
|
||||
if ( remainder == currentPosition ) {
|
||||
return 0;
|
||||
}
|
||||
unzSetOffset(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);
|
||||
unzOpenCurrentFile(fsh[f].handleFiles.file.z);
|
||||
//fallthrough
|
||||
|
||||
case FS_SEEK_END:
|
||||
case FS_SEEK_CUR:
|
||||
while( remainder > PK3_SEEK_BUFFER_SIZE ) {
|
||||
FS_Read( buffer, PK3_SEEK_BUFFER_SIZE, f );
|
||||
remainder -= PK3_SEEK_BUFFER_SIZE;
|
||||
}
|
||||
FS_Read( buffer, remainder, f );
|
||||
return 0;
|
||||
}
|
||||
unzSetOffset(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);
|
||||
unzOpenCurrentFile(fsh[f].handleFiles.file.z);
|
||||
//fallthrough
|
||||
|
||||
case FS_SEEK_END:
|
||||
case FS_SEEK_CUR:
|
||||
while (remainder > PK3_SEEK_BUFFER_SIZE) {
|
||||
FS_Read(buffer, PK3_SEEK_BUFFER_SIZE, f);
|
||||
remainder -= PK3_SEEK_BUFFER_SIZE;
|
||||
}
|
||||
FS_Read(buffer, remainder, f);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
Com_Error(ERR_FATAL, "Bad origin in FS_Seek");
|
||||
return -1;
|
||||
default:
|
||||
Com_Error( ERR_FATAL, "Bad origin in FS_Seek" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
FILE *file;
|
||||
file = FS_FileForHandle(f);
|
||||
switch (origin) {
|
||||
switch( origin ) {
|
||||
case FS_SEEK_CUR:
|
||||
_origin = SEEK_CUR;
|
||||
break;
|
||||
|
@ -1890,13 +1791,12 @@ int FS_Seek( fileHandle_t f, long offset, fsOrigin_t origin ) {
|
|||
_origin = SEEK_SET;
|
||||
break;
|
||||
default:
|
||||
Com_Error(ERR_FATAL, "Bad origin in FS_Seek");
|
||||
Com_Error( ERR_FATAL, "Bad origin in FS_Seek" );
|
||||
break;
|
||||
}
|
||||
|
||||
return fseek(file, offset, _origin);
|
||||
return fseek( file, offset, _origin );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
5058
code/qcommon/unzip.c
5058
code/qcommon/unzip.c
File diff suppressed because it is too large
Load diff
|
@ -1,259 +1,200 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 1999-2005 Id Software, Inc.
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
This file is part of Quake III Arena source code.
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
Quake III Arena source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Quake III Arena source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Quake III Arena source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
#include "../zlib/zlib.h"
|
||||
#else
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
#include "ioapi.h"
|
||||
|
||||
#define NOUNCRYPT
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef void* unzFile;
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
unsigned int tm_sec; /* seconds after the minute - [0,59] */
|
||||
unsigned int tm_min; /* minutes after the hour - [0,59] */
|
||||
unsigned int tm_hour; /* hours since midnight - [0,23] */
|
||||
unsigned int tm_mday; /* day of the month - [1,31] */
|
||||
unsigned int tm_mon; /* months since January - [0,11] */
|
||||
unsigned int tm_year; /* years - [1980..2044] */
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
unsigned long number_entry; /* total number of entries in the central dir on this disk */
|
||||
unsigned long size_comment; /* size of the global comment of the zipfile */
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
unsigned long version; /* version made by 2 unsigned chars */
|
||||
unsigned long version_needed; /* version needed to extract 2 unsigned chars */
|
||||
unsigned long flag; /* general purpose bit flag 2 unsigned chars */
|
||||
unsigned long compression_method; /* compression method 2 unsigned chars */
|
||||
unsigned long dosDate; /* last mod file date in Dos fmt 4 unsigned chars */
|
||||
unsigned long crc; /* crc-32 4 unsigned chars */
|
||||
unsigned long compressed_size; /* compressed size 4 unsigned chars */
|
||||
unsigned long uncompressed_size; /* uncompressed size 4 unsigned chars */
|
||||
unsigned long size_filename; /* filename length 2 unsigned chars */
|
||||
unsigned long size_file_extra; /* extra field length 2 unsigned chars */
|
||||
unsigned long size_file_comment; /* file comment length 2 unsigned chars */
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
unsigned long disk_num_start; /* disk number start 2 unsigned chars */
|
||||
unsigned long internal_fa; /* internal file attributes 2 unsigned chars */
|
||||
unsigned long external_fa; /* external file attributes 4 unsigned chars */
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
/* unz_file_info_interntal contain internal info about a file in zipfile*/
|
||||
typedef struct unz_file_info_internal_s
|
||||
{
|
||||
unsigned long offset_curfile;/* relative offset of static header 4 unsigned chars */
|
||||
} unz_file_info_internal;
|
||||
|
||||
typedef void* (*alloc_func) (void* opaque, unsigned int items, unsigned int size);
|
||||
typedef void (*free_func) (void* opaque, void* address);
|
||||
|
||||
struct internal_state;
|
||||
|
||||
typedef struct z_stream_s {
|
||||
unsigned char *next_in; /* next input unsigned char */
|
||||
unsigned int avail_in; /* number of unsigned chars available at next_in */
|
||||
unsigned long total_in; /* total nb of input unsigned chars read so */
|
||||
|
||||
unsigned char *next_out; /* next output unsigned char should be put there */
|
||||
unsigned int avail_out; /* remaining free space at next_out */
|
||||
unsigned long total_out; /* total nb of unsigned chars output so */
|
||||
|
||||
char *msg; /* last error message, NULL if no error */
|
||||
struct internal_state *state; /* not visible by applications */
|
||||
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
free_func zfree; /* used to free the internal state */
|
||||
unsigned char* opaque; /* private data object passed to zalloc and zfree */
|
||||
|
||||
int data_type; /* best guess about the data type: ascii or binary */
|
||||
unsigned long adler; /* adler32 value of the uncompressed data */
|
||||
unsigned long reserved; /* reserved for future use */
|
||||
} z_stream;
|
||||
|
||||
typedef z_stream *z_streamp;
|
||||
|
||||
|
||||
/* file_in_zip_read_info_s contain internal information about a file in zipfile,
|
||||
when reading and decompress it */
|
||||
typedef struct
|
||||
{
|
||||
char *read_buffer; /* internal buffer for compressed data */
|
||||
z_stream stream; /* zLib stream structure for inflate */
|
||||
|
||||
unsigned long pos_in_zipfile; /* position in unsigned char on the zipfile, for fseek*/
|
||||
unsigned long stream_initialised; /* flag set if stream structure is initialised*/
|
||||
|
||||
unsigned long offset_local_extrafield;/* offset of the static extra field */
|
||||
unsigned int size_local_extrafield;/* size of the static extra field */
|
||||
unsigned long pos_local_extrafield; /* position in the static extra field in read*/
|
||||
|
||||
unsigned long crc32; /* crc32 of all data uncompressed */
|
||||
unsigned long crc32_wait; /* crc32 we must obtain after decompress all */
|
||||
unsigned long rest_read_compressed; /* number of unsigned char to be decompressed */
|
||||
unsigned long rest_read_uncompressed;/*number of unsigned char to be obtained after decomp*/
|
||||
FILE* file; /* io structore of the zipfile */
|
||||
unsigned long compression_method; /* compression method (0==store) */
|
||||
unsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/
|
||||
} file_in_zip_read_info_s;
|
||||
|
||||
|
||||
/* unz_s contain internal information about the zipfile
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
FILE* file; /* io structore of the zipfile */
|
||||
unz_global_info gi; /* public global information */
|
||||
unsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/
|
||||
unsigned long num_file; /* number of the current file in the zipfile*/
|
||||
unsigned long pos_in_central_dir; /* pos of the current file in the central dir*/
|
||||
unsigned long current_file_ok; /* flag about the usability of the current file*/
|
||||
unsigned long central_pos; /* position of the beginning of the central dir*/
|
||||
|
||||
unsigned long size_central_dir; /* size of the central directory */
|
||||
unsigned long offset_central_dir; /* offset of start of central directory with
|
||||
respect to the starting disk number */
|
||||
|
||||
unz_file_info cur_file_info; /* public info about the current file in zip*/
|
||||
unz_file_info_internal cur_file_info_internal; /* private info about it*/
|
||||
file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
|
||||
file if we are decompressing it */
|
||||
unsigned char* tmpFile;
|
||||
int tmpPos,tmpSize;
|
||||
} unz_s;
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
#define UNZ_CASESENSITIVE 1
|
||||
#define UNZ_NOTCASESENSITIVE 2
|
||||
#define UNZ_OSDEFAULTCASE 0
|
||||
|
||||
extern int unzStringFileNameCompare (const char* fileName1, const char* fileName2, int iCaseSensitivity);
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
extern unzFile unzOpen (const char *path);
|
||||
extern unzFile unzReOpen (const char* path, unzFile file);
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||
"zlib/zlib111.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on a Unix computer
|
||||
"zlib/zlib113.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is an unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern int unzClose (unzFile file);
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info);
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int unzGetGlobalComment (unzFile file, char *szComment, unsigned long uSizeBuf);
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of unsigned char copied or an error code <0
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int unzGoToFirstFile (unzFile file);
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int unzGoToNextFile (unzFile file);
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int unzGetCurrentFileInfoPosition (unzFile file, unsigned long *pos );
|
||||
|
||||
/*
|
||||
Get the position of the info of the current file in the zip.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int unzSetCurrentFileInfoPosition (unzFile file, unsigned long pos );
|
||||
|
||||
/*
|
||||
Set the position of the info of the current file in the zip.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity);
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
@ -264,19 +205,44 @@ extern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensiti
|
|||
*/
|
||||
|
||||
|
||||
extern int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char *szFileName, unsigned long fileNameBufferSize, void *extraField, unsigned long extraFieldBufferSize, char *szComment, unsigned long commentBufferSize);
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -284,59 +250,81 @@ extern int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char
|
|||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int unzOpenCurrentFile (unzFile file);
|
||||
|
||||
/*
|
||||
Returns success if the current file is open
|
||||
*/
|
||||
extern qboolean unzIsCurrentFileOpen (unzFile file);
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int unzCloseCurrentFile (unzFile file);
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char* password));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
|
||||
extern int unzReadCurrentFile (unzFile file, void* buf, unsigned len);
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read unsigned chars from the current file (opened by unzOpenCurrentFile)
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of unsigned char copied if somes unsigned chars are copied
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern long unztell (unzFile file);
|
||||
|
||||
/*
|
||||
Seek to the specified offset according to the origin in uncompressed data
|
||||
*/
|
||||
|
||||
extern long unzseek(unzFile file, long int offset, int origin);
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int unzeof (unzFile file);
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int unzGetLocalExtrafield (unzFile file, void* buf, unsigned len);
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
|
@ -345,17 +333,23 @@ extern int unzGetLocalExtrafield (unzFile file, void* buf, unsigned len);
|
|||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of unsigned chars copied in buf, or (if <0)
|
||||
the error code
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern long unzGetOffset(unzFile file);
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int unzSetOffset(unzFile file, long pos);
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
|
|
1357
code/zlib/zlib.h
Normal file
1357
code/zlib/zlib.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue