unzip.h
Go to the documentation of this file.
00001 /* unzip.h -- IO for uncompress .zip files using zlib
00002    Version 1.1, February 14h, 2010
00003    part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
00004 
00005          Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
00006 
00007          Modifications of Unzip for Zip64
00008          Copyright (C) 2007-2008 Even Rouault
00009 
00010          Modifications for Zip64 support on both zip and unzip
00011          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
00012 
00013          For more info read MiniZip_info.txt
00014 
00015          ---------------------------------------------------------------------------------
00016 
00017         Condition of use and distribution are the same than zlib :
00018 
00019   This software is provided 'as-is', without any express or implied
00020   warranty.  In no event will the authors be held liable for any damages
00021   arising from the use of this software.
00022 
00023   Permission is granted to anyone to use this software for any purpose,
00024   including commercial applications, and to alter it and redistribute it
00025   freely, subject to the following restrictions:
00026 
00027   1. The origin of this software must not be misrepresented; you must not
00028      claim that you wrote the original software. If you use this software
00029      in a product, an acknowledgment in the product documentation would be
00030      appreciated but is not required.
00031   2. Altered source versions must be plainly marked as such, and must not be
00032      misrepresented as being the original software.
00033   3. This notice may not be removed or altered from any source distribution.
00034 
00035   ---------------------------------------------------------------------------------
00036 
00037         Changes
00038 
00039         See header of unzip64.c
00040 
00041 */
00042 
00043 #ifndef _unz64_H
00044 #define _unz64_H
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00050 #ifndef _ZLIB_H
00051 #include "zlib.h"
00052 #endif
00053 
00054 #ifndef  _ZLIBIOAPI_H
00055 #include "ioapi.h"
00056 #endif
00057 
00058 #ifdef HAVE_BZIP2
00059 #include "bzlib.h"
00060 #endif
00061 
00062 #define Z_BZIP2ED 12
00063 
00064 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
00065 /* like the STRICT of WIN32, we define a pointer that cannot be converted
00066     from (void*) without cast */
00067 typedef struct TagunzFile__ { int unused; } unzFile__;
00068 typedef unzFile__ *unzFile;
00069 #else
00070 typedef voidp unzFile;
00071 #endif
00072 
00073 
00074 #define UNZ_OK                          (0)
00075 #define UNZ_END_OF_LIST_OF_FILE         (-100)
00076 #define UNZ_ERRNO                       (Z_ERRNO)
00077 #define UNZ_EOF                         (0)
00078 #define UNZ_PARAMERROR                  (-102)
00079 #define UNZ_BADZIPFILE                  (-103)
00080 #define UNZ_INTERNALERROR               (-104)
00081 #define UNZ_CRCERROR                    (-105)
00082 
00083 /* tm_unz contain date/time info */
00084 typedef struct tm_unz_s
00085 {
00086     uInt tm_sec;            /* seconds after the minute - [0,59] */
00087     uInt tm_min;            /* minutes after the hour - [0,59] */
00088     uInt tm_hour;           /* hours since midnight - [0,23] */
00089     uInt tm_mday;           /* day of the month - [1,31] */
00090     uInt tm_mon;            /* months since January - [0,11] */
00091     uInt tm_year;           /* years - [1980..2044] */
00092 } tm_unz;
00093 
00094 /* unz_global_info structure contain global data about the ZIPfile
00095    These data comes from the end of central dir */
00096 typedef struct unz_global_info64_s
00097 {
00098     ZPOS64_T number_entry;         /* total number of entries in
00099                                      the central dir on this disk */
00100     uLong size_comment;         /* size of the global comment of the zipfile */
00101 } unz_global_info64;
00102 
00103 typedef struct unz_global_info_s
00104 {
00105     uLong number_entry;         /* total number of entries in
00106                                      the central dir on this disk */
00107     uLong size_comment;         /* size of the global comment of the zipfile */
00108 } unz_global_info;
00109 
00110 /* unz_file_info contain information about a file in the zipfile */
00111 typedef struct unz_file_info64_s
00112 {
00113     uLong version;              /* version made by                 2 bytes */
00114     uLong version_needed;       /* version needed to extract       2 bytes */
00115     uLong flag;                 /* general purpose bit flag        2 bytes */
00116     uLong compression_method;   /* compression method              2 bytes */
00117     uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
00118     uLong crc;                  /* crc-32                          4 bytes */
00119     ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
00120     ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
00121     uLong size_filename;        /* filename length                 2 bytes */
00122     uLong size_file_extra;      /* extra field length              2 bytes */
00123     uLong size_file_comment;    /* file comment length             2 bytes */
00124 
00125     uLong disk_num_start;       /* disk number start               2 bytes */
00126     uLong internal_fa;          /* internal file attributes        2 bytes */
00127     uLong external_fa;          /* external file attributes        4 bytes */
00128 
00129     tm_unz tmu_date;
00130 } unz_file_info64;
00131 
00132 typedef struct unz_file_info_s
00133 {
00134     uLong version;              /* version made by                 2 bytes */
00135     uLong version_needed;       /* version needed to extract       2 bytes */
00136     uLong flag;                 /* general purpose bit flag        2 bytes */
00137     uLong compression_method;   /* compression method              2 bytes */
00138     uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
00139     uLong crc;                  /* crc-32                          4 bytes */
00140     uLong compressed_size;      /* compressed size                 4 bytes */
00141     uLong uncompressed_size;    /* uncompressed size               4 bytes */
00142     uLong size_filename;        /* filename length                 2 bytes */
00143     uLong size_file_extra;      /* extra field length              2 bytes */
00144     uLong size_file_comment;    /* file comment length             2 bytes */
00145 
00146     uLong disk_num_start;       /* disk number start               2 bytes */
00147     uLong internal_fa;          /* internal file attributes        2 bytes */
00148     uLong external_fa;          /* external file attributes        4 bytes */
00149 
00150     tm_unz tmu_date;
00151 } unz_file_info;
00152 
00153 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
00154                                                  const char* fileName2,
00155                                                  int iCaseSensitivity));
00156 /*
00157    Compare two filename (fileName1,fileName2).
00158    If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
00159    If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
00160                                 or strcasecmp)
00161    If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
00162     (like 1 on Unix, 2 on Windows)
00163 */
00164 
00165 
00166 extern unzFile ZEXPORT unzOpen OF((const char *path));
00167 extern unzFile ZEXPORT unzOpen64 OF((const void *path));
00168 /*
00169   Open a Zip file. path contain the full pathname (by example,
00170      on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
00171      "zlib/zlib113.zip".
00172      If the zipfile cannot be opened (file don't exist or in not valid), the
00173        return value is NULL.
00174      Else, the return value is a unzFile Handle, usable with other function
00175        of this unzip package.
00176      the "64" function take a const void* pointer, because the path is just the
00177        value passed to the open64_file_func callback.
00178      Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
00179        is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
00180        does not describe the reality
00181 */
00182 
00183 
00184 extern unzFile ZEXPORT unzOpen2 OF((const char *path,
00185                                     zlib_filefunc_def* pzlib_filefunc_def));
00186 /*
00187    Open a Zip file, like unzOpen, but provide a set of file low level API
00188       for read/write the zip file (see ioapi.h)
00189 */
00190 
00191 extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
00192                                     zlib_filefunc64_def* pzlib_filefunc_def));
00193 /*
00194    Open a Zip file, like unz64Open, but provide a set of file low level API
00195       for read/write the zip file (see ioapi.h)
00196 */
00197 
00198 extern int ZEXPORT unzClose OF((unzFile file));
00199 /*
00200   Close a ZipFile opened with unzipOpen.
00201   If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
00202     these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
00203   return UNZ_OK if there is no problem. */
00204 
00205 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
00206                                         unz_global_info *pglobal_info));
00207 
00208 extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
00209                                         unz_global_info64 *pglobal_info));
00210 /*
00211   Write info about the ZipFile in the *pglobal_info structure.
00212   No preparation of the structure is needed
00213   return UNZ_OK if there is no problem. */
00214 
00215 
00216 extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
00217                                            char *szComment,
00218                                            uLong uSizeBuf));
00219 /*
00220   Get the global comment string of the ZipFile, in the szComment buffer.
00221   uSizeBuf is the size of the szComment buffer.
00222   return the number of byte copied or an error code <0
00223 */
00224 
00225 
00226 /***************************************************************************/
00227 /* Unzip package allow you browse the directory of the zipfile */
00228 
00229 extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
00230 /*
00231   Set the current file of the zipfile to the first file.
00232   return UNZ_OK if there is no problem
00233 */
00234 
00235 extern int ZEXPORT unzGoToNextFile OF((unzFile file));
00236 /*
00237   Set the current file of the zipfile to the next file.
00238   return UNZ_OK if there is no problem
00239   return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
00240 */
00241 
00242 extern int ZEXPORT unzLocateFile OF((unzFile file,
00243                      const char *szFileName,
00244                      int iCaseSensitivity));
00245 /*
00246   Try locate the file szFileName in the zipfile.
00247   For the iCaseSensitivity signification, see unzStringFileNameCompare
00248 
00249   return value :
00250   UNZ_OK if the file is found. It becomes the current file.
00251   UNZ_END_OF_LIST_OF_FILE if the file is not found
00252 */
00253 
00254 
00255 /* ****************************************** */
00256 /* Ryan supplied functions */
00257 /* unz_file_info contain information about a file in the zipfile */
00258 typedef struct unz_file_pos_s
00259 {
00260     uLong pos_in_zip_directory;   /* offset in zip file directory */
00261     uLong num_of_file;            /* # of file */
00262 } unz_file_pos;
00263 
00264 extern int ZEXPORT unzGetFilePos(
00265     unzFile file,
00266     unz_file_pos* file_pos);
00267 
00268 extern int ZEXPORT unzGoToFilePos(
00269     unzFile file,
00270     unz_file_pos* file_pos);
00271 
00272 typedef struct unz64_file_pos_s
00273 {
00274     ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
00275     ZPOS64_T num_of_file;            /* # of file */
00276 } unz64_file_pos;
00277 
00278 extern int ZEXPORT unzGetFilePos64(
00279     unzFile file,
00280     unz64_file_pos* file_pos);
00281 
00282 extern int ZEXPORT unzGoToFilePos64(
00283     unzFile file,
00284     const unz64_file_pos* file_pos);
00285 
00286 /* ****************************************** */
00287 
00288 extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
00289                          unz_file_info64 *pfile_info,
00290                          char *szFileName,
00291                          uLong fileNameBufferSize,
00292                          void *extraField,
00293                          uLong extraFieldBufferSize,
00294                          char *szComment,
00295                          uLong commentBufferSize));
00296 
00297 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
00298                          unz_file_info *pfile_info,
00299                          char *szFileName,
00300                          uLong fileNameBufferSize,
00301                          void *extraField,
00302                          uLong extraFieldBufferSize,
00303                          char *szComment,
00304                          uLong commentBufferSize));
00305 /*
00306   Get Info about the current file
00307   if pfile_info!=NULL, the *pfile_info structure will contain somes info about
00308         the current file
00309   if szFileName!=NULL, the filemane string will be copied in szFileName
00310             (fileNameBufferSize is the size of the buffer)
00311   if extraField!=NULL, the extra field information will be copied in extraField
00312             (extraFieldBufferSize is the size of the buffer).
00313             This is the Central-header version of the extra field
00314   if szComment!=NULL, the comment string of the file will be copied in szComment
00315             (commentBufferSize is the size of the buffer)
00316 */
00317 
00318 
00321 extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
00322 
00326 /***************************************************************************/
00327 /* for reading the content of the current zipfile, you can open it, read data
00328    from it, and close it (you can close it before reading all the file)
00329    */
00330 
00331 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
00332 /*
00333   Open for reading data the current file in the zipfile.
00334   If there is no error, the return value is UNZ_OK.
00335 */
00336 
00337 extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
00338                                                   const char* password));
00339 /*
00340   Open for reading data the current file in the zipfile.
00341   password is a crypting password
00342   If there is no error, the return value is UNZ_OK.
00343 */
00344 
00345 extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
00346                                            int* method,
00347                                            int* level,
00348                                            int raw));
00349 /*
00350   Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
00351     if raw==1
00352   *method will receive method of compression, *level will receive level of
00353      compression
00354   note : you can set level parameter as NULL (if you did not want known level,
00355          but you CANNOT set method parameter as NULL
00356 */
00357 
00358 extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
00359                                            int* method,
00360                                            int* level,
00361                                            int raw,
00362                                            const char* password));
00363 /*
00364   Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
00365     if raw==1
00366   *method will receive method of compression, *level will receive level of
00367      compression
00368   note : you can set level parameter as NULL (if you did not want known level,
00369          but you CANNOT set method parameter as NULL
00370 */
00371 
00372 
00373 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
00374 /*
00375   Close the file in zip opened with unzOpenCurrentFile
00376   Return UNZ_CRCERROR if all the file was read but the CRC is not good
00377 */
00378 
00379 extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
00380                       voidp buf,
00381                       unsigned len));
00382 /*
00383   Read bytes from the current file (opened by unzOpenCurrentFile)
00384   buf contain buffer where data must be copied
00385   len the size of buf.
00386 
00387   return the number of byte copied if somes bytes are copied
00388   return 0 if the end of file was reached
00389   return <0 with error code if there is an error
00390     (UNZ_ERRNO for IO error, or zLib error for uncompress error)
00391 */
00392 
00393 extern z_off_t ZEXPORT unztell OF((unzFile file));
00394 
00395 extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
00396 /*
00397   Give the current position in uncompressed data
00398 */
00399 
00400 extern int ZEXPORT unzeof OF((unzFile file));
00401 /*
00402   return 1 if the end of file was reached, 0 elsewhere
00403 */
00404 
00405 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
00406                                              voidp buf,
00407                                              unsigned len));
00408 /*
00409   Read extra field from the current file (opened by unzOpenCurrentFile)
00410   This is the local-header version of the extra field (sometimes, there is
00411     more info in the local-header version than in the central-header)
00412 
00413   if buf==NULL, it return the size of the local extra field
00414 
00415   if buf!=NULL, len is the size of the buffer, the extra header is copied in
00416     buf.
00417   the return value is the number of bytes copied in buf, or (if <0)
00418     the error code
00419 */
00420 
00421 /***************************************************************************/
00422 
00423 /* Get the current file offset */
00424 extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
00425 extern uLong ZEXPORT unzGetOffset (unzFile file);
00426 
00427 /* Set the current file offset */
00428 extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
00429 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
00430 
00431 
00432 
00433 #ifdef __cplusplus
00434 }
00435 #endif
00436 
00437 #endif /* _unz64_H */


re_object_recorder
Author(s): Andreas Koch
autogenerated on Sun Jan 5 2014 11:39:12