kusano 7d535a
/* unzip.h -- IO for uncompress .zip files using zlib
kusano 7d535a
   Version 1.1, February 14h, 2010
kusano 7d535a
   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
kusano 7d535a
kusano 7d535a
         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
kusano 7d535a
kusano 7d535a
         Modifications of Unzip for Zip64
kusano 7d535a
         Copyright (C) 2007-2008 Even Rouault
kusano 7d535a
kusano 7d535a
         Modifications for Zip64 support on both zip and unzip
kusano 7d535a
         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
kusano 7d535a
kusano 7d535a
         For more info read MiniZip_info.txt
kusano 7d535a
kusano 7d535a
         ---------------------------------------------------------------------------------
kusano 7d535a
kusano 7d535a
        Condition of use and distribution are the same than zlib :
kusano 7d535a
kusano 7d535a
  This software is provided 'as-is', without any express or implied
kusano 7d535a
  warranty.  In no event will the authors be held liable for any damages
kusano 7d535a
  arising from the use of this software.
kusano 7d535a
kusano 7d535a
  Permission is granted to anyone to use this software for any purpose,
kusano 7d535a
  including commercial applications, and to alter it and redistribute it
kusano 7d535a
  freely, subject to the following restrictions:
kusano 7d535a
kusano 7d535a
  1. The origin of this software must not be misrepresented; you must not
kusano 7d535a
     claim that you wrote the original software. If you use this software
kusano 7d535a
     in a product, an acknowledgment in the product documentation would be
kusano 7d535a
     appreciated but is not required.
kusano 7d535a
  2. Altered source versions must be plainly marked as such, and must not be
kusano 7d535a
     misrepresented as being the original software.
kusano 7d535a
  3. This notice may not be removed or altered from any source distribution.
kusano 7d535a
kusano 7d535a
  ---------------------------------------------------------------------------------
kusano 7d535a
kusano 7d535a
        Changes
kusano 7d535a
kusano 7d535a
        See header of unzip64.c
kusano 7d535a
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
#ifndef _unz64_H
kusano 7d535a
#define _unz64_H
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
extern "C" {
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifndef _ZLIB_H
kusano 7d535a
#include "zlib.h"
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifndef  _ZLIBIOAPI_H
kusano 7d535a
#include "ioapi.h"
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifdef HAVE_BZIP2
kusano 7d535a
#include "bzlib.h"
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#define Z_BZIP2ED 12
kusano 7d535a
kusano 7d535a
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
kusano 7d535a
/* like the STRICT of WIN32, we define a pointer that cannot be converted
kusano 7d535a
    from (void*) without cast */
kusano 7d535a
typedef struct TagunzFile__ { int unused; } unzFile__;
kusano 7d535a
typedef unzFile__ *unzFile;
kusano 7d535a
#else
kusano 7d535a
typedef voidp unzFile;
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
#define UNZ_OK                          (0)
kusano 7d535a
#define UNZ_END_OF_LIST_OF_FILE         (-100)
kusano 7d535a
#define UNZ_ERRNO                       (Z_ERRNO)
kusano 7d535a
#define UNZ_EOF                         (0)
kusano 7d535a
#define UNZ_PARAMERROR                  (-102)
kusano 7d535a
#define UNZ_BADZIPFILE                  (-103)
kusano 7d535a
#define UNZ_INTERNALERROR               (-104)
kusano 7d535a
#define UNZ_CRCERROR                    (-105)
kusano 7d535a
kusano 7d535a
/* tm_unz contain date/time info */
kusano 7d535a
typedef struct tm_unz_s
kusano 7d535a
{
kusano 7d535a
    uInt tm_sec;            /* seconds after the minute - [0,59] */
kusano 7d535a
    uInt tm_min;            /* minutes after the hour - [0,59] */
kusano 7d535a
    uInt tm_hour;           /* hours since midnight - [0,23] */
kusano 7d535a
    uInt tm_mday;           /* day of the month - [1,31] */
kusano 7d535a
    uInt tm_mon;            /* months since January - [0,11] */
kusano 7d535a
    uInt tm_year;           /* years - [1980..2044] */
kusano 7d535a
} tm_unz;
kusano 7d535a
kusano 7d535a
/* unz_global_info structure contain global data about the ZIPfile
kusano 7d535a
   These data comes from the end of central dir */
