Răsfoiți Sursa

Merge pull request #10428 from akien-mga/minizip

Sync minizip with closest upstream version (zlib 1.2.4 contrib) and document Godot-specific changes
Rémi Verschelde 8 ani în urmă
părinte
comite
5d85108f94

+ 2 - 1
thirdparty/README.md

@@ -180,7 +180,8 @@ Files extracted from the upstream source:
 - contrib/minizip/{crypt.h,ioapi.{c,h},zip.{c,h},unzip.{c,h}}
 
 Important: Some files have Godot-made changes for use in core/io.
-TODO: Properly sync with version 1.2.4 and document changes.
+They are marked with `/* GODOT start */` and `/* GODOT end */`
+comments and a patch is provided in the minizip/ folder.
 
 
 ## misc

+ 0 - 60
thirdparty/minizip/LICENSE-InfoZip.txt

@@ -1,60 +0,0 @@
-This is version 2007-Mar-4 of the Info-ZIP license.
-The definitive version of this document should be available at
-ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and
-a copy at http://www.info-zip.org/pub/infozip/license.html.
-
-
-Copyright (c) 1990-2007 Info-ZIP.  All rights reserved.
-
-For the purposes of this copyright and license, "Info-ZIP" is defined as
-the following set of individuals:
-
-   Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
-   Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
-   Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
-   David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
-   Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
-   Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
-   Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
-   Rich Wales, Mike White.
-
-This software is provided "as is," without warranty of any kind, express
-or implied.  In no event shall Info-ZIP or its contributors be held liable
-for any direct, indirect, incidental, special or consequential damages
-arising out of the use of or inability to use this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the above disclaimer and the following restrictions:
-
-    1. Redistributions of source code (in whole or in part) must retain
-       the above copyright notice, definition, disclaimer, and this list
-       of conditions.
-
-    2. Redistributions in binary form (compiled executables and libraries)
-       must reproduce the above copyright notice, definition, disclaimer,
-       and this list of conditions in documentation and/or other materials
-       provided with the distribution.  The sole exception to this condition
-       is redistribution of a standard UnZipSFX binary (including SFXWiz) as
-       part of a self-extracting archive; that is permitted without inclusion
-       of this license, as long as the normal SFX banner has not been removed
-       from the binary or disabled.
-
-    3. Altered versions--including, but not limited to, ports to new operating
-       systems, existing ports with new graphical interfaces, versions with
-       modified or added functionality, and dynamic, shared, or static library
-       versions not from Info-ZIP--must be plainly marked as such and must not
-       be misrepresented as being the original source or, if binaries,
-       compiled from the original source.  Such altered versions also must not
-       be misrepresented as being Info-ZIP releases--including, but not
-       limited to, labeling of the altered versions with the names "Info-ZIP"
-       (or any variation thereof, including, but not limited to, different
-       capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the
-       explicit permission of Info-ZIP.  Such altered versions are further
-       prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP
-       e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP
-       will provide support for the altered versions.
-
-    4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
-       "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
-       own source and binary releases.

+ 0 - 32
thirdparty/minizip/LICENSE-MiniZip.txt

@@ -1,32 +0,0 @@
-Credits
-
- Gilles Vollant    - Original MiniZip author
- Even Rouault      - ZIP64 unzip Support
- Daniel Borca      - BZip Compression method support in unzip
- Mathias Svensson  - ZIP64 zip support
- Mathias Svensson  - BZip Compression method support in zip
-
- This version has been modified for Godot Engine
-
-
-License
-----------------------------------------------------------------------------
-   Condition of use and distribution are the same than zlib :
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-----------------------------------------------------------------------------

+ 74 - 0
thirdparty/minizip/MiniZip_info.txt

@@ -0,0 +1,74 @@
+MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
+
+Introduction
+---------------------
+MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html )
+
+When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0.
+All possible work was done for compatibility.
+
+
+Background
+---------------------
+When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 
+support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ )
+
+That was used as a starting point. And after that ZIP64 support was added to zip.c
+some refactoring and code cleanup was also done.
+
+
+Changed from MiniZip 1.0 to MiniZip 1.1
+---------------------------------------
+* Added ZIP64 support for unzip ( by Even Rouault )
+* Added ZIP64 support for zip ( by Mathias Svensson )
+* Reverted some changed that Even Rouault did.
+* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
+* Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
+* Added BZIP Compress method for zip
+* Did some refactoring and code cleanup
+
+
+Credits
+
+ Gilles Vollant    - Original MiniZip author
+ Even Rouault      - ZIP64 unzip Support
+ Daniel Borca      - BZip Compression method support in unzip
+ Mathias Svensson  - ZIP64 zip support
+ Mathias Svensson  - BZip Compression method support in zip
+
+ Resources
+
+ ZipLayout   http://result42.com/projects/ZipFileLayout
+             Command line tool for Windows that shows the layout and information of the headers in a zip archive.
+             Used when debugging and validating the creation of zip files using MiniZip64
+
+
+ ZIP App Note  http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+               Zip File specification
+
+
+Notes.
+ * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
+
+License
+----------------------------------------------------------
+   Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+----------------------------------------------------------
+

+ 295 - 0
thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch

