]> git.sesse.net Git - vlc/blob - modules/gui/skins2/unzip/unzip.h
c3206a05899d3229a9024a1431d45416edd8c5e3
[vlc] / modules / gui / skins2 / unzip / unzip.h
1 /* unzip.h -- IO for uncompress .zip files using zlib\r
2    Version 1.01e, February 12th, 2005\r
3 \r
4    Copyright (C) 1998-2005 Gilles Vollant\r
5 \r
6    This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g\r
7      WinZip, InfoZip tools and compatible.\r
8 \r
9    Multi volume ZipFile (span) are not supported.\r
10    Encryption compatible with pkzip 2.04g only supported\r
11    Old compressions used by old PKZip 1.x are not supported\r
12 \r
13 \r
14    I WAIT FEEDBACK at mail info@winimage.com\r
15    Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution\r
16 \r
17    Condition of use and distribution are the same than zlib :\r
18 \r
19   This software is provided 'as-is', without any express or implied\r
20   warranty.  In no event will the authors be held liable for any damages\r
21   arising from the use of this software.\r
22 \r
23   Permission is granted to anyone to use this software for any purpose,\r
24   including commercial applications, and to alter it and redistribute it\r
25   freely, subject to the following restrictions:\r
26 \r
27   1. The origin of this software must not be misrepresented; you must not\r
28      claim that you wrote the original software. If you use this software\r
29      in a product, an acknowledgment in the product documentation would be\r
30      appreciated but is not required.\r
31   2. Altered source versions must be plainly marked as such, and must not be\r
32      misrepresented as being the original software.\r
33   3. This notice may not be removed or altered from any source distribution.\r
34 \r
35 \r
36 */\r
37 \r
38 /* for more info about .ZIP format, see\r
39       http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip\r
40       http://www.info-zip.org/pub/infozip/doc/\r
41    PkWare has also a specification at :\r
42       ftp://ftp.pkware.com/probdesc.zip\r
43 */\r
44 \r
45 #ifndef _unz_H\r
46 #define _unz_H\r
47 \r
48 #ifdef __cplusplus\r
49 extern "C" {\r
50 #endif\r
51 \r
52 #ifndef _ZLIB_H\r
53 #include "zlib.h"\r
54 #endif\r
55 \r
56 #ifndef _ZLIBIOAPI_H\r
57 #include "ioapi.h"\r
58 #endif\r
59 \r
60 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\r
61 /* like the STRICT of WIN32, we define a pointer that cannot be converted\r
62     from (void*) without cast */\r
63 typedef struct TagunzFile__ { int unused; } unzFile__;\r
64 typedef unzFile__ *unzFile;\r
65 #else\r
66 typedef voidp unzFile;\r
67 #endif\r
68 \r
69 \r
70 #define UNZ_OK                          (0)\r
71 #define UNZ_END_OF_LIST_OF_FILE         (-100)\r
72 #define UNZ_ERRNO                       (Z_ERRNO)\r
73 #define UNZ_EOF                         (0)\r
74 #define UNZ_PARAMERROR                  (-102)\r
75 #define UNZ_BADZIPFILE                  (-103)\r
76 #define UNZ_INTERNALERROR               (-104)\r
77 #define UNZ_CRCERROR                    (-105)\r
78 \r
79 /* tm_unz contain date/time info */\r
80 typedef struct tm_unz_s\r
81 {\r
82     uInt tm_sec;            /* seconds after the minute - [0,59] */\r
83     uInt tm_min;            /* minutes after the hour - [0,59] */\r
84     uInt tm_hour;           /* hours since midnight - [0,23] */\r
85     uInt tm_mday;           /* day of the month - [1,31] */\r
86     uInt tm_mon;            /* months since January - [0,11] */\r
87     uInt tm_year;           /* years - [1980..2044] */\r
88 } tm_unz;\r
89 \r
90 /* unz_global_info structure contain global data about the ZIPfile\r
91    These data comes from the end of central dir */\r
92 typedef struct unz_global_info_s\r
93 {\r
94     uLong number_entry;         /* total number of entries in\r
95                        the central dir on this disk */\r
96     uLong size_comment;         /* size of the global comment of the zipfile */\r
97 } unz_global_info;\r
98 \r
99 \r
100 /* unz_file_info contain information about a file in the zipfile */\r
101 typedef struct unz_file_info_s\r
102 {\r
103     uLong version;              /* version made by                 2 bytes */\r
104     uLong version_needed;       /* version needed to extract       2 bytes */\r
105     uLong flag;                 /* general purpose bit flag        2 bytes */\r
106     uLong compression_method;   /* compression method              2 bytes */\r
107     uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\r
108     uLong crc;                  /* crc-32                          4 bytes */\r
109     uLong compressed_size;      /* compressed size                 4 bytes */\r
110     uLong uncompressed_size;    /* uncompressed size               4 bytes */\r
111     uLong size_filename;        /* filename length                 2 bytes */\r
112     uLong size_file_extra;      /* extra field length              2 bytes */\r
113     uLong size_file_comment;    /* file comment length             2 bytes */\r
114 \r
115     uLong disk_num_start;       /* disk number start               2 bytes */\r
116     uLong internal_fa;          /* internal file attributes        2 bytes */\r
117     uLong external_fa;          /* external file attributes        4 bytes */\r
118 \r
119     tm_unz tmu_date;\r
120 } unz_file_info;\r
121 \r
122 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,\r
123                                                  const char* fileName2,\r
124                                                  int iCaseSensitivity));\r
125 /*\r
126    Compare two filename (fileName1,fileName2).\r
127    If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\r
128    If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\r
129                                 or strcasecmp)\r
130    If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\r
131     (like 1 on Unix, 2 on Windows)\r
132 */\r
133 \r
134 \r
135 extern unzFile ZEXPORT unzOpen OF((const char *path));\r
136 /*\r
137   Open a Zip file. path contain the full pathname (by example,\r
138      on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer\r
139      "zlib/zlib113.zip".\r
140      If the zipfile cannot be opened (file don't exist or in not valid), the\r
141        return value is NULL.\r
142      Else, the return value is a unzFile Handle, usable with other function\r
143        of this unzip package.\r
144 */\r
145 \r
146 extern unzFile ZEXPORT unzOpen2 OF((const char *path,\r
147                                     zlib_filefunc_def* pzlib_filefunc_def));\r
148 /*\r
149    Open a Zip file, like unzOpen, but provide a set of file low level API\r
150       for read/write the zip file (see ioapi.h)\r
151 */\r
152 \r
153 extern int ZEXPORT unzClose OF((unzFile file));\r
154 /*\r
155   Close a ZipFile opened with unzipOpen.\r
156   If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\r
157     these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\r
158   return UNZ_OK if there is no problem. */\r
159 \r
160 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,\r
161                                         unz_global_info *pglobal_info));\r
162 /*\r
163   Write info about the ZipFile in the *pglobal_info structure.\r
164   No preparation of the structure is needed\r
165   return UNZ_OK if there is no problem. */\r
166 \r
167 \r
168 extern int ZEXPORT unzGetGlobalComment OF((unzFile file,\r
169                                            char *szComment,\r
170                                            uLong uSizeBuf));\r
171 /*\r
172   Get the global comment string of the ZipFile, in the szComment buffer.\r
173   uSizeBuf is the size of the szComment buffer.\r
174   return the number of byte copied or an error code <0\r
175 */\r
176 \r
177 \r
178 /***************************************************************************/\r
179 /* Unzip package allow you browse the directory of the zipfile */\r
180 \r
181 extern int ZEXPORT unzGoToFirstFile OF((unzFile file));\r
182 /*\r
183   Set the current file of the zipfile to the first file.\r
184   return UNZ_OK if there is no problem\r
185 */\r
186 \r
187 extern int ZEXPORT unzGoToNextFile OF((unzFile file));\r
188 /*\r
189   Set the current file of the zipfile to the next file.\r
190   return UNZ_OK if there is no problem\r
191   return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\r
192 */\r
193 \r
194 extern int ZEXPORT unzLocateFile OF((unzFile file,\r
195                      const char *szFileName,\r
196                      int iCaseSensitivity));\r
197 /*\r
198   Try locate the file szFileName in the zipfile.\r
199   For the iCaseSensitivity signification, see unzStringFileNameCompare\r
200 \r
201   return value :\r
202   UNZ_OK if the file is found. It becomes the current file.\r
203   UNZ_END_OF_LIST_OF_FILE if the file is not found\r
204 */\r
205 \r
206 \r
207 /* ****************************************** */\r
208 /* Ryan supplied functions */\r
209 /* unz_file_info contain information about a file in the zipfile */\r
210 typedef struct unz_file_pos_s\r
211 {\r
212     uLong pos_in_zip_directory;   /* offset in zip file directory */\r
213     uLong num_of_file;            /* # of file */\r
214 } unz_file_pos;\r
215 \r
216 extern int ZEXPORT unzGetFilePos(\r
217     unzFile file,\r
218     unz_file_pos* file_pos);\r
219 \r
220 extern int ZEXPORT unzGoToFilePos(\r
221     unzFile file,\r
222     unz_file_pos* file_pos);\r
223 \r
224 /* ****************************************** */\r
225 \r
226 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,\r
227                          unz_file_info *pfile_info,\r
228                          char *szFileName,\r
229                          uLong fileNameBufferSize,\r
230                          void *extraField,\r
231                          uLong extraFieldBufferSize,\r
232                          char *szComment,\r
233                          uLong commentBufferSize));\r
234 /*\r
235   Get Info about the current file\r
236   if pfile_info!=NULL, the *pfile_info structure will contain somes info about\r
237         the current file\r
238   if szFileName!=NULL, the filemane string will be copied in szFileName\r
239             (fileNameBufferSize is the size of the buffer)\r
240   if extraField!=NULL, the extra field information will be copied in extraField\r
241             (extraFieldBufferSize is the size of the buffer).\r
242             This is the Central-header version of the extra field\r
243   if szComment!=NULL, the comment string of the file will be copied in szComment\r
244             (commentBufferSize is the size of the buffer)\r
245 */\r
246 \r
247 /***************************************************************************/\r
248 /* for reading the content of the current zipfile, you can open it, read data\r
249    from it, and close it (you can close it before reading all the file)\r
250    */\r
251 \r
252 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));\r
253 /*\r
254   Open for reading data the current file in the zipfile.\r
255   If there is no error, the return value is UNZ_OK.\r
256 */\r
257 \r
258 extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,\r
259                                                   const char* password));\r
260 /*\r
261   Open for reading data the current file in the zipfile.\r
262   password is a crypting password\r
263   If there is no error, the return value is UNZ_OK.\r
264 */\r
265 \r
266 extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,\r
267                                            int* method,\r
268                                            int* level,\r
269                                            int raw));\r
270 /*\r
271   Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\r
272     if raw==1\r
273   *method will receive method of compression, *level will receive level of\r
274      compression\r
275   note : you can set level parameter as NULL (if you did not want known level,\r
276          but you CANNOT set method parameter as NULL\r
277 */\r
278 \r
279 extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,\r
280                                            int* method,\r
281                                            int* level,\r
282                                            int raw,\r
283                                            const char* password));\r
284 /*\r
285   Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\r
286     if raw==1\r
287   *method will receive method of compression, *level will receive level of\r
288      compression\r
289   note : you can set level parameter as NULL (if you did not want known level,\r
290          but you CANNOT set method parameter as NULL\r
291 */\r
292 \r
293 \r
294 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));\r
295 /*\r
296   Close the file in zip opened with unzOpenCurrentFile\r
297   Return UNZ_CRCERROR if all the file was read but the CRC is not good\r
298 */\r
299 \r
300 extern int ZEXPORT unzReadCurrentFile OF((unzFile file,\r
301                       voidp buf,\r
302                       unsigned len));\r
303 /*\r
304   Read bytes from the current file (opened by unzOpenCurrentFile)\r
305   buf contain buffer where data must be copied\r
306   len the size of buf.\r
307 \r
308   return the number of byte copied if somes bytes are copied\r
309   return 0 if the end of file was reached\r
310   return <0 with error code if there is an error\r
311     (UNZ_ERRNO for IO error, or zLib error for uncompress error)\r
312 */\r
313 \r
314 extern z_off_t ZEXPORT unztell OF((unzFile file));\r
315 /*\r
316   Give the current position in uncompressed data\r
317 */\r
318 \r
319 extern int ZEXPORT unzeof OF((unzFile file));\r
320 /*\r
321   return 1 if the end of file was reached, 0 elsewhere\r
322 */\r
323 \r
324 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,\r
325                                              voidp buf,\r
326                                              unsigned len));\r
327 /*\r
328   Read extra field from the current file (opened by unzOpenCurrentFile)\r
329   This is the local-header version of the extra field (sometimes, there is\r
330     more info in the local-header version than in the central-header)\r
331 \r
332   if buf==NULL, it return the size of the local extra field\r
333 \r
334   if buf!=NULL, len is the size of the buffer, the extra header is copied in\r
335     buf.\r
336   the return value is the number of bytes copied in buf, or (if <0)\r
337     the error code\r
338 */\r
339 \r
340 /***************************************************************************/\r
341 \r
342 /* Get the current file offset */\r
343 extern uLong ZEXPORT unzGetOffset (unzFile file);\r
344 \r
345 /* Set the current file offset */\r
346 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);\r
347 \r
348 \r
349 \r
350 #ifdef __cplusplus\r
351 }\r
352 #endif\r
353 \r
354 #endif /* _unz_H */\r