kusano 7d535a
typedef struct unz_global_info64_s
kusano 7d535a
{
kusano 7d535a
    ZPOS64_T number_entry;         /* total number of entries in
kusano 7d535a
                                     the central dir on this disk */
kusano 7d535a
    uLong size_comment;         /* size of the global comment of the zipfile */
kusano 7d535a
} unz_global_info64;
kusano 7d535a
kusano 7d535a
typedef struct unz_global_info_s
kusano 7d535a
{
kusano 7d535a
    uLong number_entry;         /* total number of entries in
kusano 7d535a
                                     the central dir on this disk */
kusano 7d535a
    uLong size_comment;         /* size of the global comment of the zipfile */
kusano 7d535a
} unz_global_info;
kusano 7d535a
kusano 7d535a
/* unz_file_info contain information about a file in the zipfile */
kusano 7d535a
typedef struct unz_file_info64_s
kusano 7d535a
{
kusano 7d535a
    uLong version;              /* version made by                 2 bytes */
kusano 7d535a
    uLong version_needed;       /* version needed to extract       2 bytes */
kusano 7d535a
    uLong flag;                 /* general purpose bit flag        2 bytes */
kusano 7d535a
    uLong compression_method;   /* compression method              2 bytes */
kusano 7d535a
    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
kusano 7d535a
    uLong crc;                  /* crc-32                          4 bytes */
kusano 7d535a
    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
kusano 7d535a
    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
kusano 7d535a
    uLong size_filename;        /* filename length                 2 bytes */
kusano 7d535a
    uLong size_file_extra;      /* extra field length              2 bytes */
kusano 7d535a
    uLong size_file_comment;    /* file comment length             2 bytes */
kusano 7d535a
kusano 7d535a
    uLong disk_num_start;       /* disk number start               2 bytes */
kusano 7d535a
    uLong internal_fa;          /* internal file attributes        2 bytes */
kusano 7d535a
    uLong external_fa;          /* external file attributes        4 bytes */
kusano 7d535a
kusano 7d535a
    tm_unz tmu_date;
kusano 7d535a
} unz_file_info64;
kusano 7d535a
kusano 7d535a
typedef struct unz_file_info_s
kusano 7d535a
{
kusano 7d535a
    uLong version;              /* version made by                 2 bytes */
kusano 7d535a
    uLong version_needed;       /* version needed to extract       2 bytes */
kusano 7d535a
    uLong flag;                 /* general purpose bit flag        2 bytes */
kusano 7d535a
    uLong compression_method;   /* compression method              2 bytes */
kusano 7d535a
    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
kusano 7d535a
    uLong crc;                  /* crc-32                          4 bytes */
kusano 7d535a
    uLong compressed_size;      /* compressed size                 4 bytes */
kusano 7d535a
    uLong uncompressed_size;    /* uncompressed size               4 bytes */
kusano 7d535a
    uLong size_filename;        /* filename length                 2 bytes */
kusano 7d535a
    uLong size_file_extra;      /* extra field length              2 bytes */
kusano 7d535a
    uLong size_file_comment;    /* file comment length             2 bytes */
kusano 7d535a
kusano 7d535a
    uLong disk_num_start;       /* disk number start               2 bytes */
kusano 7d535a
    uLong internal_fa;          /* internal file attributes        2 bytes */
kusano 7d535a
    uLong external_fa;          /* external file attributes        4 bytes */
kusano 7d535a
kusano 7d535a
    tm_unz tmu_date;
kusano 7d535a
} unz_file_info;
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
kusano 7d535a
                                                 const char* fileName2,
kusano 7d535a
                                                 int iCaseSensitivity));
kusano 7d535a
/*
kusano 7d535a
   Compare two filename (fileName1,fileName2).
kusano 7d535a
   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
kusano 7d535a
   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
kusano 7d535a
                                or strcasecmp)
kusano 7d535a
   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
kusano 7d535a
    (like 1 on Unix, 2 on Windows)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
extern unzFile ZEXPORT unzOpen OF((const char *path));
kusano 7d535a
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
kusano 7d535a
/*
kusano 7d535a
  Open a Zip file. path contain the full pathname (by example,
kusano 7d535a
     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
kusano 7d535a
     "zlib/zlib113.zip".
kusano 7d535a
     If the zipfile cannot be opened (file don't exist or in not valid), the
kusano 7d535a
       return value is NULL.
kusano 7d535a
     Else, the return value is a unzFile Handle, usable with other function
kusano 7d535a
       of this unzip package.
kusano 7d535a
     the "64" function take a const void* pointer, because the path is just the
kusano 7d535a
       value passed to the open64_file_func callback.
kusano 7d535a
     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
kusano 7d535a
       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
kusano 7d535a
       does not describe the reality
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
kusano 7d535a
                                    zlib_filefunc_def* pzlib_filefunc_def));
kusano 7d535a
/*
kusano 7d535a
   Open a Zip file, like unzOpen, but provide a set of file low level API
kusano 7d535a
      for read/write the zip file (see ioapi.h)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
kusano 7d535a
                                    zlib_filefunc64_def* pzlib_filefunc_def));
kusano 7d535a
/*
kusano 7d535a
   Open a Zip file, like unz64Open, but provide a set of file low level API
kusano 7d535a
      for read/write the zip file (see ioapi.h)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzClose OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  Close a ZipFile opened with unzipOpen.
kusano 7d535a
  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
kusano 7d535a
    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
kusano 7d535a
  return UNZ_OK if there is no problem. */
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
kusano 7d535a
                                        unz_global_info *pglobal_info));
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
kusano 7d535a
                                        unz_global_info64 *pglobal_info));