@@ -0,0 +1,295 @@
+diff --git a/thirdparty/minizip/ioapi.c b/thirdparty/minizip/ioapi.c
+index 49958f61f..0afbdc06a 100644
+--- a/thirdparty/minizip/ioapi.c
++++ b/thirdparty/minizip/ioapi.c
+@@ -68,8 +68,15 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
+     p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
+     p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
+     p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
++    /* GODOT start */
++    p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem;
++    p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem;
++    /* GODOT end */
+ }
+ 
++/* GODOT start */
++/*
++// GODOT end
+ 
+ 
+ static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
+@@ -233,3 +240,6 @@ void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
+     pzlib_filefunc_def->zerror_file = ferror_file_func;
+     pzlib_filefunc_def->opaque = NULL;
+ }
++// GODOT start
++*/
++/* GODOT end */
+diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h
+index 8309c4cf8..f25ab6464 100644
+--- a/thirdparty/minizip/ioapi.h
++++ b/thirdparty/minizip/ioapi.h
+@@ -145,6 +145,10 @@ typedef struct zlib_filefunc_def_s
+     close_file_func     zclose_file;
+     testerror_file_func zerror_file;
+     voidpf              opaque;
++    /* GODOT start */
++    alloc_func          alloc_mem;
++    free_func           free_mem;
++    /* GODOT end */
+ } zlib_filefunc_def;
+ 
+ typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
+@@ -161,6 +165,10 @@ typedef struct zlib_filefunc64_def_s
+     close_file_func     zclose_file;
+     testerror_file_func zerror_file;
+     voidpf              opaque;
++    /* GODOT start */
++    alloc_func          alloc_mem;
++    free_func           free_mem;
++    /* GODOT end */
+ } zlib_filefunc64_def;
+ 
+ void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
+diff --git a/thirdparty/minizip/unzip.c b/thirdparty/minizip/unzip.c
+index 7617f41f1..32e27bd65 100644
+--- a/thirdparty/minizip/unzip.c
++++ b/thirdparty/minizip/unzip.c
+@@ -157,6 +157,9 @@ typedef struct
+     uLong compression_method;   /* compression method (0==store) */
+     ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+     int   raw;
++    /* GODOT start */
++    int extra_size;
++    /* GODOT end */
+ } file_in_zip64_read_info_s;
+ 
+ 
+@@ -606,9 +609,10 @@ local unzFile unzOpenInternal (const void *path,
+     us.z_filefunc.zseek32_file = NULL;
+     us.z_filefunc.ztell32_file = NULL;
+     if (pzlib_filefunc64_32_def==NULL)
+-        fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
+-    else
+-        us.z_filefunc = *pzlib_filefunc64_32_def;
++        /* GODOT start */
++        return NULL; // standard i/o not supported
++    us.z_filefunc = *pzlib_filefunc64_32_def;
++    /* GODOT end */
+     us.is64bitOpenFunction = is64bitOpenFunction;
+ 
+ 
+@@ -800,6 +804,18 @@ extern unzFile ZEXPORT unzOpen64 (const void *path)
+     return unzOpenInternal(path, NULL, 1);
+ }
+ 
++/* GODOT start */
++extern void* unzGetOpaque(unzFile file) {
++
++    unz64_s* s;
++    if (file==NULL)
++        return NULL;
++    s=(unz64_s*)file;
++
++    return s->z_filefunc.zfile_func64.opaque;
++};
++/* GODOT end */
++
+ /*
+   Close a ZipFile opened with unzipOpen.
+   If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
+@@ -1018,10 +1034,20 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+ 
+         if (lSeek!=0)
+         {
+-            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+-                lSeek=0;
+-            else
+-                err=UNZ_ERRNO;
++            /* GODOT start */
++            if (lSeek<0) {
++                // WORKAROUND for backwards seeking
++                z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
++                if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
++                    lSeek=0;
++                else
++                    err=UNZ_ERRNO;
++            } else {
++                if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
++                    lSeek=0;
++                else
++                    err=UNZ_ERRNO;
++            }
+         }
+ 
+         while(acc < file_info.size_file_extra)
+@@ -1575,8 +1601,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+     }
+     else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
+     {
+-      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+-      pfile_in_zip_read_info->stream.zfree = (free_func)0;
++      /* GODOT start */
++      pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem;
++      pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem;
++      /* GODOT end */
+       pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+       pfile_in_zip_read_info->stream.next_in = 0;
+       pfile_in_zip_read_info->stream.avail_in = 0;
+@@ -1608,6 +1636,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+               iSizeVar;
+ 
+     pfile_in_zip_read_info->stream.avail_in = (uInt)0;
++    /* GODOT start */
++    pfile_in_zip_read_info->extra_size = iSizeVar;
++    /* GODOT end */
+ 
+     s->pfile_in_zip_read = pfile_in_zip_read_info;
+                 s->encrypted = 0;
+@@ -1638,6 +1669,85 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+     return UNZ_OK;
+ }
+ 
++/* GODOT start */
++extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) {
++
++    unz64_s* s;
++    file_in_zip64_read_info_s* pfile_in_zip_read_info;
++    if (file==NULL)
++        return UNZ_PARAMERROR;
++    s=(unz64_s*)file;
++    pfile_in_zip_read_info=s->pfile_in_zip_read;
++
++    if (pfile_in_zip_read_info==NULL)
++        return UNZ_PARAMERROR;
++
++    if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip
++        return UNZ_INTERNALERROR;
++    };
++
++    if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
++
++        pfile_in_zip_read_info->rest_read_compressed =
++                s->cur_file_info.compressed_size - pos;
++        pfile_in_zip_read_info->rest_read_uncompressed =
++                s->cur_file_info.uncompressed_size - pos;
++
++        pfile_in_zip_read_info->pos_in_zipfile =
++                s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
++                        pfile_in_zip_read_info->extra_size + pos;
++
++        pfile_in_zip_read_info->stream.avail_in = (uInt)0;
++        pfile_in_zip_read_info->stream.total_out = pos;
++
++        return ZSEEK64(pfile_in_zip_read_info->z_filefunc,
++                       pfile_in_zip_read_info->filestream,
++                       pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile,
++                       ZLIB_FILEFUNC_SEEK_SET);
++
++    } else { // gzip
++
++        if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind
++
++            pfile_in_zip_read_info->rest_read_compressed =
++                    s->cur_file_info.compressed_size ;
++            pfile_in_zip_read_info->rest_read_uncompressed =
++                    s->cur_file_info.uncompressed_size ;
++
++            pfile_in_zip_read_info->pos_in_zipfile =
++                    s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
++                            pfile_in_zip_read_info->extra_size;
++
++            (void)inflateReset(&pfile_in_zip_read_info->stream);
++
++            pfile_in_zip_read_info->stream.avail_in = (uInt)0;
++            pfile_in_zip_read_info->stream.total_out = 0;
++            pfile_in_zip_read_info->stream.next_in = 0;
++        };
++
++        // not sure where to read, so read on the stack
++        {
++            char buf[512];
++            int to_read = pos - pfile_in_zip_read_info->stream.total_out;
++            while (to_read) {
++
++                int len = to_read > sizeof(buf)?sizeof(buf):to_read;
++                int read = unzReadCurrentFile(file, buf, len);
++                if (read < 0) {
++                    return read;
++                };
++                to_read -= read;
++                if (read == UNZ_EOF) {
++                    return pos;
++                };
++            };
++        };
++    };
++
++    return pos;
++};
++/* GODOT end */
++
+ extern int ZEXPORT unzOpenCurrentFile (unzFile file)
+ {
+     return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
+diff --git a/thirdparty/minizip/unzip.h b/thirdparty/minizip/unzip.h
+index 3183968b7..54e65ad8a 100644
+--- a/thirdparty/minizip/unzip.h
++++ b/thirdparty/minizip/unzip.h
+@@ -202,6 +202,10 @@ extern int ZEXPORT unzClose OF((unzFile file));
+     these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+   return UNZ_OK if there is no problem. */
+ 
++/* GODOT start */
++extern void* unzGetOpaque(unzFile file);
++/* GODOT end */
++
+ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+                                         unz_global_info *pglobal_info));
+ 
+@@ -390,6 +394,13 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+     (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+ */
+ 
++/* GODOT start */
++extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos);
++/*
++  Seek to position in uncompressed data
++*/
++/* GODOT end */
++
+ extern z_off_t ZEXPORT unztell OF((unzFile file));
+ 
+ extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
+diff --git a/thirdparty/minizip/zip.c b/thirdparty/minizip/zip.c
+index 3c34fc8bd..d7093e745 100644
+--- a/thirdparty/minizip/zip.c
++++ b/thirdparty/minizip/zip.c
+@@ -854,9 +854,11 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
+ 
+     ziinit.z_filefunc.zseek32_file = NULL;
+     ziinit.z_filefunc.ztell32_file = NULL;
+-    if (pzlib_filefunc64_32_def==NULL)
+-        fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
+-    else
++    /* GODOT start */
++    if (pzlib_filefunc64_32_def==NULL) {
++        //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
++    } else
++    /* GODOT end */
+         ziinit.z_filefunc = *pzlib_filefunc64_32_def;
+ 
+     ziinit.filestream = ZOPEN64(ziinit.z_filefunc,
+@@ -1210,8 +1212,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
+     {
+         if(zi->ci.method == Z_DEFLATED)
+         {
+-          zi->ci.stream.zalloc = (alloc_func)0;
+-          zi->ci.stream.zfree = (free_func)0;
++          /* GODOT start */
++          zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem;
++          zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem;
++          /* GODOT end */
+           zi->ci.stream.opaque = (voidpf)0;
+ 
+           if (windowBits>0)

+ 9 - 1
thirdparty/minizip/ioapi.c

@@ -6,7 +6,7 @@
          Modifications for Zip64 support
          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
 
-         For more info read LICENSE-MiniZip.txt
+         For more info read MiniZip_info.txt
 
 */
 
@@ -68,11 +68,15 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
     p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
     p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
     p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
+    /* GODOT start */
     p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem;
     p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem;
+    /* GODOT end */
 }
 
+/* GODOT start */
 /*
+// GODOT end
 
 
 static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
@@ -119,6 +123,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
     return file;
 }
 
+
 static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
 {
     uLong ret;
@@ -140,6 +145,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
     return ret;
 }
 
+
 static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
 {
     ZPOS64_T ret;
@@ -234,4 +240,6 @@ void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
     pzlib_filefunc_def->zerror_file = ferror_file_func;
     pzlib_filefunc_def->opaque = NULL;
 }
+// GODOT start
 */
+/* GODOT end */

+ 27 - 22
thirdparty/minizip/ioapi.h

@@ -1,11 +1,12 @@
-/*   this file is part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
 
          Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
 
          Modifications for Zip64 support
          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
 
-         For more info read LICENSE-MiniZip.txt
+         For more info read MiniZip_info.txt
 
          Changes
 
@@ -40,6 +41,7 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include "zlib.h"
 
 #if defined(USE_FILE32API)
@@ -122,14 +124,14 @@ extern "C" {
 
 
 
-typedef voidpf   (ZCALLBACK *open_file_func)      (voidpf opaque, const char* filename, int mode);
-typedef uLong    (ZCALLBACK *read_file_func)      (voidpf opaque, voidpf stream, void* buf, uLong size);
-typedef uLong    (ZCALLBACK *write_file_func)     (voidpf opaque, voidpf stream, const void* buf, uLong size);
-typedef int      (ZCALLBACK *close_file_func)     (voidpf opaque, voidpf stream);
-typedef int      (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
+typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
+typedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));
+typedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
 
-typedef long     (ZCALLBACK *tell_file_func)      (voidpf opaque, voidpf stream);
-typedef long     (ZCALLBACK *seek_file_func)      (voidpf opaque, voidpf stream, uLong offset, int origin);
+typedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));
+typedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));
 
 
 /* here is the "old" 32 bits structure structure */
@@ -143,13 +145,15 @@ typedef struct zlib_filefunc_def_s
     close_file_func     zclose_file;
     testerror_file_func zerror_file;
     voidpf              opaque;
-    alloc_func alloc_mem;
-    free_func free_mem;
+    /* GODOT start */
+    alloc_func          alloc_mem;
+    free_func           free_mem;
+    /* GODOT end */
 } zlib_filefunc_def;
 
-typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    (voidpf opaque, voidpf stream);
-typedef long     (ZCALLBACK *seek64_file_func)    (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
-typedef voidpf   (ZCALLBACK *open64_file_func)    (voidpf opaque, const void* filename, int mode);
+typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
+typedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+typedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));
 
 typedef struct zlib_filefunc64_def_s
 {
@@ -161,13 +165,14 @@ typedef struct zlib_filefunc64_def_s
     close_file_func     zclose_file;
     testerror_file_func zerror_file;
     voidpf              opaque;
-    alloc_func alloc_mem;
-    free_func free_mem;
-
+    /* GODOT start */
+    alloc_func          alloc_mem;
+    free_func           free_mem;
+    /* GODOT end */
 } zlib_filefunc64_def;
 
