Debian Codegraph @

mz_zip.h

raw symbols SCIP
1 /* mz_zip.h -- Zip manipulation
2 part of the minizip-ng project
3
4 Copyright (C) Nathan Moinvaziri
5 https://github.com/zlib-ng/minizip-ng
6 Copyright (C) 2009-2010 Mathias Svensson
7 Modifications for Zip64 support
8 http://result42.com
9 Copyright (C) 1998-2010 Gilles Vollant
10 https://www.winimage.com/zLibDll/minizip.html
11
12 This program is distributed under the terms of the same license as zlib.
13 See the accompanying LICENSE file for the full text of the license.
14 */
15
16 #ifndef MZ_ZIP_H
17 #define MZ_ZIP_H
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /***************************************************************************/
24
25 typedef struct mz_zip_file_s {
26 uint16_t version_madeby; /* version made by */
27 uint16_t version_needed; /* version needed to extract */
28 uint16_t flag; /* general purpose bit flag */
29 uint16_t compression_method; /* compression method */
30 time_t modified_date; /* last modified date in unix time */
31 time_t accessed_date; /* last accessed date in unix time */
32 time_t creation_date; /* creation date in unix time */
33 uint32_t crc; /* crc-32 */
34 int64_t compressed_size; /* compressed size */
35 int64_t uncompressed_size; /* uncompressed size */
36 uint16_t filename_size; /* filename length */
37 uint16_t extrafield_size; /* extra field length */
38 uint16_t comment_size; /* file comment length */
39 uint32_t disk_number; /* disk number start */
40 int64_t disk_offset; /* relative offset of local header */
41 uint16_t internal_fa; /* internal file attributes */
42 uint32_t external_fa; /* external file attributes */
43 const char *filename; /* filename utf8 null-terminated string */
44 const uint8_t *extrafield; /* extrafield data */
45 const char *comment; /* comment utf8 null-terminated string */
46 const char *linkname; /* sym-link filename utf8 null-terminated string */
47 uint16_t zip64; /* zip64 extension mode */
48 uint16_t aes_version; /* winzip aes extension if not 0 */
49 uint8_t aes_strength; /* winzip aes encryption strength */
50 uint16_t pk_verify; /* pkware encryption verifier */
51 } mz_zip_file, mz_zip_entry;
52
53 /***************************************************************************/
54
55 typedef int32_t (*mz_zip_locate_entry_cb)(void *handle, void *userdata, mz_zip_file *file_info);
56
57 /***************************************************************************/
58
59 void *mz_zip_create(void);
60 /* Create zip instance for opening */
61
62 void mz_zip_delete(void **handle);
63 /* Delete zip object */
64
65 int32_t mz_zip_open(void *handle, void *stream, int32_t mode);
66 /* Create a zip file, no delete file in zip functionality */
67
68 int32_t mz_zip_close(void *handle);
69 /* Close the zip file */
70
71 int32_t mz_zip_get_comment(void *handle, const char **comment);
72 /* Get a pointer to the global comment */
73
74 int32_t mz_zip_set_comment(void *handle, const char *comment);
75 /* Sets the global comment used for writing zip file */
76
77 int32_t mz_zip_get_version_madeby(void *handle, uint16_t *version_madeby);
78 /* Get the version made by */
79
80 int32_t mz_zip_set_version_madeby(void *handle, uint16_t version_madeby);
81 /* Sets the version made by used for writing zip file */
82
83 int32_t mz_zip_set_recover(void *handle, uint8_t recover);
84 /* Sets the ability to recover the central dir by reading local file headers */
85
86 int32_t mz_zip_set_data_descriptor(void *handle, uint8_t data_descriptor);
87 /* Sets the use of data descriptor flag when writing zip entries */
88
89 int32_t mz_zip_get_stream(void *handle, void **stream);
90 /* Get a pointer to the stream used to open */
91
92 int32_t mz_zip_set_cd_stream(void *handle, int64_t cd_start_pos, void *cd_stream);
93 /* Sets the stream to use for reading the central dir */
94
95 int32_t mz_zip_get_cd_mem_stream(void *handle, void **cd_mem_stream);
96 /* Get a pointer to the stream used to store the central dir in memory */
97
98 int32_t mz_zip_set_number_entry(void *handle, uint64_t number_entry);
99 /* Sets the total number of entries */
100
101 int32_t mz_zip_get_number_entry(void *handle, uint64_t *number_entry);
102 /* Get the total number of entries */
103
104 int32_t mz_zip_set_disk_number_with_cd(void *handle, uint32_t disk_number_with_cd);
105 /* Sets the disk number containing the central directory record */
106
107 int32_t mz_zip_get_disk_number_with_cd(void *handle, uint32_t *disk_number_with_cd);
108 /* Get the disk number containing the central directory record */
109
110 /***************************************************************************/
111
112 int32_t mz_zip_entry_is_open(void *handle);
113 /* Check to see if entry is open for read/write */
114
115 int32_t mz_zip_entry_read_open(void *handle, uint8_t raw, const char *password);
116 /* Open for reading the current file in the zip file */
117
118 int32_t mz_zip_entry_read(void *handle, void *buf, int32_t len);
119 /* Read bytes from the current file in the zip file */
120
121 int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, int64_t *uncompressed_size);
122 /* Close the current file for reading and get data descriptor values */
123
124 int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int16_t compress_level, uint8_t raw,
125 const char *password);
126 /* Open for writing the current file in the zip file */
127
128 int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len);
129 /* Write bytes from the current file in the zip file */
130
131 int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, int64_t uncompressed_size);
132 /* Close the current file for writing and set data descriptor values */
133
134 int32_t mz_zip_entry_seek_local_header(void *handle);
135 /* Seeks to the local header for the entry */
136
137 int32_t mz_zip_entry_get_compress_stream(void *handle, void **compress_stream);
138 /* Get a pointer to the compression stream used for the current entry */
139
140 int32_t mz_zip_entry_close_raw(void *handle, int64_t uncompressed_size, uint32_t crc32);
141 /* Close the current file in the zip file where raw is compressed data */
142
143 int32_t mz_zip_entry_close(void *handle);
144 /* Close the current file in the zip file */
145
146 /***************************************************************************/
147
148 int32_t mz_zip_entry_is_dir(void *handle);
149 /* Checks to see if the entry is a directory */
150
151 int32_t mz_zip_entry_is_symlink(void *handle);
152 /* Checks to see if the entry is a symbolic link */
153
154 int32_t mz_zip_entry_get_info(void *handle, mz_zip_file **file_info);
155 /* Get info about the current file, only valid while current entry is open */
156
157 int32_t mz_zip_entry_get_local_info(void *handle, mz_zip_file **local_file_info);
158 /* Get local info about the current file, only valid while current entry is being read */
159
160 int32_t mz_zip_entry_set_extrafield(void *handle, const uint8_t *extrafield, uint16_t extrafield_size);
161 /* Sets or updates the extra field for the entry to be used before writing cd */
162
163 int64_t mz_zip_get_entry(void *handle);
164 /* Return offset of the current entry in the zip file */
165
166 int32_t mz_zip_goto_entry(void *handle, int64_t cd_pos);
167 /* Go to specified entry in the zip file */
168
169 int32_t mz_zip_goto_first_entry(void *handle);
170 /* Go to the first entry in the zip file */
171
172 int32_t mz_zip_goto_next_entry(void *handle);
173 /* Go to the next entry in the zip file or MZ_END_OF_LIST if reaching the end */
174
175 int32_t mz_zip_locate_entry(void *handle, const char *filename, uint8_t ignore_case);
176 /* Locate the file with the specified name in the zip file or MZ_END_LIST if not found */
177
178 int32_t mz_zip_locate_first_entry(void *handle, void *userdata, mz_zip_locate_entry_cb cb);
179 /* Locate the first matching entry based on a match callback */
180
181 int32_t mz_zip_locate_next_entry(void *handle, void *userdata, mz_zip_locate_entry_cb cb);
182 /* Locate the next matching entry based on a match callback */
183
184 /***************************************************************************/
185
186 int32_t mz_zip_attrib_is_dir(uint32_t attrib, int32_t version_madeby);
187 /* Checks to see if the attribute is a directory based on platform */
188
189 int32_t mz_zip_attrib_is_symlink(uint32_t attrib, int32_t version_madeby);
190 /* Checks to see if the attribute is a symbolic link based on platform */
191
192 int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, uint32_t *target_attrib);
193 /* Converts file attributes from one host system to another */
194
195 int32_t mz_zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t *win32_attrib);
196 /* Converts posix file attributes to win32 file attributes */
197
198 int32_t mz_zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t *posix_attrib);
199 /* Converts win32 file attributes to posix file attributes */
200
201 /***************************************************************************/
202
203 int32_t mz_zip_extrafield_find(void *stream, uint16_t type, int32_t max_seek, uint16_t *length);
204 /* Seeks to extra field by its type and returns its length */
205
206 int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, uint16_t type, uint16_t *length);
207 /* Gets whether an extrafield exists and its size */
208
209 int32_t mz_zip_extrafield_read(void *stream, uint16_t *type, uint16_t *length);
210 /* Reads an extrafield header from a stream */
211
212 int32_t mz_zip_extrafield_write(void *stream, uint16_t type, uint16_t length);
213 /* Writes an extrafield header to a stream */
214
215 /***************************************************************************/
216
217 int32_t mz_zip_dosdate_to_tm(uint64_t dos_date, struct tm *ptm);
218 /* Convert dos date/time format to struct tm */
219
220 time_t mz_zip_dosdate_to_time_t(uint64_t dos_date);
221 /* Convert dos date/time format to time_t */
222
223 time_t mz_zip_tm_to_time_t(struct tm *ptm);
224 /* Convert time struct to time_t */
225
226 int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm);
227 /* Convert time_t to time struct */
228
229 uint32_t mz_zip_time_t_to_dos_date(time_t unix_time);
230 /* Convert time_t to dos date/time format */
231
232 uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm);
233 /* Convert struct tm to dos date/time format */
234
235 int32_t mz_zip_ntfs_to_unix_time(uint64_t ntfs_time, time_t *unix_time);
236 /* Convert ntfs time to unix time */
237
238 int32_t mz_zip_unix_to_ntfs_time(time_t unix_time, uint64_t *ntfs_time);
239 /* Convert unix time to ntfs time */
240
241 /***************************************************************************/
242
243 int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore_case);
244 /* Compare two paths without regard to slashes */
245
246 /***************************************************************************/
247
248 const char *mz_zip_get_compression_method_string(int32_t compression_method);
249 /* Gets a string representing the compression method */
250
251 /***************************************************************************/
252
253 #ifdef __cplusplus
254 }
255 #endif
256
257 #endif /* _ZIP_H */