Annotation of hatari/src/includes/unzip.h, revision 1.1.1.5

1.1       root        1: /*
1.1.1.2   root        2:   Hatari - unzip.h
1.1       root        3: 
1.1.1.2   root        4:   Support for *.zip files, using zlib.
1.1       root        5: 
1.1.1.2   root        6:   This file is originally from the minizip code by Gilles Vollant.
1.1       root        7: 
                      8: */
                      9: /* unzip.h -- IO for uncompress .zip files using zlib 
                     10:    Version 0.15 beta, Mar 19th, 1998,
                     11: 
                     12:    Copyright (C) 1998 Gilles Vollant
                     13: 
                     14:    This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
                     15:      WinZip, InfoZip tools and compatible.
                     16:    Encryption and multi volume ZipFile (span) are not supported.
                     17:    Old compressions used by old PKZip 1.x are not supported
                     18: 
                     19:    THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
                     20:    CAN CHANGE IN FUTURE VERSION !!
                     21:    I WAIT FEEDBACK at mail [email protected]
                     22:    Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
                     23: 
                     24:    Condition of use and distribution are the same than zlib :
                     25: 
                     26:   This software is provided 'as-is', without any express or implied
                     27:   warranty.  In no event will the authors be held liable for any damages
                     28:   arising from the use of this software.
                     29: 
                     30:   Permission is granted to anyone to use this software for any purpose,
                     31:   including commercial applications, and to alter it and redistribute it
                     32:   freely, subject to the following restrictions:
                     33: 
                     34:   1. The origin of this software must not be misrepresented; you must not
                     35:      claim that you wrote the original software. If you use this software
                     36:      in a product, an acknowledgment in the product documentation would be
                     37:      appreciated but is not required.
                     38:   2. Altered source versions must be plainly marked as such, and must not be
                     39:      misrepresented as being the original software.
                     40:   3. This notice may not be removed or altered from any source distribution.
                     41: 
                     42: 
                     43: */
                     44: /* for more info about .ZIP format, see 
                     45:       ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
                     46:    PkWare has also a specification at :
                     47:       ftp://ftp.pkware.com/probdesc.zip */
                     48: 
                     49: #ifndef _unz_H
                     50: #define _unz_H
                     51: 
                     52: #ifdef __cplusplus
                     53: extern "C" {
                     54: #endif
                     55: 
                     56: #ifndef _ZLIB_H
                     57: #include "zlib.h"
                     58: #endif
                     59: 
                     60: #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
                     61: /* like the STRICT of WIN32, we define a pointer that cannot be converted
                     62:     from (void*) without cast */
                     63: typedef struct TagunzFile__ { int unused; } unzFile__; 
                     64: typedef unzFile__ *unzFile;
                     65: #else
                     66: typedef voidp unzFile;
                     67: #endif
                     68: 
                     69: 
                     70: #define UNZ_OK                                  (0)
                     71: #define UNZ_END_OF_LIST_OF_FILE (-100)
                     72: #define UNZ_ERRNO               (Z_ERRNO)
                     73: #define UNZ_EOF                 (0)
                     74: #define UNZ_PARAMERROR                  (-102)
                     75: #define UNZ_BADZIPFILE                  (-103)
                     76: #define UNZ_INTERNALERROR               (-104)
                     77: #define UNZ_CRCERROR                    (-105)
                     78: 
                     79: /* tm_unz contain date/time info */
                     80: typedef struct tm_unz_s 
                     81: {
                     82:        uInt tm_sec;            /* seconds after the minute - [0,59] */
                     83:        uInt tm_min;            /* minutes after the hour - [0,59] */
                     84:        uInt tm_hour;           /* hours since midnight - [0,23] */
                     85:        uInt tm_mday;           /* day of the month - [1,31] */
                     86:        uInt tm_mon;            /* months since January - [0,11] */
                     87:        uInt tm_year;           /* years - [1980..2044] */
                     88: } tm_unz;
                     89: 
                     90: /* unz_global_info structure contain global data about the ZIPfile
                     91:    These data comes from the end of central dir */
                     92: typedef struct unz_global_info_s
                     93: {
                     94:        uLong number_entry;         /* total number of entries in
                     95:                                       the central dir on this disk */
                     96:        uLong size_comment;         /* size of the global comment of the zipfile */
                     97: } unz_global_info;
                     98: 
                     99: 
                    100: /* unz_file_info contain information about a file in the zipfile */
                    101: typedef struct unz_file_info_s
                    102: {
                    103:     uLong version;              /* version made by                 2 bytes */
                    104:     uLong version_needed;       /* version needed to extract       2 bytes */
                    105:     uLong flag;                 /* general purpose bit flag        2 bytes */
                    106:     uLong compression_method;   /* compression method              2 bytes */
                    107:     uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
                    108:     uLong crc;                  /* crc-32                          4 bytes */
                    109:     uLong compressed_size;      /* compressed size                 4 bytes */ 
                    110:     uLong uncompressed_size;    /* uncompressed size               4 bytes */ 
                    111:     uLong size_filename;        /* filename length                 2 bytes */
                    112:     uLong size_file_extra;      /* extra field length              2 bytes */
                    113:     uLong size_file_comment;    /* file comment length             2 bytes */
                    114: 
                    115:     uLong disk_num_start;       /* disk number start               2 bytes */
                    116:     uLong internal_fa;          /* internal file attributes        2 bytes */
                    117:     uLong external_fa;          /* external file attributes        4 bytes */
                    118: 
                    119:     tm_unz tmu_date;
                    120: } unz_file_info;
                    121: 
1.1.1.3   root      122: extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
                    123:                                             const char* fileName2,
                    124:                                             int iCaseSensitivity);