kusano 7d535a
/*
kusano 7d535a
  Write info about the ZipFile in the *pglobal_info structure.
kusano 7d535a
  No preparation of the structure is needed
kusano 7d535a
  return UNZ_OK if there is no problem. */
kusano 7d535a
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
kusano 7d535a
                                           char *szComment,
kusano 7d535a
                                           uLong uSizeBuf));
kusano 7d535a
/*
kusano 7d535a
  Get the global comment string of the ZipFile, in the szComment buffer.
kusano 7d535a
  uSizeBuf is the size of the szComment buffer.
kusano 7d535a
  return the number of byte copied or an error code <0
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
/***************************************************************************/
kusano 7d535a
/* Unzip package allow you browse the directory of the zipfile */
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  Set the current file of the zipfile to the first file.
kusano 7d535a
  return UNZ_OK if there is no problem
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  Set the current file of the zipfile to the next file.
kusano 7d535a
  return UNZ_OK if there is no problem
kusano 7d535a
  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzLocateFile OF((unzFile file,
kusano 7d535a
                     const char *szFileName,
kusano 7d535a
                     int iCaseSensitivity));
kusano 7d535a
/*
kusano 7d535a
  Try locate the file szFileName in the zipfile.
kusano 7d535a
  For the iCaseSensitivity signification, see unzStringFileNameCompare
kusano 7d535a
kusano 7d535a
  return value :
kusano 7d535a
  UNZ_OK if the file is found. It becomes the current file.
kusano 7d535a
  UNZ_END_OF_LIST_OF_FILE if the file is not found
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* ****************************************** */
kusano 7d535a
/* Ryan supplied functions */
kusano 7d535a
/* unz_file_info contain information about a file in the zipfile */
kusano 7d535a
typedef struct unz_file_pos_s
kusano 7d535a
{
kusano 7d535a
    uLong pos_in_zip_directory;   /* offset in zip file directory */
kusano 7d535a
    uLong num_of_file;            /* # of file */
kusano 7d535a
} unz_file_pos;
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetFilePos(
kusano 7d535a
    unzFile file,
kusano 7d535a
    unz_file_pos* file_pos);
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGoToFilePos(
kusano 7d535a
    unzFile file,
kusano 7d535a
    unz_file_pos* file_pos);
kusano 7d535a
kusano 7d535a
typedef struct unz64_file_pos_s
kusano 7d535a
{
kusano 7d535a
    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
kusano 7d535a
    ZPOS64_T num_of_file;            /* # of file */
kusano 7d535a
} unz64_file_pos;
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetFilePos64(
kusano 7d535a
    unzFile file,
kusano 7d535a
    unz64_file_pos* file_pos);
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGoToFilePos64(
kusano 7d535a
    unzFile file,
kusano 7d535a
    const unz64_file_pos* file_pos);
kusano 7d535a
kusano 7d535a
/* ****************************************** */
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
kusano 7d535a
                         unz_file_info64 *pfile_info,
kusano 7d535a
                         char *szFileName,
kusano 7d535a
                         uLong fileNameBufferSize,
kusano 7d535a
                         void *extraField,
kusano 7d535a
                         uLong extraFieldBufferSize,
kusano 7d535a
                         char *szComment,
kusano 7d535a
                         uLong commentBufferSize));
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
kusano 7d535a
                         unz_file_info *pfile_info,
kusano 7d535a
                         char *szFileName,
kusano 7d535a
                         uLong fileNameBufferSize,
kusano 7d535a
                         void *extraField,
kusano 7d535a
                         uLong extraFieldBufferSize,
kusano 7d535a
                         char *szComment,
kusano 7d535a
                         uLong commentBufferSize));
