rlm@1: /* unzip.h -- IO for uncompress .zip files using zlib rlm@1: Version 0.15 beta, Mar 19th, 1998, rlm@1: rlm@1: Copyright (C) 1998 Gilles Vollant rlm@1: rlm@1: This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g rlm@1: WinZip, InfoZip tools and compatible. rlm@1: Encryption and multi volume ZipFile (span) are not supported. rlm@1: Old compressions used by old PKZip 1.x are not supported rlm@1: rlm@1: THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE rlm@1: CAN CHANGE IN FUTURE VERSION !! rlm@1: I WAIT FEEDBACK at mail info@winimage.com rlm@1: Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution rlm@1: rlm@1: Condition of use and distribution are the same than zlib : rlm@1: rlm@1: This software is provided 'as-is', without any express or implied rlm@1: warranty. In no event will the authors be held liable for any damages rlm@1: arising from the use of this software. rlm@1: rlm@1: Permission is granted to anyone to use this software for any purpose, rlm@1: including commercial applications, and to alter it and redistribute it rlm@1: freely, subject to the following restrictions: rlm@1: rlm@1: 1. The origin of this software must not be misrepresented; you must not rlm@1: claim that you wrote the original software. If you use this software rlm@1: in a product, an acknowledgment in the product documentation would be rlm@1: appreciated but is not required. rlm@1: 2. Altered source versions must be plainly marked as such, and must not be rlm@1: misrepresented as being the original software. rlm@1: 3. This notice may not be removed or altered from any source distribution. rlm@1: rlm@1: rlm@1: */ rlm@1: /* for more info about .ZIP format, see rlm@1: ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip rlm@1: PkWare has also a specification at : rlm@1: ftp://ftp.pkware.com/probdesc.zip */ rlm@1: rlm@1: #ifndef _unz_H rlm@1: #define _unz_H rlm@1: rlm@1: #ifdef __cplusplus rlm@1: extern "C" { rlm@1: #endif rlm@1: rlm@1: #ifndef _ZLIB_H rlm@1: #include "zlib.h" rlm@1: #endif rlm@1: rlm@1: #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) rlm@1: /* like the STRICT of WIN32, we define a pointer that cannot be converted rlm@1: from (void*) without cast */ rlm@1: typedef struct TagunzFile__ { int unused; } unzFile__; rlm@1: typedef unzFile__ *unzFile; rlm@1: #else rlm@1: typedef voidp unzFile; rlm@1: #endif rlm@1: rlm@1: rlm@1: #define UNZ_OK (0) rlm@1: #define UNZ_END_OF_LIST_OF_FILE (-100) rlm@1: #define UNZ_ERRNO (Z_ERRNO) rlm@1: #define UNZ_EOF (0) rlm@1: #define UNZ_PARAMERROR (-102) rlm@1: #define UNZ_BADZIPFILE (-103) rlm@1: #define UNZ_INTERNALERROR (-104) rlm@1: #define UNZ_CRCERROR (-105) rlm@1: rlm@1: /* tm_unz contain date/time info */ rlm@1: typedef struct tm_unz_s rlm@1: { rlm@1: uInt tm_sec; /* seconds after the minute - [0,59] */ rlm@1: uInt tm_min; /* minutes after the hour - [0,59] */ rlm@1: uInt tm_hour; /* hours since midnight - [0,23] */ rlm@1: uInt tm_mday; /* day of the month - [1,31] */ rlm@1: uInt tm_mon; /* months since January - [0,11] */ rlm@1: uInt tm_year; /* years - [1980..2044] */ rlm@1: } tm_unz; rlm@1: rlm@1: /* unz_global_info structure contain global data about the ZIPfile rlm@1: These data comes from the end of central dir */ rlm@1: typedef struct unz_global_info_s rlm@1: { rlm@1: uLong number_entry; /* total number of entries in rlm@1: the central dir on this disk */ rlm@1: uLong size_comment; /* size of the global comment of the zipfile */ rlm@1: } unz_global_info; rlm@1: rlm@1: rlm@1: /* unz_file_info contain information about a file in the zipfile */ rlm@1: typedef struct unz_file_info_s rlm@1: { rlm@1: uLong version; /* version made by 2 bytes */ rlm@1: uLong version_needed; /* version needed to extract 2 bytes */ rlm@1: uLong flag; /* general purpose bit flag 2 bytes */ rlm@1: uLong compression_method; /* compression method 2 bytes */ rlm@1: uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ rlm@1: uLong crc; /* crc-32 4 bytes */ rlm@1: uLong compressed_size; /* compressed size 4 bytes */ rlm@1: uLong uncompressed_size; /* uncompressed size 4 bytes */ rlm@1: uLong size_filename; /* filename length 2 bytes */ rlm@1: uLong size_file_extra; /* extra field length 2 bytes */ rlm@1: uLong size_file_comment; /* file comment length 2 bytes */ rlm@1: rlm@1: uLong disk_num_start; /* disk number start 2 bytes */ rlm@1: uLong internal_fa; /* internal file attributes 2 bytes */ rlm@1: uLong external_fa; /* external file attributes 4 bytes */ rlm@1: rlm@1: tm_unz tmu_date; rlm@1: } unz_file_info; rlm@1: rlm@1: extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, rlm@1: const char* fileName2, rlm@1: int iCaseSensitivity)); rlm@1: /* rlm@1: Compare two filename (fileName1,fileName2). rlm@1: If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) rlm@1: If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi rlm@1: or strcasecmp) rlm@1: If iCaseSenisivity = 0, case sensitivity is defaut of your operating system rlm@1: (like 1 on Unix, 2 on Windows) rlm@1: */ rlm@1: rlm@1: rlm@1: extern unzFile ZEXPORT unzOpen OF((const char *path)); rlm@1: /* rlm@1: Open a Zip file. path contain the full pathname (by example, rlm@1: on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer rlm@1: "zlib/zlib111.zip". rlm@1: If the zipfile cannot be opened (file don't exist or in not valid), the rlm@1: return value is NULL. rlm@1: Else, the return value is a unzFile Handle, usable with other function rlm@1: of this unzip package. rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzClose OF((unzFile file)); rlm@1: /* rlm@1: Close a ZipFile opened with unzipOpen. rlm@1: If there is files inside the .Zip opened with unzOpenCurrentFile (see later), rlm@1: these files MUST be closed with unzipCloseCurrentFile before call unzipClose. rlm@1: return UNZ_OK if there is no problem. */ rlm@1: rlm@1: extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, rlm@1: unz_global_info *pglobal_info)); rlm@1: /* rlm@1: Write info about the ZipFile in the *pglobal_info structure. rlm@1: No preparation of the structure is needed rlm@1: return UNZ_OK if there is no problem. */ rlm@1: rlm@1: rlm@1: extern int ZEXPORT unzGetGlobalComment OF((unzFile file, rlm@1: char *szComment, rlm@1: uLong uSizeBuf)); rlm@1: /* rlm@1: Get the global comment string of the ZipFile, in the szComment buffer. rlm@1: uSizeBuf is the size of the szComment buffer. rlm@1: return the number of byte copied or an error code <0 rlm@1: */ rlm@1: rlm@1: rlm@1: /***************************************************************************/ rlm@1: /* Unzip package allow you browse the directory of the zipfile */ rlm@1: rlm@1: extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); rlm@1: /* rlm@1: Set the current file of the zipfile to the first file. rlm@1: return UNZ_OK if there is no problem rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzGoToNextFile OF((unzFile file)); rlm@1: /* rlm@1: Set the current file of the zipfile to the next file. rlm@1: return UNZ_OK if there is no problem rlm@1: return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzLocateFile OF((unzFile file, rlm@1: const char *szFileName, rlm@1: int iCaseSensitivity)); rlm@1: /* rlm@1: Try locate the file szFileName in the zipfile. rlm@1: For the iCaseSensitivity signification, see unzStringFileNameCompare rlm@1: rlm@1: return value : rlm@1: UNZ_OK if the file is found. It becomes the current file. rlm@1: UNZ_END_OF_LIST_OF_FILE if the file is not found rlm@1: */ rlm@1: rlm@1: rlm@1: extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, rlm@1: unz_file_info *pfile_info, rlm@1: char *szFileName, rlm@1: uLong fileNameBufferSize, rlm@1: void *extraField, rlm@1: uLong extraFieldBufferSize, rlm@1: char *szComment, rlm@1: uLong commentBufferSize)); rlm@1: /* rlm@1: Get Info about the current file rlm@1: if pfile_info!=NULL, the *pfile_info structure will contain somes info about rlm@1: the current file rlm@1: if szFileName!=NULL, the filemane string will be copied in szFileName rlm@1: (fileNameBufferSize is the size of the buffer) rlm@1: if extraField!=NULL, the extra field information will be copied in extraField rlm@1: (extraFieldBufferSize is the size of the buffer). rlm@1: This is the Central-header version of the extra field rlm@1: if szComment!=NULL, the comment string of the file will be copied in szComment rlm@1: (commentBufferSize is the size of the buffer) rlm@1: */ rlm@1: rlm@1: /***************************************************************************/ rlm@1: /* for reading the content of the current zipfile, you can open it, read data rlm@1: from it, and close it (you can close it before reading all the file) rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); rlm@1: /* rlm@1: Open for reading data the current file in the zipfile. rlm@1: If there is no error, the return value is UNZ_OK. rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); rlm@1: /* rlm@1: Close the file in zip opened with unzOpenCurrentFile rlm@1: Return UNZ_CRCERROR if all the file was read but the CRC is not good rlm@1: */ rlm@1: rlm@1: rlm@1: extern int ZEXPORT unzReadCurrentFile OF((unzFile file, rlm@1: voidp buf, rlm@1: unsigned len)); rlm@1: /* rlm@1: Read bytes from the current file (opened by unzOpenCurrentFile) rlm@1: buf contain buffer where data must be copied rlm@1: len the size of buf. rlm@1: rlm@1: return the number of byte copied if somes bytes are copied rlm@1: return 0 if the end of file was reached rlm@1: return <0 with error code if there is an error rlm@1: (UNZ_ERRNO for IO error, or zLib error for uncompress error) rlm@1: */ rlm@1: rlm@1: extern z_off_t ZEXPORT unztell OF((unzFile file)); rlm@1: /* rlm@1: Give the current position in uncompressed data rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzeof OF((unzFile file)); rlm@1: /* rlm@1: return 1 if the end of file was reached, 0 elsewhere rlm@1: */ rlm@1: rlm@1: extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, rlm@1: voidp buf, rlm@1: unsigned len)); rlm@1: /* rlm@1: Read extra field from the current file (opened by unzOpenCurrentFile) rlm@1: This is the local-header version of the extra field (sometimes, there is rlm@1: more info in the local-header version than in the central-header) rlm@1: rlm@1: if buf==NULL, it return the size of the local extra field rlm@1: rlm@1: if buf!=NULL, len is the size of the buffer, the extra header is copied in rlm@1: buf. rlm@1: the return value is the number of bytes copied in buf, or (if <0) rlm@1: the error code rlm@1: */ rlm@1: rlm@1: #ifdef __cplusplus rlm@1: } rlm@1: #endif rlm@1: rlm@1: #endif /* _unz_H */