-void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def);
-void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def);
+void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
 
 /* now internal definition, only for zip.c and unzip.h */
 typedef struct zlib_filefunc64_32_def_s
@@ -186,9 +191,9 @@ typedef struct zlib_filefunc64_32_def_s
 #define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
 #define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
 
-voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
-long    call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
-ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
+voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
+long    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
+ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
 
 void    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
 

+ 125 - 116
thirdparty/minizip/unzip.c

@@ -10,7 +10,7 @@
          Modifications for Zip64 support on both zip and unzip
          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
 
-         For more info read LICENSE-MiniZip.txt
+         For more info read MiniZip_info.txt
 
 
   ------------------------------------------------------------------------------------
@@ -157,7 +157,9 @@ typedef struct
     uLong compression_method;   /* compression method (0==store) */
     ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
     int   raw;
-	int extra_size;
+    /* GODOT start */
+    int extra_size;
+    /* GODOT end */
 } file_in_zip64_read_info_s;
 
 
@@ -205,10 +207,10 @@ typedef struct
 */
 
 
-local int unz64local_getByte (
+local int unz64local_getByte OF((
     const zlib_filefunc64_32_def* pzlib_filefunc_def,
     voidpf filestream,
-    int *pi);
+    int *pi));
 
 local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
 {
@@ -232,10 +234,10 @@ local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, v
 /* ===========================================================================
    Reads a long in LSB order from the given gz_stream. Sets
 */
-local int unz64local_getShort (
+local int unz64local_getShort OF((
     const zlib_filefunc64_32_def* pzlib_filefunc_def,
     voidpf filestream,
-    uLong *pX);
+    uLong *pX));
 
 local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
                              voidpf filestream,
@@ -259,10 +261,10 @@ local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
     return err;
 }
 