kusano 7d535a
/*
kusano 7d535a
  Get Info about the current file
kusano 7d535a
  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
kusano 7d535a
        the current file
kusano 7d535a
  if szFileName!=NULL, the filemane string will be copied in szFileName
kusano 7d535a
            (fileNameBufferSize is the size of the buffer)
kusano 7d535a
  if extraField!=NULL, the extra field information will be copied in extraField
kusano 7d535a
            (extraFieldBufferSize is the size of the buffer).
kusano 7d535a
            This is the Central-header version of the extra field
kusano 7d535a
  if szComment!=NULL, the comment string of the file will be copied in szComment
kusano 7d535a
            (commentBufferSize is the size of the buffer)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
/** Addition for GDAL : START */
kusano 7d535a
kusano 7d535a
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
kusano 7d535a
kusano 7d535a
/** Addition for GDAL : END */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/***************************************************************************/
kusano 7d535a
/* for reading the content of the current zipfile, you can open it, read data
kusano 7d535a
   from it, and close it (you can close it before reading all the file)
kusano 7d535a
   */
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  Open for reading data the current file in the zipfile.
kusano 7d535a
  If there is no error, the return value is UNZ_OK.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
kusano 7d535a
                                                  const char* password));
kusano 7d535a
/*
kusano 7d535a
  Open for reading data the current file in the zipfile.
kusano 7d535a
  password is a crypting password
kusano 7d535a
  If there is no error, the return value is UNZ_OK.
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
kusano 7d535a
                                           int* method,
kusano 7d535a
                                           int* level,
kusano 7d535a
                                           int raw));
kusano 7d535a
/*
kusano 7d535a
  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
kusano 7d535a
    if raw==1
kusano 7d535a
  *method will receive method of compression, *level will receive level of
kusano 7d535a
     compression
kusano 7d535a
  note : you can set level parameter as NULL (if you did not want known level,
kusano 7d535a
         but you CANNOT set method parameter as NULL
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
kusano 7d535a
                                           int* method,
kusano 7d535a
                                           int* level,
kusano 7d535a
                                           int raw,
kusano 7d535a
                                           const char* password));
kusano 7d535a
/*
kusano 7d535a
  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
kusano 7d535a
    if raw==1
kusano 7d535a
  *method will receive method of compression, *level will receive level of
kusano 7d535a
     compression
kusano 7d535a
  note : you can set level parameter as NULL (if you did not want known level,
kusano 7d535a
         but you CANNOT set method parameter as NULL
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  Close the file in zip opened with unzOpenCurrentFile
kusano 7d535a
  Return UNZ_CRCERROR if all the file was read but the CRC is not good
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
kusano 7d535a
                      voidp buf,
kusano 7d535a
                      unsigned len));
kusano 7d535a
/*
kusano 7d535a
  Read bytes from the current file (opened by unzOpenCurrentFile)
kusano 7d535a
  buf contain buffer where data must be copied
kusano 7d535a
  len the size of buf.
kusano 7d535a
kusano 7d535a
  return the number of byte copied if somes bytes are copied
kusano 7d535a
  return 0 if the end of file was reached
kusano 7d535a
  return <0 with error code if there is an error
kusano 7d535a
    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern z_off_t ZEXPORT unztell OF((unzFile file));
kusano 7d535a
kusano 7d535a
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  Give the current position in uncompressed data
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzeof OF((unzFile file));
kusano 7d535a
/*
kusano 7d535a
  return 1 if the end of file was reached, 0 elsewhere
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
kusano 7d535a
                                             voidp buf,
kusano 7d535a
                                             unsigned len));
kusano 7d535a
/*
kusano 7d535a
  Read extra field from the current file (opened by unzOpenCurrentFile)
kusano 7d535a
  This is the local-header version of the extra field (sometimes, there is
kusano 7d535a
    more info in the local-header version than in the central-header)
kusano 7d535a
kusano 7d535a
  if buf==NULL, it return the size of the local extra field
kusano 7d535a
kusano 7d535a
  if buf!=NULL, len is the size of the buffer, the extra header is copied in
kusano 7d535a
    buf.
kusano 7d535a
  the return value is the number of bytes copied in buf, or (if <0)
kusano 7d535a
    the error code
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
/***************************************************************************/
kusano 7d535a
kusano 7d535a
/* Get the current file offset */
kusano 7d535a
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
kusano 7d535a
extern uLong ZEXPORT unzGetOffset (unzFile file);
kusano 7d535a
kusano 7d535a
/* Set the current file offset */
kusano 7d535a
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
kusano 7d535a
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
}
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif /* _unz64_H */