1.1       root      125: /*
                    126:    Compare two filename (fileName1,fileName2).
1.1.1.4   root      127:    If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
                    128:    If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
1.1       root      129:                                                                or strcasecmp)
                    130:    If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
                    131:        (like 1 on Unix, 2 on Windows)
                    132: */
                    133: 
                    134: 
1.1.1.3   root      135: extern unzFile ZEXPORT unzOpen (const char *path);
1.1       root      136: /*
                    137:   Open a Zip file. path contain the full pathname (by example,
                    138:      on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
                    139:         "zlib/zlib111.zip".
                    140:         If the zipfile cannot be opened (file don't exist or in not valid), the
                    141:           return value is NULL.
                    142:      Else, the return value is a unzFile Handle, usable with other function
                    143:           of this unzip package.
                    144: */
                    145: 
1.1.1.3   root      146: extern int ZEXPORT unzClose (unzFile file);
1.1       root      147: /*
                    148:   Close a ZipFile opened with unzipOpen.
                    149:   If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
                    150:     these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
                    151:   return UNZ_OK if there is no problem. */
                    152: 
1.1.1.3   root      153: extern int ZEXPORT unzGetGlobalInfo (unzFile file,
                    154:                                     unz_global_info *pglobal_info);
1.1       root      155: /*
                    156:   Write info about the ZipFile in the *pglobal_info structure.
                    157:   No preparation of the structure is needed
                    158:   return UNZ_OK if there is no problem. */
                    159: 
                    160: 
                    161: /***************************************************************************/
                    162: /* Unzip package allow you browse the directory of the zipfile */
                    163: 
1.1.1.3   root      164: extern int ZEXPORT unzGoToFirstFile (unzFile file);
1.1       root      165: /*
                    166:   Set the current file of the zipfile to the first file.
                    167:   return UNZ_OK if there is no problem
                    168: */
                    169: 
1.1.1.3   root      170: extern int ZEXPORT unzGoToNextFile (unzFile file);
1.1       root      171: /*
                    172:   Set the current file of the zipfile to the next file.
                    173:   return UNZ_OK if there is no problem
                    174:   return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
                    175: */
                    176: 
1.1.1.3   root      177: extern int ZEXPORT unzLocateFile (unzFile file, 
                    178:                                  const char *szFileName,
                    179:                                  int iCaseSensitivity);
1.1       root      180: /*
                    181:   Try locate the file szFileName in the zipfile.
                    182:   For the iCaseSensitivity signification, see unzStringFileNameCompare
                    183: 
                    184:   return value :
                    185:   UNZ_OK if the file is found. It becomes the current file.
                    186:   UNZ_END_OF_LIST_OF_FILE if the file is not found
                    187: */
                    188: 
                    189: 
1.1.1.3   root      190: extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
                    191:                                          unz_file_info *pfile_info,
                    192:                                          char *szFileName,
                    193:                                          uLong fileNameBufferSize,
                    194:                                          void *extraField,
                    195:                                          uLong extraFieldBufferSize,
                    196:                                          char *szComment,
                    197:                                          uLong commentBufferSize);
1.1       root      198: /*
                    199:   Get Info about the current file
                    200:   if pfile_info!=NULL, the *pfile_info structure will contain somes info about
                    201:            the current file
                    202:   if szFileName!=NULL, the filemane string will be copied in szFileName
                    203:                        (fileNameBufferSize is the size of the buffer)
                    204:   if extraField!=NULL, the extra field information will be copied in extraField
                    205:                        (extraFieldBufferSize is the size of the buffer).
                    206:                        This is the Central-header version of the extra field
                    207:   if szComment!=NULL, the comment string of the file will be copied in szComment
                    208:                        (commentBufferSize is the size of the buffer)
                    209: */
                    210: 
                    211: /***************************************************************************/
                    212: /* for reading the content of the current zipfile, you can open it, read data
                    213:    from it, and close it (you can close it before reading all the file)
                    214:    */
                    215: 
1.1.1.3   root      216: extern int ZEXPORT unzOpenCurrentFile (unzFile file);
1.1       root      217: /*
                    218:   Open for reading data the current file in the zipfile.
                    219:   If there is no error, the return value is UNZ_OK.
                    220: */
                    221: 
1.1.1.3   root      222: extern int ZEXPORT unzCloseCurrentFile (unzFile file);
1.1       root      223: /*
                    224:   Close the file in zip opened with unzOpenCurrentFile
                    225:   Return UNZ_CRCERROR if all the file was read but the CRC is not good
                    226: */
                    227: 
                    228:                                                                                                
1.1.1.3   root      229: extern int ZEXPORT unzReadCurrentFile (unzFile file, 
                    230:                                       voidp buf,
                    231:                                       unsigned len);
1.1       root      232: /*
                    233:   Read bytes from the current file (opened by unzOpenCurrentFile)
                    234:   buf contain buffer where data must be copied
                    235:   len the size of buf.
                    236: 
                    237:   return the number of byte copied if somes bytes are copied
                    238:   return 0 if the end of file was reached
                    239:   return <0 with error code if there is an error
                    240:     (UNZ_ERRNO for IO error, or zLib error for uncompress error)
                    241: */
                    242: 
1.1.1.3   root      243: extern z_off_t ZEXPORT unztell (unzFile file);
1.1       root      244: /*
                    245:   Give the current position in uncompressed data
                    246: */
                    247: 
1.1.1.3   root      248: extern int ZEXPORT unzeof (unzFile file);
1.1       root      249: /*
                    250:   return 1 if the end of file was reached, 0 elsewhere 
                    251: */
                    252: 
                    253: #ifdef __cplusplus
                    254: }
                    255: #endif
                    256: 
                    257: #endif /* _unz_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.