-local int unz64local_getLong (
+local int unz64local_getLong OF((
     const zlib_filefunc64_32_def* pzlib_filefunc_def,
     voidpf filestream,
-    uLong *pX);
+    uLong *pX));
 
 local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
                             voidpf filestream,
@@ -294,10 +296,10 @@ local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
     return err;
 }
 
-local int unz64local_getLong64 (
+local int unz64local_getLong64 OF((
     const zlib_filefunc64_32_def* pzlib_filefunc_def,
     voidpf filestream,
-    ZPOS64_T *pX);
+    ZPOS64_T *pX));
 
 
 local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
@@ -410,7 +412,7 @@ extern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,
   Locate the Central directory of a zipfile (at the end, just before
     the global comment)
 */
-local ZPOS64_T unz64local_SearchCentralDir (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream);
+local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
 local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
 {
     unsigned char* buf;
@@ -472,9 +474,9 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
   Locate the Central directory 64 of a zipfile (at the end, just before
     the global comment)
 */
-local ZPOS64_T unz64local_SearchCentralDir64 (
+local ZPOS64_T unz64local_SearchCentralDir64 OF((
     const zlib_filefunc64_32_def* pzlib_filefunc_def,
-    voidpf filestream);
+    voidpf filestream));
 
 local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
                                       voidpf filestream)
@@ -606,9 +608,11 @@ local unzFile unzOpenInternal (const void *path,
 
     us.z_filefunc.zseek32_file = NULL;
     us.z_filefunc.ztell32_file = NULL;
-	if (pzlib_filefunc64_32_def==NULL)
-		return NULL; // standard i/o not supported
-	us.z_filefunc = *pzlib_filefunc64_32_def;
+    if (pzlib_filefunc64_32_def==NULL)
+        /* GODOT start */
+        return NULL; // standard i/o not supported
+    us.z_filefunc = *pzlib_filefunc64_32_def;
+    /* GODOT end */
     us.is64bitOpenFunction = is64bitOpenFunction;
 
 
@@ -617,10 +621,8 @@ local unzFile unzOpenInternal (const void *path,
                                                  path,
                                                  ZLIB_FILEFUNC_MODE_READ |
                                                  ZLIB_FILEFUNC_MODE_EXISTING);
-	if (us.filestream==NULL) {
-		printf("no stream\n");
+    if (us.filestream==NULL)
         return NULL;
-	};
 
     central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
     if (central_pos)
@@ -743,7 +745,6 @@ local unzFile unzOpenInternal (const void *path,
 
     if (err!=UNZ_OK)
     {
-		printf("err is %i, %x\n", err, err);
         ZCLOSE64(us.z_filefunc, us.filestream);
         return NULL;
     }
@@ -803,15 +804,17 @@ extern unzFile ZEXPORT unzOpen64 (const void *path)
     return unzOpenInternal(path, NULL, 1);
 }
 
+/* GODOT start */
 extern void* unzGetOpaque(unzFile file) {
 
-	unz64_s* s;
-	if (file==NULL)
-		return NULL;
-	s=(unz64_s*)file;
+    unz64_s* s;
+    if (file==NULL)
+        return NULL;
+    s=(unz64_s*)file;
 
-	return s->z_filefunc.zfile_func64.opaque;
+    return s->z_filefunc.zfile_func64.opaque;
 };
+/* GODOT end */
 
 /*
   Close a ZipFile opened with unzipOpen.
@@ -878,7 +881,7 @@ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
 /*
   Get Info about the current file in the zipfile, with internal only info
 */
-local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
                                                   unz_file_info64 *pfile_info,
                                                   unz_file_info64_internal
                                                   *pfile_info_internal,
@@ -887,7 +890,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
                                                   void *extraField,
                                                   uLong extraFieldBufferSize,
                                                   char *szComment,
-                                                  uLong commentBufferSize);
+                                                  uLong commentBufferSize));
 
 local int unz64local_GetCurrentFileInfoInternal (unzFile file,
                                                   unz_file_info64 *pfile_info,
@@ -1031,19 +1034,20 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
 
         if (lSeek!=0)
         {
-			if (lSeek<0) {
-				// WORKAROUND for backwards seeking
-				z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
-				if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
-					lSeek=0;
-				else
-					err=UNZ_ERRNO;
-			} else {
-				if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-					lSeek=0;
-				else
-					err=UNZ_ERRNO;
-			}
+            /* GODOT start */
+            if (lSeek<0) {
+                // WORKAROUND for backwards seeking
+                z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
+                if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
+                    lSeek=0;
+                else
+                    err=UNZ_ERRNO;
+            } else {
+                if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+                    lSeek=0;
+                else
+                    err=UNZ_ERRNO;
+            }
         }
 
         while(acc < file_info.size_file_extra)
@@ -1597,8 +1601,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
     }
     else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
     {
+      /* GODOT start */
       pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem;
       pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem;
+      /* GODOT end */
       pfile_in_zip_read_info->stream.opaque = (voidpf)0;
       pfile_in_zip_read_info->stream.next_in = 0;
       pfile_in_zip_read_info->stream.avail_in = 0;
@@ -1608,7 +1614,6 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
         pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
       else
       {
-	   printf("NO OPEN ZLIB %i\n",err);
         TRYFREE(pfile_in_zip_read_info);
         return err;
       }
@@ -1631,7 +1636,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
               iSizeVar;
 
     pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-	pfile_in_zip_read_info->extra_size = iSizeVar;
+    /* GODOT start */
+    pfile_in_zip_read_info->extra_size = iSizeVar;
+    /* GODOT end */
 
     s->pfile_in_zip_read = pfile_in_zip_read_info;
                 s->encrypted = 0;
@@ -1662,82 +1669,84 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
     return UNZ_OK;
 }
 
