diff options
author | Max Horn | 2008-09-23 10:08:45 +0000 |
---|---|---|
committer | Max Horn | 2008-09-23 10:08:45 +0000 |
commit | 20aea4e5fa8308a77450fa8c1584a78c60671364 (patch) | |
tree | bca4a287da3b287409202552ffb879566904ecc9 | |
parent | 9216eeabce6181398435c68d5225205fbb4f7111 (diff) | |
download | scummvm-rg350-20aea4e5fa8308a77450fa8c1584a78c60671364.tar.gz scummvm-rg350-20aea4e5fa8308a77450fa8c1584a78c60671364.tar.bz2 scummvm-rg350-20aea4e5fa8308a77450fa8c1584a78c60671364.zip |
cleanup
svn-id: r34633
-rw-r--r-- | common/unzip.cpp | 278 |
1 files changed, 72 insertions, 206 deletions
diff --git a/common/unzip.cpp b/common/unzip.cpp index a4cd4d31fc..1f70996c39 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -73,10 +73,6 @@ #ifdef USE_ZLIB -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifdef __SYMBIAN32__ #include <zlib\zlib.h> #else @@ -86,27 +82,6 @@ #include "common/unzip.h" #include "common/file.h" -#ifdef STDC -# include <stddef.h> -# include <string.h> -# include <stdlib.h> -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include <errno.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __SYMBIAN32__ -#include <zlib\zlib.h> -#else -#include <zlib.h> -#endif - #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ @@ -127,8 +102,7 @@ typedef voidp unzFile; #define UNZ_CRCERROR (-105) /* tm_unz contain date/time info */ -typedef struct tm_unz_s -{ +typedef struct { 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] */ @@ -139,8 +113,7 @@ typedef struct tm_unz_s /* 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 -{ +typedef struct { 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 */ @@ -148,8 +121,7 @@ typedef struct unz_global_info_s /* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_info_s -{ +typedef struct { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ @@ -169,9 +141,9 @@ typedef struct unz_file_info_s tm_unz tmu_date; } unz_file_info; -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, +int unzStringFileNameCompare(const char* fileName1, const char* fileName2, - int iCaseSensitivity)); + int iCaseSensitivity); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) @@ -182,7 +154,7 @@ extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, */ -extern unzFile ZEXPORT unzOpen OF((const char *path)); +unzFile unzOpen(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 @@ -193,24 +165,22 @@ extern unzFile ZEXPORT unzOpen OF((const char *path)); of this unzip package. */ -extern int ZEXPORT unzClose OF((unzFile file)); +int unzClose(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 ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); +int unzGetGlobalInfo(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 ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); +int unzGetGlobalComment(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. @@ -221,22 +191,20 @@ extern int ZEXPORT unzGetGlobalComment OF((unzFile file, /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +int unzGoToFirstFile(unzFile file); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +int unzGoToNextFile(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 ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); +int unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare @@ -247,14 +215,14 @@ extern int ZEXPORT unzLocateFile OF((unzFile file, */ -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, +int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, - uLong commentBufferSize)); + uLong commentBufferSize); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about @@ -273,22 +241,20 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, from it, and close it (you can close it before reading all the file) */ -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +int unzOpenCurrentFile(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 ZEXPORT unzCloseCurrentFile OF((unzFile file)); +int unzCloseCurrentFile(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 ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); +int unzReadCurrentFile(unzFile file, voidp buf, unsigned len); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied @@ -300,19 +266,17 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ -extern z_off_t ZEXPORT unztell OF((unzFile file)); +z_off_t unztell(unzFile file); /* Give the current position in uncompressed data */ -extern int ZEXPORT unzeof OF((unzFile file)); +int unzeof(unzFile file); /* return 1 if the end of file was reached, 0 elsewhere */ -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); +int unzGetLocalExtrafield(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 @@ -326,19 +290,6 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, the error code */ -#ifdef __cplusplus -} -#endif - - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - - - #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ !defined(CASESENSITIVITYDEFAULT_NO) #define CASESENSITIVITYDEFAULT_NO @@ -353,45 +304,22 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, #define UNZ_MAXFILENAMEINZIP (256) #endif -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - const char unz_copyright[] = " unzip 0.15 Copyright 1998 Gilles Vollant "; /* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info_internal_s -{ +typedef struct { uLong offset_curfile;/* relative offset of local header 4 bytes */ } unz_file_info_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, when reading and decompress it */ -typedef struct -{ +typedef struct { char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ @@ -414,8 +342,7 @@ typedef struct /* unz_s contain internal information about the zipfile */ -typedef struct -{ +typedef struct { Common::File file; /* io structore of the zipfile */ unz_global_info gi; /* public global information */ uLong byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx)*/ @@ -441,14 +368,11 @@ typedef struct */ -/*local int unzlocal_getByte(Common::File &fin, int *pi) -{ +/*static int unzlocal_getByte(Common::File &fin, int *pi) { unsigned char c = fin.readByte(); *pi = (int)c; return UNZ_OK; - } - else - { + } else { if (fin.ioFailed()) return UNZ_ERRNO; else @@ -460,39 +384,16 @@ typedef struct /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ -local int unzlocal_getShort (Common::File &fin, uLong *pX) -{ +static int unzlocal_getShort(Common::File &fin, uLong *pX) { *pX = fin.readUint16LE(); return UNZ_OK; } -local int unzlocal_getLong (Common::File &fin, uLong *pX) -{ +static int unzlocal_getLong(Common::File &fin, uLong *pX) { *pX = fin.readUint32LE(); return UNZ_OK; } -/* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) { - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1<c2) - return -1; - if (c1>c2) - return 1; - } -} - #ifdef CASESENSITIVITYDEFAULT_NO #define CASESENSITIVITYDEFAULTVALUE 2 @@ -500,10 +401,6 @@ local int strcmpcasenosensitive_internal (const char* fileName1, const char* fil #define CASESENSITIVITYDEFAULTVALUE 1 #endif -#ifndef STRCMPCASENOSENTIVEFUNCTION -#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal -#endif - /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) @@ -513,15 +410,14 @@ local int strcmpcasenosensitive_internal (const char* fileName1, const char* fil (like 1 on Unix, 2 on Windows) */ -extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, const char* fileName2, int iCaseSensitivity) -{ +int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int iCaseSensitivity) { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); + return scumm_stricmp(fileName1,fileName2); } #define BUFREADCOMMENT (0x400) @@ -530,8 +426,7 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, const char* Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local uLong unzlocal_SearchCentralDir(Common::File &fin) -{ +static uLong unzlocal_SearchCentralDir(Common::File &fin) { unsigned char* buf; uLong uSizeFile; uLong uBackRead; @@ -545,13 +440,12 @@ local uLong unzlocal_SearchCentralDir(Common::File &fin) if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + buf = (unsigned char*)malloc(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; - while (uBackRead<uMaxBack) - { + while (uBackRead<uMaxBack) { uLong uReadSize,uReadPos ; int i; if (uBackRead+BUFREADCOMMENT>uMaxBack) @@ -580,7 +474,7 @@ local uLong unzlocal_SearchCentralDir(Common::File &fin) if (uPosFound!=0) break; } - TRYFREE(buf); + free(buf); return uPosFound; } @@ -593,8 +487,7 @@ local uLong unzlocal_SearchCentralDir(Common::File &fin) Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ -extern unzFile ZEXPORT unzOpen (const char *path) -{ +unzFile unzOpen(const char *path) { unz_s *us = new unz_s; uLong central_pos,uL; @@ -683,8 +576,7 @@ extern unzFile ZEXPORT unzOpen (const char *path) If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzClose (unzFile file) -{ +int unzClose(unzFile file) { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; @@ -703,8 +595,7 @@ extern int ZEXPORT unzClose (unzFile file) 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 ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info) -{ +int unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info) { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; @@ -717,8 +608,7 @@ extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info /* Translate date/time from Dos format to tm_unz (readable more easilty) */ -local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm) -{ +static void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm) { uLong uDate; uDate = (uLong)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; @@ -733,7 +623,7 @@ local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm) /* Get Info about the current file in the zipfile, with internal only info */ -local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, +static int unzlocal_GetCurrentFileInfoInternal(unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, @@ -742,9 +632,9 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, void *extraField, uLong extraFieldBufferSize, char *szComment, - uLong commentBufferSize)); + uLong commentBufferSize); -local int unzlocal_GetCurrentFileInfoInternal (unzFile file, +static int unzlocal_GetCurrentFileInfoInternal(unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, @@ -767,8 +657,7 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file, /* we check the magic */ - if (err==UNZ_OK) - { + if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) @@ -823,15 +712,12 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file, err=UNZ_ERRNO; lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { + if ((err==UNZ_OK) && (szFileName!=NULL)) { uLong uSizeRead ; - if (file_info.size_filename<fileNameBufferSize) - { + if (file_info.size_filename<fileNameBufferSize) { *(szFileName+file_info.size_filename)='\0'; uSizeRead = file_info.size_filename; - } - else + } else uSizeRead = fileNameBufferSize; if ((file_info.size_filename>0) && (fileNameBufferSize>0)) @@ -841,16 +727,14 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file, } - if ((err==UNZ_OK) && (extraField!=NULL)) - { + if ((err==UNZ_OK) && (extraField!=NULL)) { uLong uSizeRead ; if (file_info.size_file_extra<extraFieldBufferSize) uSizeRead = file_info.size_file_extra; else uSizeRead = extraFieldBufferSize; - if (lSeek!=0) - { + if (lSeek!=0) { s->file.seek(lSeek, SEEK_CUR); if (s->file.ioFailed()) lSeek=0; @@ -866,19 +750,15 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file, lSeek+=file_info.size_file_extra; - if ((err==UNZ_OK) && (szComment!=NULL)) - { + if ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; - if (file_info.size_file_comment<commentBufferSize) - { + if (file_info.size_file_comment<commentBufferSize) { *(szComment+file_info.size_file_comment)='\0'; uSizeRead = file_info.size_file_comment; - } - else + } else uSizeRead = commentBufferSize; - if (lSeek!=0) - { + if (lSeek!=0) { s->file.seek(lSeek, SEEK_CUR); if (s->file.ioFailed()) lSeek=0; @@ -889,8 +769,7 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file, if (s->file.read(szComment,(uInt)uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek+=file_info.size_file_comment - uSizeRead; - } - else + } else lSeek+=file_info.size_file_comment; if ((err==UNZ_OK) && (pfile_info!=NULL)) @@ -909,7 +788,7 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file, No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, +int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, @@ -925,8 +804,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ -extern int ZEXPORT unzGoToFirstFile (unzFile file) -{ +int unzGoToFirstFile(unzFile file) { int err=UNZ_OK; unz_s* s; if (file==NULL) @@ -947,8 +825,7 @@ extern int ZEXPORT unzGoToFirstFile (unzFile 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 ZEXPORT unzGoToNextFile (unzFile file) -{ +int unzGoToNextFile(unzFile file) { unz_s* s; int err; @@ -979,8 +856,7 @@ extern int ZEXPORT unzGoToNextFile (unzFile file) UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ -extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) -{ +int unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) { unz_s* s; int err; @@ -1004,8 +880,7 @@ extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCas err = unzGoToFirstFile(file); - while (err == UNZ_OK) - { + while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; unzGetCurrentFileInfo(file,NULL, szCurrentFileName,sizeof(szCurrentFileName)-1, @@ -1029,10 +904,9 @@ extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCas store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ -local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar, +static int unzlocal_CheckCurrentFileCoherencyHeader(unz_s* s, uInt* piSizeVar, uLong *poffset_local_extrafield, - uInt *psize_local_extrafield) -{ + uInt *psize_local_extrafield) { uLong uMagic,uData,uFlags; uLong size_filename; uLong size_extra_field; @@ -1048,8 +922,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar, return UNZ_ERRNO; - if (err==UNZ_OK) - { + if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) @@ -1118,8 +991,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar, Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ -extern int ZEXPORT unzOpenCurrentFile (unzFile file) -{ +int unzOpenCurrentFile (unzFile file) { int err=UNZ_OK; int Store; uInt iSizeVar; @@ -1141,19 +1013,19 @@ extern int ZEXPORT unzOpenCurrentFile (unzFile file) &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; - pfile_in_zip_read_info = (file_in_zip_read_info_s*) ALLOC(sizeof(file_in_zip_read_info_s)); + pfile_in_zip_read_info = (file_in_zip_read_info_s*) malloc(sizeof(file_in_zip_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->read_buffer=(char*)malloc(UNZ_BUFSIZE); pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; pfile_in_zip_read_info->pos_local_extrafield=0; if (pfile_in_zip_read_info->read_buffer==NULL) { - TRYFREE(pfile_in_zip_read_info); + free(pfile_in_zip_read_info); return UNZ_INTERNALERROR; } @@ -1213,8 +1085,7 @@ extern int ZEXPORT unzOpenCurrentFile (unzFile file) return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ -extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) -{ +int unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { int err=UNZ_OK; uInt iRead = 0; unz_s* s; @@ -1326,8 +1197,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) /* Give the current position in uncompressed data */ -extern z_off_t ZEXPORT unztell (unzFile file) -{ +z_off_t unztell(unzFile file) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) @@ -1345,8 +1215,7 @@ extern z_off_t ZEXPORT unztell (unzFile file) /* return 1 if the end of file was reached, 0 elsewhere */ -extern int ZEXPORT unzeof (unzFile file) -{ +int unzeof(unzFile file) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) @@ -1377,8 +1246,7 @@ extern int ZEXPORT unzeof (unzFile file) the return value is the number of bytes copied in buf, or (if <0) the error code */ -extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len) -{ +int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uInt read_now; @@ -1421,8 +1289,7 @@ extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len) Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ -extern int ZEXPORT unzCloseCurrentFile (unzFile file) -{ +int unzCloseCurrentFile(unzFile file) { int err=UNZ_OK; unz_s* s; @@ -1442,13 +1309,13 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file) } - TRYFREE(pfile_in_zip_read_info->read_buffer); + free(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised) inflateEnd(&pfile_in_zip_read_info->stream); pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); + free(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; @@ -1461,8 +1328,7 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file) uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ -extern int ZEXPORT unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf) -{ +int unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf) { unz_s* s; uLong uReadThis ; if (file==NULL) |