1 | /*- |
2 | * Copyright (c) 2003-2010 Tim Kientzle |
3 | * All rights reserved. |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR |
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, |
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | * |
25 | * $FreeBSD: src/lib/libarchive/archive.h.in,v 1.50 2008/05/26 17:00:22 kientzle Exp $ |
26 | */ |
27 | |
28 | #ifndef ARCHIVE_H_INCLUDED |
29 | #define ARCHIVE_H_INCLUDED |
30 | |
31 | #include <sys/stat.h> |
32 | #include <stddef.h> /* for wchar_t */ |
33 | #include <stdio.h> /* For FILE * */ |
34 | |
35 | /* |
36 | * Note: archive.h is for use outside of libarchive; the configuration |
37 | * headers (config.h, archive_platform.h, etc.) are purely internal. |
38 | * Do NOT use HAVE_XXX configuration macros to control the behavior of |
39 | * this header! If you must conditionalize, use predefined compiler and/or |
40 | * platform macros. |
41 | */ |
42 | #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 |
43 | # include <stdint.h> |
44 | #elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) |
45 | # include <inttypes.h> |
46 | #endif |
47 | |
48 | /* Get appropriate definitions of standard POSIX-style types. */ |
49 | /* These should match the types used in 'struct stat' */ |
50 | #if defined(_WIN32) && !defined(__CYGWIN__) |
51 | # define __LA_INT64_T __int64 |
52 | # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) |
53 | # define __LA_SSIZE_T ssize_t |
54 | # elif defined(_WIN64) |
55 | # define __LA_SSIZE_T __int64 |
56 | # else |
57 | # define __LA_SSIZE_T long |
58 | # endif |
59 | #else |
60 | # include <unistd.h> /* ssize_t */ |
61 | # if defined(_SCO_DS) |
62 | # define __LA_INT64_T long long |
63 | # else |
64 | # define __LA_INT64_T int64_t |
65 | # endif |
66 | # define __LA_SSIZE_T ssize_t |
67 | #endif |
68 | |
69 | /* |
70 | * On Windows, define LIBARCHIVE_STATIC if you're building or using a |
71 | * .lib. The default here assumes you're building a DLL. Only |
72 | * libarchive source should ever define __LIBARCHIVE_BUILD. |
73 | */ |
74 | #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC) |
75 | # ifdef __LIBARCHIVE_BUILD |
76 | # ifdef __GNUC__ |
77 | # define __LA_DECL __attribute__((dllexport)) extern |
78 | # else |
79 | # define __LA_DECL __declspec(dllexport) |
80 | # endif |
81 | # else |
82 | # ifdef __GNUC__ |
83 | # define __LA_DECL |
84 | # else |
85 | # define __LA_DECL __declspec(dllimport) |
86 | # endif |
87 | # endif |
88 | #else |
89 | /* Static libraries or non-Windows needs no special declaration. */ |
90 | # define __LA_DECL |
91 | #endif |
92 | |
93 | #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__) |
94 | #define __LA_PRINTF(fmtarg, firstvararg) \ |
95 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) |
96 | #else |
97 | #define __LA_PRINTF(fmtarg, firstvararg) /* nothing */ |
98 | #endif |
99 | |
100 | #if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1 |
101 | # define __LA_DEPRECATED __attribute__((deprecated)) |
102 | #else |
103 | # define __LA_DEPRECATED |
104 | #endif |
105 | |
106 | #ifdef __cplusplus |
107 | extern "C" { |
108 | #endif |
109 | |
110 | /* |
111 | * The version number is provided as both a macro and a function. |
112 | * The macro identifies the installed header; the function identifies |
113 | * the library version (which may not be the same if you're using a |
114 | * dynamically-linked version of the library). Of course, if the |
115 | * header and library are very different, you should expect some |
116 | * strangeness. Don't do that. |
117 | */ |
118 | |
119 | /* |
120 | * The version number is expressed as a single integer that makes it |
121 | * easy to compare versions at build time: for version a.b.c, the |
122 | * version number is printf("%d%03d%03d",a,b,c). For example, if you |
123 | * know your application requires version 2.12.108 or later, you can |
124 | * assert that ARCHIVE_VERSION_NUMBER >= 2012108. |
125 | */ |
126 | /* Note: Compiler will complain if this does not match archive_entry.h! */ |
127 | #define ARCHIVE_VERSION_NUMBER 3001002 |
128 | __LA_DECL int archive_version_number(void); |
129 | |
130 | /* |
131 | * Textual name/version of the library, useful for version displays. |
132 | */ |
133 | #define ARCHIVE_VERSION_STRING "libarchive 3.1.2" |
134 | __LA_DECL const char * archive_version_string(void); |
135 | |
136 | /* Declare our basic types. */ |
137 | struct archive; |
138 | struct archive_entry; |
139 | |
140 | /* |
141 | * Error codes: Use archive_errno() and archive_error_string() |
142 | * to retrieve details. Unless specified otherwise, all functions |
143 | * that return 'int' use these codes. |
144 | */ |
145 | #define ARCHIVE_EOF 1 /* Found end of archive. */ |
146 | #define ARCHIVE_OK 0 /* Operation was successful. */ |
147 | #define ARCHIVE_RETRY (-10) /* Retry might succeed. */ |
148 | #define ARCHIVE_WARN (-20) /* Partial success. */ |
149 | /* For example, if write_header "fails", then you can't push data. */ |
150 | #define ARCHIVE_FAILED (-25) /* Current operation cannot complete. */ |
151 | /* But if write_header is "fatal," then this archive is dead and useless. */ |
152 | #define ARCHIVE_FATAL (-30) /* No more operations are possible. */ |
153 | |
154 | /* |
155 | * As far as possible, archive_errno returns standard platform errno codes. |
156 | * Of course, the details vary by platform, so the actual definitions |
157 | * here are stored in "archive_platform.h". The symbols are listed here |
158 | * for reference; as a rule, clients should not need to know the exact |
159 | * platform-dependent error code. |
160 | */ |
161 | /* Unrecognized or invalid file format. */ |
162 | /* #define ARCHIVE_ERRNO_FILE_FORMAT */ |
163 | /* Illegal usage of the library. */ |
164 | /* #define ARCHIVE_ERRNO_PROGRAMMER_ERROR */ |
165 | /* Unknown or unclassified error. */ |
166 | /* #define ARCHIVE_ERRNO_MISC */ |
167 | |
168 | /* |
169 | * Callbacks are invoked to automatically read/skip/write/open/close the |
170 | * archive. You can provide your own for complex tasks (like breaking |
171 | * archives across multiple tapes) or use standard ones built into the |
172 | * library. |
173 | */ |
174 | |
175 | /* Returns pointer and size of next block of data from archive. */ |
176 | typedef __LA_SSIZE_T archive_read_callback(struct archive *, |
177 | void *_client_data, const void **_buffer); |
178 | |
179 | /* Skips at most request bytes from archive and returns the skipped amount. |
180 | * This may skip fewer bytes than requested; it may even skip zero bytes. |
181 | * If you do skip fewer bytes than requested, libarchive will invoke your |
182 | * read callback and discard data as necessary to make up the full skip. |
183 | */ |
184 | typedef __LA_INT64_T archive_skip_callback(struct archive *, |
185 | void *_client_data, __LA_INT64_T request); |
186 | |
187 | /* Seeks to specified location in the file and returns the position. |
188 | * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h. |
189 | * Return ARCHIVE_FATAL if the seek fails for any reason. |
190 | */ |
191 | typedef __LA_INT64_T archive_seek_callback(struct archive *, |
192 | void *_client_data, __LA_INT64_T offset, int whence); |
193 | |
194 | /* Returns size actually written, zero on EOF, -1 on error. */ |
195 | typedef __LA_SSIZE_T archive_write_callback(struct archive *, |
196 | void *_client_data, |
197 | const void *_buffer, size_t _length); |
198 | |
199 | typedef int archive_open_callback(struct archive *, void *_client_data); |
200 | |
201 | typedef int archive_close_callback(struct archive *, void *_client_data); |
202 | |
203 | /* Switches from one client data object to the next/prev client data object. |
204 | * This is useful for reading from different data blocks such as a set of files |
205 | * that make up one large file. |
206 | */ |
207 | typedef int archive_switch_callback(struct archive *, void *_client_data1, |
208 | void *_client_data2); |
209 | |
210 | /* |
211 | * Codes to identify various stream filters. |
212 | */ |
213 | #define ARCHIVE_FILTER_NONE 0 |
214 | #define ARCHIVE_FILTER_GZIP 1 |
215 | #define ARCHIVE_FILTER_BZIP2 2 |
216 | #define ARCHIVE_FILTER_COMPRESS 3 |
217 | #define ARCHIVE_FILTER_PROGRAM 4 |
218 | #define ARCHIVE_FILTER_LZMA 5 |
219 | #define ARCHIVE_FILTER_XZ 6 |
220 | #define ARCHIVE_FILTER_UU 7 |
221 | #define ARCHIVE_FILTER_RPM 8 |
222 | #define ARCHIVE_FILTER_LZIP 9 |
223 | #define ARCHIVE_FILTER_LRZIP 10 |
224 | #define ARCHIVE_FILTER_LZOP 11 |
225 | #define ARCHIVE_FILTER_GRZIP 12 |
226 | |
227 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
228 | #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE |
229 | #define ARCHIVE_COMPRESSION_GZIP ARCHIVE_FILTER_GZIP |
230 | #define ARCHIVE_COMPRESSION_BZIP2 ARCHIVE_FILTER_BZIP2 |
231 | #define ARCHIVE_COMPRESSION_COMPRESS ARCHIVE_FILTER_COMPRESS |
232 | #define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM |
233 | #define ARCHIVE_COMPRESSION_LZMA ARCHIVE_FILTER_LZMA |
234 | #define ARCHIVE_COMPRESSION_XZ ARCHIVE_FILTER_XZ |
235 | #define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU |
236 | #define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM |
237 | #define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP |
238 | #define ARCHIVE_COMPRESSION_LRZIP ARCHIVE_FILTER_LRZIP |
239 | #endif |
240 | |
241 | /* |
242 | * Codes returned by archive_format. |
243 | * |
244 | * Top 16 bits identifies the format family (e.g., "tar"); lower |
245 | * 16 bits indicate the variant. This is updated by read_next_header. |
246 | * Note that the lower 16 bits will often vary from entry to entry. |
247 | * In some cases, this variation occurs as libarchive learns more about |
248 | * the archive (for example, later entries might utilize extensions that |
249 | * weren't necessary earlier in the archive; in this case, libarchive |
250 | * will change the format code to indicate the extended format that |
251 | * was used). In other cases, it's because different tools have |
252 | * modified the archive and so different parts of the archive |
253 | * actually have slightly different formats. (Both tar and cpio store |
254 | * format codes in each entry, so it is quite possible for each |
255 | * entry to be in a different format.) |
256 | */ |
257 | #define ARCHIVE_FORMAT_BASE_MASK 0xff0000 |
258 | #define ARCHIVE_FORMAT_CPIO 0x10000 |
259 | #define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1) |
260 | #define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2) |
261 | #define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3) |
262 | #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4) |
263 | #define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5) |
264 | #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6) |
265 | #define ARCHIVE_FORMAT_SHAR 0x20000 |
266 | #define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1) |
267 | #define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2) |
268 | #define ARCHIVE_FORMAT_TAR 0x30000 |
269 | #define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1) |
270 | #define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2) |
271 | #define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3) |
272 | #define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4) |
273 | #define ARCHIVE_FORMAT_ISO9660 0x40000 |
274 | #define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1) |
275 | #define ARCHIVE_FORMAT_ZIP 0x50000 |
276 | #define ARCHIVE_FORMAT_EMPTY 0x60000 |
277 | #define ARCHIVE_FORMAT_AR 0x70000 |
278 | #define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1) |
279 | #define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2) |
280 | #define ARCHIVE_FORMAT_MTREE 0x80000 |
281 | #define ARCHIVE_FORMAT_RAW 0x90000 |
282 | #define ARCHIVE_FORMAT_XAR 0xA0000 |
283 | #define ARCHIVE_FORMAT_LHA 0xB0000 |
284 | #define ARCHIVE_FORMAT_CAB 0xC0000 |
285 | #define ARCHIVE_FORMAT_RAR 0xD0000 |
286 | #define ARCHIVE_FORMAT_7ZIP 0xE0000 |
287 | |
288 | /*- |
289 | * Basic outline for reading an archive: |
290 | * 1) Ask archive_read_new for an archive reader object. |
291 | * 2) Update any global properties as appropriate. |
292 | * In particular, you'll certainly want to call appropriate |
293 | * archive_read_support_XXX functions. |
294 | * 3) Call archive_read_open_XXX to open the archive |
295 | * 4) Repeatedly call archive_read_next_header to get information about |
296 | * successive archive entries. Call archive_read_data to extract |
297 | * data for entries of interest. |
298 | * 5) Call archive_read_finish to end processing. |
299 | */ |
300 | __LA_DECL struct archive *archive_read_new(void); |
301 | |
302 | /* |
303 | * The archive_read_support_XXX calls enable auto-detect for this |
304 | * archive handle. They also link in the necessary support code. |
305 | * For example, if you don't want bzlib linked in, don't invoke |
306 | * support_compression_bzip2(). The "all" functions provide the |
307 | * obvious shorthand. |
308 | */ |
309 | |
310 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
311 | __LA_DECL int archive_read_support_compression_all(struct archive *) |
312 | __LA_DEPRECATED; |
313 | __LA_DECL int archive_read_support_compression_bzip2(struct archive *) |
314 | __LA_DEPRECATED; |
315 | __LA_DECL int archive_read_support_compression_compress(struct archive *) |
316 | __LA_DEPRECATED; |
317 | __LA_DECL int archive_read_support_compression_gzip(struct archive *) |
318 | __LA_DEPRECATED; |
319 | __LA_DECL int archive_read_support_compression_lzip(struct archive *) |
320 | __LA_DEPRECATED; |
321 | __LA_DECL int archive_read_support_compression_lzma(struct archive *) |
322 | __LA_DEPRECATED; |
323 | __LA_DECL int archive_read_support_compression_none(struct archive *) |
324 | __LA_DEPRECATED; |
325 | __LA_DECL int archive_read_support_compression_program(struct archive *, |
326 | const char *command) __LA_DEPRECATED; |
327 | __LA_DECL int archive_read_support_compression_program_signature |
328 | (struct archive *, const char *, |
329 | const void * /* match */, size_t) __LA_DEPRECATED; |
330 | |
331 | __LA_DECL int archive_read_support_compression_rpm(struct archive *) |
332 | __LA_DEPRECATED; |
333 | __LA_DECL int archive_read_support_compression_uu(struct archive *) |
334 | __LA_DEPRECATED; |
335 | __LA_DECL int archive_read_support_compression_xz(struct archive *) |
336 | __LA_DEPRECATED; |
337 | #endif |
338 | |
339 | __LA_DECL int archive_read_support_filter_all(struct archive *); |
340 | __LA_DECL int archive_read_support_filter_bzip2(struct archive *); |
341 | __LA_DECL int archive_read_support_filter_compress(struct archive *); |
342 | __LA_DECL int archive_read_support_filter_gzip(struct archive *); |
343 | __LA_DECL int archive_read_support_filter_grzip(struct archive *); |
344 | __LA_DECL int archive_read_support_filter_lrzip(struct archive *); |
345 | __LA_DECL int archive_read_support_filter_lzip(struct archive *); |
346 | __LA_DECL int archive_read_support_filter_lzma(struct archive *); |
347 | __LA_DECL int archive_read_support_filter_lzop(struct archive *); |
348 | __LA_DECL int archive_read_support_filter_none(struct archive *); |
349 | __LA_DECL int archive_read_support_filter_program(struct archive *, |
350 | const char *command); |
351 | __LA_DECL int archive_read_support_filter_program_signature |
352 | (struct archive *, const char * /* cmd */, |
353 | const void * /* match */, size_t); |
354 | __LA_DECL int archive_read_support_filter_rpm(struct archive *); |
355 | __LA_DECL int archive_read_support_filter_uu(struct archive *); |
356 | __LA_DECL int archive_read_support_filter_xz(struct archive *); |
357 | |
358 | __LA_DECL int archive_read_support_format_7zip(struct archive *); |
359 | __LA_DECL int archive_read_support_format_all(struct archive *); |
360 | __LA_DECL int archive_read_support_format_ar(struct archive *); |
361 | __LA_DECL int archive_read_support_format_by_code(struct archive *, int); |
362 | __LA_DECL int archive_read_support_format_cab(struct archive *); |
363 | __LA_DECL int archive_read_support_format_cpio(struct archive *); |
364 | __LA_DECL int archive_read_support_format_empty(struct archive *); |
365 | __LA_DECL int archive_read_support_format_gnutar(struct archive *); |
366 | __LA_DECL int archive_read_support_format_iso9660(struct archive *); |
367 | __LA_DECL int archive_read_support_format_lha(struct archive *); |
368 | __LA_DECL int archive_read_support_format_mtree(struct archive *); |
369 | __LA_DECL int archive_read_support_format_rar(struct archive *); |
370 | __LA_DECL int archive_read_support_format_raw(struct archive *); |
371 | __LA_DECL int archive_read_support_format_tar(struct archive *); |
372 | __LA_DECL int archive_read_support_format_xar(struct archive *); |
373 | __LA_DECL int archive_read_support_format_zip(struct archive *); |
374 | |
375 | /* Functions to manually set the format and filters to be used. This is |
376 | * useful to bypass the bidding process when the format and filters to use |
377 | * is known in advance. |
378 | */ |
379 | __LA_DECL int archive_read_set_format(struct archive *, int); |
380 | __LA_DECL int archive_read_append_filter(struct archive *, int); |
381 | __LA_DECL int archive_read_append_filter_program(struct archive *, |
382 | const char *); |
383 | __LA_DECL int archive_read_append_filter_program_signature |
384 | (struct archive *, const char *, const void * /* match */, size_t); |
385 | |
386 | /* Set various callbacks. */ |
387 | __LA_DECL int archive_read_set_open_callback(struct archive *, |
388 | archive_open_callback *); |
389 | __LA_DECL int archive_read_set_read_callback(struct archive *, |
390 | archive_read_callback *); |
391 | __LA_DECL int archive_read_set_seek_callback(struct archive *, |
392 | archive_seek_callback *); |
393 | __LA_DECL int archive_read_set_skip_callback(struct archive *, |
394 | archive_skip_callback *); |
395 | __LA_DECL int archive_read_set_close_callback(struct archive *, |
396 | archive_close_callback *); |
397 | /* Callback used to switch between one data object to the next */ |
398 | __LA_DECL int archive_read_set_switch_callback(struct archive *, |
399 | archive_switch_callback *); |
400 | |
401 | /* This sets the first data object. */ |
402 | __LA_DECL int archive_read_set_callback_data(struct archive *, void *); |
403 | /* This sets data object at specified index */ |
404 | __LA_DECL int archive_read_set_callback_data2(struct archive *, void *, |
405 | unsigned int); |
406 | /* This adds a data object at the specified index. */ |
407 | __LA_DECL int archive_read_add_callback_data(struct archive *, void *, |
408 | unsigned int); |
409 | /* This appends a data object to the end of list */ |
410 | __LA_DECL int archive_read_append_callback_data(struct archive *, void *); |
411 | /* This prepends a data object to the beginning of list */ |
412 | __LA_DECL int archive_read_prepend_callback_data(struct archive *, void *); |
413 | |
414 | /* Opening freezes the callbacks. */ |
415 | __LA_DECL int archive_read_open1(struct archive *); |
416 | |
417 | /* Convenience wrappers around the above. */ |
418 | __LA_DECL int archive_read_open(struct archive *, void *_client_data, |
419 | archive_open_callback *, archive_read_callback *, |
420 | archive_close_callback *); |
421 | __LA_DECL int archive_read_open2(struct archive *, void *_client_data, |
422 | archive_open_callback *, archive_read_callback *, |
423 | archive_skip_callback *, archive_close_callback *); |
424 | |
425 | /* |
426 | * A variety of shortcuts that invoke archive_read_open() with |
427 | * canned callbacks suitable for common situations. The ones that |
428 | * accept a block size handle tape blocking correctly. |
429 | */ |
430 | /* Use this if you know the filename. Note: NULL indicates stdin. */ |
431 | __LA_DECL int archive_read_open_filename(struct archive *, |
432 | const char *_filename, size_t _block_size); |
433 | /* Use this for reading multivolume files by filenames. |
434 | * NOTE: Must be NULL terminated. Sorting is NOT done. */ |
435 | __LA_DECL int archive_read_open_filenames(struct archive *, |
436 | const char **_filenames, size_t _block_size); |
437 | __LA_DECL int archive_read_open_filename_w(struct archive *, |
438 | const wchar_t *_filename, size_t _block_size); |
439 | /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ |
440 | __LA_DECL int archive_read_open_file(struct archive *, |
441 | const char *_filename, size_t _block_size) __LA_DEPRECATED; |
442 | /* Read an archive that's stored in memory. */ |
443 | __LA_DECL int archive_read_open_memory(struct archive *, |
444 | void * buff, size_t size); |
445 | /* A more involved version that is only used for internal testing. */ |
446 | __LA_DECL int archive_read_open_memory2(struct archive *a, void *buff, |
447 | size_t size, size_t read_size); |
448 | /* Read an archive that's already open, using the file descriptor. */ |
449 | __LA_DECL int archive_read_open_fd(struct archive *, int _fd, |
450 | size_t _block_size); |
451 | /* Read an archive that's already open, using a FILE *. */ |
452 | /* Note: DO NOT use this with tape drives. */ |
453 | __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file); |
454 | |
455 | /* Parses and returns next entry header. */ |
456 | __LA_DECL int (struct archive *, |
457 | struct archive_entry **); |
458 | |
459 | /* Parses and returns next entry header using the archive_entry passed in */ |
460 | __LA_DECL int (struct archive *, |
461 | struct archive_entry *); |
462 | |
463 | /* |
464 | * Retrieve the byte offset in UNCOMPRESSED data where last-read |
465 | * header started. |
466 | */ |
467 | __LA_DECL __LA_INT64_T (struct archive *); |
468 | |
469 | /* Read data from the body of an entry. Similar to read(2). */ |
470 | __LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, |
471 | void *, size_t); |
472 | |
473 | /* Seek within the body of an entry. Similar to lseek(2). */ |
474 | __LA_DECL __LA_INT64_T archive_seek_data(struct archive *, __LA_INT64_T, int); |
475 | |
476 | /* |
477 | * A zero-copy version of archive_read_data that also exposes the file offset |
478 | * of each returned block. Note that the client has no way to specify |
479 | * the desired size of the block. The API does guarantee that offsets will |
480 | * be strictly increasing and that returned blocks will not overlap. |
481 | */ |
482 | __LA_DECL int archive_read_data_block(struct archive *a, |
483 | const void **buff, size_t *size, __LA_INT64_T *offset); |
484 | |
485 | /*- |
486 | * Some convenience functions that are built on archive_read_data: |
487 | * 'skip': skips entire entry |
488 | * 'into_buffer': writes data into memory buffer that you provide |
489 | * 'into_fd': writes data to specified filedes |
490 | */ |
491 | __LA_DECL int archive_read_data_skip(struct archive *); |
492 | __LA_DECL int archive_read_data_into_fd(struct archive *, int fd); |
493 | |
494 | /* |
495 | * Set read options. |
496 | */ |
497 | /* Apply option to the format only. */ |
498 | __LA_DECL int archive_read_set_format_option(struct archive *_a, |
499 | const char *m, const char *o, |
500 | const char *v); |
501 | /* Apply option to the filter only. */ |
502 | __LA_DECL int archive_read_set_filter_option(struct archive *_a, |
503 | const char *m, const char *o, |
504 | const char *v); |
505 | /* Apply option to both the format and the filter. */ |
506 | __LA_DECL int archive_read_set_option(struct archive *_a, |
507 | const char *m, const char *o, |
508 | const char *v); |
509 | /* Apply option string to both the format and the filter. */ |
510 | __LA_DECL int archive_read_set_options(struct archive *_a, |
511 | const char *opts); |
512 | |
513 | /*- |
514 | * Convenience function to recreate the current entry (whose header |
515 | * has just been read) on disk. |
516 | * |
517 | * This does quite a bit more than just copy data to disk. It also: |
518 | * - Creates intermediate directories as required. |
519 | * - Manages directory permissions: non-writable directories will |
520 | * be initially created with write permission enabled; when the |
521 | * archive is closed, dir permissions are edited to the values specified |
522 | * in the archive. |
523 | * - Checks hardlinks: hardlinks will not be extracted unless the |
524 | * linked-to file was also extracted within the same session. (TODO) |
525 | */ |
526 | |
527 | /* The "flags" argument selects optional behavior, 'OR' the flags you want. */ |
528 | |
529 | /* Default: Do not try to set owner/group. */ |
530 | #define ARCHIVE_EXTRACT_OWNER (0x0001) |
531 | /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */ |
532 | #define ARCHIVE_EXTRACT_PERM (0x0002) |
533 | /* Default: Do not restore mtime/atime. */ |
534 | #define ARCHIVE_EXTRACT_TIME (0x0004) |
535 | /* Default: Replace existing files. */ |
536 | #define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008) |
537 | /* Default: Try create first, unlink only if create fails with EEXIST. */ |
538 | #define ARCHIVE_EXTRACT_UNLINK (0x0010) |
539 | /* Default: Do not restore ACLs. */ |
540 | #define ARCHIVE_EXTRACT_ACL (0x0020) |
541 | /* Default: Do not restore fflags. */ |
542 | #define ARCHIVE_EXTRACT_FFLAGS (0x0040) |
543 | /* Default: Do not restore xattrs. */ |
544 | #define ARCHIVE_EXTRACT_XATTR (0x0080) |
545 | /* Default: Do not try to guard against extracts redirected by symlinks. */ |
546 | /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */ |
547 | #define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100) |
548 | /* Default: Do not reject entries with '..' as path elements. */ |
549 | #define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200) |
550 | /* Default: Create parent directories as needed. */ |
551 | #define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400) |
552 | /* Default: Overwrite files, even if one on disk is newer. */ |
553 | #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800) |
554 | /* Detect blocks of 0 and write holes instead. */ |
555 | #define ARCHIVE_EXTRACT_SPARSE (0x1000) |
556 | /* Default: Do not restore Mac extended metadata. */ |
557 | /* This has no effect except on Mac OS. */ |
558 | #define ARCHIVE_EXTRACT_MAC_METADATA (0x2000) |
559 | /* Default: Use HFS+ compression if it was compressed. */ |
560 | /* This has no effect except on Mac OS v10.6 or later. */ |
561 | #define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000) |
562 | /* Default: Do not use HFS+ compression if it was not compressed. */ |
563 | /* This has no effect except on Mac OS v10.6 or later. */ |
564 | #define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000) |
565 | |
566 | __LA_DECL int (struct archive *, struct archive_entry *, |
567 | int flags); |
568 | __LA_DECL int (struct archive *, struct archive_entry *, |
569 | struct archive * /* dest */); |
570 | __LA_DECL void (struct archive *, |
571 | void (*_progress_func)(void *), void *_user_data); |
572 | |
573 | /* Record the dev/ino of a file that will not be written. This is |
574 | * generally set to the dev/ino of the archive being read. */ |
575 | __LA_DECL void (struct archive *, |
576 | __LA_INT64_T, __LA_INT64_T); |
577 | |
578 | /* Close the file and release most resources. */ |
579 | __LA_DECL int archive_read_close(struct archive *); |
580 | /* Release all resources and destroy the object. */ |
581 | /* Note that archive_read_free will call archive_read_close for you. */ |
582 | __LA_DECL int archive_read_free(struct archive *); |
583 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
584 | /* Synonym for archive_read_free() for backwards compatibility. */ |
585 | __LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED; |
586 | #endif |
587 | |
588 | /*- |
589 | * To create an archive: |
590 | * 1) Ask archive_write_new for an archive writer object. |
591 | * 2) Set any global properties. In particular, you should set |
592 | * the compression and format to use. |
593 | * 3) Call archive_write_open to open the file (most people |
594 | * will use archive_write_open_file or archive_write_open_fd, |
595 | * which provide convenient canned I/O callbacks for you). |
596 | * 4) For each entry: |
597 | * - construct an appropriate struct archive_entry structure |
598 | * - archive_write_header to write the header |
599 | * - archive_write_data to write the entry data |
600 | * 5) archive_write_close to close the output |
601 | * 6) archive_write_free to cleanup the writer and release resources |
602 | */ |
603 | __LA_DECL struct archive *archive_write_new(void); |
604 | __LA_DECL int archive_write_set_bytes_per_block(struct archive *, |
605 | int bytes_per_block); |
606 | __LA_DECL int archive_write_get_bytes_per_block(struct archive *); |
607 | /* XXX This is badly misnamed; suggestions appreciated. XXX */ |
608 | __LA_DECL int archive_write_set_bytes_in_last_block(struct archive *, |
609 | int bytes_in_last_block); |
610 | __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *); |
611 | |
612 | /* The dev/ino of a file that won't be archived. This is used |
613 | * to avoid recursively adding an archive to itself. */ |
614 | __LA_DECL int archive_write_set_skip_file(struct archive *, |
615 | __LA_INT64_T, __LA_INT64_T); |
616 | |
617 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
618 | __LA_DECL int archive_write_set_compression_bzip2(struct archive *) |
619 | __LA_DEPRECATED; |
620 | __LA_DECL int archive_write_set_compression_compress(struct archive *) |
621 | __LA_DEPRECATED; |
622 | __LA_DECL int archive_write_set_compression_gzip(struct archive *) |
623 | __LA_DEPRECATED; |
624 | __LA_DECL int archive_write_set_compression_lzip(struct archive *) |
625 | __LA_DEPRECATED; |
626 | __LA_DECL int archive_write_set_compression_lzma(struct archive *) |
627 | __LA_DEPRECATED; |
628 | __LA_DECL int archive_write_set_compression_none(struct archive *) |
629 | __LA_DEPRECATED; |
630 | __LA_DECL int archive_write_set_compression_program(struct archive *, |
631 | const char *cmd) __LA_DEPRECATED; |
632 | __LA_DECL int archive_write_set_compression_xz(struct archive *) |
633 | __LA_DEPRECATED; |
634 | #endif |
635 | |
636 | /* A convenience function to set the filter based on the code. */ |
637 | __LA_DECL int archive_write_add_filter(struct archive *, int filter_code); |
638 | __LA_DECL int archive_write_add_filter_by_name(struct archive *, |
639 | const char *name); |
640 | __LA_DECL int archive_write_add_filter_b64encode(struct archive *); |
641 | __LA_DECL int archive_write_add_filter_bzip2(struct archive *); |
642 | __LA_DECL int archive_write_add_filter_compress(struct archive *); |
643 | __LA_DECL int archive_write_add_filter_grzip(struct archive *); |
644 | __LA_DECL int archive_write_add_filter_gzip(struct archive *); |
645 | __LA_DECL int archive_write_add_filter_lrzip(struct archive *); |
646 | __LA_DECL int archive_write_add_filter_lzip(struct archive *); |
647 | __LA_DECL int archive_write_add_filter_lzma(struct archive *); |
648 | __LA_DECL int archive_write_add_filter_lzop(struct archive *); |
649 | __LA_DECL int archive_write_add_filter_none(struct archive *); |
650 | __LA_DECL int archive_write_add_filter_program(struct archive *, |
651 | const char *cmd); |
652 | __LA_DECL int archive_write_add_filter_uuencode(struct archive *); |
653 | __LA_DECL int archive_write_add_filter_xz(struct archive *); |
654 | |
655 | |
656 | /* A convenience function to set the format based on the code or name. */ |
657 | __LA_DECL int archive_write_set_format(struct archive *, int format_code); |
658 | __LA_DECL int archive_write_set_format_by_name(struct archive *, |
659 | const char *name); |
660 | /* To minimize link pollution, use one or more of the following. */ |
661 | __LA_DECL int archive_write_set_format_7zip(struct archive *); |
662 | __LA_DECL int archive_write_set_format_ar_bsd(struct archive *); |
663 | __LA_DECL int archive_write_set_format_ar_svr4(struct archive *); |
664 | __LA_DECL int archive_write_set_format_cpio(struct archive *); |
665 | __LA_DECL int archive_write_set_format_cpio_newc(struct archive *); |
666 | __LA_DECL int archive_write_set_format_gnutar(struct archive *); |
667 | __LA_DECL int archive_write_set_format_iso9660(struct archive *); |
668 | __LA_DECL int archive_write_set_format_mtree(struct archive *); |
669 | __LA_DECL int archive_write_set_format_mtree_classic(struct archive *); |
670 | /* TODO: int archive_write_set_format_old_tar(struct archive *); */ |
671 | __LA_DECL int archive_write_set_format_pax(struct archive *); |
672 | __LA_DECL int archive_write_set_format_pax_restricted(struct archive *); |
673 | __LA_DECL int archive_write_set_format_shar(struct archive *); |
674 | __LA_DECL int archive_write_set_format_shar_dump(struct archive *); |
675 | __LA_DECL int archive_write_set_format_ustar(struct archive *); |
676 | __LA_DECL int archive_write_set_format_v7tar(struct archive *); |
677 | __LA_DECL int archive_write_set_format_xar(struct archive *); |
678 | __LA_DECL int archive_write_set_format_zip(struct archive *); |
679 | __LA_DECL int archive_write_zip_set_compression_deflate(struct archive *); |
680 | __LA_DECL int archive_write_zip_set_compression_store(struct archive *); |
681 | __LA_DECL int archive_write_open(struct archive *, void *, |
682 | archive_open_callback *, archive_write_callback *, |
683 | archive_close_callback *); |
684 | __LA_DECL int archive_write_open_fd(struct archive *, int _fd); |
685 | __LA_DECL int archive_write_open_filename(struct archive *, const char *_file); |
686 | __LA_DECL int archive_write_open_filename_w(struct archive *, |
687 | const wchar_t *_file); |
688 | /* A deprecated synonym for archive_write_open_filename() */ |
689 | __LA_DECL int archive_write_open_file(struct archive *, const char *_file) |
690 | __LA_DEPRECATED; |
691 | __LA_DECL int archive_write_open_FILE(struct archive *, FILE *); |
692 | /* _buffSize is the size of the buffer, _used refers to a variable that |
693 | * will be updated after each write into the buffer. */ |
694 | __LA_DECL int archive_write_open_memory(struct archive *, |
695 | void *_buffer, size_t _buffSize, size_t *_used); |
696 | |
697 | /* |
698 | * Note that the library will truncate writes beyond the size provided |
699 | * to archive_write_header or pad if the provided data is short. |
700 | */ |
701 | __LA_DECL int (struct archive *, |
702 | struct archive_entry *); |
703 | __LA_DECL __LA_SSIZE_T archive_write_data(struct archive *, |
704 | const void *, size_t); |
705 | |
706 | /* This interface is currently only available for archive_write_disk handles. */ |
707 | __LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *, |
708 | const void *, size_t, __LA_INT64_T); |
709 | |
710 | __LA_DECL int archive_write_finish_entry(struct archive *); |
711 | __LA_DECL int archive_write_close(struct archive *); |
712 | /* Marks the archive as FATAL so that a subsequent free() operation |
713 | * won't try to close() cleanly. Provides a fast abort capability |
714 | * when the client discovers that things have gone wrong. */ |
715 | __LA_DECL int archive_write_fail(struct archive *); |
716 | /* This can fail if the archive wasn't already closed, in which case |
717 | * archive_write_free() will implicitly call archive_write_close(). */ |
718 | __LA_DECL int archive_write_free(struct archive *); |
719 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
720 | /* Synonym for archive_write_free() for backwards compatibility. */ |
721 | __LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED; |
722 | #endif |
723 | |
724 | /* |
725 | * Set write options. |
726 | */ |
727 | /* Apply option to the format only. */ |
728 | __LA_DECL int archive_write_set_format_option(struct archive *_a, |
729 | const char *m, const char *o, |
730 | const char *v); |
731 | /* Apply option to the filter only. */ |
732 | __LA_DECL int archive_write_set_filter_option(struct archive *_a, |
733 | const char *m, const char *o, |
734 | const char *v); |
735 | /* Apply option to both the format and the filter. */ |
736 | __LA_DECL int archive_write_set_option(struct archive *_a, |
737 | const char *m, const char *o, |
738 | const char *v); |
739 | /* Apply option string to both the format and the filter. */ |
740 | __LA_DECL int archive_write_set_options(struct archive *_a, |
741 | const char *opts); |
742 | |
743 | /*- |
744 | * ARCHIVE_WRITE_DISK API |
745 | * |
746 | * To create objects on disk: |
747 | * 1) Ask archive_write_disk_new for a new archive_write_disk object. |
748 | * 2) Set any global properties. In particular, you probably |
749 | * want to set the options. |
750 | * 3) For each entry: |
751 | * - construct an appropriate struct archive_entry structure |
752 | * - archive_write_header to create the file/dir/etc on disk |
753 | * - archive_write_data to write the entry data |
754 | * 4) archive_write_free to cleanup the writer and release resources |
755 | * |
756 | * In particular, you can use this in conjunction with archive_read() |
757 | * to pull entries out of an archive and create them on disk. |
758 | */ |
759 | __LA_DECL struct archive *archive_write_disk_new(void); |
760 | /* This file will not be overwritten. */ |
761 | __LA_DECL int archive_write_disk_set_skip_file(struct archive *, |
762 | __LA_INT64_T, __LA_INT64_T); |
763 | /* Set flags to control how the next item gets created. |
764 | * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */ |
765 | __LA_DECL int archive_write_disk_set_options(struct archive *, |
766 | int flags); |
767 | /* |
768 | * The lookup functions are given uname/uid (or gname/gid) pairs and |
769 | * return a uid (gid) suitable for this system. These are used for |
770 | * restoring ownership and for setting ACLs. The default functions |
771 | * are naive, they just return the uid/gid. These are small, so reasonable |
772 | * for applications that don't need to preserve ownership; they |
773 | * are probably also appropriate for applications that are doing |
774 | * same-system backup and restore. |
775 | */ |
776 | /* |
777 | * The "standard" lookup functions use common system calls to lookup |
778 | * the uname/gname, falling back to the uid/gid if the names can't be |
779 | * found. They cache lookups and are reasonably fast, but can be very |
780 | * large, so they are not used unless you ask for them. In |
781 | * particular, these match the specifications of POSIX "pax" and old |
782 | * POSIX "tar". |
783 | */ |
784 | __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *); |
785 | /* |
786 | * If neither the default (naive) nor the standard (big) functions suit |
787 | * your needs, you can write your own and register them. Be sure to |
788 | * include a cleanup function if you have allocated private data. |
789 | */ |
790 | __LA_DECL int archive_write_disk_set_group_lookup(struct archive *, |
791 | void * /* private_data */, |
792 | __LA_INT64_T (*)(void *, const char *, __LA_INT64_T), |
793 | void (* /* cleanup */)(void *)); |
794 | __LA_DECL int archive_write_disk_set_user_lookup(struct archive *, |
795 | void * /* private_data */, |
796 | __LA_INT64_T (*)(void *, const char *, __LA_INT64_T), |
797 | void (* /* cleanup */)(void *)); |
798 | __LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T); |
799 | __LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T); |
800 | |
801 | /* |
802 | * ARCHIVE_READ_DISK API |
803 | * |
804 | * This is still evolving and somewhat experimental. |
805 | */ |
806 | __LA_DECL struct archive *archive_read_disk_new(void); |
807 | /* The names for symlink modes here correspond to an old BSD |
808 | * command-line argument convention: -L, -P, -H */ |
809 | /* Follow all symlinks. */ |
810 | __LA_DECL int archive_read_disk_set_symlink_logical(struct archive *); |
811 | /* Follow no symlinks. */ |
812 | __LA_DECL int archive_read_disk_set_symlink_physical(struct archive *); |
813 | /* Follow symlink initially, then not. */ |
814 | __LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *); |
815 | /* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */ |
816 | __LA_DECL int archive_read_disk_entry_from_file(struct archive *, |
817 | struct archive_entry *, int /* fd */, const struct stat *); |
818 | /* Look up gname for gid or uname for uid. */ |
819 | /* Default implementations are very, very stupid. */ |
820 | __LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T); |
821 | __LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T); |
822 | /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the |
823 | * results for performance. */ |
824 | __LA_DECL int archive_read_disk_set_standard_lookup(struct archive *); |
825 | /* You can install your own lookups if you like. */ |
826 | __LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, |
827 | void * /* private_data */, |
828 | const char *(* /* lookup_fn */)(void *, __LA_INT64_T), |
829 | void (* /* cleanup_fn */)(void *)); |
830 | __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, |
831 | void * /* private_data */, |
832 | const char *(* /* lookup_fn */)(void *, __LA_INT64_T), |
833 | void (* /* cleanup_fn */)(void *)); |
834 | /* Start traversal. */ |
835 | __LA_DECL int archive_read_disk_open(struct archive *, const char *); |
836 | __LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *); |
837 | /* |
838 | * Request that current entry be visited. If you invoke it on every |
839 | * directory, you'll get a physical traversal. This is ignored if the |
840 | * current entry isn't a directory or a link to a directory. So, if |
841 | * you invoke this on every returned path, you'll get a full logical |
842 | * traversal. |
843 | */ |
844 | __LA_DECL int archive_read_disk_descend(struct archive *); |
845 | __LA_DECL int archive_read_disk_can_descend(struct archive *); |
846 | __LA_DECL int archive_read_disk_current_filesystem(struct archive *); |
847 | __LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *); |
848 | __LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *); |
849 | /* Request that the access time of the entry visited by travesal be restored. */ |
850 | __LA_DECL int archive_read_disk_set_atime_restored(struct archive *); |
851 | /* |
852 | * Set behavior. The "flags" argument selects optional behavior. |
853 | */ |
854 | /* Request that the access time of the entry visited by travesal be restored. |
855 | * This is the same as archive_read_disk_set_atime_restored. */ |
856 | #define ARCHIVE_READDISK_RESTORE_ATIME (0x0001) |
857 | /* Default: Do not skip an entry which has nodump flags. */ |
858 | #define ARCHIVE_READDISK_HONOR_NODUMP (0x0002) |
859 | /* Default: Skip a mac resource fork file whose prefix is "._" because of |
860 | * using copyfile. */ |
861 | #define ARCHIVE_READDISK_MAC_COPYFILE (0x0004) |
862 | /* Default: Do not traverse mount points. */ |
863 | #define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008) |
864 | |
865 | __LA_DECL int archive_read_disk_set_behavior(struct archive *, |
866 | int flags); |
867 | |
868 | /* |
869 | * Set archive_match object that will be used in archive_read_disk to |
870 | * know whether an entry should be skipped. The callback function |
871 | * _excluded_func will be invoked when an entry is skipped by the result |
872 | * of archive_match. |
873 | */ |
874 | __LA_DECL int archive_read_disk_set_matching(struct archive *, |
875 | struct archive *_matching, void (*_excluded_func) |
876 | (struct archive *, void *, struct archive_entry *), |
877 | void *_client_data); |
878 | __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, |
879 | int (*_metadata_filter_func)(struct archive *, void *, |
880 | struct archive_entry *), void *_client_data); |
881 | |
882 | /* |
883 | * Accessor functions to read/set various information in |
884 | * the struct archive object: |
885 | */ |
886 | |
887 | /* Number of filters in the current filter pipeline. */ |
888 | /* Filter #0 is the one closest to the format, -1 is a synonym for the |
889 | * last filter, which is always the pseudo-filter that wraps the |
890 | * client callbacks. */ |
891 | __LA_DECL int archive_filter_count(struct archive *); |
892 | __LA_DECL __LA_INT64_T archive_filter_bytes(struct archive *, int); |
893 | __LA_DECL int archive_filter_code(struct archive *, int); |
894 | __LA_DECL const char * archive_filter_name(struct archive *, int); |
895 | |
896 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
897 | /* These don't properly handle multiple filters, so are deprecated and |
898 | * will eventually be removed. */ |
899 | /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */ |
900 | __LA_DECL __LA_INT64_T archive_position_compressed(struct archive *) |
901 | __LA_DEPRECATED; |
902 | /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */ |
903 | __LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *) |
904 | __LA_DEPRECATED; |
905 | /* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */ |
906 | __LA_DECL const char *archive_compression_name(struct archive *) |
907 | __LA_DEPRECATED; |
908 | /* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */ |
909 | __LA_DECL int archive_compression(struct archive *) |
910 | __LA_DEPRECATED; |
911 | #endif |
912 | |
913 | __LA_DECL int archive_errno(struct archive *); |
914 | __LA_DECL const char *archive_error_string(struct archive *); |
915 | __LA_DECL const char *archive_format_name(struct archive *); |
916 | __LA_DECL int archive_format(struct archive *); |
917 | __LA_DECL void archive_clear_error(struct archive *); |
918 | __LA_DECL void archive_set_error(struct archive *, int _err, |
919 | const char *fmt, ...) __LA_PRINTF(3, 4); |
920 | __LA_DECL void archive_copy_error(struct archive *dest, |
921 | struct archive *src); |
922 | __LA_DECL int archive_file_count(struct archive *); |
923 | |
924 | /* |
925 | * ARCHIVE_MATCH API |
926 | */ |
927 | __LA_DECL struct archive *archive_match_new(void); |
928 | __LA_DECL int archive_match_free(struct archive *); |
929 | |
930 | /* |
931 | * Test if archive_entry is excluded. |
932 | * This is a convenience function. This is the same as calling all |
933 | * archive_match_path_excluded, archive_match_time_excluded |
934 | * and archive_match_owner_excluded. |
935 | */ |
936 | __LA_DECL int archive_match_excluded(struct archive *, |
937 | struct archive_entry *); |
938 | |
939 | /* |
940 | * Test if pathname is excluded. The conditions are set by following functions. |
941 | */ |
942 | __LA_DECL int archive_match_path_excluded(struct archive *, |
943 | struct archive_entry *); |
944 | /* Add exclusion pathname pattern. */ |
945 | __LA_DECL int archive_match_exclude_pattern(struct archive *, const char *); |
946 | __LA_DECL int archive_match_exclude_pattern_w(struct archive *, |
947 | const wchar_t *); |
948 | /* Add exclusion pathname pattern from file. */ |
949 | __LA_DECL int archive_match_exclude_pattern_from_file(struct archive *, |
950 | const char *, int _nullSeparator); |
951 | __LA_DECL int archive_match_exclude_pattern_from_file_w(struct archive *, |
952 | const wchar_t *, int _nullSeparator); |
953 | /* Add inclusion pathname pattern. */ |
954 | __LA_DECL int archive_match_include_pattern(struct archive *, const char *); |
955 | __LA_DECL int archive_match_include_pattern_w(struct archive *, |
956 | const wchar_t *); |
957 | /* Add inclusion pathname pattern from file. */ |
958 | __LA_DECL int archive_match_include_pattern_from_file(struct archive *, |
959 | const char *, int _nullSeparator); |
960 | __LA_DECL int archive_match_include_pattern_from_file_w(struct archive *, |
961 | const wchar_t *, int _nullSeparator); |
962 | /* |
963 | * How to get statistic information for inclusion patterns. |
964 | */ |
965 | /* Return the amount number of unmatched inclusion patterns. */ |
966 | __LA_DECL int archive_match_path_unmatched_inclusions(struct archive *); |
967 | /* Return the pattern of unmatched inclusion with ARCHIVE_OK. |
968 | * Return ARCHIVE_EOF if there is no inclusion pattern. */ |
969 | __LA_DECL int archive_match_path_unmatched_inclusions_next( |
970 | struct archive *, const char **); |
971 | __LA_DECL int archive_match_path_unmatched_inclusions_next_w( |
972 | struct archive *, const wchar_t **); |
973 | |
974 | /* |
975 | * Test if a file is excluded by its time stamp. |
976 | * The conditions are set by following functions. |
977 | */ |
978 | __LA_DECL int archive_match_time_excluded(struct archive *, |
979 | struct archive_entry *); |
980 | |
981 | /* |
982 | * Flags to tell a matching type of time stamps. These are used for |
983 | * following functinos. |
984 | */ |
985 | /* Time flag: mtime to be tested. */ |
986 | #define ARCHIVE_MATCH_MTIME (0x0100) |
987 | /* Time flag: ctime to be tested. */ |
988 | #define ARCHIVE_MATCH_CTIME (0x0200) |
989 | /* Comparison flag: Match the time if it is newer than. */ |
990 | #define ARCHIVE_MATCH_NEWER (0x0001) |
991 | /* Comparison flag: Match the time if it is older than. */ |
992 | #define ARCHIVE_MATCH_OLDER (0x0002) |
993 | /* Comparison flag: Match the time if it is equal to. */ |
994 | #define ARCHIVE_MATCH_EQUAL (0x0010) |
995 | /* Set inclusion time. */ |
996 | __LA_DECL int archive_match_include_time(struct archive *, int _flag, |
997 | time_t _sec, long _nsec); |
998 | /* Set inclusion time by a date string. */ |
999 | __LA_DECL int archive_match_include_date(struct archive *, int _flag, |
1000 | const char *_datestr); |
1001 | __LA_DECL int archive_match_include_date_w(struct archive *, int _flag, |
1002 | const wchar_t *_datestr); |
1003 | /* Set inclusion time by a particluar file. */ |
1004 | __LA_DECL int archive_match_include_file_time(struct archive *, |
1005 | int _flag, const char *_pathname); |
1006 | __LA_DECL int archive_match_include_file_time_w(struct archive *, |
1007 | int _flag, const wchar_t *_pathname); |
1008 | /* Add exclusion entry. */ |
1009 | __LA_DECL int archive_match_exclude_entry(struct archive *, |
1010 | int _flag, struct archive_entry *); |
1011 | |
1012 | /* |
1013 | * Test if a file is excluded by its uid ,gid, uname or gname. |
1014 | * The conditions are set by following functions. |
1015 | */ |
1016 | __LA_DECL int archive_match_owner_excluded(struct archive *, |
1017 | struct archive_entry *); |
1018 | /* Add inclusion uid, gid, uname and gname. */ |
1019 | __LA_DECL int archive_match_include_uid(struct archive *, __LA_INT64_T); |
1020 | __LA_DECL int archive_match_include_gid(struct archive *, __LA_INT64_T); |
1021 | __LA_DECL int archive_match_include_uname(struct archive *, const char *); |
1022 | __LA_DECL int archive_match_include_uname_w(struct archive *, |
1023 | const wchar_t *); |
1024 | __LA_DECL int archive_match_include_gname(struct archive *, const char *); |
1025 | __LA_DECL int archive_match_include_gname_w(struct archive *, |
1026 | const wchar_t *); |
1027 | |
1028 | #ifdef __cplusplus |
1029 | } |
1030 | #endif |
1031 | |
1032 | /* These are meaningless outside of this header. */ |
1033 | #undef __LA_DECL |
1034 | |
1035 | /* These need to remain defined because they're used in the |
1036 | * callback type definitions. XXX Fix this. This is ugly. XXX */ |
1037 | /* #undef __LA_INT64_T */ |
1038 | /* #undef __LA_SSIZE_T */ |
1039 | |
1040 | #endif /* !ARCHIVE_H_INCLUDED */ |
1041 | |