]>
Commit | Line | Data |
---|---|---|
eaae26f3 | 1 | /*- |
911dc2bf | 2 | * Copyright (c) 2003-2010 Tim Kientzle |
eaae26f3 TK |
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 | /* | |
32 | * Note: archive.h is for use outside of libarchive; the configuration | |
33 | * headers (config.h, archive_platform.h, etc.) are purely internal. | |
34 | * Do NOT use HAVE_XXX configuration macros to control the behavior of | |
35 | * this header! If you must conditionalize, use predefined compiler and/or | |
36 | * platform macros. | |
37 | */ | |
f828fbc1 BK |
38 | #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 |
39 | # define __LA_STDINT_H <stdint.h> | |
40 | #elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) | |
41 | # define __LA_STDINT_H <inttypes.h> | |
42 | #endif | |
eaae26f3 | 43 | |
a8ac0b18 | 44 | #include <sys/stat.h> |
73f39d90 TK |
45 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
46 | #include <sys/types.h> /* Linux needs this for off_t; 3.0+ doesn't need it */ | |
47 | #endif | |
f828fbc1 BK |
48 | #ifdef __LA_STDINT_H |
49 | # include __LA_STDINT_H /* int64_t, etc. */ | |
eaae26f3 TK |
50 | #endif |
51 | #include <stdio.h> /* For FILE * */ | |
52 | ||
53 | /* Get appropriate definitions of standard POSIX-style types. */ | |
54 | /* These should match the types used in 'struct stat' */ | |
44f9eb57 | 55 | #if defined(_WIN32) && !defined(__CYGWIN__) |
07be984c | 56 | #define __LA_INT64_T __int64 |
e0f0abf0 BK |
57 | # if defined(_SSIZE_T_DEFINED) |
58 | # define __LA_SSIZE_T ssize_t | |
59 | # elif defined(_WIN64) | |
b05b5e14 TK |
60 | # define __LA_SSIZE_T __int64 |
61 | # else | |
62 | # define __LA_SSIZE_T long | |
63 | # endif | |
2566a7ab BK |
64 | # if defined(__BORLANDC__) |
65 | # define __LA_UID_T uid_t | |
66 | # define __LA_GID_T gid_t | |
67 | # else | |
68 | # define __LA_UID_T short | |
69 | # define __LA_GID_T short | |
70 | # endif | |
eaae26f3 TK |
71 | #else |
72 | #include <unistd.h> /* ssize_t, uid_t, and gid_t */ | |
07be984c | 73 | #define __LA_INT64_T int64_t |
eaae26f3 TK |
74 | #define __LA_SSIZE_T ssize_t |
75 | #define __LA_UID_T uid_t | |
76 | #define __LA_GID_T gid_t | |
77 | #endif | |
78 | ||
79 | /* | |
80 | * On Windows, define LIBARCHIVE_STATIC if you're building or using a | |
81 | * .lib. The default here assumes you're building a DLL. Only | |
82 | * libarchive source should ever define __LIBARCHIVE_BUILD. | |
83 | */ | |
44f9eb57 | 84 | #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC) |
eaae26f3 TK |
85 | # ifdef __LIBARCHIVE_BUILD |
86 | # ifdef __GNUC__ | |
87 | # define __LA_DECL __attribute__((dllexport)) extern | |
88 | # else | |
89 | # define __LA_DECL __declspec(dllexport) | |
90 | # endif | |
91 | # else | |
92 | # ifdef __GNUC__ | |
93 | # define __LA_DECL __attribute__((dllimport)) extern | |
94 | # else | |
95 | # define __LA_DECL __declspec(dllimport) | |
96 | # endif | |
97 | # endif | |
98 | #else | |
99 | /* Static libraries or non-Windows needs no special declaration. */ | |
100 | # define __LA_DECL | |
101 | #endif | |
102 | ||
ac8ba3fa JS |
103 | #if defined(__GNUC__) && __GNUC__ >= 3 |
104 | #define __LA_PRINTF(fmtarg, firstvararg) \ | |
105 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) | |
106 | #else | |
107 | #define __LA_PRINTF(fmtarg, firstvararg) /* nothing */ | |
108 | #endif | |
109 | ||
eaae26f3 TK |
110 | #ifdef __cplusplus |
111 | extern "C" { | |
112 | #endif | |
113 | ||
114 | /* | |
115 | * The version number is provided as both a macro and a function. | |
116 | * The macro identifies the installed header; the function identifies | |
117 | * the library version (which may not be the same if you're using a | |
118 | * dynamically-linked version of the library). Of course, if the | |
119 | * header and library are very different, you should expect some | |
120 | * strangeness. Don't do that. | |
121 | */ | |
122 | ||
123 | /* | |
124 | * The version number is expressed as a single integer that makes it | |
125 | * easy to compare versions at build time: for version a.b.c, the | |
126 | * version number is printf("%d%03d%03d",a,b,c). For example, if you | |
127 | * know your application requires version 2.12.108 or later, you can | |
128 | * assert that ARCHIVE_VERSION >= 2012108. | |
129 | * | |
130 | * This single-number format was introduced with libarchive 1.9.0 in | |
131 | * the libarchive 1.x family and libarchive 2.2.4 in the libarchive | |
132 | * 2.x family. The following may be useful if you really want to do | |
133 | * feature detection for earlier libarchive versions (which defined | |
134 | * ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead): | |
135 | * | |
136 | * #ifndef ARCHIVE_VERSION_NUMBER | |
137 | * #define ARCHIVE_VERSION_NUMBER \ | |
138 | * (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000) | |
139 | * #endif | |
140 | */ | |
42c1f3e1 TK |
141 | /* Note: Compiler will complain if this does not match archive_entry.h! */ |
142 | #define ARCHIVE_VERSION_NUMBER 2008900 | |
eaae26f3 TK |
143 | __LA_DECL int archive_version_number(void); |
144 | ||
145 | /* | |
146 | * Textual name/version of the library, useful for version displays. | |
147 | */ | |
42c1f3e1 | 148 | #define ARCHIVE_VERSION_STRING "libarchive 2.8.900a" |
eaae26f3 TK |
149 | __LA_DECL const char * archive_version_string(void); |
150 | ||
151 | #if ARCHIVE_VERSION_NUMBER < 3000000 | |
152 | /* | |
153 | * Deprecated; these are older names that will be removed in favor of | |
154 | * the simpler definitions above. | |
155 | */ | |
156 | #define ARCHIVE_VERSION_STAMP ARCHIVE_VERSION_NUMBER | |
157 | __LA_DECL int archive_version_stamp(void); | |
158 | #define ARCHIVE_LIBRARY_VERSION ARCHIVE_VERSION_STRING | |
159 | __LA_DECL const char * archive_version(void); | |
160 | #define ARCHIVE_API_VERSION (ARCHIVE_VERSION_NUMBER / 1000000) | |
161 | __LA_DECL int archive_api_version(void); | |
162 | #define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_NUMBER / 1000) % 1000) | |
163 | __LA_DECL int archive_api_feature(void); | |
164 | #endif | |
165 | ||
166 | #if ARCHIVE_VERSION_NUMBER < 3000000 | |
167 | /* This should never have been here in the first place. */ | |
168 | /* Legacy of old tar assumptions, will be removed in libarchive 3.0. */ | |
169 | #define ARCHIVE_BYTES_PER_RECORD 512 | |
170 | #define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240 | |
171 | #endif | |
172 | ||
173 | /* Declare our basic types. */ | |
174 | struct archive; | |
175 | struct archive_entry; | |
176 | ||
177 | /* | |
178 | * Error codes: Use archive_errno() and archive_error_string() | |
179 | * to retrieve details. Unless specified otherwise, all functions | |
180 | * that return 'int' use these codes. | |
181 | */ | |
182 | #define ARCHIVE_EOF 1 /* Found end of archive. */ | |
183 | #define ARCHIVE_OK 0 /* Operation was successful. */ | |
184 | #define ARCHIVE_RETRY (-10) /* Retry might succeed. */ | |
185 | #define ARCHIVE_WARN (-20) /* Partial success. */ | |
186 | /* For example, if write_header "fails", then you can't push data. */ | |
187 | #define ARCHIVE_FAILED (-25) /* Current operation cannot complete. */ | |
188 | /* But if write_header is "fatal," then this archive is dead and useless. */ | |
189 | #define ARCHIVE_FATAL (-30) /* No more operations are possible. */ | |
190 | ||
191 | /* | |
192 | * As far as possible, archive_errno returns standard platform errno codes. | |
193 | * Of course, the details vary by platform, so the actual definitions | |
194 | * here are stored in "archive_platform.h". The symbols are listed here | |
195 | * for reference; as a rule, clients should not need to know the exact | |
196 | * platform-dependent error code. | |
197 | */ | |
198 | /* Unrecognized or invalid file format. */ | |
199 | /* #define ARCHIVE_ERRNO_FILE_FORMAT */ | |
200 | /* Illegal usage of the library. */ | |
201 | /* #define ARCHIVE_ERRNO_PROGRAMMER_ERROR */ | |
202 | /* Unknown or unclassified error. */ | |
203 | /* #define ARCHIVE_ERRNO_MISC */ | |
204 | ||
205 | /* | |
206 | * Callbacks are invoked to automatically read/skip/write/open/close the | |
207 | * archive. You can provide your own for complex tasks (like breaking | |
208 | * archives across multiple tapes) or use standard ones built into the | |
209 | * library. | |
210 | */ | |
211 | ||
212 | /* Returns pointer and size of next block of data from archive. */ | |
fc95189e TK |
213 | typedef __LA_SSIZE_T archive_read_callback(struct archive *, |
214 | void *_client_data, const void **_buffer); | |
215 | ||
eaae26f3 | 216 | /* Skips at most request bytes from archive and returns the skipped amount */ |
afea1b2b | 217 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
fc95189e TK |
218 | /* Libarchive 2.0 used off_t here, but that is a bad idea on Linux and a |
219 | * few other platforms where off_t varies with build settings. */ | |
220 | typedef off_t archive_skip_callback(struct archive *, | |
221 | void *_client_data, off_t request); | |
eaae26f3 | 222 | #else |
fc95189e TK |
223 | /* Libarchive 3.0 uses int64_t here, which is actually guaranteed to be |
224 | * 64 bits on every platform. */ | |
225 | typedef __LA_INT64_T archive_skip_callback(struct archive *, | |
226 | void *_client_data, __LA_INT64_T request); | |
eaae26f3 | 227 | #endif |
fc95189e | 228 | |
eaae26f3 | 229 | /* Returns size actually written, zero on EOF, -1 on error. */ |
fc95189e TK |
230 | typedef __LA_SSIZE_T archive_write_callback(struct archive *, |
231 | void *_client_data, | |
232 | const void *_buffer, size_t _length); | |
233 | ||
eaae26f3 | 234 | typedef int archive_open_callback(struct archive *, void *_client_data); |
fc95189e | 235 | |
eaae26f3 TK |
236 | typedef int archive_close_callback(struct archive *, void *_client_data); |
237 | ||
238 | /* | |
911dc2bf | 239 | * Codes to identify various stream filters. |
eaae26f3 | 240 | */ |
911dc2bf TK |
241 | #define ARCHIVE_FILTER_NONE 0 |
242 | #define ARCHIVE_FILTER_GZIP 1 | |
243 | #define ARCHIVE_FILTER_BZIP2 2 | |
244 | #define ARCHIVE_FILTER_COMPRESS 3 | |
245 | #define ARCHIVE_FILTER_PROGRAM 4 | |
246 | #define ARCHIVE_FILTER_LZMA 5 | |
247 | #define ARCHIVE_FILTER_XZ 6 | |
248 | #define ARCHIVE_FILTER_UU 7 | |
249 | #define ARCHIVE_FILTER_RPM 8 | |
d8961d39 | 250 | #define ARCHIVE_FILTER_LZIP 9 |
911dc2bf TK |
251 | |
252 | #if ARCHIVE_VERSION_NUMBER < 4000000 | |
253 | #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE | |
254 | #define ARCHIVE_COMPRESSION_GZIP ARCHIVE_FILTER_GZIP | |
255 | #define ARCHIVE_COMPRESSION_BZIP2 ARCHIVE_FILTER_BZIP2 | |
256 | #define ARCHIVE_COMPRESSION_COMPRESS ARCHIVE_FILTER_COMPRESS | |
257 | #define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM | |
258 | #define ARCHIVE_COMPRESSION_LZMA ARCHIVE_FILTER_LZMA | |
259 | #define ARCHIVE_COMPRESSION_XZ ARCHIVE_FILTER_XZ | |
260 | #define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU | |
261 | #define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM | |
d8961d39 | 262 | #define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP |
911dc2bf | 263 | #endif |
eaae26f3 TK |
264 | |
265 | /* | |
266 | * Codes returned by archive_format. | |
267 | * | |
268 | * Top 16 bits identifies the format family (e.g., "tar"); lower | |
269 | * 16 bits indicate the variant. This is updated by read_next_header. | |
270 | * Note that the lower 16 bits will often vary from entry to entry. | |
271 | * In some cases, this variation occurs as libarchive learns more about | |
272 | * the archive (for example, later entries might utilize extensions that | |
273 | * weren't necessary earlier in the archive; in this case, libarchive | |
274 | * will change the format code to indicate the extended format that | |
275 | * was used). In other cases, it's because different tools have | |
276 | * modified the archive and so different parts of the archive | |
277 | * actually have slightly different formts. (Both tar and cpio store | |
278 | * format codes in each entry, so it is quite possible for each | |
279 | * entry to be in a different format.) | |
280 | */ | |
281 | #define ARCHIVE_FORMAT_BASE_MASK 0xff0000 | |
282 | #define ARCHIVE_FORMAT_CPIO 0x10000 | |
283 | #define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1) | |
284 | #define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2) | |
285 | #define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3) | |
286 | #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4) | |
287 | #define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5) | |
19cc1b68 | 288 | #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6) |
eaae26f3 TK |
289 | #define ARCHIVE_FORMAT_SHAR 0x20000 |
290 | #define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1) | |
291 | #define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2) | |
292 | #define ARCHIVE_FORMAT_TAR 0x30000 | |
293 | #define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1) | |
294 | #define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2) | |
295 | #define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3) | |
296 | #define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4) | |
297 | #define ARCHIVE_FORMAT_ISO9660 0x40000 | |
298 | #define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1) | |
299 | #define ARCHIVE_FORMAT_ZIP 0x50000 | |
300 | #define ARCHIVE_FORMAT_EMPTY 0x60000 | |
301 | #define ARCHIVE_FORMAT_AR 0x70000 | |
302 | #define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1) | |
303 | #define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2) | |
304 | #define ARCHIVE_FORMAT_MTREE 0x80000 | |
ccdb0318 | 305 | #define ARCHIVE_FORMAT_RAW 0x90000 |
d2c0930d | 306 | #define ARCHIVE_FORMAT_XAR 0xA0000 |
eaae26f3 TK |
307 | |
308 | /*- | |
309 | * Basic outline for reading an archive: | |
310 | * 1) Ask archive_read_new for an archive reader object. | |
311 | * 2) Update any global properties as appropriate. | |
312 | * In particular, you'll certainly want to call appropriate | |
313 | * archive_read_support_XXX functions. | |
314 | * 3) Call archive_read_open_XXX to open the archive | |
315 | * 4) Repeatedly call archive_read_next_header to get information about | |
316 | * successive archive entries. Call archive_read_data to extract | |
317 | * data for entries of interest. | |
318 | * 5) Call archive_read_finish to end processing. | |
319 | */ | |
320 | __LA_DECL struct archive *archive_read_new(void); | |
321 | ||
322 | /* | |
323 | * The archive_read_support_XXX calls enable auto-detect for this | |
324 | * archive handle. They also link in the necessary support code. | |
325 | * For example, if you don't want bzlib linked in, don't invoke | |
326 | * support_compression_bzip2(). The "all" functions provide the | |
327 | * obvious shorthand. | |
328 | */ | |
911dc2bf TK |
329 | /* TODO: Rename 'compression' here to 'filter' for libarchive 3.0, deprecate |
330 | * the old names. */ | |
331 | ||
332 | __LA_DECL int archive_read_support_compression_all(struct archive *); | |
333 | __LA_DECL int archive_read_support_compression_bzip2(struct archive *); | |
334 | __LA_DECL int archive_read_support_compression_compress(struct archive *); | |
335 | __LA_DECL int archive_read_support_compression_gzip(struct archive *); | |
d8961d39 | 336 | __LA_DECL int archive_read_support_compression_lzip(struct archive *); |
911dc2bf TK |
337 | __LA_DECL int archive_read_support_compression_lzma(struct archive *); |
338 | __LA_DECL int archive_read_support_compression_none(struct archive *); | |
339 | __LA_DECL int archive_read_support_compression_program(struct archive *, | |
eaae26f3 | 340 | const char *command); |
911dc2bf TK |
341 | __LA_DECL int archive_read_support_compression_program_signature |
342 | (struct archive *, const char *, | |
21062430 | 343 | const void * /* match */, size_t); |
71aa143d | 344 | |
911dc2bf TK |
345 | __LA_DECL int archive_read_support_compression_rpm(struct archive *); |
346 | __LA_DECL int archive_read_support_compression_uu(struct archive *); | |
347 | __LA_DECL int archive_read_support_compression_xz(struct archive *); | |
eaae26f3 | 348 | |
911dc2bf TK |
349 | __LA_DECL int archive_read_support_format_all(struct archive *); |
350 | __LA_DECL int archive_read_support_format_ar(struct archive *); | |
351 | __LA_DECL int archive_read_support_format_cpio(struct archive *); | |
352 | __LA_DECL int archive_read_support_format_empty(struct archive *); | |
353 | __LA_DECL int archive_read_support_format_gnutar(struct archive *); | |
354 | __LA_DECL int archive_read_support_format_iso9660(struct archive *); | |
355 | __LA_DECL int archive_read_support_format_mtree(struct archive *); | |
356 | __LA_DECL int archive_read_support_format_raw(struct archive *); | |
357 | __LA_DECL int archive_read_support_format_tar(struct archive *); | |
358 | __LA_DECL int archive_read_support_format_xar(struct archive *); | |
359 | __LA_DECL int archive_read_support_format_zip(struct archive *); | |
eaae26f3 TK |
360 | |
361 | ||
362 | /* Open the archive using callbacks for archive I/O. */ | |
911dc2bf | 363 | __LA_DECL int archive_read_open(struct archive *, void *_client_data, |
eaae26f3 TK |
364 | archive_open_callback *, archive_read_callback *, |
365 | archive_close_callback *); | |
911dc2bf | 366 | __LA_DECL int archive_read_open2(struct archive *, void *_client_data, |
eaae26f3 TK |
367 | archive_open_callback *, archive_read_callback *, |
368 | archive_skip_callback *, archive_close_callback *); | |
369 | ||
370 | /* | |
371 | * A variety of shortcuts that invoke archive_read_open() with | |
372 | * canned callbacks suitable for common situations. The ones that | |
373 | * accept a block size handle tape blocking correctly. | |
374 | */ | |
375 | /* Use this if you know the filename. Note: NULL indicates stdin. */ | |
911dc2bf | 376 | __LA_DECL int archive_read_open_filename(struct archive *, |
eaae26f3 TK |
377 | const char *_filename, size_t _block_size); |
378 | /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ | |
911dc2bf | 379 | __LA_DECL int archive_read_open_file(struct archive *, |
eaae26f3 TK |
380 | const char *_filename, size_t _block_size); |
381 | /* Read an archive that's stored in memory. */ | |
911dc2bf | 382 | __LA_DECL int archive_read_open_memory(struct archive *, |
eaae26f3 TK |
383 | void * buff, size_t size); |
384 | /* A more involved version that is only used for internal testing. */ | |
911dc2bf | 385 | __LA_DECL int archive_read_open_memory2(struct archive *a, void *buff, |
eaae26f3 TK |
386 | size_t size, size_t read_size); |
387 | /* Read an archive that's already open, using the file descriptor. */ | |
911dc2bf | 388 | __LA_DECL int archive_read_open_fd(struct archive *, int _fd, |
eaae26f3 TK |
389 | size_t _block_size); |
390 | /* Read an archive that's already open, using a FILE *. */ | |
391 | /* Note: DO NOT use this with tape drives. */ | |
911dc2bf | 392 | __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file); |
eaae26f3 TK |
393 | |
394 | /* Parses and returns next entry header. */ | |
911dc2bf | 395 | __LA_DECL int archive_read_next_header(struct archive *, |
eaae26f3 TK |
396 | struct archive_entry **); |
397 | ||
ff12dfa8 | 398 | /* Parses and returns next entry header using the archive_entry passed in */ |
911dc2bf | 399 | __LA_DECL int archive_read_next_header2(struct archive *, |
ff12dfa8 TK |
400 | struct archive_entry *); |
401 | ||
eaae26f3 TK |
402 | /* |
403 | * Retrieve the byte offset in UNCOMPRESSED data where last-read | |
404 | * header started. | |
405 | */ | |
07be984c | 406 | __LA_DECL __LA_INT64_T archive_read_header_position(struct archive *); |
eaae26f3 TK |
407 | |
408 | /* Read data from the body of an entry. Similar to read(2). */ | |
fc95189e TK |
409 | __LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, |
410 | void *, size_t); | |
411 | ||
eaae26f3 TK |
412 | /* |
413 | * A zero-copy version of archive_read_data that also exposes the file offset | |
414 | * of each returned block. Note that the client has no way to specify | |
415 | * the desired size of the block. The API does guarantee that offsets will | |
416 | * be strictly increasing and that returned blocks will not overlap. | |
417 | */ | |
fc95189e | 418 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
911dc2bf TK |
419 | __LA_DECL int archive_read_data_block(struct archive *a, |
420 | const void **buff, size_t *size, off_t *offset); | |
fc95189e | 421 | #else |
911dc2bf TK |
422 | __LA_DECL int archive_read_data_block(struct archive *a, |
423 | const void **buff, size_t *size, __LA_INT64_T *offset); | |
fc95189e | 424 | #endif |
eaae26f3 TK |
425 | |
426 | /*- | |
427 | * Some convenience functions that are built on archive_read_data: | |
428 | * 'skip': skips entire entry | |
429 | * 'into_buffer': writes data into memory buffer that you provide | |
430 | * 'into_fd': writes data to specified filedes | |
431 | */ | |
911dc2bf TK |
432 | __LA_DECL int archive_read_data_skip(struct archive *); |
433 | __LA_DECL int archive_read_data_into_buffer(struct archive *, | |
fc95189e | 434 | void *buffer, __LA_SSIZE_T len); |
911dc2bf | 435 | __LA_DECL int archive_read_data_into_fd(struct archive *, int fd); |
eaae26f3 | 436 | |
6943997e MN |
437 | /* |
438 | * Set read options. | |
439 | */ | |
440 | /* Apply option string to the format only. */ | |
911dc2bf | 441 | __LA_DECL int archive_read_set_format_options(struct archive *_a, |
6943997e MN |
442 | const char *s); |
443 | /* Apply option string to the filter only. */ | |
911dc2bf | 444 | __LA_DECL int archive_read_set_filter_options(struct archive *_a, |
6943997e MN |
445 | const char *s); |
446 | /* Apply option string to both the format and the filter. */ | |
911dc2bf | 447 | __LA_DECL int archive_read_set_options(struct archive *_a, |
6943997e MN |
448 | const char *s); |
449 | ||
eaae26f3 TK |
450 | /*- |
451 | * Convenience function to recreate the current entry (whose header | |
452 | * has just been read) on disk. | |
453 | * | |
454 | * This does quite a bit more than just copy data to disk. It also: | |
455 | * - Creates intermediate directories as required. | |
456 | * - Manages directory permissions: non-writable directories will | |
457 | * be initially created with write permission enabled; when the | |
458 | * archive is closed, dir permissions are edited to the values specified | |
459 | * in the archive. | |
460 | * - Checks hardlinks: hardlinks will not be extracted unless the | |
461 | * linked-to file was also extracted within the same session. (TODO) | |
462 | */ | |
463 | ||
464 | /* The "flags" argument selects optional behavior, 'OR' the flags you want. */ | |
465 | ||
466 | /* Default: Do not try to set owner/group. */ | |
467 | #define ARCHIVE_EXTRACT_OWNER (0x0001) | |
468 | /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */ | |
469 | #define ARCHIVE_EXTRACT_PERM (0x0002) | |
470 | /* Default: Do not restore mtime/atime. */ | |
471 | #define ARCHIVE_EXTRACT_TIME (0x0004) | |
472 | /* Default: Replace existing files. */ | |
473 | #define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008) | |
474 | /* Default: Try create first, unlink only if create fails with EEXIST. */ | |
475 | #define ARCHIVE_EXTRACT_UNLINK (0x0010) | |
476 | /* Default: Do not restore ACLs. */ | |
477 | #define ARCHIVE_EXTRACT_ACL (0x0020) | |
478 | /* Default: Do not restore fflags. */ | |
479 | #define ARCHIVE_EXTRACT_FFLAGS (0x0040) | |
480 | /* Default: Do not restore xattrs. */ | |
481 | #define ARCHIVE_EXTRACT_XATTR (0x0080) | |
482 | /* Default: Do not try to guard against extracts redirected by symlinks. */ | |
483 | /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */ | |
484 | #define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100) | |
485 | /* Default: Do not reject entries with '..' as path elements. */ | |
486 | #define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200) | |
487 | /* Default: Create parent directories as needed. */ | |
488 | #define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400) | |
489 | /* Default: Overwrite files, even if one on disk is newer. */ | |
490 | #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800) | |
491 | /* Detect blocks of 0 and write holes instead. */ | |
492 | #define ARCHIVE_EXTRACT_SPARSE (0x1000) | |
493 | ||
911dc2bf | 494 | __LA_DECL int archive_read_extract(struct archive *, struct archive_entry *, |
eaae26f3 | 495 | int flags); |
911dc2bf | 496 | __LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *, |
eaae26f3 TK |
497 | struct archive * /* dest */); |
498 | __LA_DECL void archive_read_extract_set_progress_callback(struct archive *, | |
499 | void (*_progress_func)(void *), void *_user_data); | |
500 | ||
501 | /* Record the dev/ino of a file that will not be written. This is | |
502 | * generally set to the dev/ino of the archive being read. */ | |
73f39d90 | 503 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
eaae26f3 TK |
504 | __LA_DECL void archive_read_extract_set_skip_file(struct archive *, |
505 | dev_t, ino_t); | |
73f39d90 TK |
506 | #else |
507 | __LA_DECL void archive_read_extract_set_skip_file(struct archive *, | |
508 | __LA_INT64_T, __LA_INT64_T); | |
509 | #endif | |
eaae26f3 TK |
510 | |
511 | /* Close the file and release most resources. */ | |
512 | __LA_DECL int archive_read_close(struct archive *); | |
513 | /* Release all resources and destroy the object. */ | |
9890b31f TK |
514 | /* Note that archive_read_free will call archive_read_close for you. */ |
515 | __LA_DECL int archive_read_free(struct archive *); | |
516 | #if ARCHIVE_VERSION_NUMBER < 4000000 | |
517 | /* Synonym for archive_read_free() for backwards compatibility. */ | |
fc95189e | 518 | __LA_DECL int archive_read_finish(struct archive *); |
9890b31f | 519 | #endif |
eaae26f3 TK |
520 | |
521 | /*- | |
522 | * To create an archive: | |
523 | * 1) Ask archive_write_new for a archive writer object. | |
524 | * 2) Set any global properties. In particular, you should set | |
525 | * the compression and format to use. | |
526 | * 3) Call archive_write_open to open the file (most people | |
527 | * will use archive_write_open_file or archive_write_open_fd, | |
528 | * which provide convenient canned I/O callbacks for you). | |
529 | * 4) For each entry: | |
530 | * - construct an appropriate struct archive_entry structure | |
531 | * - archive_write_header to write the header | |
532 | * - archive_write_data to write the entry data | |
533 | * 5) archive_write_close to close the output | |
9890b31f | 534 | * 6) archive_write_free to cleanup the writer and release resources |
eaae26f3 TK |
535 | */ |
536 | __LA_DECL struct archive *archive_write_new(void); | |
911dc2bf | 537 | __LA_DECL int archive_write_set_bytes_per_block(struct archive *, |
eaae26f3 | 538 | int bytes_per_block); |
911dc2bf | 539 | __LA_DECL int archive_write_get_bytes_per_block(struct archive *); |
eaae26f3 | 540 | /* XXX This is badly misnamed; suggestions appreciated. XXX */ |
911dc2bf | 541 | __LA_DECL int archive_write_set_bytes_in_last_block(struct archive *, |
eaae26f3 | 542 | int bytes_in_last_block); |
911dc2bf | 543 | __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *); |
eaae26f3 TK |
544 | |
545 | /* The dev/ino of a file that won't be archived. This is used | |
546 | * to avoid recursively adding an archive to itself. */ | |
73f39d90 | 547 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
911dc2bf | 548 | __LA_DECL int archive_write_set_skip_file(struct archive *, dev_t, ino_t); |
73f39d90 TK |
549 | #else |
550 | __LA_DECL int archive_write_set_skip_file(struct archive *, | |
551 | __LA_INT64_T, __LA_INT64_T); | |
552 | #endif | |
911dc2bf TK |
553 | |
554 | #if ARCHIVE_VERSION_NUMBER < 4000000 | |
555 | __LA_DECL int archive_write_set_compression_bzip2(struct archive *); | |
556 | __LA_DECL int archive_write_set_compression_compress(struct archive *); | |
557 | __LA_DECL int archive_write_set_compression_gzip(struct archive *); | |
558 | __LA_DECL int archive_write_set_compression_lzma(struct archive *); | |
559 | __LA_DECL int archive_write_set_compression_none(struct archive *); | |
560 | __LA_DECL int archive_write_set_compression_program(struct archive *, | |
561 | const char *cmd); | |
562 | __LA_DECL int archive_write_set_compression_xz(struct archive *); | |
563 | #endif | |
564 | ||
565 | __LA_DECL int archive_write_add_filter_bzip2(struct archive *); | |
566 | __LA_DECL int archive_write_add_filter_compress(struct archive *); | |
567 | __LA_DECL int archive_write_add_filter_gzip(struct archive *); | |
568 | __LA_DECL int archive_write_add_filter_lzma(struct archive *); | |
569 | __LA_DECL int archive_write_add_filter_none(struct archive *); | |
570 | __LA_DECL int archive_write_add_filter_program(struct archive *, | |
eaae26f3 | 571 | const char *cmd); |
911dc2bf TK |
572 | __LA_DECL int archive_write_add_filter_xz(struct archive *); |
573 | ||
574 | ||
eaae26f3 | 575 | /* A convenience function to set the format based on the code or name. */ |
911dc2bf TK |
576 | __LA_DECL int archive_write_set_format(struct archive *, int format_code); |
577 | __LA_DECL int archive_write_set_format_by_name(struct archive *, | |
eaae26f3 TK |
578 | const char *name); |
579 | /* To minimize link pollution, use one or more of the following. */ | |
911dc2bf TK |
580 | __LA_DECL int archive_write_set_format_ar_bsd(struct archive *); |
581 | __LA_DECL int archive_write_set_format_ar_svr4(struct archive *); | |
582 | __LA_DECL int archive_write_set_format_cpio(struct archive *); | |
583 | __LA_DECL int archive_write_set_format_cpio_newc(struct archive *); | |
7862cf7a | 584 | __LA_DECL int archive_write_set_format_gnutar(struct archive *); |
9d72ea76 | 585 | __LA_DECL int archive_write_set_format_iso9660(struct archive *); |
911dc2bf | 586 | __LA_DECL int archive_write_set_format_mtree(struct archive *); |
eaae26f3 | 587 | /* TODO: int archive_write_set_format_old_tar(struct archive *); */ |
911dc2bf TK |
588 | __LA_DECL int archive_write_set_format_pax(struct archive *); |
589 | __LA_DECL int archive_write_set_format_pax_restricted(struct archive *); | |
590 | __LA_DECL int archive_write_set_format_shar(struct archive *); | |
591 | __LA_DECL int archive_write_set_format_shar_dump(struct archive *); | |
592 | __LA_DECL int archive_write_set_format_ustar(struct archive *); | |
593 | __LA_DECL int archive_write_set_format_zip(struct archive *); | |
594 | __LA_DECL int archive_write_open(struct archive *, void *, | |
eaae26f3 TK |
595 | archive_open_callback *, archive_write_callback *, |
596 | archive_close_callback *); | |
911dc2bf TK |
597 | __LA_DECL int archive_write_open_fd(struct archive *, int _fd); |
598 | __LA_DECL int archive_write_open_filename(struct archive *, const char *_file); | |
eaae26f3 | 599 | /* A deprecated synonym for archive_write_open_filename() */ |
911dc2bf TK |
600 | __LA_DECL int archive_write_open_file(struct archive *, const char *_file); |
601 | __LA_DECL int archive_write_open_FILE(struct archive *, FILE *); | |
eaae26f3 TK |
602 | /* _buffSize is the size of the buffer, _used refers to a variable that |
603 | * will be updated after each write into the buffer. */ | |
911dc2bf | 604 | __LA_DECL int archive_write_open_memory(struct archive *, |
eaae26f3 TK |
605 | void *_buffer, size_t _buffSize, size_t *_used); |
606 | ||
607 | /* | |
608 | * Note that the library will truncate writes beyond the size provided | |
609 | * to archive_write_header or pad if the provided data is short. | |
610 | */ | |
911dc2bf | 611 | __LA_DECL int archive_write_header(struct archive *, |
eaae26f3 | 612 | struct archive_entry *); |
911dc2bf | 613 | __LA_DECL __LA_SSIZE_T archive_write_data(struct archive *, |
fc95189e | 614 | const void *, size_t); |
fc95189e TK |
615 | |
616 | #if ARCHIVE_VERSION_NUMBER < 3000000 | |
617 | /* Libarchive 1.x and 2.x use off_t for the argument, but that's not | |
618 | * stable on Linux. */ | |
619 | __LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *, | |
620 | const void *, size_t, off_t); | |
621 | #else | |
622 | /* Libarchive 3.0 uses explicit int64_t to ensure consistent 64-bit support. */ | |
623 | __LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *, | |
624 | const void *, size_t, __LA_INT64_T); | |
eaae26f3 | 625 | #endif |
eaae26f3 TK |
626 | __LA_DECL int archive_write_finish_entry(struct archive *); |
627 | __LA_DECL int archive_write_close(struct archive *); | |
9890b31f TK |
628 | /* This can fail if the archive wasn't already closed, in which case |
629 | * archive_write_free() will implicitly call archive_write_close(). */ | |
630 | __LA_DECL int archive_write_free(struct archive *); | |
631 | #if ARCHIVE_VERSION_NUMBER < 4000000 | |
632 | /* Synonym for archive_write_free() for backwards compatibility. */ | |
fc95189e | 633 | __LA_DECL int archive_write_finish(struct archive *); |
9890b31f | 634 | #endif |
eaae26f3 | 635 | |
6943997e | 636 | /* |
bcbf7a2a TK |
637 | * Set write options. Note that there's really no reason to use |
638 | * anything but archive_write_set_options(). The others should probably | |
639 | * all be deprecated and eventually removed. | |
6943997e | 640 | */ |
bcbf7a2a TK |
641 | /* Apply option string to both the format and all filters. */ |
642 | __LA_DECL int archive_write_set_options(struct archive *_a, | |
643 | const char *s); | |
6943997e MN |
644 | /* Apply option string to the format only. */ |
645 | __LA_DECL int archive_write_set_format_options(struct archive *_a, | |
646 | const char *s); | |
bcbf7a2a TK |
647 | /* Apply option string to all matching filters. */ |
648 | __LA_DECL int archive_write_set_filter_options(struct archive *_a, | |
6943997e | 649 | const char *s); |
bcbf7a2a TK |
650 | #if ARCHIVE_VERSION_NUMBER < 4000000 |
651 | /* Deprecated synonym for archive_write_set_filter_options. */ | |
652 | __LA_DECL int archive_write_set_compressor_options(struct archive *_a, | |
6943997e | 653 | const char *s); |
bcbf7a2a | 654 | #endif |
6943997e | 655 | |
eaae26f3 | 656 | /*- |
2d892504 TK |
657 | * ARCHIVE_WRITE_DISK API |
658 | * | |
eaae26f3 TK |
659 | * To create objects on disk: |
660 | * 1) Ask archive_write_disk_new for a new archive_write_disk object. | |
2d892504 TK |
661 | * 2) Set any global properties. In particular, you probably |
662 | * want to set the options. | |
eaae26f3 TK |
663 | * 3) For each entry: |
664 | * - construct an appropriate struct archive_entry structure | |
665 | * - archive_write_header to create the file/dir/etc on disk | |
666 | * - archive_write_data to write the entry data | |
9890b31f | 667 | * 4) archive_write_free to cleanup the writer and release resources |
eaae26f3 TK |
668 | * |
669 | * In particular, you can use this in conjunction with archive_read() | |
670 | * to pull entries out of an archive and create them on disk. | |
671 | */ | |
672 | __LA_DECL struct archive *archive_write_disk_new(void); | |
673 | /* This file will not be overwritten. */ | |
73f39d90 | 674 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
eaae26f3 TK |
675 | __LA_DECL int archive_write_disk_set_skip_file(struct archive *, |
676 | dev_t, ino_t); | |
73f39d90 TK |
677 | #else |
678 | __LA_DECL int archive_write_disk_set_skip_file(struct archive *, | |
679 | __LA_INT64_T, __LA_INT64_T); | |
680 | #endif | |
2d892504 TK |
681 | /* Set flags to control how the next item gets created. |
682 | * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */ | |
eaae26f3 TK |
683 | __LA_DECL int archive_write_disk_set_options(struct archive *, |
684 | int flags); | |
685 | /* | |
686 | * The lookup functions are given uname/uid (or gname/gid) pairs and | |
687 | * return a uid (gid) suitable for this system. These are used for | |
688 | * restoring ownership and for setting ACLs. The default functions | |
689 | * are naive, they just return the uid/gid. These are small, so reasonable | |
690 | * for applications that don't need to preserve ownership; they | |
691 | * are probably also appropriate for applications that are doing | |
692 | * same-system backup and restore. | |
693 | */ | |
694 | /* | |
695 | * The "standard" lookup functions use common system calls to lookup | |
696 | * the uname/gname, falling back to the uid/gid if the names can't be | |
697 | * found. They cache lookups and are reasonably fast, but can be very | |
698 | * large, so they are not used unless you ask for them. In | |
699 | * particular, these match the specifications of POSIX "pax" and old | |
700 | * POSIX "tar". | |
701 | */ | |
702 | __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *); | |
703 | /* | |
704 | * If neither the default (naive) nor the standard (big) functions suit | |
705 | * your needs, you can write your own and register them. Be sure to | |
706 | * include a cleanup function if you have allocated private data. | |
707 | */ | |
73f39d90 | 708 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
eaae26f3 TK |
709 | __LA_DECL int archive_write_disk_set_group_lookup(struct archive *, |
710 | void * /* private_data */, | |
711 | __LA_GID_T (*)(void *, const char *, __LA_GID_T), | |
712 | void (* /* cleanup */)(void *)); | |
713 | __LA_DECL int archive_write_disk_set_user_lookup(struct archive *, | |
714 | void * /* private_data */, | |
715 | __LA_UID_T (*)(void *, const char *, __LA_UID_T), | |
716 | void (* /* cleanup */)(void *)); | |
73f39d90 TK |
717 | #else |
718 | __LA_DECL int archive_write_disk_set_group_lookup(struct archive *, | |
719 | void * /* private_data */, | |
720 | __LA_INT64_T (*)(void *, const char *, __LA_INT64_T), | |
721 | void (* /* cleanup */)(void *)); | |
722 | __LA_DECL int archive_write_disk_set_user_lookup(struct archive *, | |
723 | void * /* private_data */, | |
724 | __LA_INT64_T (*)(void *, const char *, __LA_INT64_T), | |
725 | void (* /* cleanup */)(void *)); | |
726 | #endif | |
eaae26f3 | 727 | |
aede8174 TK |
728 | /* |
729 | * ARCHIVE_READ_DISK API | |
a8ac0b18 TK |
730 | * |
731 | * This is still evolving and somewhat experimental. | |
aede8174 TK |
732 | */ |
733 | __LA_DECL struct archive *archive_read_disk_new(void); | |
a8ac0b18 TK |
734 | /* The names for symlink modes here correspond to an old BSD |
735 | * command-line argument convention: -L, -P, -H */ | |
736 | /* Follow all symlinks. */ | |
737 | __LA_DECL int archive_read_disk_set_symlink_logical(struct archive *); | |
738 | /* Follow no symlinks. */ | |
739 | __LA_DECL int archive_read_disk_set_symlink_physical(struct archive *); | |
740 | /* Follow symlink initially, then not. */ | |
741 | __LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *); | |
742 | /* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */ | |
743 | __LA_DECL int archive_read_disk_entry_from_file(struct archive *, | |
744 | struct archive_entry *, int /* fd */, const struct stat *); | |
745 | /* Look up gname for gid or uname for uid. */ | |
746 | /* Default implementations are very, very stupid. */ | |
73f39d90 | 747 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
aede8174 TK |
748 | __LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_GID_T); |
749 | __LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_UID_T); | |
73f39d90 TK |
750 | #else |
751 | __LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T); | |
752 | __LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T); | |
753 | #endif | |
a8ac0b18 TK |
754 | /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the |
755 | * results for performance. */ | |
756 | __LA_DECL int archive_read_disk_set_standard_lookup(struct archive *); | |
757 | /* You can install your own lookups if you like. */ | |
73f39d90 | 758 | #if ARCHIVE_VERSION_NUMBER < 3000000 |
aede8174 TK |
759 | __LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, |
760 | void * /* private_data */, | |
761 | const char *(* /* lookup_fn */)(void *, __LA_GID_T), | |
762 | void (* /* cleanup_fn */)(void *)); | |
763 | __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, | |
764 | void * /* private_data */, | |
765 | const char *(* /* lookup_fn */)(void *, __LA_UID_T), | |
766 | void (* /* cleanup_fn */)(void *)); | |
73f39d90 TK |
767 | #else |
768 | __LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, | |
769 | void * /* private_data */, | |
770 | const char *(* /* lookup_fn */)(void *, __LA_INT64_T), | |
771 | void (* /* cleanup_fn */)(void *)); | |
772 | __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, | |
773 | void * /* private_data */, | |
774 | const char *(* /* lookup_fn */)(void *, __LA_INT64_T), | |
775 | void (* /* cleanup_fn */)(void *)); | |
776 | #endif | |
aede8174 | 777 | |
eaae26f3 TK |
778 | /* |
779 | * Accessor functions to read/set various information in | |
780 | * the struct archive object: | |
781 | */ | |
911dc2bf TK |
782 | |
783 | /* Number of filters in the current filter pipeline. */ | |
784 | /* Filter #0 is the one closest to the format, -1 is a synonym for the | |
785 | * last filter, which is always the pseudo-filter that wraps the | |
786 | * client callbacks. */ | |
787 | __LA_DECL int archive_filter_count(struct archive *); | |
788 | __LA_DECL __LA_INT64_T archive_filter_bytes(struct archive *, int); | |
789 | __LA_DECL int archive_filter_code(struct archive *, int); | |
790 | __LA_DECL const char * archive_filter_name(struct archive *, int); | |
791 | ||
792 | #if ARCHIVE_VERSION_NUMBER < 4000000 | |
793 | /* These don't properly handle multiple filters, so are deprecated and | |
794 | * will eventually be removed. */ | |
795 | /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */ | |
07be984c | 796 | __LA_DECL __LA_INT64_T archive_position_compressed(struct archive *); |
911dc2bf | 797 | /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */ |
07be984c | 798 | __LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *); |
911dc2bf | 799 | /* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */ |
eaae26f3 | 800 | __LA_DECL const char *archive_compression_name(struct archive *); |
911dc2bf | 801 | /* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */ |
eaae26f3 | 802 | __LA_DECL int archive_compression(struct archive *); |
911dc2bf TK |
803 | #endif |
804 | ||
eaae26f3 TK |
805 | __LA_DECL int archive_errno(struct archive *); |
806 | __LA_DECL const char *archive_error_string(struct archive *); | |
807 | __LA_DECL const char *archive_format_name(struct archive *); | |
808 | __LA_DECL int archive_format(struct archive *); | |
809 | __LA_DECL void archive_clear_error(struct archive *); | |
810 | __LA_DECL void archive_set_error(struct archive *, int _err, | |
ac8ba3fa | 811 | const char *fmt, ...) __LA_PRINTF(3, 4); |
eaae26f3 TK |
812 | __LA_DECL void archive_copy_error(struct archive *dest, |
813 | struct archive *src); | |
ab649de7 | 814 | __LA_DECL int archive_file_count(struct archive *); |
eaae26f3 TK |
815 | |
816 | #ifdef __cplusplus | |
817 | } | |
818 | #endif | |
819 | ||
1ca7365e | 820 | /* These are meaningless outside of this header. */ |
eaae26f3 | 821 | #undef __LA_DECL |
fa9a301c | 822 | #undef __LA_GID_T |
fa9a301c | 823 | #undef __LA_UID_T |
eaae26f3 | 824 | |
1ca7365e TK |
825 | /* These need to remain defined because they're used in the |
826 | * callback type definitions. XXX Fix this. This is ugly. XXX */ | |
827 | /* #undef __LA_INT64_T */ | |
828 | /* #undef __LA_SSIZE_T */ | |
829 | ||
eaae26f3 | 830 | #endif /* !ARCHIVE_H_INCLUDED */ |