diff src/common/unzip.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/common/unzip.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,275 @@
     1.4 +/* unzip.h -- IO for uncompress .zip files using zlib 
     1.5 +   Version 0.15 beta, Mar 19th, 1998,
     1.6 +
     1.7 +   Copyright (C) 1998 Gilles Vollant
     1.8 +
     1.9 +   This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
    1.10 +     WinZip, InfoZip tools and compatible.
    1.11 +   Encryption and multi volume ZipFile (span) are not supported.
    1.12 +   Old compressions used by old PKZip 1.x are not supported
    1.13 +
    1.14 +   THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
    1.15 +   CAN CHANGE IN FUTURE VERSION !!
    1.16 +   I WAIT FEEDBACK at mail info@winimage.com
    1.17 +   Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
    1.18 +
    1.19 +   Condition of use and distribution are the same than zlib :
    1.20 +
    1.21 +  This software is provided 'as-is', without any express or implied
    1.22 +  warranty.  In no event will the authors be held liable for any damages
    1.23 +  arising from the use of this software.
    1.24 +
    1.25 +  Permission is granted to anyone to use this software for any purpose,
    1.26 +  including commercial applications, and to alter it and redistribute it
    1.27 +  freely, subject to the following restrictions:
    1.28 +
    1.29 +  1. The origin of this software must not be misrepresented; you must not
    1.30 +     claim that you wrote the original software. If you use this software
    1.31 +     in a product, an acknowledgment in the product documentation would be
    1.32 +     appreciated but is not required.
    1.33 +  2. Altered source versions must be plainly marked as such, and must not be
    1.34 +     misrepresented as being the original software.
    1.35 +  3. This notice may not be removed or altered from any source distribution.
    1.36 +
    1.37 +
    1.38 +*/
    1.39 +/* for more info about .ZIP format, see 
    1.40 +      ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
    1.41 +   PkWare has also a specification at :
    1.42 +      ftp://ftp.pkware.com/probdesc.zip */
    1.43 +
    1.44 +#ifndef _unz_H
    1.45 +#define _unz_H
    1.46 +
    1.47 +#ifdef __cplusplus
    1.48 +extern "C" {
    1.49 +#endif
    1.50 +
    1.51 +#ifndef _ZLIB_H
    1.52 +#include "zlib.h"
    1.53 +#endif
    1.54 +
    1.55 +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
    1.56 +/* like the STRICT of WIN32, we define a pointer that cannot be converted
    1.57 +    from (void*) without cast */
    1.58 +typedef struct TagunzFile__ { int unused; } unzFile__; 
    1.59 +typedef unzFile__ *unzFile;
    1.60 +#else
    1.61 +typedef voidp unzFile;
    1.62 +#endif
    1.63 +
    1.64 +
    1.65 +#define UNZ_OK                                  (0)
    1.66 +#define UNZ_END_OF_LIST_OF_FILE (-100)
    1.67 +#define UNZ_ERRNO               (Z_ERRNO)
    1.68 +#define UNZ_EOF                 (0)
    1.69 +#define UNZ_PARAMERROR                  (-102)
    1.70 +#define UNZ_BADZIPFILE                  (-103)
    1.71 +#define UNZ_INTERNALERROR               (-104)
    1.72 +#define UNZ_CRCERROR                    (-105)
    1.73 +
    1.74 +/* tm_unz contain date/time info */
    1.75 +typedef struct tm_unz_s 
    1.76 +{
    1.77 +        uInt tm_sec;            /* seconds after the minute - [0,59] */
    1.78 +        uInt tm_min;            /* minutes after the hour - [0,59] */
    1.79 +        uInt tm_hour;           /* hours since midnight - [0,23] */
    1.80 +        uInt tm_mday;           /* day of the month - [1,31] */
    1.81 +        uInt tm_mon;            /* months since January - [0,11] */
    1.82 +        uInt tm_year;           /* years - [1980..2044] */
    1.83 +} tm_unz;
    1.84 +
    1.85 +/* unz_global_info structure contain global data about the ZIPfile
    1.86 +   These data comes from the end of central dir */
    1.87 +typedef struct unz_global_info_s
    1.88 +{
    1.89 +        uLong number_entry;         /* total number of entries in
    1.90 +                                       the central dir on this disk */
    1.91 +        uLong size_comment;         /* size of the global comment of the zipfile */
    1.92 +} unz_global_info;
    1.93 +
    1.94 +
    1.95 +/* unz_file_info contain information about a file in the zipfile */
    1.96 +typedef struct unz_file_info_s
    1.97 +{
    1.98 +    uLong version;              /* version made by                 2 bytes */
    1.99 +    uLong version_needed;       /* version needed to extract       2 bytes */
   1.100 +    uLong flag;                 /* general purpose bit flag        2 bytes */
   1.101 +    uLong compression_method;   /* compression method              2 bytes */
   1.102 +    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
   1.103 +    uLong crc;                  /* crc-32                          4 bytes */
   1.104 +    uLong compressed_size;      /* compressed size                 4 bytes */ 
   1.105 +    uLong uncompressed_size;    /* uncompressed size               4 bytes */ 
   1.106 +    uLong size_filename;        /* filename length                 2 bytes */
   1.107 +    uLong size_file_extra;      /* extra field length              2 bytes */
   1.108 +    uLong size_file_comment;    /* file comment length             2 bytes */
   1.109 +
   1.110 +    uLong disk_num_start;       /* disk number start               2 bytes */
   1.111 +    uLong internal_fa;          /* internal file attributes        2 bytes */
   1.112 +    uLong external_fa;          /* external file attributes        4 bytes */
   1.113 +
   1.114 +    tm_unz tmu_date;
   1.115 +} unz_file_info;
   1.116 +
   1.117 +extern int ZEXPORT  unzStringFileNameCompare OF ((const char* fileName1,
   1.118 +                                                 const char* fileName2,
   1.119 +                                                 int iCaseSensitivity));
   1.120 +/*
   1.121 +   Compare two filename (fileName1,fileName2).
   1.122 +   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
   1.123 +   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
   1.124 +                                                                or strcasecmp)
   1.125 +   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
   1.126 +        (like 1 on Unix, 2 on Windows)
   1.127 +*/
   1.128 +
   1.129 +
   1.130 +extern unzFile ZEXPORT  unzOpen OF((const char *path));
   1.131 +/*
   1.132 +  Open a Zip file. path contain the full pathname (by example,
   1.133 +     on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
   1.134 +         "zlib/zlib111.zip".
   1.135 +         If the zipfile cannot be opened (file don't exist or in not valid), the
   1.136 +           return value is NULL.
   1.137 +     Else, the return value is a unzFile Handle, usable with other function
   1.138 +           of this unzip package.
   1.139 +*/
   1.140 +
   1.141 +extern int ZEXPORT  unzClose OF((unzFile file));
   1.142 +/*
   1.143 +  Close a ZipFile opened with unzipOpen.
   1.144 +  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
   1.145 +    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
   1.146 +  return UNZ_OK if there is no problem. */
   1.147 +
   1.148 +extern int ZEXPORT  unzGetGlobalInfo OF((unzFile file,
   1.149 +                                        unz_global_info *pglobal_info));
   1.150 +/*
   1.151 +  Write info about the ZipFile in the *pglobal_info structure.
   1.152 +  No preparation of the structure is needed
   1.153 +  return UNZ_OK if there is no problem. */
   1.154 +
   1.155 +
   1.156 +extern int ZEXPORT  unzGetGlobalComment OF((unzFile file,
   1.157 +                                           char *szComment,
   1.158 +                                           uLong uSizeBuf));
   1.159 +/*
   1.160 +  Get the global comment string of the ZipFile, in the szComment buffer.
   1.161 +  uSizeBuf is the size of the szComment buffer.
   1.162 +  return the number of byte copied or an error code <0
   1.163 +*/
   1.164 +
   1.165 +
   1.166 +/***************************************************************************/
   1.167 +/* Unzip package allow you browse the directory of the zipfile */
   1.168 +
   1.169 +extern int ZEXPORT  unzGoToFirstFile OF((unzFile file));
   1.170 +/*
   1.171 +  Set the current file of the zipfile to the first file.
   1.172 +  return UNZ_OK if there is no problem
   1.173 +*/
   1.174 +
   1.175 +extern int ZEXPORT  unzGoToNextFile OF((unzFile file));
   1.176 +/*
   1.177 +  Set the current file of the zipfile to the next file.
   1.178 +  return UNZ_OK if there is no problem
   1.179 +  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
   1.180 +*/
   1.181 +
   1.182 +extern int ZEXPORT  unzLocateFile OF((unzFile file, 
   1.183 +                                     const char *szFileName,
   1.184 +                                     int iCaseSensitivity));
   1.185 +/*
   1.186 +  Try locate the file szFileName in the zipfile.
   1.187 +  For the iCaseSensitivity signification, see unzStringFileNameCompare
   1.188 +
   1.189 +  return value :
   1.190 +  UNZ_OK if the file is found. It becomes the current file.
   1.191 +  UNZ_END_OF_LIST_OF_FILE if the file is not found
   1.192 +*/
   1.193 +
   1.194 +
   1.195 +extern int ZEXPORT  unzGetCurrentFileInfo OF((unzFile file,
   1.196 +                                             unz_file_info *pfile_info,
   1.197 +                                             char *szFileName,
   1.198 +                                             uLong fileNameBufferSize,
   1.199 +                                             void *extraField,
   1.200 +                                             uLong extraFieldBufferSize,
   1.201 +                                             char *szComment,
   1.202 +                                             uLong commentBufferSize));
   1.203 +/*
   1.204 +  Get Info about the current file
   1.205 +  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
   1.206 +            the current file
   1.207 +  if szFileName!=NULL, the filemane string will be copied in szFileName
   1.208 +                        (fileNameBufferSize is the size of the buffer)
   1.209 +  if extraField!=NULL, the extra field information will be copied in extraField
   1.210 +                        (extraFieldBufferSize is the size of the buffer).
   1.211 +                        This is the Central-header version of the extra field
   1.212 +  if szComment!=NULL, the comment string of the file will be copied in szComment
   1.213 +                        (commentBufferSize is the size of the buffer)
   1.214 +*/
   1.215 +
   1.216 +/***************************************************************************/
   1.217 +/* for reading the content of the current zipfile, you can open it, read data
   1.218 +   from it, and close it (you can close it before reading all the file)
   1.219 +   */
   1.220 +
   1.221 +extern int ZEXPORT  unzOpenCurrentFile OF((unzFile file));
   1.222 +/*
   1.223 +  Open for reading data the current file in the zipfile.
   1.224 +  If there is no error, the return value is UNZ_OK.
   1.225 +*/
   1.226 +
   1.227 +extern int ZEXPORT  unzCloseCurrentFile OF((unzFile file));
   1.228 +/*
   1.229 +  Close the file in zip opened with unzOpenCurrentFile
   1.230 +  Return UNZ_CRCERROR if all the file was read but the CRC is not good
   1.231 +*/
   1.232 +
   1.233 +                                                                                                
   1.234 +extern int ZEXPORT  unzReadCurrentFile OF((unzFile file, 
   1.235 +                                          voidp buf,
   1.236 +                                          unsigned len));
   1.237 +/*
   1.238 +  Read bytes from the current file (opened by unzOpenCurrentFile)
   1.239 +  buf contain buffer where data must be copied
   1.240 +  len the size of buf.
   1.241 +
   1.242 +  return the number of byte copied if somes bytes are copied
   1.243 +  return 0 if the end of file was reached
   1.244 +  return <0 with error code if there is an error
   1.245 +    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
   1.246 +*/
   1.247 +
   1.248 +extern z_off_t ZEXPORT  unztell OF((unzFile file));
   1.249 +/*
   1.250 +  Give the current position in uncompressed data
   1.251 +*/
   1.252 +
   1.253 +extern int ZEXPORT  unzeof OF((unzFile file));
   1.254 +/*
   1.255 +  return 1 if the end of file was reached, 0 elsewhere 
   1.256 +*/
   1.257 +
   1.258 +extern int ZEXPORT  unzGetLocalExtrafield OF((unzFile file,
   1.259 +                                             voidp buf,
   1.260 +                                             unsigned len));
   1.261 +/*
   1.262 +  Read extra field from the current file (opened by unzOpenCurrentFile)
   1.263 +  This is the local-header version of the extra field (sometimes, there is
   1.264 +    more info in the local-header version than in the central-header)
   1.265 +
   1.266 +  if buf==NULL, it return the size of the local extra field
   1.267 +
   1.268 +  if buf!=NULL, len is the size of the buffer, the extra header is copied in
   1.269 +        buf.
   1.270 +  the return value is the number of bytes copied in buf, or (if <0) 
   1.271 +        the error code
   1.272 +*/
   1.273 +
   1.274 +#ifdef __cplusplus
   1.275 +}
   1.276 +#endif
   1.277 +
   1.278 +#endif /* _unz_H */