mirror of https://github.com/madler/zlib
Clean up minizip to reduce warnings for testing.
Also fix Makefile test target and permit added compile options.
This commit is contained in:
parent
58ca4e57ce
commit
2014a993ad
|
@ -1,5 +1,5 @@
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-O -I../..
|
CFLAGS := $(CFLAGS) -O -I../..
|
||||||
|
|
||||||
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
|
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
|
||||||
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
|
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
|
||||||
|
@ -16,10 +16,14 @@ minizip: $(ZIP_OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
|
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
|
||||||
|
|
||||||
test: miniunz minizip
|
test: miniunz minizip
|
||||||
./minizip test readme.txt
|
@rm -f test.*
|
||||||
|
@echo hello hello hello > test.txt
|
||||||
|
./minizip test test.txt
|
||||||
./miniunz -l test.zip
|
./miniunz -l test.zip
|
||||||
mv readme.txt readme.old
|
@mv test.txt test.old
|
||||||
./miniunz test.zip
|
./miniunz test.zip
|
||||||
|
@cmp test.txt test.old
|
||||||
|
@rm -f test.*
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
/bin/rm -f *.o *~ minizip miniunz
|
/bin/rm -f *.o *~ minizip miniunz test.*
|
||||||
|
|
|
@ -78,24 +78,24 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
|
||||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||||
|
|
||||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
|
||||||
|
|
||||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||||
|
|
||||||
#define RAND_HEAD_LEN 12
|
#define RAND_HEAD_LEN 12
|
||||||
/* "last resort" source for second part of crypt seed pattern */
|
/* "last resort" source for second part of crypt seed pattern */
|
||||||
# ifndef ZCR_SEED2
|
# ifndef ZCR_SEED2
|
||||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
# define ZCR_SEED2 3141592654L /* use PI as default pattern */
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
static int crypthead(const char* passwd, /* password string */
|
static unsigned crypthead(const char* passwd, /* password string */
|
||||||
unsigned char* buf, /* where to write header */
|
unsigned char* buf, /* where to write header */
|
||||||
int bufSize,
|
int bufSize,
|
||||||
unsigned long* pkeys,
|
unsigned long* pkeys,
|
||||||
const z_crc_t* pcrc_32_tab,
|
const z_crc_t* pcrc_32_tab,
|
||||||
unsigned long crcForCrypting)
|
unsigned long crcForCrypting)
|
||||||
{
|
{
|
||||||
int n; /* index in random header */
|
unsigned n; /* index in random header */
|
||||||
int t; /* temporary */
|
int t; /* temporary */
|
||||||
int c; /* random byte */
|
int c; /* random byte */
|
||||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||||
|
|
|
@ -58,7 +58,7 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
|
||||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||||
if ((tell_uLong) == MAXU32)
|
if ((tell_uLong) == MAXU32)
|
||||||
return (ZPOS64_T)-1;
|
return (ZPOS64_T)-1;
|
||||||
else
|
else
|
||||||
|
@ -160,7 +160,7 @@ static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
ZPOS64_T ret;
|
ZPOS64_T ret;
|
||||||
ret = FTELLO_FUNC((FILE *)stream);
|
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
||||||
default: return -1;
|
default: return -1;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
|
if(FSEEKO_FUNC((FILE *)stream, (long)offset, fseek_origin) != 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
filename : the filename of the file where date/time must be modified
|
filename : the filename of the file where date/time must be modified
|
||||||
dosdate : the new date at the MSDos format (4 bytes)
|
dosdate : the new date at the MSDos format (4 bytes)
|
||||||
tmu_date : the SAME new date at the tm_unz format */
|
tmu_date : the SAME new date at the tm_unz format */
|
||||||
void change_file_date(filename,dosdate,tmu_date)
|
static void change_file_date(filename,dosdate,tmu_date)
|
||||||
const char *filename;
|
const char *filename;
|
||||||
uLong dosdate;
|
uLong dosdate;
|
||||||
tm_unz tmu_date;
|
tm_unz tmu_date;
|
||||||
|
@ -123,7 +123,7 @@ void change_file_date(filename,dosdate,tmu_date)
|
||||||
/* mymkdir and change_file_date are not 100 % portable
|
/* mymkdir and change_file_date are not 100 % portable
|
||||||
As I don't know well Unix, I wait feedback for the unix portion */
|
As I don't know well Unix, I wait feedback for the unix portion */
|
||||||
|
|
||||||
int mymkdir(dirname)
|
static int mymkdir(dirname)
|
||||||
const char* dirname;
|
const char* dirname;
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
@ -137,14 +137,14 @@ int mymkdir(dirname)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int makedir (newdir)
|
static int makedir (newdir)
|
||||||
const char *newdir;
|
const char *newdir;
|
||||||
{
|
{
|
||||||
char *buffer ;
|
char *buffer ;
|
||||||
char *p;
|
char *p;
|
||||||
int len = (int)strlen(newdir);
|
size_t len = strlen(newdir);
|
||||||
|
|
||||||
if (len <= 0)
|
if (len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer = (char*)malloc(len+1);
|
buffer = (char*)malloc(len+1);
|
||||||
|
@ -187,13 +187,13 @@ int makedir (newdir)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_banner()
|
static void do_banner()
|
||||||
{
|
{
|
||||||
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
|
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
|
||||||
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_help()
|
static void do_help()
|
||||||
{
|
{
|
||||||
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
|
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
|
||||||
" -e Extract without pathname (junk paths)\n" \
|
" -e Extract without pathname (junk paths)\n" \
|
||||||
|
@ -205,7 +205,7 @@ void do_help()
|
||||||
" -p extract crypted file using password\n\n");
|
" -p extract crypted file using password\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display64BitsSize(ZPOS64_T n, int size_char)
|
static void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||||
{
|
{
|
||||||
/* to avoid compatibility problem , we do here the conversion */
|
/* to avoid compatibility problem , we do here the conversion */
|
||||||
char number[21];
|
char number[21];
|
||||||
|
@ -233,7 +233,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||||
printf("%s",&number[pos_string]);
|
printf("%s",&number[pos_string]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_list(uf)
|
static int do_list(uf)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
{
|
{
|
||||||
uLong i;
|
uLong i;
|
||||||
|
@ -311,7 +311,7 @@ int do_list(uf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
const int* popt_extract_without_path;
|
const int* popt_extract_without_path;
|
||||||
int* popt_overwrite;
|
int* popt_overwrite;
|
||||||
|
@ -440,7 +440,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (err>0)
|
if (err>0)
|
||||||
if (fwrite(buf,err,1,fout)!=1)
|
if (fwrite(buf,(unsigned)err,1,fout)!=1)
|
||||||
{
|
{
|
||||||
printf("error in writing extracted file\n");
|
printf("error in writing extracted file\n");
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -473,7 +473,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
static int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
int opt_extract_without_path;
|
int opt_extract_without_path;
|
||||||
int opt_overwrite;
|
int opt_overwrite;
|
||||||
|
@ -508,7 +508,7 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
|
static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
const char* filename;
|
const char* filename;
|
||||||
int opt_extract_without_path;
|
int opt_extract_without_path;
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#define MAXFILENAME (256)
|
#define MAXFILENAME (256)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
uLong filetime(f, tmzip, dt)
|
static int filetime(f, tmzip, dt)
|
||||||
const 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 */
|
||||||
|
@ -95,7 +95,7 @@ uLong filetime(f, tmzip, dt)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if defined(unix) || defined(__APPLE__)
|
#if defined(unix) || defined(__APPLE__)
|
||||||
uLong filetime(f, tmzip, dt)
|
static int filetime(f, tmzip, dt)
|
||||||
const 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 */
|
||||||
|
@ -109,7 +109,7 @@ uLong filetime(f, tmzip, dt)
|
||||||
if (strcmp(f,"-")!=0)
|
if (strcmp(f,"-")!=0)
|
||||||
{
|
{
|
||||||
char name[MAXFILENAME+1];
|
char name[MAXFILENAME+1];
|
||||||
int len = strlen(f);
|
size_t len = strlen(f);
|
||||||
if (len > MAXFILENAME)
|
if (len > MAXFILENAME)
|
||||||
len = MAXFILENAME;
|
len = MAXFILENAME;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ uLong filetime(f, tmzip, dt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int check_exist_file(filename)
|
static int check_exist_file(filename)
|
||||||
const char* filename;
|
const char* filename;
|
||||||
{
|
{
|
||||||
FILE* ftestexist;
|
FILE* ftestexist;
|
||||||
|
@ -164,13 +164,13 @@ int check_exist_file(filename)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_banner()
|
static void do_banner()
|
||||||
{
|
{
|
||||||
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
|
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
|
||||||
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
|
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_help()
|
static void do_help()
|
||||||
{
|
{
|
||||||
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
||||||
" -o Overwrite existing file.zip\n" \
|
" -o Overwrite existing file.zip\n" \
|
||||||
|
@ -183,7 +183,7 @@ void do_help()
|
||||||
|
|
||||||
/* calculate the CRC32 of a file,
|
/* calculate the CRC32 of a file,
|
||||||
because to encrypt a file, we need known the CRC32 of the file before */
|
because to encrypt a file, we need known the CRC32 of the file before */
|
||||||
int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
|
static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
|
||||||
{
|
{
|
||||||
unsigned long calculate_crc=0;
|
unsigned long calculate_crc=0;
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
|
@ -200,7 +200,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
err = ZIP_OK;
|
err = ZIP_OK;
|
||||||
size_read = (int)fread(buf,1,size_buf,fin);
|
size_read = fread(buf,1,size_buf,fin);
|
||||||
if (size_read < size_buf)
|
if (size_read < size_buf)
|
||||||
if (feof(fin)==0)
|
if (feof(fin)==0)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +209,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_read>0)
|
if (size_read>0)
|
||||||
calculate_crc = crc32(calculate_crc,buf,size_read);
|
calculate_crc = crc32_z(calculate_crc,buf,size_read);
|
||||||
total_read += size_read;
|
total_read += size_read;
|
||||||
|
|
||||||
} while ((err == ZIP_OK) && (size_read>0));
|
} while ((err == ZIP_OK) && (size_read>0));
|
||||||
|
@ -222,7 +222,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isLargeFile(const char* filename)
|
static int isLargeFile(const char* filename)
|
||||||
{
|
{
|
||||||
int largeFile = 0;
|
int largeFile = 0;
|
||||||
ZPOS64_T pos = 0;
|
ZPOS64_T pos = 0;
|
||||||
|
@ -231,7 +231,7 @@ int isLargeFile(const char* filename)
|
||||||
if(pFile != NULL)
|
if(pFile != NULL)
|
||||||
{
|
{
|
||||||
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||||
pos = FTELLO_FUNC(pFile);
|
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
|
||||||
|
|
||||||
printf("File : %s is %lld bytes\n", filename, pos);
|
printf("File : %s is %lld bytes\n", filename, pos);
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ int main(argc,argv)
|
||||||
char filename_try[MAXFILENAME+16];
|
char filename_try[MAXFILENAME+16];
|
||||||
int zipok;
|
int zipok;
|
||||||
int err=0;
|
int err=0;
|
||||||
int size_buf=0;
|
size_t size_buf=0;
|
||||||
void* buf=NULL;
|
void* buf=NULL;
|
||||||
const char* password=NULL;
|
const char* password=NULL;
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ int main(argc,argv)
|
||||||
(strlen(argv[i]) == 2)))
|
(strlen(argv[i]) == 2)))
|
||||||
{
|
{
|
||||||
FILE * fin;
|
FILE * fin;
|
||||||
int size_read;
|
size_t size_read;
|
||||||
const char* filenameinzip = argv[i];
|
const char* filenameinzip = argv[i];
|
||||||
const char *savefilenameinzip;
|
const char *savefilenameinzip;
|
||||||
zip_fileinfo zi;
|
zip_fileinfo zi;
|
||||||
|
@ -473,7 +473,7 @@ int main(argc,argv)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
err = ZIP_OK;
|
err = ZIP_OK;
|
||||||
size_read = (int)fread(buf,1,size_buf,fin);
|
size_read = fread(buf,1,size_buf,fin);
|
||||||
if (size_read < size_buf)
|
if (size_read < size_buf)
|
||||||
if (feof(fin)==0)
|
if (feof(fin)==0)
|
||||||
{
|
{
|
||||||
|
@ -483,7 +483,7 @@ int main(argc,argv)
|
||||||
|
|
||||||
if (size_read>0)
|
if (size_read>0)
|
||||||
{
|
{
|
||||||
err = zipWriteInFileInZip (zf,buf,size_read);
|
err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
|
||||||
if (err<0)
|
if (err<0)
|
||||||
{
|
{
|
||||||
printf("error in writing %s in the zipfile\n",
|
printf("error in writing %s in the zipfile\n",
|
||||||
|
|
|
@ -455,7 +455,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||||
((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,13 +853,13 @@ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
|
||||||
{
|
{
|
||||||
ZPOS64_T uDate;
|
ZPOS64_T uDate;
|
||||||
uDate = (ZPOS64_T)(ulDosDate>>16);
|
uDate = (ZPOS64_T)(ulDosDate>>16);
|
||||||
ptm->tm_mday = (uInt)(uDate&0x1f) ;
|
ptm->tm_mday = (int)(uDate&0x1f) ;
|
||||||
ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
|
ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ;
|
||||||
ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
|
ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ;
|
||||||
|
|
||||||
ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
|
ptm->tm_hour = (int) ((ulDosDate &0xF800)/0x800);
|
||||||
ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
|
ptm->tm_min = (int) ((ulDosDate&0x7E0)/0x20) ;
|
||||||
ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
|
ptm->tm_sec = (int) (2*(ulDosDate&0x1f)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -993,7 +993,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
|
||||||
|
|
||||||
if (lSeek!=0)
|
if (lSeek!=0)
|
||||||
{
|
{
|
||||||
if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||||
lSeek=0;
|
lSeek=0;
|
||||||
else
|
else
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -1018,7 +1018,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
|
||||||
|
|
||||||
if (lSeek!=0)
|
if (lSeek!=0)
|
||||||
{
|
{
|
||||||
if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||||
lSeek=0;
|
lSeek=0;
|
||||||
else
|
else
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -1090,7 +1090,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
|
||||||
|
|
||||||
if (lSeek!=0)
|
if (lSeek!=0)
|
||||||
{
|
{
|
||||||
if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||||
lSeek=0;
|
lSeek=0;
|
||||||
else
|
else
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -1767,7 +1767,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
||||||
|
|
||||||
if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
|
if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
|
||||||
(pfile_in_zip_read_info->rest_read_compressed == 0))
|
(pfile_in_zip_read_info->rest_read_compressed == 0))
|
||||||
return (iRead==0) ? UNZ_EOF : iRead;
|
return (iRead==0) ? UNZ_EOF : (int)iRead;
|
||||||
|
|
||||||
if (pfile_in_zip_read_info->stream.avail_out <
|
if (pfile_in_zip_read_info->stream.avail_out <
|
||||||
pfile_in_zip_read_info->stream.avail_in)
|
pfile_in_zip_read_info->stream.avail_in)
|
||||||
|
@ -1874,14 +1874,14 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
||||||
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
|
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
|
||||||
|
|
||||||
if (err==Z_STREAM_END)
|
if (err==Z_STREAM_END)
|
||||||
return (iRead==0) ? UNZ_EOF : iRead;
|
return (iRead==0) ? UNZ_EOF : (int)iRead;
|
||||||
if (err!=Z_OK)
|
if (err!=Z_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err==Z_OK)
|
if (err==Z_OK)
|
||||||
return iRead;
|
return (int)iRead;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,12 @@ typedef voidp unzFile;
|
||||||
/* tm_unz contain date/time info */
|
/* tm_unz contain date/time info */
|
||||||
typedef struct tm_unz_s
|
typedef struct tm_unz_s
|
||||||
{
|
{
|
||||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
int tm_sec; /* seconds after the minute - [0,59] */
|
||||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
int tm_min; /* minutes after the hour - [0,59] */
|
||||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
int tm_hour; /* hours since midnight - [0,23] */
|
||||||
uInt tm_mday; /* day of the month - [1,31] */
|
int tm_mday; /* day of the month - [1,31] */
|
||||||
uInt tm_mon; /* months since January - [0,11] */
|
int tm_mon; /* months since January - [0,11] */
|
||||||
uInt tm_year; /* years - [1980..2044] */
|
int tm_year; /* years - [1980..2044] */
|
||||||
} tm_unz;
|
} tm_unz;
|
||||||
|
|
||||||
/* unz_global_info structure contain global data about the ZIPfile
|
/* unz_global_info structure contain global data about the ZIPfile
|
||||||
|
|
|
@ -158,7 +158,7 @@ typedef struct
|
||||||
#ifndef NOCRYPT
|
#ifndef NOCRYPT
|
||||||
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
||||||
const z_crc_t* pcrc_32_tab;
|
const z_crc_t* pcrc_32_tab;
|
||||||
int crypt_header_size;
|
unsigned crypt_header_size;
|
||||||
#endif
|
#endif
|
||||||
} curfile64_info;
|
} curfile64_info;
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
|
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte)
|
||||||
return ZIP_ERRNO;
|
return ZIP_ERRNO;
|
||||||
else
|
else
|
||||||
return ZIP_OK;
|
return ZIP_OK;
|
||||||
|
@ -337,8 +337,8 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
|
||||||
else if (year>=80)
|
else if (year>=80)
|
||||||
year-=80;
|
year-=80;
|
||||||
return
|
return
|
||||||
(uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
|
(uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||||
((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
(((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||||
// Signature "0x07064b50" Zip64 end of central directory locater
|
// Signature "0x07064b50" Zip64 end of central directory locater
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +637,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||||
return relativeOffset;
|
return relativeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
local int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||||
{
|
{
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||||
|
@ -955,7 +955,7 @@ extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)
|
||||||
return zipOpen3(pathname,append,NULL,NULL);
|
return zipOpen3(pathname,append,NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
||||||
{
|
{
|
||||||
/* write the local header */
|
/* write the local header */
|
||||||
int err;
|
int err;
|
||||||
|
@ -1034,8 +1034,8 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
|
||||||
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
|
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
|
||||||
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
|
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
|
||||||
|
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2);
|
||||||
|
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
|
||||||
|
@ -1516,7 +1516,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
|
||||||
zip64_internal* zi;
|
zip64_internal* zi;
|
||||||
ZPOS64_T compressed_size;
|
ZPOS64_T compressed_size;
|
||||||
uLong invalidValue = 0xffffffff;
|
uLong invalidValue = 0xffffffff;
|
||||||
short datasize = 0;
|
unsigned datasize = 0;
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
|
@ -1752,7 +1752,7 @@ extern int ZEXPORT zipCloseFileInZip (zipFile file)
|
||||||
return zipCloseFileInZipRaw (file,0,0);
|
return zipCloseFileInZipRaw (file,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
|
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
|
||||||
|
@ -1774,7 +1774,7 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
|
|
||||||
|
@ -1813,7 +1813,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
|
|
||||||
|
@ -1861,7 +1861,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
local int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
uInt size_global_comment = 0;
|
uInt size_global_comment = 0;
|
||||||
|
@ -1962,7 +1962,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
||||||
if(pData == NULL || *dataLen < 4)
|
if(pData == NULL || *dataLen < 4)
|
||||||
return ZIP_PARAMERROR;
|
return ZIP_PARAMERROR;
|
||||||
|
|
||||||
pNewHeader = (char*)ALLOC(*dataLen);
|
pNewHeader = (char*)ALLOC((unsigned)*dataLen);
|
||||||
pTmp = pNewHeader;
|
pTmp = pNewHeader;
|
||||||
|
|
||||||
while(p < (pData + *dataLen))
|
while(p < (pData + *dataLen))
|
||||||
|
|
|
@ -88,12 +88,12 @@ typedef voidp zipFile;
|
||||||
/* tm_zip contain date/time info */
|
/* tm_zip contain date/time info */
|
||||||
typedef struct tm_zip_s
|
typedef struct tm_zip_s
|
||||||
{
|
{
|
||||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
int tm_sec; /* seconds after the minute - [0,59] */
|
||||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
int tm_min; /* minutes after the hour - [0,59] */
|
||||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
int tm_hour; /* hours since midnight - [0,23] */
|
||||||
uInt tm_mday; /* day of the month - [1,31] */
|
int tm_mday; /* day of the month - [1,31] */
|
||||||
uInt tm_mon; /* months since January - [0,11] */
|
int tm_mon; /* months since January - [0,11] */
|
||||||
uInt tm_year; /* years - [1980..2044] */
|
int tm_year; /* years - [1980..2044] */
|
||||||
} tm_zip;
|
} tm_zip;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -144,6 +144,11 @@ extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
|
||||||
zipcharpc* globalcomment,
|
zipcharpc* globalcomment,
|
||||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
|
extern zipFile ZEXPORT zipOpen3 OF((const void *pathname,
|
||||||
|
int append,
|
||||||
|
zipcharpc* globalcomment,
|
||||||
|
zlib_filefunc64_32_def* pzlib_filefunc64_32_def));
|
||||||
|
|
||||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||||
const char* filename,
|
const char* filename,
|
||||||
const zip_fileinfo* zipfi,
|
const zip_fileinfo* zipfi,
|
||||||
|
|
Loading…
Reference in New Issue