diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2021-02-10 15:03:22 -0800 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2021-02-10 15:03:22 -0800 |
| commit | 0530dbcef992b56b88a6bfd0fd2efa868669d04e (patch) | |
| tree | 62c07c921c7532bc4ff56803761ec9d84875116e /contrib | |
| parent | 506424c6405d0cf7ea7b9c3316516676f259c665 (diff) | |
| download | zlib-0530dbcef992b56b88a6bfd0fd2efa868669d04e.tar.gz zlib-0530dbcef992b56b88a6bfd0fd2efa868669d04e.tar.bz2 zlib-0530dbcef992b56b88a6bfd0fd2efa868669d04e.zip | |
Improve portability of contrib/minizip.
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/minizip/crypt.h | 1 | ||||
| -rw-r--r-- | contrib/minizip/ioapi.c | 10 | ||||
| -rw-r--r-- | contrib/minizip/miniunz.c | 9 | ||||
| -rw-r--r-- | contrib/minizip/minizip.c | 11 |
4 files changed, 21 insertions, 10 deletions
diff --git a/contrib/minizip/crypt.h b/contrib/minizip/crypt.h index 1e9e820..131543f 100644 --- a/contrib/minizip/crypt.h +++ b/contrib/minizip/crypt.h | |||
| @@ -38,6 +38,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) | |||
| 38 | * unpredictable manner on 16-bit systems; not a problem | 38 | * unpredictable manner on 16-bit systems; not a problem |
| 39 | * with any known compiler so far, though */ | 39 | * with any known compiler so far, though */ |
| 40 | 40 | ||
| 41 | (void)pcrc_32_tab; | ||
| 41 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; | 42 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; |
| 42 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); | 43 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); |
| 43 | } | 44 | } |
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c index 7f5c191..1571914 100644 --- a/contrib/minizip/ioapi.c +++ b/contrib/minizip/ioapi.c | |||
| @@ -94,6 +94,7 @@ static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); | |||
| 94 | 94 | ||
| 95 | static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) | 95 | static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) |
| 96 | { | 96 | { |
| 97 | (void)opaque; | ||
| 97 | FILE* file = NULL; | 98 | FILE* file = NULL; |
| 98 | const char* mode_fopen = NULL; | 99 | const char* mode_fopen = NULL; |
| 99 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) | 100 | 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 | |||
| 112 | 113 | ||
| 113 | static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) | 114 | static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) |
| 114 | { | 115 | { |
| 116 | (void)opaque; | ||
| 115 | FILE* file = NULL; | 117 | FILE* file = NULL; |
| 116 | const char* mode_fopen = NULL; | 118 | const char* mode_fopen = NULL; |
| 117 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) | 119 | 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, | |||
| 131 | 133 | ||
| 132 | static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) | 134 | static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) |
| 133 | { | 135 | { |
| 136 | (void)opaque; | ||
| 134 | uLong ret; | 137 | uLong ret; |
| 135 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); | 138 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); |
| 136 | return ret; | 139 | return ret; |
| @@ -138,6 +141,7 @@ static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, | |||
| 138 | 141 | ||
| 139 | static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) | 142 | static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) |
| 140 | { | 143 | { |
| 144 | (void)opaque; | ||
| 141 | uLong ret; | 145 | uLong ret; |
| 142 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); | 146 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); |
| 143 | return ret; | 147 | return ret; |
| @@ -145,6 +149,7 @@ static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const voi | |||
| 145 | 149 | ||
| 146 | static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) | 150 | static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) |
| 147 | { | 151 | { |
| 152 | (void)opaque; | ||
| 148 | long ret; | 153 | long ret; |
| 149 | ret = ftell((FILE *)stream); | 154 | ret = ftell((FILE *)stream); |
| 150 | return ret; | 155 | return ret; |
| @@ -153,6 +158,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) | |||
| 153 | 158 | ||
| 154 | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) | 159 | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) |
| 155 | { | 160 | { |
| 161 | (void)opaque; | ||
| 156 | ZPOS64_T ret; | 162 | ZPOS64_T ret; |
| 157 | ret = FTELLO_FUNC((FILE *)stream); | 163 | ret = FTELLO_FUNC((FILE *)stream); |
| 158 | return ret; | 164 | return ret; |
| @@ -160,6 +166,7 @@ static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) | |||
| 160 | 166 | ||
| 161 | static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) | 167 | static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) |
| 162 | { | 168 | { |
| 169 | (void)opaque; | ||
| 163 | int fseek_origin=0; | 170 | int fseek_origin=0; |
| 164 | long ret; | 171 | long ret; |
| 165 | switch (origin) | 172 | switch (origin) |
| @@ -183,6 +190,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs | |||
| 183 | 190 | ||
| 184 | static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) | 191 | static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) |
| 185 | { | 192 | { |
| 193 | (void)opaque; | ||
| 186 | int fseek_origin=0; | 194 | int fseek_origin=0; |
| 187 | long ret; | 195 | long ret; |
| 188 | switch (origin) | 196 | switch (origin) |
| @@ -209,6 +217,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T | |||
| 209 | 217 | ||
| 210 | static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) | 218 | static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) |
| 211 | { | 219 | { |
| 220 | (void)opaque; | ||
| 212 | int ret; | 221 | int ret; |
| 213 | ret = fclose((FILE *)stream); | 222 | ret = fclose((FILE *)stream); |
| 214 | return ret; | 223 | return ret; |
| @@ -216,6 +225,7 @@ static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) | |||
| 216 | 225 | ||
| 217 | static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) | 226 | static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) |
| 218 | { | 227 | { |
| 228 | (void)opaque; | ||
| 219 | int ret; | 229 | int ret; |
| 220 | ret = ferror((FILE *)stream); | 230 | ret = ferror((FILE *)stream); |
| 221 | return ret; | 231 | return ret; |
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c index 3d65401..8e34bd9 100644 --- a/contrib/minizip/miniunz.c +++ b/contrib/minizip/miniunz.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include <time.h> | 45 | #include <time.h> |
| 46 | #include <errno.h> | 46 | #include <errno.h> |
| 47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
| 48 | #include <sys/stat.h> | ||
| 48 | 49 | ||
| 49 | #ifdef _WIN32 | 50 | #ifdef _WIN32 |
| 50 | # include <direct.h> | 51 | # include <direct.h> |
| @@ -97,7 +98,8 @@ void change_file_date(filename,dosdate,tmu_date) | |||
| 97 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); | 98 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); |
| 98 | CloseHandle(hFile); | 99 | CloseHandle(hFile); |
| 99 | #else | 100 | #else |
| 100 | #ifdef unix || __APPLE__ | 101 | #if defined(unix) || defined(__APPLE__) |
| 102 | (void)dosdate; | ||
| 101 | struct utimbuf ut; | 103 | struct utimbuf ut; |
| 102 | struct tm newdate; | 104 | struct tm newdate; |
| 103 | newdate.tm_sec = tmu_date.tm_sec; | 105 | newdate.tm_sec = tmu_date.tm_sec; |
| @@ -136,7 +138,7 @@ int mymkdir(dirname) | |||
| 136 | } | 138 | } |
| 137 | 139 | ||
| 138 | int makedir (newdir) | 140 | int makedir (newdir) |
| 139 | char *newdir; | 141 | const char *newdir; |
| 140 | { | 142 | { |
| 141 | char *buffer ; | 143 | char *buffer ; |
| 142 | char *p; | 144 | char *p; |
| @@ -324,7 +326,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | |||
| 324 | uInt size_buf; | 326 | uInt size_buf; |
| 325 | 327 | ||
| 326 | unz_file_info64 file_info; | 328 | unz_file_info64 file_info; |
| 327 | uLong ratio=0; | ||
| 328 | err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); | 329 | err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |
| 329 | 330 | ||
| 330 | if (err!=UNZ_OK) | 331 | if (err!=UNZ_OK) |
| @@ -481,7 +482,6 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password) | |||
| 481 | uLong i; | 482 | uLong i; |
| 482 | unz_global_info64 gi; | 483 | unz_global_info64 gi; |
| 483 | int err; | 484 | int err; |
| 484 | FILE* fout=NULL; | ||
| 485 | 485 | ||
| 486 | err = unzGetGlobalInfo64(uf,&gi); | 486 | err = unzGetGlobalInfo64(uf,&gi); |
| 487 | if (err!=UNZ_OK) | 487 | if (err!=UNZ_OK) |
| @@ -515,7 +515,6 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo | |||
| 515 | int opt_overwrite; | 515 | int opt_overwrite; |
| 516 | const char* password; | 516 | const char* password; |
| 517 | { | 517 | { |
| 518 | int err = UNZ_OK; | ||
| 519 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) | 518 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) |
| 520 | { | 519 | { |
| 521 | printf("file %s not found in the zipfile\n",filename); | 520 | printf("file %s not found in the zipfile\n",filename); |
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c index 4288962..2a38549 100644 --- a/contrib/minizip/minizip.c +++ b/contrib/minizip/minizip.c | |||
| @@ -72,7 +72,7 @@ | |||
| 72 | 72 | ||
| 73 | #ifdef _WIN32 | 73 | #ifdef _WIN32 |
| 74 | uLong filetime(f, tmzip, dt) | 74 | uLong filetime(f, tmzip, dt) |
| 75 | char *f; /* name of file to get info on */ | 75 | const char *f; /* name of file to get info on */ |
| 76 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 76 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
| 77 | uLong *dt; /* dostime */ | 77 | uLong *dt; /* dostime */ |
| 78 | { | 78 | { |
| @@ -94,12 +94,13 @@ uLong filetime(f, tmzip, dt) | |||
| 94 | return ret; | 94 | return ret; |
| 95 | } | 95 | } |
| 96 | #else | 96 | #else |
| 97 | #ifdef unix || __APPLE__ | 97 | #if defined(unix) || defined(__APPLE__) |
| 98 | uLong filetime(f, tmzip, dt) | 98 | uLong filetime(f, tmzip, dt) |
| 99 | char *f; /* name of file to get info on */ | 99 | const char *f; /* name of file to get info on */ |
| 100 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 100 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
| 101 | uLong *dt; /* dostime */ | 101 | uLong *dt; /* dostime */ |
| 102 | { | 102 | { |
| 103 | (void)dt; | ||
| 103 | int ret=0; | 104 | int ret=0; |
| 104 | struct stat s; /* results of stat() */ | 105 | struct stat s; /* results of stat() */ |
| 105 | struct tm* filedate; | 106 | struct tm* filedate; |
| @@ -138,7 +139,7 @@ uLong filetime(f, tmzip, dt) | |||
| 138 | } | 139 | } |
| 139 | #else | 140 | #else |
| 140 | uLong filetime(f, tmzip, dt) | 141 | uLong filetime(f, tmzip, dt) |
| 141 | char *f; /* name of file to get info on */ | 142 | const char *f; /* name of file to get info on */ |
| 142 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 143 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
| 143 | uLong *dt; /* dostime */ | 144 | uLong *dt; /* dostime */ |
| 144 | { | 145 | { |
| @@ -229,7 +230,7 @@ int isLargeFile(const char* filename) | |||
| 229 | 230 | ||
| 230 | if(pFile != NULL) | 231 | if(pFile != NULL) |
| 231 | { | 232 | { |
| 232 | int n = FSEEKO_FUNC(pFile, 0, SEEK_END); | 233 | FSEEKO_FUNC(pFile, 0, SEEK_END); |
| 233 | pos = FTELLO_FUNC(pFile); | 234 | pos = FTELLO_FUNC(pFile); |
| 234 | 235 | ||
| 235 | printf("File : %s is %lld bytes\n", filename, pos); | 236 | printf("File : %s is %lld bytes\n", filename, pos); |
