summaryrefslogtreecommitdiff
path: root/contrib/minizip/zip.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/minizip/zip.c')
-rw-r--r--contrib/minizip/zip.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index e12da4c..698dcec 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -73,7 +73,7 @@
73 73
74 74
75// NOT sure that this work on ALL platform 75// NOT sure that this work on ALL platform
76#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) 76#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))
77 77
78#ifndef SEEK_CUR 78#ifndef SEEK_CUR
79#define SEEK_CUR 1 79#define SEEK_CUR 1
@@ -759,7 +759,7 @@ int LoadCentralDirectoryRecord(zip64_internal* pziinit)
759 number_entry_CD = 0; 759 number_entry_CD = 0;
760 if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) 760 if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)
761 err=ZIP_ERRNO; 761 err=ZIP_ERRNO;
762 else 762 else
763 number_entry_CD = uL; 763 number_entry_CD = uL;
764 764
765 if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) 765 if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))
@@ -1021,7 +1021,7 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
1021 err = ZIP_ERRNO; 1021 err = ZIP_ERRNO;
1022 } 1022 }
1023 1023
1024 1024
1025 if ((err==ZIP_OK) && (zi->ci.zip64)) 1025 if ((err==ZIP_OK) && (zi->ci.zip64))
1026 { 1026 {
1027 // write the Zip64 extended info 1027 // write the Zip64 extended info
@@ -1035,7 +1035,7 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
1035 1035
1036 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2); 1036 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
1037 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2); 1037 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
1038 1038
1039 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); 1039 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
1040 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); 1040 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
1041 } 1041 }
@@ -1044,11 +1044,11 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
1044} 1044}
1045 1045
1046/* 1046/*
1047 NOTE. 1047 NOTE.
1048 When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped 1048 When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped
1049 before calling this function it can be done with zipRemoveExtraInfoBlock 1049 before calling this function it can be done with zipRemoveExtraInfoBlock
1050 1050
1051 It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize 1051 It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize
1052 unnecessary allocations. 1052 unnecessary allocations.
1053 */ 1053 */
1054extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, 1054extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
@@ -1106,7 +1106,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
1106 { 1106 {
1107 if (zipfi->dosDate != 0) 1107 if (zipfi->dosDate != 0)
1108 zi->ci.dosDate = zipfi->dosDate; 1108 zi->ci.dosDate = zipfi->dosDate;
1109 else 1109 else
1110 zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date); 1110 zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date);
1111 } 1111 }
1112 1112
@@ -1305,7 +1305,7 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c
1305 windowBits, memLevel, strategy, 1305 windowBits, memLevel, strategy,
1306 password, crcForCrypting, VERSIONMADEBY, 0, zip64); 1306 password, crcForCrypting, VERSIONMADEBY, 0, zip64);
1307} 1307}
1308 1308
1309extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, 1309extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,
1310 const void* extrafield_local, uInt size_extrafield_local, 1310 const void* extrafield_local, uInt size_extrafield_local,
1311 const void* extrafield_global, uInt size_extrafield_global, 1311 const void* extrafield_global, uInt size_extrafield_global,
@@ -1393,7 +1393,7 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
1393 1393
1394 1394
1395 zi->ci.pos_in_buffered_data = 0; 1395 zi->ci.pos_in_buffered_data = 0;
1396 1396
1397 return err; 1397 return err;
1398} 1398}
1399 1399
@@ -1581,7 +1581,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1581 if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) 1581 if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
1582 { 1582 {
1583 int tmp_err = deflateEnd(&zi->ci.stream); 1583 int tmp_err = deflateEnd(&zi->ci.stream);
1584 if (err == ZIP_OK) 1584 if (err == ZIP_OK)
1585 err = tmp_err; 1585 err = tmp_err;
1586 zi->ci.stream_initialised = 0; 1586 zi->ci.stream_initialised = 0;
1587 } 1587 }
@@ -1589,7 +1589,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1589 else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) 1589 else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1590 { 1590 {
1591 int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream); 1591 int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream);
1592 if (err==ZIP_OK) 1592 if (err==ZIP_OK)
1593 err = tmperr; 1593 err = tmperr;
1594 zi->ci.stream_initialised = 0; 1594 zi->ci.stream_initialised = 0;
1595 } 1595 }
@@ -1662,7 +1662,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1662 p += 2; 1662 p += 2;
1663 zip64local_putValue_inmemory(p, datasize, 2); // DataSize 1663 zip64local_putValue_inmemory(p, datasize, 2); // DataSize
1664 p += 2; 1664 p += 2;
1665 1665
1666 if(uncompressed_size >= 0xffffffff) 1666 if(uncompressed_size >= 0xffffffff)
1667 { 1667 {
1668 zip64local_putValue_inmemory(p, uncompressed_size, 8); 1668 zip64local_putValue_inmemory(p, uncompressed_size, 8);
@@ -1680,7 +1680,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1680 zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8); 1680 zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8);
1681 p += 8; 1681 p += 8;
1682 } 1682 }
1683 1683
1684 // Update how much extra free space we got in the memory buffer 1684 // Update how much extra free space we got in the memory buffer
1685 // and increase the centralheader size so the new ZIP64 fields are included 1685 // and increase the centralheader size so the new ZIP64 fields are included
1686 // ( 4 below is the size of HeaderID and DataSize field ) 1686 // ( 4 below is the size of HeaderID and DataSize field )
@@ -1691,7 +1691,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1691 zi->ci.size_centralExtra += datasize + 4; 1691 zi->ci.size_centralExtra += datasize + 4;
1692 zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2); 1692 zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2);
1693 } 1693 }
1694 1694
1695 if (err==ZIP_OK) 1695 if (err==ZIP_OK)
1696 err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader); 1696 err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader);
1697 1697
@@ -1752,9 +1752,9 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo
1752{ 1752{
1753 int err = ZIP_OK; 1753 int err = ZIP_OK;
1754 ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; 1754 ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset;
1755 1755
1756 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); 1756 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4);
1757 1757
1758 /*num disks*/ 1758 /*num disks*/
1759 if (err==ZIP_OK) /* number of the disk with the start of the central directory */ 1759 if (err==ZIP_OK) /* number of the disk with the start of the central directory */
1760 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); 1760 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4);
@@ -1807,12 +1807,12 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
1807 ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; 1807 ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
1808 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); 1808 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8);
1809 } 1809 }
1810 return err; 1810 return err;
1811} 1811}
1812int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) 1812int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
1813{ 1813{
1814 int err = ZIP_OK; 1814 int err = ZIP_OK;
1815 1815
1816 /*signature*/ 1816 /*signature*/
1817 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); 1817 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);
1818 1818
@@ -1861,7 +1861,7 @@ int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
1861{ 1861{
1862 int err = ZIP_OK; 1862 int err = ZIP_OK;
1863 uInt size_global_comment = 0; 1863 uInt size_global_comment = 0;
1864 1864
1865 if(global_comment != NULL) 1865 if(global_comment != NULL)
1866 size_global_comment = (uInt)strlen(global_comment); 1866 size_global_comment = (uInt)strlen(global_comment);
1867 1867
@@ -1897,7 +1897,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
1897 if (global_comment==NULL) 1897 if (global_comment==NULL)
1898 global_comment = zi->globalcomment; 1898 global_comment = zi->globalcomment;
1899#endif 1899#endif
1900 1900
1901 centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); 1901 centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
1902 1902
1903 if (err==ZIP_OK) 1903 if (err==ZIP_OK)
@@ -1922,7 +1922,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
1922 { 1922 {
1923 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); 1923 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
1924 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); 1924 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
1925 1925
1926 Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); 1926 Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
1927 } 1927 }
1928 1928
@@ -1977,7 +1977,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
1977 p += dataSize + 4; 1977 p += dataSize + 4;
1978 size += dataSize + 4; 1978 size += dataSize + 4;
1979 } 1979 }
1980 1980
1981 } 1981 }
1982 1982
1983 if(size < *dataLen) 1983 if(size < *dataLen)