1 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
\r
2 /* like the STRICT of WIN32, we define a pointer that cannot be converted
\r
3 from (void*) without cast */
\r
4 typedef struct TagunzFile__ { int unused; } unzFile__;
\r
5 typedef unzFile__ *unzFile;
\r
7 typedef void* unzFile;
\r
11 /* tm_unz contain date/time info */
\r
12 typedef struct tm_unz_s
\r
14 unsigned int tm_sec; /* seconds after the minute - [0,59] */
\r
15 unsigned int tm_min; /* minutes after the hour - [0,59] */
\r
16 unsigned int tm_hour; /* hours since midnight - [0,23] */
\r
17 unsigned int tm_mday; /* day of the month - [1,31] */
\r
18 unsigned int tm_mon; /* months since January - [0,11] */
\r
19 unsigned int tm_year; /* years - [1980..2044] */
\r
22 /* unz_global_info structure contain global data about the ZIPfile
\r
23 These data comes from the end of central dir */
\r
24 typedef struct unz_global_info_s
\r
26 unsigned long number_entry; /* total number of entries in the central dir on this disk */
\r
27 unsigned long size_comment; /* size of the global comment of the zipfile */
\r
31 /* unz_file_info contain information about a file in the zipfile */
\r
32 typedef struct unz_file_info_s
\r
34 unsigned long version; /* version made by 2 unsigned chars */
\r
35 unsigned long version_needed; /* version needed to extract 2 unsigned chars */
\r
36 unsigned long flag; /* general purpose bit flag 2 unsigned chars */
\r
37 unsigned long compression_method; /* compression method 2 unsigned chars */
\r
38 unsigned long dosDate; /* last mod file date in Dos fmt 4 unsigned chars */
\r
39 unsigned long crc; /* crc-32 4 unsigned chars */
\r
40 unsigned long compressed_size; /* compressed size 4 unsigned chars */
\r
41 unsigned long uncompressed_size; /* uncompressed size 4 unsigned chars */
\r
42 unsigned long size_filename; /* filename length 2 unsigned chars */
\r
43 unsigned long size_file_extra; /* extra field length 2 unsigned chars */
\r
44 unsigned long size_file_comment; /* file comment length 2 unsigned chars */
\r
46 unsigned long disk_num_start; /* disk number start 2 unsigned chars */
\r
47 unsigned long internal_fa; /* internal file attributes 2 unsigned chars */
\r
48 unsigned long external_fa; /* external file attributes 4 unsigned chars */
\r
53 /* unz_file_info_interntal contain internal info about a file in zipfile*/
\r
54 typedef struct unz_file_info_internal_s
\r
56 unsigned long offset_curfile;/* relative offset of static header 4 unsigned chars */
\r
57 } unz_file_info_internal;
\r
59 typedef void* (*alloc_func) (void* opaque, unsigned int items, unsigned int size);
\r
60 typedef void (*free_func) (void* opaque, void* address);
\r
62 struct internal_state;
\r
64 typedef struct z_stream_s {
\r
65 unsigned char *next_in; /* next input unsigned char */
\r
66 unsigned int avail_in; /* number of unsigned chars available at next_in */
\r
67 unsigned long total_in; /* total nb of input unsigned chars read so */
\r
69 unsigned char *next_out; /* next output unsigned char should be put there */
\r
70 unsigned int avail_out; /* remaining free space at next_out */
\r
71 unsigned long total_out; /* total nb of unsigned chars output so */
\r
73 char *msg; /* last error message, NULL if no error */
\r
74 struct internal_state *state; /* not visible by applications */
\r
76 alloc_func zalloc; /* used to allocate the internal state */
\r
77 free_func zfree; /* used to free the internal state */
\r
78 unsigned char* opaque; /* private data object passed to zalloc and zfree */
\r
80 int data_type; /* best guess about the data type: ascii or binary */
\r
81 unsigned long adler; /* adler32 value of the uncompressed data */
\r
82 unsigned long reserved; /* reserved for future use */
\r
85 typedef z_stream *z_streamp;
\r
88 /* file_in_zip_read_info_s contain internal information about a file in zipfile,
\r
89 when reading and decompress it */
\r
92 char *read_buffer; /* internal buffer for compressed data */
\r
93 z_stream stream; /* zLib stream structure for inflate */
\r
95 unsigned long pos_in_zipfile; /* position in unsigned char on the zipfile, for fseek*/
\r
96 unsigned long stream_initialised; /* flag set if stream structure is initialised*/
\r
98 unsigned long offset_local_extrafield;/* offset of the static extra field */
\r
99 unsigned int size_local_extrafield;/* size of the static extra field */
\r
100 unsigned long pos_local_extrafield; /* position in the static extra field in read*/
\r
102 unsigned long crc32; /* crc32 of all data uncompressed */
\r
103 unsigned long crc32_wait; /* crc32 we must obtain after decompress all */
\r
104 unsigned long rest_read_compressed; /* number of unsigned char to be decompressed */
\r
105 unsigned long rest_read_uncompressed;/*number of unsigned char to be obtained after decomp*/
\r
106 FILE* file; /* io structore of the zipfile */
\r
107 unsigned long compression_method; /* compression method (0==store) */
\r
108 unsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/
\r
109 } file_in_zip_read_info_s;
\r
112 /* unz_s contain internal information about the zipfile
\r
116 FILE* file; /* io structore of the zipfile */
\r
117 unz_global_info gi; /* public global information */
\r
118 unsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/
\r
119 unsigned long num_file; /* number of the current file in the zipfile*/
\r
120 unsigned long pos_in_central_dir; /* pos of the current file in the central dir*/
\r
121 unsigned long current_file_ok; /* flag about the usability of the current file*/
\r
122 unsigned long central_pos; /* position of the beginning of the central dir*/
\r
124 unsigned long size_central_dir; /* size of the central directory */
\r
125 unsigned long offset_central_dir; /* offset of start of central directory with
\r
126 respect to the starting disk number */
\r
128 unz_file_info cur_file_info; /* public info about the current file in zip*/
\r
129 unz_file_info_internal cur_file_info_internal; /* private info about it*/
\r
130 file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
\r
131 file if we are decompressing it */
\r
135 #define UNZ_END_OF_LIST_OF_FILE (-100)
\r
136 #define UNZ_ERRNO (Z_ERRNO)
\r
137 #define UNZ_EOF (0)
\r
138 #define UNZ_PARAMERROR (-102)
\r
139 #define UNZ_BADZIPFILE (-103)
\r
140 #define UNZ_INTERNALERROR (-104)
\r
141 #define UNZ_CRCERROR (-105)
\r
143 #define UNZ_CASESENSITIVE 1
\r
144 #define UNZ_NOTCASESENSITIVE 2
\r
145 #define UNZ_OSDEFAULTCASE 0
\r
147 extern int unzStringFileNameCompare (const char* fileName1, const char* fileName2, int iCaseSensitivity);
\r
150 Compare two filename (fileName1,fileName2).
\r
151 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
\r
152 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
\r
154 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
\r
155 (like 1 on Unix, 2 on Windows)
\r
158 extern unzFile unzOpen (const char *path);
\r
159 extern unzFile unzReOpen (const char* path, unzFile file);
\r
162 Open a Zip file. path contain the full pathname (by example,
\r
163 on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
\r
164 "zlib/zlib111.zip".
\r
165 If the zipfile cannot be opened (file don't exist or in not valid), the
\r
166 return value is NULL.
\r
167 Else, the return value is a unzFile Handle, usable with other function
\r
168 of this unzip package.
\r
171 extern int unzClose (unzFile file);
\r
174 Close a ZipFile opened with unzipOpen.
\r
175 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
\r
176 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
\r
177 return UNZ_OK if there is no problem. */
\r
179 extern int unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info);
\r
182 Write info about the ZipFile in the *pglobal_info structure.
\r
183 No preparation of the structure is needed
\r
184 return UNZ_OK if there is no problem. */
\r
187 extern int unzGetGlobalComment (unzFile file, char *szComment, unsigned long uSizeBuf);
\r
190 Get the global comment string of the ZipFile, in the szComment buffer.
\r
191 uSizeBuf is the size of the szComment buffer.
\r
192 return the number of unsigned char copied or an error code <0
\r
196 /***************************************************************************/
\r
197 /* Unzip package allow you browse the directory of the zipfile */
\r
199 extern int unzGoToFirstFile (unzFile file);
\r
202 Set the current file of the zipfile to the first file.
\r
203 return UNZ_OK if there is no problem
\r
206 extern int unzGoToNextFile (unzFile file);
\r
209 Set the current file of the zipfile to the next file.
\r
210 return UNZ_OK if there is no problem
\r
211 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
\r
214 extern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity);
\r
217 Try locate the file szFileName in the zipfile.
\r
218 For the iCaseSensitivity signification, see unzStringFileNameCompare
\r
221 UNZ_OK if the file is found. It becomes the current file.
\r
222 UNZ_END_OF_LIST_OF_FILE if the file is not found
\r
226 extern int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char *szFileName, unsigned long fileNameBufferSize, void *extraField, unsigned long extraFieldBufferSize, char *szComment, unsigned long commentBufferSize);
\r
229 Get Info about the current file
\r
230 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
\r
232 if szFileName!=NULL, the filemane string will be copied in szFileName
\r
233 (fileNameBufferSize is the size of the buffer)
\r
234 if extraField!=NULL, the extra field information will be copied in extraField
\r
235 (extraFieldBufferSize is the size of the buffer).
\r
236 This is the Central-header version of the extra field
\r
237 if szComment!=NULL, the comment string of the file will be copied in szComment
\r
238 (commentBufferSize is the size of the buffer)
\r
241 /***************************************************************************/
\r
242 /* for reading the content of the current zipfile, you can open it, read data
\r
243 from it, and close it (you can close it before reading all the file)
\r
246 extern int unzOpenCurrentFile (unzFile file);
\r
249 Open for reading data the current file in the zipfile.
\r
250 If there is no error, the return value is UNZ_OK.
\r
253 extern int unzCloseCurrentFile (unzFile file);
\r
256 Close the file in zip opened with unzOpenCurrentFile
\r
257 Return UNZ_CRCERROR if all the file was read but the CRC is not good
\r
261 extern int unzReadCurrentFile (unzFile file, void* buf, unsigned len);
\r
264 Read unsigned chars from the current file (opened by unzOpenCurrentFile)
\r
265 buf contain buffer where data must be copied
\r
266 len the size of buf.
\r
268 return the number of unsigned char copied if somes unsigned chars are copied
\r
269 return 0 if the end of file was reached
\r
270 return <0 with error code if there is an error
\r
271 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
\r
274 extern long unztell(unzFile file);
\r
277 Give the current position in uncompressed data
\r
280 extern int unzeof (unzFile file);
\r
283 return 1 if the end of file was reached, 0 elsewhere
\r
286 extern int unzGetLocalExtrafield (unzFile file, void* buf, unsigned len);
\r
289 Read extra field from the current file (opened by unzOpenCurrentFile)
\r
290 This is the local-header version of the extra field (sometimes, there is
\r
291 more info in the local-header version than in the central-header)
\r
293 if buf==NULL, it return the size of the local extra field
\r
295 if buf!=NULL, len is the size of the buffer, the extra header is copied in
\r
297 the return value is the number of unsigned chars copied in buf, or (if <0)
\r