+/* GODOT start */
 extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) {
 
-	unz64_s* s;
-	file_in_zip64_read_info_s* pfile_in_zip_read_info;
-	if (file==NULL)
-		return UNZ_PARAMERROR;
-	s=(unz64_s*)file;
-	pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-	if (pfile_in_zip_read_info==NULL)
-		return UNZ_PARAMERROR;
-
-	if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip
-		return UNZ_INTERNALERROR;
-	};
-
-	if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
-
-		pfile_in_zip_read_info->rest_read_compressed =
-				s->cur_file_info.compressed_size - pos;
-		pfile_in_zip_read_info->rest_read_uncompressed =
-				s->cur_file_info.uncompressed_size - pos;
-
-		pfile_in_zip_read_info->pos_in_zipfile =
-				s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
-				  pfile_in_zip_read_info->extra_size + pos;
-
-		pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-		pfile_in_zip_read_info->stream.total_out = pos;
-
-		return ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-					  pfile_in_zip_read_info->filestream,
-					  pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile,
-						 ZLIB_FILEFUNC_SEEK_SET);
-
-	} else { // gzip
-
-		if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind
-
-			pfile_in_zip_read_info->rest_read_compressed =
-					s->cur_file_info.compressed_size ;
-			pfile_in_zip_read_info->rest_read_uncompressed =
-					s->cur_file_info.uncompressed_size ;
-
-			pfile_in_zip_read_info->pos_in_zipfile =
-					s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
-					  pfile_in_zip_read_info->extra_size;
-
-			(void)inflateReset(&pfile_in_zip_read_info->stream);
-
-			pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-			pfile_in_zip_read_info->stream.total_out = 0;
-			pfile_in_zip_read_info->stream.next_in = 0;
-		};
-
-		// not sure where to read, so read on the stack
-		{
-			char buf[512];
-			int to_read = pos - pfile_in_zip_read_info->stream.total_out;
-			while (to_read) {
-
-				int len = to_read > sizeof(buf)?sizeof(buf):to_read;
-				int read = unzReadCurrentFile(file, buf, len);
-				if (read < 0) {
-					return read;
-				};
-				to_read -= read;
-				if (read == UNZ_EOF) {
-					return pos;
-				};
-			};
-		};
-	};
-
-	return pos;
+    unz64_s* s;
+    file_in_zip64_read_info_s* pfile_in_zip_read_info;
+    if (file==NULL)
+        return UNZ_PARAMERROR;
+    s=(unz64_s*)file;
+    pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+    if (pfile_in_zip_read_info==NULL)
+        return UNZ_PARAMERROR;
+
+    if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip
+        return UNZ_INTERNALERROR;
+    };
+
+    if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
+
+        pfile_in_zip_read_info->rest_read_compressed =
+                s->cur_file_info.compressed_size - pos;
+        pfile_in_zip_read_info->rest_read_uncompressed =
+                s->cur_file_info.uncompressed_size - pos;
+
+        pfile_in_zip_read_info->pos_in_zipfile =
+                s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+                        pfile_in_zip_read_info->extra_size + pos;
+
+        pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+        pfile_in_zip_read_info->stream.total_out = pos;
+
+        return ZSEEK64(pfile_in_zip_read_info->z_filefunc,
+                       pfile_in_zip_read_info->filestream,
+                       pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile,
+                       ZLIB_FILEFUNC_SEEK_SET);
+
+    } else { // gzip
+
+        if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind
+
+            pfile_in_zip_read_info->rest_read_compressed =
+                    s->cur_file_info.compressed_size ;
+            pfile_in_zip_read_info->rest_read_uncompressed =
+                    s->cur_file_info.uncompressed_size ;
+
+            pfile_in_zip_read_info->pos_in_zipfile =
+                    s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+                            pfile_in_zip_read_info->extra_size;
+
+            (void)inflateReset(&pfile_in_zip_read_info->stream);
+
+            pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+            pfile_in_zip_read_info->stream.total_out = 0;
+            pfile_in_zip_read_info->stream.next_in = 0;
+        };
+
+        // not sure where to read, so read on the stack
+        {
+            char buf[512];
+            int to_read = pos - pfile_in_zip_read_info->stream.total_out;
+            while (to_read) {
+
+                int len = to_read > sizeof(buf)?sizeof(buf):to_read;
+                int read = unzReadCurrentFile(file, buf, len);
+                if (read < 0) {
+                    return read;
+                };
+                to_read -= read;
+                if (read == UNZ_EOF) {
+                    return pos;
+                };
+            };
+        };
+    };
+
+    return pos;
 };
