Improve portability of contrib/minizip.
This commit is contained in:
parent
506424c640
commit
0530dbcef9
@ -38,6 +38,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
|||||||
* unpredictable manner on 16-bit systems; not a problem
|
* unpredictable manner on 16-bit systems; not a problem
|
||||||
* with any known compiler so far, though */
|
* with any known compiler so far, though */
|
||||||
|
|
||||||
|
(void)pcrc_32_tab;
|
||||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
|||||||
|
|
||||||
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char* mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
@ -112,6 +113,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
|
|||||||
|
|
||||||
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char* mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
@ -131,6 +133,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
|
|||||||
|
|
||||||
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
uLong ret;
|
uLong ret;
|
||||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
@ -138,6 +141,7 @@ static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf,
|
|||||||
|
|
||||||
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
uLong ret;
|
uLong ret;
|
||||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
@ -145,6 +149,7 @@ static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const voi
|
|||||||
|
|
||||||
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
long ret;
|
long ret;
|
||||||
ret = ftell((FILE *)stream);
|
ret = ftell((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
@ -153,6 +158,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
|||||||
|
|
||||||
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
ZPOS64_T ret;
|
ZPOS64_T ret;
|
||||||
ret = FTELLO_FUNC((FILE *)stream);
|
ret = FTELLO_FUNC((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
@ -160,6 +166,7 @@ static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
|||||||
|
|
||||||
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
int fseek_origin=0;
|
int fseek_origin=0;
|
||||||
long ret;
|
long ret;
|
||||||
switch (origin)
|
switch (origin)
|
||||||
@ -183,6 +190,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
|||||||
|
|
||||||
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
int fseek_origin=0;
|
int fseek_origin=0;
|
||||||
long ret;
|
long ret;
|
||||||
switch (origin)
|
switch (origin)
|
||||||
@ -209,6 +217,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
|||||||
|
|
||||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
int ret;
|
int ret;
|
||||||
ret = fclose((FILE *)stream);
|
ret = fclose((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
@ -216,6 +225,7 @@ static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
|||||||
|
|
||||||
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
|
(void)opaque;
|
||||||
int ret;
|
int ret;
|
||||||
ret = ferror((FILE *)stream);
|
ret = ferror((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
@ -97,7 +98,8 @@ void change_file_date(filename,dosdate,tmu_date)
|
|||||||
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
#else
|
#else
|
||||||
#ifdef unix || __APPLE__
|
#if defined(unix) || defined(__APPLE__)
|
||||||
|
(void)dosdate;
|
||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
struct tm newdate;
|
struct tm newdate;
|
||||||
newdate.tm_sec = tmu_date.tm_sec;
|
newdate.tm_sec = tmu_date.tm_sec;
|
||||||
@ -136,7 +138,7 @@ int mymkdir(dirname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int makedir (newdir)
|
int makedir (newdir)
|
||||||
char *newdir;
|
const char *newdir;
|
||||||
{
|
{
|
||||||
char *buffer ;
|
char *buffer ;
|
||||||
char *p;
|
char *p;
|
||||||
@ -324,7 +326,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||||||
uInt size_buf;
|
uInt size_buf;
|
||||||
|
|
||||||
unz_file_info64 file_info;
|
unz_file_info64 file_info;
|
||||||
uLong ratio=0;
|
|
||||||
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||||
|
|
||||||
if (err!=UNZ_OK)
|
if (err!=UNZ_OK)
|
||||||
@ -481,7 +482,6 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
|||||||
uLong i;
|
uLong i;
|
||||||
unz_global_info64 gi;
|
unz_global_info64 gi;
|
||||||
int err;
|
int err;
|
||||||
FILE* fout=NULL;
|
|
||||||
|
|
||||||
err = unzGetGlobalInfo64(uf,&gi);
|
err = unzGetGlobalInfo64(uf,&gi);
|
||||||
if (err!=UNZ_OK)
|
if (err!=UNZ_OK)
|
||||||
@ -515,7 +515,6 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
|
|||||||
int opt_overwrite;
|
int opt_overwrite;
|
||||||
const char* password;
|
const char* password;
|
||||||
{
|
{
|
||||||
int err = UNZ_OK;
|
|
||||||
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
|
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
|
||||||
{
|
{
|
||||||
printf("file %s not found in the zipfile\n",filename);
|
printf("file %s not found in the zipfile\n",filename);
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
uLong filetime(f, tmzip, dt)
|
uLong filetime(f, tmzip, dt)
|
||||||
char *f; /* name of file to get info on */
|
const char *f; /* name of file to get info on */
|
||||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||||
uLong *dt; /* dostime */
|
uLong *dt; /* dostime */
|
||||||
{
|
{
|
||||||
@ -94,12 +94,13 @@ uLong filetime(f, tmzip, dt)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef unix || __APPLE__
|
#if defined(unix) || defined(__APPLE__)
|
||||||
uLong filetime(f, tmzip, dt)
|
uLong filetime(f, tmzip, dt)
|
||||||
char *f; /* name of file to get info on */
|
const char *f; /* name of file to get info on */
|
||||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||||
uLong *dt; /* dostime */
|
uLong *dt; /* dostime */
|
||||||
{
|
{
|
||||||
|
(void)dt;
|
||||||
int ret=0;
|
int ret=0;
|
||||||
struct stat s; /* results of stat() */
|
struct stat s; /* results of stat() */
|
||||||
struct tm* filedate;
|
struct tm* filedate;
|
||||||
@ -138,7 +139,7 @@ uLong filetime(f, tmzip, dt)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uLong filetime(f, tmzip, dt)
|
uLong filetime(f, tmzip, dt)
|
||||||
char *f; /* name of file to get info on */
|
const char *f; /* name of file to get info on */
|
||||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||||
uLong *dt; /* dostime */
|
uLong *dt; /* dostime */
|
||||||
{
|
{
|
||||||
@ -229,7 +230,7 @@ int isLargeFile(const char* filename)
|
|||||||
|
|
||||||
if(pFile != NULL)
|
if(pFile != NULL)
|
||||||
{
|
{
|
||||||
int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
|
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||||
pos = FTELLO_FUNC(pFile);
|
pos = FTELLO_FUNC(pFile);
|
||||||
|
|
||||||
printf("File : %s is %lld bytes\n", filename, pos);
|
printf("File : %s is %lld bytes\n", filename, pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user