Annotation of embedaddon/php/ext/zip/lib/zip.h, revision 1.1.1.1
1.1 misho 1: #ifndef _HAD_ZIP_H
2: #define _HAD_ZIP_H
3:
4: /*
5: zip.h -- exported declarations.
6: Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
7:
8: This file is part of libzip, a library to manipulate ZIP archives.
9: The authors can be contacted at <libzip@nih.at>
10:
11: Redistribution and use in source and binary forms, with or without
12: modification, are permitted provided that the following conditions
13: are met:
14: 1. Redistributions of source code must retain the above copyright
15: notice, this list of conditions and the following disclaimer.
16: 2. Redistributions in binary form must reproduce the above copyright
17: notice, this list of conditions and the following disclaimer in
18: the documentation and/or other materials provided with the
19: distribution.
20: 3. The names of the authors may not be used to endorse or promote
21: products derived from this software without specific prior
22: written permission.
23:
24: THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
25: OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
28: DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30: GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32: IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33: OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34: IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35: */
36:
37:
38: #include "main/php.h"
39:
40: #ifdef PHP_WIN32
41: # include "zip_win32.h"
42: # ifdef PHP_ZIP_EXPORTS
43: # define ZIP_EXTERN(rt) __declspec(dllexport)rt _stdcall
44: # else
45: # define ZIP_EXTERN(rt) rt
46: # endif
47: #elif defined(__GNUC__) && __GNUC__ >= 4
48: # define ZIP_EXTERN(rt) __attribute__ ((visibility("default"))) rt
49: #else
50: # define ZIP_EXTERN(rt) rt
51: #endif
52:
53: BEGIN_EXTERN_C()
54:
55: #include <sys/types.h>
56: #include <stdio.h>
57: #include <time.h>
58:
59: /* flags for zip_open */
60:
61: #define ZIP_CREATE 1
62: #define ZIP_EXCL 2
63: #define ZIP_CHECKCONS 4
64: #define ZIP_OVERWRITE 8
65:
66:
67: /* flags for zip_name_locate, zip_fopen, zip_stat, ... */
68:
69: #define ZIP_FL_NOCASE 1 /* ignore case on name lookup */
70: #define ZIP_FL_NODIR 2 /* ignore directory component */
71: #define ZIP_FL_COMPRESSED 4 /* read compressed data */
72: #define ZIP_FL_UNCHANGED 8 /* use original data, ignoring changes */
73: #define ZIP_FL_RECOMPRESS 16 /* force recompression of data */
74:
75: /* archive global flags flags */
76:
77: #define ZIP_AFL_TORRENT 1 /* torrent zipped */
78:
79: /* libzip error codes */
80:
81: #define ZIP_ER_OK 0 /* N No error */
82: #define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */
83: #define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */
84: #define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */
85: #define ZIP_ER_SEEK 4 /* S Seek error */
86: #define ZIP_ER_READ 5 /* S Read error */
87: #define ZIP_ER_WRITE 6 /* S Write error */
88: #define ZIP_ER_CRC 7 /* N CRC error */
89: #define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */
90: #define ZIP_ER_NOENT 9 /* N No such file */
91: #define ZIP_ER_EXISTS 10 /* N File already exists */
92: #define ZIP_ER_OPEN 11 /* S Can't open file */
93: #define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */
94: #define ZIP_ER_ZLIB 13 /* Z Zlib error */
95: #define ZIP_ER_MEMORY 14 /* N Malloc failure */
96: #define ZIP_ER_CHANGED 15 /* N Entry has been changed */
97: #define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */
98: #define ZIP_ER_EOF 17 /* N Premature EOF */
99: #define ZIP_ER_INVAL 18 /* N Invalid argument */
100: #define ZIP_ER_NOZIP 19 /* N Not a zip archive */
101: #define ZIP_ER_INTERNAL 20 /* N Internal error */
102: #define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */
103: #define ZIP_ER_REMOVE 22 /* S Can't remove file */
104: #define ZIP_ER_DELETED 23 /* N Entry has been deleted */
105:
106:
107: /* type of system error value */
108:
109: #define ZIP_ET_NONE 0 /* sys_err unused */
110: #define ZIP_ET_SYS 1 /* sys_err is errno */
111: #define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */
112:
113: /* compression methods */
114:
115: #define ZIP_CM_DEFAULT -1 /* better of deflate or store */
116: #define ZIP_CM_STORE 0 /* stored (uncompressed) */
117: #define ZIP_CM_SHRINK 1 /* shrunk */
118: #define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */
119: #define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */
120: #define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */
121: #define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */
122: #define ZIP_CM_IMPLODE 6 /* imploded */
123: /* 7 - Reserved for Tokenizing compression algorithm */
124: #define ZIP_CM_DEFLATE 8 /* deflated */
125: #define ZIP_CM_DEFLATE64 9 /* deflate64 */
126: #define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */
127: /* 11 - Reserved by PKWARE */
128: #define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */
129: /* 13 - Reserved by PKWARE */
130: #define ZIP_CM_LZMA 14 /* LZMA (EFS) */
131: /* 15-17 - Reserved by PKWARE */
132: #define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */
133: #define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */
134: #define ZIP_CM_WAVPACK 97 /* WavPack compressed data */
135: #define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */
136:
137: /* encryption methods */
138:
139: #define ZIP_EM_NONE 0 /* not encrypted */
140: #define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */
141: #if 0 /* Strong Encryption Header not parsed yet */
142: #define ZIP_EM_DES 0x6601 /* strong encryption: DES */
143: #define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */
144: #define ZIP_EM_3DES_168 0x6603
145: #define ZIP_EM_3DES_112 0x6609
146: #define ZIP_EM_AES_128 0x660e
147: #define ZIP_EM_AES_192 0x660f
148: #define ZIP_EM_AES_256 0x6610
149: #define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */
150: #define ZIP_EM_RC4 0x6801
151: #endif
152: #define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */
153:
154:
155:
156: enum zip_source_cmd {
157: ZIP_SOURCE_OPEN, /* prepare for reading */
158: ZIP_SOURCE_READ, /* read data */
159: ZIP_SOURCE_CLOSE, /* reading is done */
160: ZIP_SOURCE_STAT, /* get meta information */
161: ZIP_SOURCE_ERROR, /* get error information */
162: ZIP_SOURCE_FREE /* cleanup and free resources */
163: };
164:
165: typedef ssize_t (*zip_source_callback)(void *state, void *data,
166: size_t len, enum zip_source_cmd cmd);
167:
168: struct zip_stat {
169: const char *name; /* name of the file */
170: int index; /* index within archive */
171: unsigned int crc; /* crc of file data */
172: time_t mtime; /* modification time */
173: off_t size; /* size of file (uncompressed) */
174: off_t comp_size; /* size of file (compressed) */
175: unsigned short comp_method; /* compression method used */
176: unsigned short encryption_method; /* encryption method used */
177: };
178:
179: struct zip;
180: struct zip_file;
181: struct zip_source;
182:
183:
184:
185: ZIP_EXTERN(int) zip_add(struct zip *, const char *, struct zip_source *);
186: ZIP_EXTERN(int) zip_add_dir(struct zip *, const char *);
187: ZIP_EXTERN(int) zip_close(struct zip *);
188: ZIP_EXTERN(int) zip_delete(struct zip *, int);
189: ZIP_EXTERN(void) zip_error_clear(struct zip *);
190: ZIP_EXTERN(void) zip_error_get(struct zip *, int *, int *);
191: ZIP_EXTERN(int) zip_error_get_sys_type(int);
192: ZIP_EXTERN(int) zip_error_to_str(char *, size_t, int, int);
193: ZIP_EXTERN(int) zip_fclose(struct zip_file *);
194: ZIP_EXTERN(void) zip_file_error_clear(struct zip_file *);
195: ZIP_EXTERN(void) zip_file_error_get(struct zip_file *, int *, int *);
196: ZIP_EXTERN(const char *)zip_file_strerror(struct zip_file *);
197: ZIP_EXTERN(struct zip_file *)zip_fopen(struct zip *, const char *, int);
198: ZIP_EXTERN(struct zip_file *)zip_fopen_index(struct zip *, int, int);
199: ZIP_EXTERN(ssize_t) zip_fread(struct zip_file *, void *, size_t);
200: ZIP_EXTERN(const char *)zip_get_archive_comment(struct zip *, int *, int);
201: ZIP_EXTERN(int) zip_get_archive_flag(struct zip *, int, int);
202: ZIP_EXTERN(const char *)zip_get_file_comment(struct zip *, int, int *, int);
203: ZIP_EXTERN(const char *)zip_get_name(struct zip *, int, int);
204: ZIP_EXTERN(int) zip_get_num_files(struct zip *);
205: ZIP_EXTERN(int) zip_name_locate(struct zip *, const char *, int);
206: ZIP_EXTERN(struct zip *)zip_open(const char *, int, int *);
207: ZIP_EXTERN(int) zip_rename(struct zip *, int, const char *);
208: ZIP_EXTERN(int) zip_replace(struct zip *, int, struct zip_source *);
209: ZIP_EXTERN(int) zip_set_archive_comment(struct zip *, const char *, int);
210: ZIP_EXTERN(int) zip_set_archive_flag(struct zip *, int, int);
211: ZIP_EXTERN(int) zip_set_file_comment(struct zip *, int, const char *, int);
212: ZIP_EXTERN(struct zip_source *)zip_source_buffer(struct zip *, const void *,
213: off_t, int);
214: ZIP_EXTERN(struct zip_source *)zip_source_file(struct zip *, const char *,
215: off_t, off_t);
216: ZIP_EXTERN(struct zip_source *)zip_source_filep(struct zip *, FILE *,
217: off_t, off_t);
218: ZIP_EXTERN(void) zip_source_free(struct zip_source *);
219: ZIP_EXTERN(struct zip_source *)zip_source_function(struct zip *,
220: zip_source_callback, void *);
221: ZIP_EXTERN(struct zip_source *)zip_source_zip(struct zip *, struct zip *,
222: int, int, off_t, off_t);
223: ZIP_EXTERN(int) zip_stat(struct zip *, const char *, int, struct zip_stat *);
224: ZIP_EXTERN(int) zip_stat_index(struct zip *, int, int, struct zip_stat *);
225: ZIP_EXTERN(void) zip_stat_init(struct zip_stat *);
226: ZIP_EXTERN(const char *)zip_strerror(struct zip *);
227: ZIP_EXTERN(int) zip_unchange(struct zip *, int);
228: ZIP_EXTERN(int) zip_unchange_all(struct zip *);
229: ZIP_EXTERN(int) zip_unchange_archive(struct zip *);
230:
231: END_EXTERN_C();
232: #endif /* _HAD_ZIP_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>