+/* GODOT end */
 
 extern int ZEXPORT unzOpenCurrentFile (unzFile file)
 {
@@ -1797,7 +1806,7 @@ extern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)
         return UNZ_PARAMERROR;
 
 
-    if (pfile_in_zip_read_info->read_buffer==NULL)
+    if ((pfile_in_zip_read_info->read_buffer == NULL))
         return UNZ_END_OF_LIST_OF_FILE;
     if (len==0)
         return 0;

+ 44 - 41
thirdparty/minizip/unzip.h

@@ -10,7 +10,7 @@
          Modifications for Zip64 support on both zip and unzip
          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
 
-         For more info read LICENSE-MiniZip.txt
+         For more info read MiniZip_info.txt
 
          ---------------------------------------------------------------------------------
 
@@ -150,9 +150,9 @@ typedef struct unz_file_info_s
     tm_unz tmu_date;
 } unz_file_info;
 
-extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
                                                  const char* fileName2,
-                                                 int iCaseSensitivity);
+                                                 int iCaseSensitivity));
 /*
    Compare two filename (fileName1,fileName2).
    If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
@@ -163,8 +163,8 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
 */
 
 
-extern unzFile ZEXPORT unzOpen (const char *path);
-extern unzFile ZEXPORT unzOpen64 (const void *path);
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+extern unzFile ZEXPORT unzOpen64 OF((const void *path));
 /*
   Open a Zip file. path contain the full pathname (by example,
      on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
@@ -181,44 +181,45 @@ extern unzFile ZEXPORT unzOpen64 (const void *path);
 */
 
 
-extern unzFile ZEXPORT unzOpen2 (const char *path,
-                                    zlib_filefunc_def* pzlib_filefunc_def);
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+                                    zlib_filefunc_def* pzlib_filefunc_def));
 /*
    Open a Zip file, like unzOpen, but provide a set of file low level API
       for read/write the zip file (see ioapi.h)
 */
 
-extern unzFile ZEXPORT unzOpen2_64 (const void *path,
-                                    zlib_filefunc64_def* pzlib_filefunc_def);
+extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
+                                    zlib_filefunc64_def* pzlib_filefunc_def));
 /*
    Open a Zip file, like unz64Open, but provide a set of file low level API
       for read/write the zip file (see ioapi.h)
 */
 
-extern int ZEXPORT unzClose (unzFile file);
+extern int ZEXPORT unzClose OF((unzFile file));
 /*
   Close a ZipFile opened with unzipOpen.
   If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
     these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
   return UNZ_OK if there is no problem. */
 
+/* GODOT start */
 extern void* unzGetOpaque(unzFile file);
+/* GODOT end */
 
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+                                        unz_global_info *pglobal_info));
 
-extern int ZEXPORT unzGetGlobalInfo (unzFile file,
-                                        unz_global_info *pglobal_info);
-
-extern int ZEXPORT unzGetGlobalInfo64 (unzFile file,
-                                        unz_global_info64 *pglobal_info);
+extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
+                                        unz_global_info64 *pglobal_info));
 /*
   Write info about the ZipFile in the *pglobal_info structure.
   No preparation of the structure is needed
   return UNZ_OK if there is no problem. */
 
 
-extern int ZEXPORT unzGetGlobalComment (unzFile file,
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
                                            char *szComment,
-                                           uLong uSizeBuf);
+                                           uLong uSizeBuf));
 /*
   Get the global comment string of the ZipFile, in the szComment buffer.
   uSizeBuf is the size of the szComment buffer.
@@ -229,22 +230,22 @@ extern int ZEXPORT unzGetGlobalComment (unzFile file,
 /***************************************************************************/
 /* Unzip package allow you browse the directory of the zipfile */
 
-extern int ZEXPORT unzGoToFirstFile (unzFile file);
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
 /*
   Set the current file of the zipfile to the first file.
   return UNZ_OK if there is no problem
 */
 
-extern int ZEXPORT unzGoToNextFile (unzFile file);
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
 /*
   Set the current file of the zipfile to the next file.
   return UNZ_OK if there is no problem
   return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
 */
 
-extern int ZEXPORT unzLocateFile (unzFile file,
+extern int ZEXPORT unzLocateFile OF((unzFile file,
                      const char *szFileName,
-                     int iCaseSensitivity);
+                     int iCaseSensitivity));
 /*
   Try locate the file szFileName in the zipfile.
   For the iCaseSensitivity signification, see unzStringFileNameCompare
@@ -288,23 +289,23 @@ extern int ZEXPORT unzGoToFilePos64(
 
 /* ****************************************** */
 
-extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
+extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
                          unz_file_info64 *pfile_info,
                          char *szFileName,
                          uLong fileNameBufferSize,
                          void *extraField,
                          uLong extraFieldBufferSize,
                          char *szComment,
-                         uLong commentBufferSize);
+                         uLong commentBufferSize));
 
-extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
                          unz_file_info *pfile_info,
                          char *szFileName,
                          uLong fileNameBufferSize,
                          void *extraField,
                          uLong extraFieldBufferSize,
                          char *szComment,
-                         uLong commentBufferSize);
+                         uLong commentBufferSize));
 /*
   Get Info about the current file
   if pfile_info!=NULL, the *pfile_info structure will contain somes info about
@@ -321,7 +322,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
 
 /** Addition for GDAL : START */
 
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 (unzFile file);
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
 
 /** Addition for GDAL : END */
 
