aboutsummaryrefslogtreecommitdiff
path: root/contrib/minizip/zip.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/minizip/zip.c')
-rw-r--r--contrib/minizip/zip.c274
1 files changed, 111 insertions, 163 deletions
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 66d693f..7b559b7 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -25,6 +25,7 @@
25#include <stdio.h> 25#include <stdio.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28#include <stdint.h>
28#include <time.h> 29#include <time.h>
29#include "zlib.h" 30#include "zlib.h"
30#include "zip.h" 31#include "zip.h"
@@ -186,8 +187,7 @@ typedef struct
186#include "crypt.h" 187#include "crypt.h"
187#endif 188#endif
188 189
189local linkedlist_datablock_internal* allocate_new_datablock() 190local linkedlist_datablock_internal* allocate_new_datablock(void) {
190{
191 linkedlist_datablock_internal* ldi; 191 linkedlist_datablock_internal* ldi;
192 ldi = (linkedlist_datablock_internal*) 192 ldi = (linkedlist_datablock_internal*)
193 ALLOC(sizeof(linkedlist_datablock_internal)); 193 ALLOC(sizeof(linkedlist_datablock_internal));
@@ -200,8 +200,7 @@ local linkedlist_datablock_internal* allocate_new_datablock()
200 return ldi; 200 return ldi;
201} 201}
202 202
203local void free_datablock(linkedlist_datablock_internal* ldi) 203local void free_datablock(linkedlist_datablock_internal* ldi) {
204{
205 while (ldi!=NULL) 204 while (ldi!=NULL)
206 { 205 {
207 linkedlist_datablock_internal* ldinext = ldi->next_datablock; 206 linkedlist_datablock_internal* ldinext = ldi->next_datablock;
@@ -210,20 +209,17 @@ local void free_datablock(linkedlist_datablock_internal* ldi)
210 } 209 }
211} 210}
212 211
213local void init_linkedlist(linkedlist_data* ll) 212local void init_linkedlist(linkedlist_data* ll) {
214{
215 ll->first_block = ll->last_block = NULL; 213 ll->first_block = ll->last_block = NULL;
216} 214}
217 215
218local void free_linkedlist(linkedlist_data* ll) 216local void free_linkedlist(linkedlist_data* ll) {
219{
220 free_datablock(ll->first_block); 217 free_datablock(ll->first_block);
221 ll->first_block = ll->last_block = NULL; 218 ll->first_block = ll->last_block = NULL;
222} 219}
223 220
224 221
225local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) 222local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) {
226{
227 linkedlist_datablock_internal* ldi; 223 linkedlist_datablock_internal* ldi;
228 const unsigned char* from_copy; 224 const unsigned char* from_copy;
229 225
@@ -238,7 +234,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
238 } 234 }
239 235
240 ldi = ll->last_block; 236 ldi = ll->last_block;
241 from_copy = (unsigned char*)buf; 237 from_copy = (const unsigned char*)buf;
242 238
243 while (len>0) 239 while (len>0)
244 { 240 {
@@ -283,9 +279,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
283 nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) 279 nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)
284*/ 280*/
285 281
286local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); 282local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) {
287local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
288{
289 unsigned char buf[8]; 283 unsigned char buf[8];
290 int n; 284 int n;
291 for (n = 0; n < nbByte; n++) 285 for (n = 0; n < nbByte; n++)
@@ -307,9 +301,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
307 return ZIP_OK; 301 return ZIP_OK;
308} 302}
309 303
310local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); 304local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) {
311local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
312{
313 unsigned char* buf=(unsigned char*)dest; 305 unsigned char* buf=(unsigned char*)dest;
314 int n; 306 int n;
315 for (n = 0; n < nbByte; n++) { 307 for (n = 0; n < nbByte; n++) {
@@ -329,8 +321,7 @@ local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
329/****************************************************************************/ 321/****************************************************************************/
330 322
331 323
332local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) 324local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) {
333{
334 uLong year = (uLong)ptm->tm_year; 325 uLong year = (uLong)ptm->tm_year;
335 if (year>=1980) 326 if (year>=1980)
336 year-=1980; 327 year-=1980;
@@ -344,10 +335,7 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
344 335
345/****************************************************************************/ 336/****************************************************************************/
346 337
347local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); 338local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) {
348
349local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)
350{
351 unsigned char c; 339 unsigned char c;
352 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); 340 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
353 if (err==1) 341 if (err==1)
@@ -368,10 +356,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo
368/* =========================================================================== 356/* ===========================================================================
369 Reads a long in LSB order from the given gz_stream. Sets 357 Reads a long in LSB order from the given gz_stream. Sets
370*/ 358*/
371local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); 359local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
372
373local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
374{
375 uLong x ; 360 uLong x ;
376 int i = 0; 361 int i = 0;
377 int err; 362 int err;
@@ -390,10 +375,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
390 return err; 375 return err;
391} 376}
392 377
393local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); 378local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
394
395local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
396{
397 uLong x ; 379 uLong x ;
398 int i = 0; 380 int i = 0;
399 int err; 381 int err;
@@ -420,11 +402,8 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
420 return err; 402 return err;
421} 403}
422 404
423local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));
424
425 405
426local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) 406local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) {
427{
428 ZPOS64_T x; 407 ZPOS64_T x;
429 int i = 0; 408 int i = 0;
430 int err; 409 int err;
@@ -475,10 +454,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def
475 Locate the Central directory of a zipfile (at the end, just before 454 Locate the Central directory of a zipfile (at the end, just before
476 the global comment) 455 the global comment)
477*/ 456*/
478local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); 457local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
479
480local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
481{
482 unsigned char* buf; 458 unsigned char* buf;
483 ZPOS64_T uSizeFile; 459 ZPOS64_T uSizeFile;
484 ZPOS64_T uBackRead; 460 ZPOS64_T uBackRead;
@@ -537,10 +513,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
537Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before 513Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before
538the global comment) 514the global comment)
539*/ 515*/
540local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); 516local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
541
542local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
543{
544 unsigned char* buf; 517 unsigned char* buf;
545 ZPOS64_T uSizeFile; 518 ZPOS64_T uSizeFile;
546 ZPOS64_T uBackRead; 519 ZPOS64_T uBackRead;
@@ -637,8 +610,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
637 return relativeOffset; 610 return relativeOffset;
638} 611}
639 612
640local int LoadCentralDirectoryRecord(zip64_internal* pziinit) 613local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
641{
642 int err=ZIP_OK; 614 int err=ZIP_OK;
643 ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ 615 ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
644 616
@@ -846,8 +818,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit)
846 818
847 819
848/************************************************************/ 820/************************************************************/
849extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) 821extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) {
850{
851 zip64_internal ziinit; 822 zip64_internal ziinit;
852 zip64_internal* zi; 823 zip64_internal* zi;
853 int err=ZIP_OK; 824 int err=ZIP_OK;
@@ -917,8 +888,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
917 } 888 }
918} 889}
919 890
920extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) 891extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) {
921{
922 if (pzlib_filefunc32_def != NULL) 892 if (pzlib_filefunc32_def != NULL)
923 { 893 {
924 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; 894 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -929,8 +899,7 @@ extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* gl
929 return zipOpen3(pathname, append, globalcomment, NULL); 899 return zipOpen3(pathname, append, globalcomment, NULL);
930} 900}
931 901
932extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) 902extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) {
933{
934 if (pzlib_filefunc_def != NULL) 903 if (pzlib_filefunc_def != NULL)
935 { 904 {
936 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; 905 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -945,18 +914,15 @@ extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc*
945 914
946 915
947 916
948extern zipFile ZEXPORT zipOpen (const char* pathname, int append) 917extern zipFile ZEXPORT zipOpen(const char* pathname, int append) {
949{
950 return zipOpen3((const void*)pathname,append,NULL,NULL); 918 return zipOpen3((const void*)pathname,append,NULL,NULL);
951} 919}
952 920
953extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) 921extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) {
954{
955 return zipOpen3(pathname,append,NULL,NULL); 922 return zipOpen3(pathname,append,NULL,NULL);
956} 923}
957 924
958local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) 925local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) {
959{
960 /* write the local header */ 926 /* write the local header */
961 int err; 927 int err;
962 uInt size_filename = (uInt)strlen(filename); 928 uInt size_filename = (uInt)strlen(filename);
@@ -1052,14 +1018,13 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
1052 It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize 1018 It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize
1053 unnecessary allocations. 1019 unnecessary allocations.
1054 */ 1020 */
1055extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, 1021extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1056 const void* extrafield_local, uInt size_extrafield_local, 1022 const void* extrafield_local, uInt size_extrafield_local,
1057 const void* extrafield_global, uInt size_extrafield_global, 1023 const void* extrafield_global, uInt size_extrafield_global,
1058 const char* comment, int method, int level, int raw, 1024 const char* comment, int method, int level, int raw,
1059 int windowBits,int memLevel, int strategy, 1025 int windowBits,int memLevel, int strategy,
1060 const char* password, uLong crcForCrypting, 1026 const char* password, uLong crcForCrypting,
1061 uLong versionMadeBy, uLong flagBase, int zip64) 1027 uLong versionMadeBy, uLong flagBase, int zip64) {
1062{
1063 zip64_internal* zi; 1028 zip64_internal* zi;
1064 uInt size_filename; 1029 uInt size_filename;
1065 uInt size_comment; 1030 uInt size_comment;
@@ -1262,35 +1227,33 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
1262 return err; 1227 return err;
1263} 1228}
1264 1229
1265extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, 1230extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1266 const void* extrafield_local, uInt size_extrafield_local, 1231 const void* extrafield_local, uInt size_extrafield_local,
1267 const void* extrafield_global, uInt size_extrafield_global, 1232 const void* extrafield_global, uInt size_extrafield_global,
1268 const char* comment, int method, int level, int raw, 1233 const char* comment, int method, int level, int raw,
1269 int windowBits,int memLevel, int strategy, 1234 int windowBits,int memLevel, int strategy,
1270 const char* password, uLong crcForCrypting, 1235 const char* password, uLong crcForCrypting,
1271 uLong versionMadeBy, uLong flagBase) 1236 uLong versionMadeBy, uLong flagBase) {
1272{ 1237 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1273 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1238 extrafield_local, size_extrafield_local,
1274 extrafield_local, size_extrafield_local, 1239 extrafield_global, size_extrafield_global,
1275 extrafield_global, size_extrafield_global, 1240 comment, method, level, raw,
1276 comment, method, level, raw, 1241 windowBits, memLevel, strategy,
1277 windowBits, memLevel, strategy, 1242 password, crcForCrypting, versionMadeBy, flagBase, 0);
1278 password, crcForCrypting, versionMadeBy, flagBase, 0);
1279} 1243}
1280 1244
1281extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, 1245extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1282 const void* extrafield_local, uInt size_extrafield_local, 1246 const void* extrafield_local, uInt size_extrafield_local,
1283 const void* extrafield_global, uInt size_extrafield_global, 1247 const void* extrafield_global, uInt size_extrafield_global,
1284 const char* comment, int method, int level, int raw, 1248 const char* comment, int method, int level, int raw,
1285 int windowBits,int memLevel, int strategy, 1249 int windowBits,int memLevel, int strategy,
1286 const char* password, uLong crcForCrypting) 1250 const char* password, uLong crcForCrypting) {
1287{ 1251 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1288 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1252 extrafield_local, size_extrafield_local,
1289 extrafield_local, size_extrafield_local, 1253 extrafield_global, size_extrafield_global,
1290 extrafield_global, size_extrafield_global, 1254 comment, method, level, raw,
1291 comment, method, level, raw, 1255 windowBits, memLevel, strategy,
1292 windowBits, memLevel, strategy, 1256 password, crcForCrypting, VERSIONMADEBY, 0, 0);
1293 password, crcForCrypting, VERSIONMADEBY, 0, 0);
1294} 1257}
1295 1258
1296extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, 1259extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
@@ -1298,70 +1261,64 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c
1298 const void* extrafield_global, uInt size_extrafield_global, 1261 const void* extrafield_global, uInt size_extrafield_global,
1299 const char* comment, int method, int level, int raw, 1262 const char* comment, int method, int level, int raw,
1300 int windowBits,int memLevel, int strategy, 1263 int windowBits,int memLevel, int strategy,
1301 const char* password, uLong crcForCrypting, int zip64) 1264 const char* password, uLong crcForCrypting, int zip64) {
1302{ 1265 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1303 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1266 extrafield_local, size_extrafield_local,
1304 extrafield_local, size_extrafield_local, 1267 extrafield_global, size_extrafield_global,
1305 extrafield_global, size_extrafield_global, 1268 comment, method, level, raw,
1306 comment, method, level, raw, 1269 windowBits, memLevel, strategy,
1307 windowBits, memLevel, strategy, 1270 password, crcForCrypting, VERSIONMADEBY, 0, zip64);
1308 password, crcForCrypting, VERSIONMADEBY, 0, zip64);
1309} 1271}
1310 1272
1311extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, 1273extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1312 const void* extrafield_local, uInt size_extrafield_local, 1274 const void* extrafield_local, uInt size_extrafield_local,
1313 const void* extrafield_global, uInt size_extrafield_global, 1275 const void* extrafield_global, uInt size_extrafield_global,
1314 const char* comment, int method, int level, int raw) 1276 const char* comment, int method, int level, int raw) {
1315{ 1277 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1316 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1278 extrafield_local, size_extrafield_local,
1317 extrafield_local, size_extrafield_local, 1279 extrafield_global, size_extrafield_global,
1318 extrafield_global, size_extrafield_global, 1280 comment, method, level, raw,
1319 comment, method, level, raw, 1281 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
1320 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, 1282 NULL, 0, VERSIONMADEBY, 0, 0);
1321 NULL, 0, VERSIONMADEBY, 0, 0);
1322} 1283}
1323 1284
1324extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, 1285extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1325 const void* extrafield_local, uInt size_extrafield_local, 1286 const void* extrafield_local, uInt size_extrafield_local,
1326 const void* extrafield_global, uInt size_extrafield_global, 1287 const void* extrafield_global, uInt size_extrafield_global,
1327 const char* comment, int method, int level, int raw, int zip64) 1288 const char* comment, int method, int level, int raw, int zip64) {
1328{ 1289 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1329 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1290 extrafield_local, size_extrafield_local,
1330 extrafield_local, size_extrafield_local, 1291 extrafield_global, size_extrafield_global,
1331 extrafield_global, size_extrafield_global, 1292 comment, method, level, raw,
1332 comment, method, level, raw, 1293 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
1333 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, 1294 NULL, 0, VERSIONMADEBY, 0, zip64);
1334 NULL, 0, VERSIONMADEBY, 0, zip64);
1335} 1295}
1336 1296
1337extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, 1297extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1338 const void* extrafield_local, uInt size_extrafield_local, 1298 const void* extrafield_local, uInt size_extrafield_local,
1339 const void*extrafield_global, uInt size_extrafield_global, 1299 const void*extrafield_global, uInt size_extrafield_global,
1340 const char* comment, int method, int level, int zip64) 1300 const char* comment, int method, int level, int zip64) {
1341{ 1301 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1342 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1302 extrafield_local, size_extrafield_local,
1343 extrafield_local, size_extrafield_local, 1303 extrafield_global, size_extrafield_global,
1344 extrafield_global, size_extrafield_global, 1304 comment, method, level, 0,
1345 comment, method, level, 0, 1305 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
1346 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, 1306 NULL, 0, VERSIONMADEBY, 0, zip64);
1347 NULL, 0, VERSIONMADEBY, 0, zip64);
1348} 1307}
1349 1308
1350extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, 1309extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1351 const void* extrafield_local, uInt size_extrafield_local, 1310 const void* extrafield_local, uInt size_extrafield_local,
1352 const void*extrafield_global, uInt size_extrafield_global, 1311 const void*extrafield_global, uInt size_extrafield_global,
1353 const char* comment, int method, int level) 1312 const char* comment, int method, int level) {
1354{ 1313 return zipOpenNewFileInZip4_64(file, filename, zipfi,
1355 return zipOpenNewFileInZip4_64 (file, filename, zipfi, 1314 extrafield_local, size_extrafield_local,
1356 extrafield_local, size_extrafield_local, 1315 extrafield_global, size_extrafield_global,
1357 extrafield_global, size_extrafield_global, 1316 comment, method, level, 0,
1358 comment, method, level, 0, 1317 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
1359 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, 1318 NULL, 0, VERSIONMADEBY, 0, 0);
1360 NULL, 0, VERSIONMADEBY, 0, 0);
1361} 1319}
1362 1320
1363local int zip64FlushWriteBuffer(zip64_internal* zi) 1321local int zip64FlushWriteBuffer(zip64_internal* zi) {
1364{
1365 int err=ZIP_OK; 1322 int err=ZIP_OK;
1366 1323
1367 if (zi->ci.encrypt != 0) 1324 if (zi->ci.encrypt != 0)
@@ -1399,8 +1356,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
1399 return err; 1356 return err;
1400} 1357}
1401 1358
1402extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) 1359extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) {
1403{
1404 zip64_internal* zi; 1360 zip64_internal* zi;
1405 int err=ZIP_OK; 1361 int err=ZIP_OK;
1406 1362
@@ -1450,7 +1406,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
1450 else 1406 else
1451#endif 1407#endif
1452 { 1408 {
1453 zi->ci.stream.next_in = (Bytef*)buf; 1409 zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
1454 zi->ci.stream.avail_in = len; 1410 zi->ci.stream.avail_in = len;
1455 1411
1456 while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) 1412 while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
@@ -1501,13 +1457,11 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
1501 return err; 1457 return err;
1502} 1458}
1503 1459
1504extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) 1460extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) {
1505{
1506 return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); 1461 return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);
1507} 1462}
1508 1463
1509extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) 1464extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) {
1510{
1511 zip64_internal* zi; 1465 zip64_internal* zi;
1512 ZPOS64_T compressed_size; 1466 ZPOS64_T compressed_size;
1513 uLong invalidValue = 0xffffffff; 1467 uLong invalidValue = 0xffffffff;
@@ -1742,13 +1696,11 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1742 return err; 1696 return err;
1743} 1697}
1744 1698
1745extern int ZEXPORT zipCloseFileInZip (zipFile file) 1699extern int ZEXPORT zipCloseFileInZip(zipFile file) {
1746{
1747 return zipCloseFileInZipRaw (file,0,0); 1700 return zipCloseFileInZipRaw (file,0,0);
1748} 1701}
1749 1702
1750local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) 1703local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) {
1751{
1752 int err = ZIP_OK; 1704 int err = ZIP_OK;
1753 ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; 1705 ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
1754 1706
@@ -1769,8 +1721,7 @@ local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T z
1769 return err; 1721 return err;
1770} 1722}
1771 1723
1772local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) 1724local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
1773{
1774 int err = ZIP_OK; 1725 int err = ZIP_OK;
1775 1726
1776 uLong Zip64DataSize = 44; 1727 uLong Zip64DataSize = 44;
@@ -1808,8 +1759,8 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_
1808 } 1759 }
1809 return err; 1760 return err;
1810} 1761}
1811local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) 1762
1812{ 1763local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
1813 int err = ZIP_OK; 1764 int err = ZIP_OK;
1814 1765
1815 /*signature*/ 1766 /*signature*/
@@ -1856,8 +1807,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
1856 return err; 1807 return err;
1857} 1808}
1858 1809
1859local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) 1810local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) {
1860{
1861 int err = ZIP_OK; 1811 int err = ZIP_OK;
1862 uInt size_global_comment = 0; 1812 uInt size_global_comment = 0;
1863 1813
@@ -1874,8 +1824,7 @@ local int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
1874 return err; 1824 return err;
1875} 1825}
1876 1826
1877extern int ZEXPORT zipClose (zipFile file, const char* global_comment) 1827extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
1878{
1879 zip64_internal* zi; 1828 zip64_internal* zi;
1880 int err = 0; 1829 int err = 0;
1881 uLong size_centraldir = 0; 1830 uLong size_centraldir = 0;
@@ -1943,8 +1892,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
1943 return err; 1892 return err;
1944} 1893}
1945 1894
1946extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) 1895extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) {
1947{
1948 char* p = pData; 1896 char* p = pData;
1949 int size = 0; 1897 int size = 0;
1950 char* pNewHeader; 1898 char* pNewHeader;