@@ -331,24 +332,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 (unzFile file);
    from it, and close it (you can close it before reading all the file)
    */
 
-extern int ZEXPORT unzOpenCurrentFile (unzFile file);
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
 /*
   Open for reading data the current file in the zipfile.
   If there is no error, the return value is UNZ_OK.
 */
 
-extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file,
-                                                  const char* password);
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+                                                  const char* password));
 /*
   Open for reading data the current file in the zipfile.
   password is a crypting password
   If there is no error, the return value is UNZ_OK.
 */
 
-extern int ZEXPORT unzOpenCurrentFile2 (unzFile file,
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
                                            int* method,
                                            int* level,
-                                           int raw);
+                                           int raw));
 /*
   Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
     if raw==1
@@ -358,11 +359,11 @@ extern int ZEXPORT unzOpenCurrentFile2 (unzFile file,
          but you CANNOT set method parameter as NULL
 */
 
-extern int ZEXPORT unzOpenCurrentFile3 (unzFile file,
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
                                            int* method,
                                            int* level,
                                            int raw,
-                                           const char* password);
+                                           const char* password));
 /*
   Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
     if raw==1
@@ -373,15 +374,15 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file,
 */
 
 
-extern int ZEXPORT unzCloseCurrentFile (unzFile file);
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
 /*
   Close the file in zip opened with unzOpenCurrentFile
   Return UNZ_CRCERROR if all the file was read but the CRC is not good
 */
 
-extern int ZEXPORT unzReadCurrentFile (unzFile file,
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
                       voidp buf,
-                      unsigned len);
+                      unsigned len));
 /*
   Read bytes from the current file (opened by unzOpenCurrentFile)
   buf contain buffer where data must be copied
@@ -393,26 +394,28 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file,
     (UNZ_ERRNO for IO error, or zLib error for uncompress error)
 */
 
+/* GODOT start */
 extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos);
 /*
   Seek to position in uncompressed data
 */
+/* GODOT end */
 
-extern z_off_t ZEXPORT unztell (unzFile file);
+extern z_off_t ZEXPORT unztell OF((unzFile file));
 
-extern ZPOS64_T ZEXPORT unztell64 (unzFile file);
+extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
 /*
   Give the current position in uncompressed data
 */
 
-extern int ZEXPORT unzeof (unzFile file);
+extern int ZEXPORT unzeof OF((unzFile file));
 /*
   return 1 if the end of file was reached, 0 elsewhere
 */
 
-extern int ZEXPORT unzGetLocalExtrafield (unzFile file,
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
                                              voidp buf,
-                                             unsigned len);
+                                             unsigned len));
 /*
   Read extra field from the current file (opened by unzOpenCurrentFile)
   This is the local-header version of the extra field (sometimes, there is

+ 18 - 15
thirdparty/minizip/zip.c

@@ -7,7 +7,7 @@
          Modifications for Zip64 support
          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
 
-         For more info read LICENSE-MiniZip.txt
+         For more info read MiniZip_info.txt
 
          Changes
    Oct-2009 - Mathias Svensson - Remove old C style function prototypes
@@ -283,7 +283,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
    nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)
 */
 
-local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte);
+local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte));
 local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
 {
     unsigned char buf[8];
@@ -307,7 +307,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
         return ZIP_OK;
 }
 
-local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte);
+local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte));
 local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
 {
     unsigned char* buf=(unsigned char*)dest;
@@ -344,7 +344,7 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
 
 /****************************************************************************/
 
-local int zip64local_getByte (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi);
+local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi));
 
 local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)
 {
@@ -368,7 +368,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo
 /* ===========================================================================
    Reads a long in LSB order from the given gz_stream. Sets
 */
-local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX);
+local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
 
 local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
 {
@@ -390,7 +390,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
     return err;
 }
 
-local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX);
+local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
 
 local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
 {
@@ -420,7 +420,7 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
     return err;
 }
 
-local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX);
+local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));
 
 
 local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
@@ -475,7 +475,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def
   Locate the Central directory of a zipfile (at the end, just before
     the global comment)
 */
-local ZPOS64_T zip64local_SearchCentralDir (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream);
+local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
 
 local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
 {
@@ -537,7 +537,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
 Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before
 the global comment)
 */
-local ZPOS64_T zip64local_SearchCentralDir64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream);
+local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
 
 local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
 {
@@ -854,9 +854,11 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
 
     ziinit.z_filefunc.zseek32_file = NULL;
     ziinit.z_filefunc.ztell32_file = NULL;
+    /* GODOT start */
     if (pzlib_filefunc64_32_def==NULL) {
-	//fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
+        //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
     } else
+    /* GODOT end */
         ziinit.z_filefunc = *pzlib_filefunc64_32_def;
 
     ziinit.filestream = ZOPEN64(ziinit.z_filefunc,
@@ -1114,9 +1116,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
     zi->ci.flag = flagBase;
     if ((level==8) || (level==9))
       zi->ci.flag |= 2;
-    if (level==2)
+    if ((level==2))
       zi->ci.flag |= 4;
-    if (level==1)
+    if ((level==1))
       zi->ci.flag |= 6;
     if (password != NULL)
       zi->ci.flag |= 1;
@@ -1210,9 +1212,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
     {
         if(zi->ci.method == Z_DEFLATED)
         {
-	  zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem;
-	  zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem;
-
+          /* GODOT start */
+          zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem;
+          zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem;
+          /* GODOT end */
           zi->ci.stream.opaque = (voidpf)0;
 
           if (windowBits>0)

+ 35 - 36
thirdparty/minizip/zip.h

@@ -1,4 +1,5 @@
-/*   Version 1.1, February 14h, 2010
+/* zip.h -- IO on .zip files using zlib
+   Version 1.1, February 14h, 2010
    part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
 
          Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
@@ -6,7 +7,7 @@
          Modifications for Zip64 support
          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
 
-         For more info read LICENSE-MiniZip.txt
+         For more info read MiniZip_info.txt
 
          ---------------------------------------------------------------------------
 
@@ -39,8 +40,6 @@
 #ifndef _zip12_H
 #define _zip12_H
 
-#include <stdlib.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -114,8 +113,8 @@ typedef const char* zipcharpc;
 #define APPEND_STATUS_CREATEAFTER   (1)
 #define APPEND_STATUS_ADDINZIP      (2)
 
-extern zipFile ZEXPORT zipOpen (const char *pathname, int append);
-extern zipFile ZEXPORT zipOpen64 (const void *pathname, int append);
+extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
+extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
 /*
   Create a zipfile.
      pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
@@ -135,17 +134,17 @@ extern zipFile ZEXPORT zipOpen64 (const void *pathname, int append);
    Of couse, you can use RAW reading and writing to copy the file you did not want delte
 */
 
-extern zipFile ZEXPORT zipOpen2 (const char *pathname,
+extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
                                    int append,
                                    zipcharpc* globalcomment,
-                                   zlib_filefunc_def* pzlib_filefunc_def);
+                                   zlib_filefunc_def* pzlib_filefunc_def));
 
-extern zipFile ZEXPORT zipOpen2_64 (const void *pathname,
+extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
                                    int append,
                                    zipcharpc* globalcomment,
-                                   zlib_filefunc64_def* pzlib_filefunc_def);
+                                   zlib_filefunc64_def* pzlib_filefunc_def));
 
-extern int ZEXPORT zipOpenNewFileInZip (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
                        const char* filename,
                        const zip_fileinfo* zipfi,
                        const void* extrafield_local,
@@ -154,9 +153,9 @@ extern int ZEXPORT zipOpenNewFileInZip (zipFile file,
                        uInt size_extrafield_global,
                        const char* comment,
                        int method,
-                       int level);
+                       int level));
 
-extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
                        const char* filename,
                        const zip_fileinfo* zipfi,
                        const void* extrafield_local,
@@ -166,7 +165,7 @@ extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file,
                        const char* comment,
                        int method,
                        int level,
-                       int zip64);
+                       int zip64));
 
 /*
   Open a file in the ZIP for writing.
@@ -185,7 +184,7 @@ extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file,
 */
 
 
-extern int ZEXPORT zipOpenNewFileInZip2 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
                                             const char* filename,
                                             const zip_fileinfo* zipfi,
                                             const void* extrafield_local,
@@ -195,10 +194,10 @@ extern int ZEXPORT zipOpenNewFileInZip2 (zipFile file,
                                             const char* comment,
                                             int method,
                                             int level,
-                                            int raw);
+                                            int raw));
 
 
-extern int ZEXPORT zipOpenNewFileInZip2_64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
                                             const char* filename,
                                             const zip_fileinfo* zipfi,
                                             const void* extrafield_local,
@@ -209,12 +208,12 @@ extern int ZEXPORT zipOpenNewFileInZip2_64 (zipFile file,
                                             int method,
                                             int level,
                                             int raw,
-                                            int zip64);
+                                            int zip64));
 /*
   Same than zipOpenNewFileInZip, except if raw=1, we write raw file
  */
 
-extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
                                             const char* filename,
                                             const zip_fileinfo* zipfi,
                                             const void* extrafield_local,
@@ -229,9 +228,9 @@ extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file,
                                             int memLevel,
                                             int strategy,
                                             const char* password,
-                                            uLong crcForCrypting);
+                                            uLong crcForCrypting));
 
-extern int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
                                             const char* filename,
                                             const zip_fileinfo* zipfi,
                                             const void* extrafield_local,
@@ -248,7 +247,7 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file,
                                             const char* password,
                                             uLong crcForCrypting,
                                             int zip64
-                                            );
+                                            ));
 
 /*
   Same than zipOpenNewFileInZip2, except
@@ -257,7 +256,7 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file,
     crcForCrypting : crc of file to compress (needed for crypting)
  */
 
-extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
                                             const char* filename,
                                             const zip_fileinfo* zipfi,
                                             const void* extrafield_local,
@@ -275,10 +274,10 @@ extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file,
                                             uLong crcForCrypting,
                                             uLong versionMadeBy,
                                             uLong flagBase
-                                            );
+                                            ));
 
 
-extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
                                             const char* filename,
                                             const zip_fileinfo* zipfi,
                                             const void* extrafield_local,
@@ -297,7 +296,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file,
                                             uLong versionMadeBy,
                                             uLong flagBase,
                                             int zip64
-                                            );
+                                            ));
 /*
   Same than zipOpenNewFileInZip4, except
     versionMadeBy : value for Version made by field
@@ -305,25 +304,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file,
  */
 
 
-extern int ZEXPORT zipWriteInFileInZip (zipFile file,
+extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
                        const void* buf,
-                       unsigned len);
+                       unsigned len));
 /*
   Write data in the zipfile
 */
 
-extern int ZEXPORT zipCloseFileInZip (zipFile file);
+extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
 /*
   Close the current file in the zipfile
 */
 
-extern int ZEXPORT zipCloseFileInZipRaw (zipFile file,
+extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
                                             uLong uncompressed_size,
-                                            uLong crc32);
+                                            uLong crc32));
 
-extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file,
+extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
                                             ZPOS64_T uncompressed_size,
-                                            uLong crc32);
+                                            uLong crc32));
 
 /*
   Close the current file in the zipfile, for file opened with
@@ -331,14 +330,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file,
   uncompressed_size and crc32 are value for the uncompressed size
 */
 
-extern int ZEXPORT zipClose (zipFile file,
-                const char* global_comment);
+extern int ZEXPORT zipClose OF((zipFile file,
+                const char* global_comment));
 /*
   Close the zipfile
 */
 
 
-extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader);
+extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
 /*
   zipRemoveExtraInfoBlock -  Added by Mathias Svensson