38
42
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
39
# define __LA_STDINT_H <stdint.h>
40
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(__osf__)
41
# define __LA_STDINT_H <inttypes.h>
44
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
45
# include <inttypes.h>
45
#include <sys/types.h> /* Linux requires this for off_t */
47
# include __LA_STDINT_H /* int64_t, etc. */
48
/* Borland symbols are case-insensitive. This workaround only works
49
within CMake because we do not mix compilers. */
50
#if defined(__BORLANDC__)
51
# define archive_read_open_FILE archive_read_open_FILE_
52
# define archive_write_open_FILE archive_write_open_FILE_
49
#include <stdio.h> /* For FILE * */
51
55
/* Get appropriate definitions of standard POSIX-style types. */
52
56
/* These should match the types used in 'struct stat' */
53
57
#if defined(_WIN32) && !defined(__CYGWIN__)
54
#define __LA_INT64_T __int64
58
# define __LA_INT64_T __int64
55
59
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
56
# define __LA_SSIZE_T ssize_t
60
# define __LA_SSIZE_T ssize_t
57
61
# elif defined(_WIN64)
58
# define __LA_SSIZE_T __int64
62
# define __LA_SSIZE_T __int64
60
# define __LA_SSIZE_T long
64
# define __LA_SSIZE_T long
62
66
# if defined(__BORLANDC__)
63
# define __LA_UID_T uid_t
64
# define __LA_GID_T gid_t
66
# define __LA_UID_T short
67
# define __LA_GID_T short
70
#include <unistd.h> /* ssize_t, uid_t, and gid_t */
72
# define __LA_INT64_T long long
74
# define __LA_INT64_T int64_t
76
#define __LA_SSIZE_T ssize_t
77
#define __LA_UID_T uid_t
78
#define __LA_GID_T gid_t
67
# define __LA_UID_T uid_t
68
# define __LA_GID_T gid_t
70
# define __LA_UID_T short
71
# define __LA_GID_T short
74
# include <unistd.h> /* ssize_t, uid_t, and gid_t */
75
# if defined(_SCO_DS) || defined(__osf__)
76
# define __LA_INT64_T long long
78
# define __LA_INT64_T int64_t
80
# define __LA_SSIZE_T ssize_t
81
# define __LA_UID_T uid_t
82
# define __LA_GID_T gid_t
120
131
* easy to compare versions at build time: for version a.b.c, the
121
132
* version number is printf("%d%03d%03d",a,b,c). For example, if you
122
133
* know your application requires version 2.12.108 or later, you can
123
* assert that ARCHIVE_VERSION >= 2012108.
125
* This single-number format was introduced with libarchive 1.9.0 in
126
* the libarchive 1.x family and libarchive 2.2.4 in the libarchive
127
* 2.x family. The following may be useful if you really want to do
128
* feature detection for earlier libarchive versions (which defined
129
* ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead):
131
* #ifndef ARCHIVE_VERSION_NUMBER
132
* #define ARCHIVE_VERSION_NUMBER \
133
* (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
134
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
136
#define ARCHIVE_VERSION_NUMBER 2007900
137
__LA_DECL int archive_version_number(void);
136
/* Note: Compiler will complain if this does not match archive_entry.h! */
137
#define ARCHIVE_VERSION_NUMBER 3000002
138
__LA_DECL int archive_version_number(void);
140
141
* Textual name/version of the library, useful for version displays.
142
#define ARCHIVE_VERSION_STRING "libarchive 2.7.900a"
143
__LA_DECL const char * archive_version_string(void);
145
#if ARCHIVE_VERSION_NUMBER < 3000000
147
* Deprecated; these are older names that will be removed in favor of
148
* the simpler definitions above.
150
#define ARCHIVE_VERSION_STAMP ARCHIVE_VERSION_NUMBER
151
__LA_DECL int archive_version_stamp(void);
152
#define ARCHIVE_LIBRARY_VERSION ARCHIVE_VERSION_STRING
153
__LA_DECL const char * archive_version(void);
154
#define ARCHIVE_API_VERSION (ARCHIVE_VERSION_NUMBER / 1000000)
155
__LA_DECL int archive_api_version(void);
156
#define ARCHIVE_API_FEATURE ((ARCHIVE_VERSION_NUMBER / 1000) % 1000)
157
__LA_DECL int archive_api_feature(void);
160
#if ARCHIVE_VERSION_NUMBER < 3000000
161
/* This should never have been here in the first place. */
162
/* Legacy of old tar assumptions, will be removed in libarchive 3.0. */
163
#define ARCHIVE_BYTES_PER_RECORD 512
164
#define ARCHIVE_DEFAULT_BYTES_PER_BLOCK 10240
143
#define ARCHIVE_VERSION_STRING "libarchive 3.0.2"
144
__LA_DECL const char * archive_version_string(void);
167
146
/* Declare our basic types. */
206
185
/* Returns pointer and size of next block of data from archive. */
207
typedef __LA_SSIZE_T archive_read_callback(struct archive *,
208
void *_client_data, const void **_buffer);
210
/* Skips at most request bytes from archive and returns the skipped amount */
211
#if ARCHIVE_VERSION_NUMBER < 2000000
212
/* Libarchive 1.0 used ssize_t for the return, which is only 32 bits
213
* on most 32-bit platforms; not large enough. */
214
typedef __LA_SSIZE_T archive_skip_callback(struct archive *,
215
void *_client_data, size_t request);
216
#elif ARCHIVE_VERSION_NUMBER < 3000000
217
/* Libarchive 2.0 used off_t here, but that is a bad idea on Linux and a
218
* few other platforms where off_t varies with build settings. */
219
typedef off_t archive_skip_callback(struct archive *,
220
void *_client_data, off_t request);
222
/* Libarchive 3.0 uses int64_t here, which is actually guaranteed to be
223
* 64 bits on every platform. */
224
typedef __LA_INT64_T archive_skip_callback(struct archive *,
225
void *_client_data, __LA_INT64_T request);
186
typedef __LA_SSIZE_T archive_read_callback(struct archive *,
187
void *_client_data, const void **_buffer);
189
/* Skips at most request bytes from archive and returns the skipped amount.
190
* This may skip fewer bytes than requested; it may even skip zero bytes.
191
* If you do skip fewer bytes than requested, libarchive will invoke your
192
* read callback and discard data as necessary to make up the full skip.
194
typedef __LA_INT64_T archive_skip_callback(struct archive *,
195
void *_client_data, __LA_INT64_T request);
197
/* Seeks to specified location in the file and returns the position.
198
* Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
199
* Return ARCHIVE_FATAL if the seek fails for any reason.
201
typedef __LA_INT64_T archive_seek_callback(struct archive *,
202
void *_client_data, __LA_INT64_T offset, int whence);
228
204
/* Returns size actually written, zero on EOF, -1 on error. */
229
typedef __LA_SSIZE_T archive_write_callback(struct archive *,
231
const void *_buffer, size_t _length);
233
#if ARCHIVE_VERSION_NUMBER < 3000000
234
/* Open callback is actually never needed; remove it in libarchive 3.0. */
235
typedef int archive_open_callback(struct archive *, void *_client_data);
205
typedef __LA_SSIZE_T archive_write_callback(struct archive *,
207
const void *_buffer, size_t _length);
209
typedef int archive_open_callback(struct archive *, void *_client_data);
211
typedef int archive_close_callback(struct archive *, void *_client_data);
214
* Codes to identify various stream filters.
216
#define ARCHIVE_FILTER_NONE 0
217
#define ARCHIVE_FILTER_GZIP 1
218
#define ARCHIVE_FILTER_BZIP2 2
219
#define ARCHIVE_FILTER_COMPRESS 3
220
#define ARCHIVE_FILTER_PROGRAM 4
221
#define ARCHIVE_FILTER_LZMA 5
222
#define ARCHIVE_FILTER_XZ 6
223
#define ARCHIVE_FILTER_UU 7
224
#define ARCHIVE_FILTER_RPM 8
225
#define ARCHIVE_FILTER_LZIP 9
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
typedef int archive_close_callback(struct archive *, void *_client_data);
241
* Codes for archive_compression.
243
#define ARCHIVE_COMPRESSION_NONE 0
244
#define ARCHIVE_COMPRESSION_GZIP 1
245
#define ARCHIVE_COMPRESSION_BZIP2 2
246
#define ARCHIVE_COMPRESSION_COMPRESS 3
247
#define ARCHIVE_COMPRESSION_PROGRAM 4
248
#define ARCHIVE_COMPRESSION_LZMA 5
249
#define ARCHIVE_COMPRESSION_XZ 6
252
241
* Codes returned by archive_format.
260
249
* will change the format code to indicate the extended format that
261
250
* was used). In other cases, it's because different tools have
262
251
* modified the archive and so different parts of the archive
263
* actually have slightly different formts. (Both tar and cpio store
252
* actually have slightly different formats. (Both tar and cpio store
264
253
* format codes in each entry, so it is quite possible for each
265
254
* entry to be in a different format.)
267
#define ARCHIVE_FORMAT_BASE_MASK 0xff0000
268
#define ARCHIVE_FORMAT_CPIO 0x10000
269
#define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1)
270
#define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2)
271
#define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3)
272
#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4)
273
#define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5)
274
#define ARCHIVE_FORMAT_SHAR 0x20000
275
#define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1)
276
#define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2)
277
#define ARCHIVE_FORMAT_TAR 0x30000
278
#define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1)
279
#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2)
280
#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3)
281
#define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4)
282
#define ARCHIVE_FORMAT_ISO9660 0x40000
283
#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1)
284
#define ARCHIVE_FORMAT_ZIP 0x50000
285
#define ARCHIVE_FORMAT_EMPTY 0x60000
286
#define ARCHIVE_FORMAT_AR 0x70000
287
#define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1)
288
#define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2)
289
#define ARCHIVE_FORMAT_MTREE 0x80000
290
#define ARCHIVE_FORMAT_RAW 0x90000
256
#define ARCHIVE_FORMAT_BASE_MASK 0xff0000
257
#define ARCHIVE_FORMAT_CPIO 0x10000
258
#define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1)
259
#define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2)
260
#define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3)
261
#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4)
262
#define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5)
263
#define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6)
264
#define ARCHIVE_FORMAT_SHAR 0x20000
265
#define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1)
266
#define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2)
267
#define ARCHIVE_FORMAT_TAR 0x30000
268
#define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1)
269
#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2)
270
#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3)
271
#define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4)
272
#define ARCHIVE_FORMAT_ISO9660 0x40000
273
#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1)
274
#define ARCHIVE_FORMAT_ZIP 0x50000
275
#define ARCHIVE_FORMAT_EMPTY 0x60000
276
#define ARCHIVE_FORMAT_AR 0x70000
277
#define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1)
278
#define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2)
279
#define ARCHIVE_FORMAT_MTREE 0x80000
280
#define ARCHIVE_FORMAT_RAW 0x90000
281
#define ARCHIVE_FORMAT_XAR 0xA0000
282
#define ARCHIVE_FORMAT_LHA 0xB0000
283
#define ARCHIVE_FORMAT_CAB 0xC0000
284
#define ARCHIVE_FORMAT_RAR 0xD0000
285
#define ARCHIVE_FORMAT_7ZIP 0xE0000
293
288
* Basic outline for reading an archive:
310
305
* support_compression_bzip2(). The "all" functions provide the
311
306
* obvious shorthand.
313
__LA_DECL int archive_read_support_compression_all(struct archive *);
314
__LA_DECL int archive_read_support_compression_bzip2(struct archive *);
315
__LA_DECL int archive_read_support_compression_compress(struct archive *);
316
__LA_DECL int archive_read_support_compression_gzip(struct archive *);
317
__LA_DECL int archive_read_support_compression_lzma(struct archive *);
318
__LA_DECL int archive_read_support_compression_none(struct archive *);
319
__LA_DECL int archive_read_support_compression_program(struct archive *,
320
const char *command);
321
__LA_DECL int archive_read_support_compression_program_signature
322
(struct archive *, const char *,
323
const void * /* match */, size_t);
325
__LA_DECL int archive_read_support_compression_xz(struct archive *);
327
__LA_DECL int archive_read_support_format_all(struct archive *);
328
__LA_DECL int archive_read_support_format_ar(struct archive *);
329
__LA_DECL int archive_read_support_format_cpio(struct archive *);
330
__LA_DECL int archive_read_support_format_empty(struct archive *);
331
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
332
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
333
__LA_DECL int archive_read_support_format_mtree(struct archive *);
334
__LA_DECL int archive_read_support_format_raw(struct archive *);
335
__LA_DECL int archive_read_support_format_tar(struct archive *);
336
__LA_DECL int archive_read_support_format_zip(struct archive *);
339
/* Open the archive using callbacks for archive I/O. */
340
__LA_DECL int archive_read_open(struct archive *, void *_client_data,
341
archive_open_callback *, archive_read_callback *,
342
archive_close_callback *);
343
__LA_DECL int archive_read_open2(struct archive *, void *_client_data,
344
archive_open_callback *, archive_read_callback *,
345
archive_skip_callback *, archive_close_callback *);
309
#if ARCHIVE_VERSION_NUMBER < 4000000
310
__LA_DECL int archive_read_support_compression_all(struct archive *);
311
__LA_DECL int archive_read_support_compression_bzip2(struct archive *);
312
__LA_DECL int archive_read_support_compression_compress(struct archive *);
313
__LA_DECL int archive_read_support_compression_gzip(struct archive *);
314
__LA_DECL int archive_read_support_compression_lzip(struct archive *);
315
__LA_DECL int archive_read_support_compression_lzma(struct archive *);
316
__LA_DECL int archive_read_support_compression_none(struct archive *);
317
__LA_DECL int archive_read_support_compression_program(struct archive *,
318
const char *command);
319
__LA_DECL int archive_read_support_compression_program_signature
320
(struct archive *, const char *,
321
const void * /* match */, size_t);
323
__LA_DECL int archive_read_support_compression_rpm(struct archive *);
324
__LA_DECL int archive_read_support_compression_uu(struct archive *);
325
__LA_DECL int archive_read_support_compression_xz(struct archive *);
328
__LA_DECL int archive_read_support_filter_all(struct archive *);
329
__LA_DECL int archive_read_support_filter_bzip2(struct archive *);
330
__LA_DECL int archive_read_support_filter_compress(struct archive *);
331
__LA_DECL int archive_read_support_filter_gzip(struct archive *);
332
__LA_DECL int archive_read_support_filter_lzip(struct archive *);
333
__LA_DECL int archive_read_support_filter_lzma(struct archive *);
334
__LA_DECL int archive_read_support_filter_none(struct archive *);
335
__LA_DECL int archive_read_support_filter_program(struct archive *,
336
const char *command);
337
__LA_DECL int archive_read_support_filter_program_signature
338
(struct archive *, const char *,
339
const void * /* match */, size_t);
341
__LA_DECL int archive_read_support_filter_rpm(struct archive *);
342
__LA_DECL int archive_read_support_filter_uu(struct archive *);
343
__LA_DECL int archive_read_support_filter_xz(struct archive *);
345
__LA_DECL int archive_read_support_format_7zip(struct archive *);
346
__LA_DECL int archive_read_support_format_all(struct archive *);
347
__LA_DECL int archive_read_support_format_ar(struct archive *);
348
__LA_DECL int archive_read_support_format_by_code(struct archive *, int);
349
__LA_DECL int archive_read_support_format_cab(struct archive *);
350
__LA_DECL int archive_read_support_format_cpio(struct archive *);
351
__LA_DECL int archive_read_support_format_empty(struct archive *);
352
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
353
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
354
__LA_DECL int archive_read_support_format_lha(struct archive *);
355
__LA_DECL int archive_read_support_format_mtree(struct archive *);
356
__LA_DECL int archive_read_support_format_rar(struct archive *);
357
__LA_DECL int archive_read_support_format_raw(struct archive *);
358
__LA_DECL int archive_read_support_format_tar(struct archive *);
359
__LA_DECL int archive_read_support_format_xar(struct archive *);
360
__LA_DECL int archive_read_support_format_zip(struct archive *);
362
/* Set various callbacks. */
363
__LA_DECL int archive_read_set_open_callback(struct archive *,
364
archive_open_callback *);
365
__LA_DECL int archive_read_set_read_callback(struct archive *,
366
archive_read_callback *);
367
__LA_DECL int archive_read_set_seek_callback(struct archive *,
368
archive_seek_callback *);
369
__LA_DECL int archive_read_set_skip_callback(struct archive *,
370
archive_skip_callback *);
371
__LA_DECL int archive_read_set_close_callback(struct archive *,
372
archive_close_callback *);
373
/* The callback data is provided to all of the callbacks above. */
374
__LA_DECL int archive_read_set_callback_data(struct archive *, void *);
375
/* Opening freezes the callbacks. */
376
__LA_DECL int archive_read_open1(struct archive *);
378
/* Convenience wrappers around the above. */
379
__LA_DECL int archive_read_open(struct archive *, void *_client_data,
380
archive_open_callback *, archive_read_callback *,
381
archive_close_callback *);
382
__LA_DECL int archive_read_open2(struct archive *, void *_client_data,
383
archive_open_callback *, archive_read_callback *,
384
archive_skip_callback *, archive_close_callback *);
348
387
* A variety of shortcuts that invoke archive_read_open() with
350
389
* accept a block size handle tape blocking correctly.
352
391
/* Use this if you know the filename. Note: NULL indicates stdin. */
353
__LA_DECL int archive_read_open_filename(struct archive *,
354
const char *_filename, size_t _block_size);
392
__LA_DECL int archive_read_open_filename(struct archive *,
393
const char *_filename, size_t _block_size);
394
__LA_DECL int archive_read_open_filename_w(struct archive *,
395
const wchar_t *_filename, size_t _block_size);
355
396
/* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
356
__LA_DECL int archive_read_open_file(struct archive *,
357
const char *_filename, size_t _block_size);
397
__LA_DECL int archive_read_open_file(struct archive *,
398
const char *_filename, size_t _block_size);
358
399
/* Read an archive that's stored in memory. */
359
__LA_DECL int archive_read_open_memory(struct archive *,
360
void * buff, size_t size);
400
__LA_DECL int archive_read_open_memory(struct archive *,
401
void * buff, size_t size);
361
402
/* A more involved version that is only used for internal testing. */
362
__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff,
363
size_t size, size_t read_size);
403
__LA_DECL int archive_read_open_memory2(struct archive *a, void *buff,
404
size_t size, size_t read_size);
364
405
/* Read an archive that's already open, using the file descriptor. */
365
__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
406
__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
367
408
/* Read an archive that's already open, using a FILE *. */
368
409
/* Note: DO NOT use this with tape drives. */
369
__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
410
__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
371
412
/* Parses and returns next entry header. */
372
__LA_DECL int archive_read_next_header(struct archive *,
373
struct archive_entry **);
413
__LA_DECL int archive_read_next_header(struct archive *,
414
struct archive_entry **);
375
416
/* Parses and returns next entry header using the archive_entry passed in */
376
__LA_DECL int archive_read_next_header2(struct archive *,
377
struct archive_entry *);
417
__LA_DECL int archive_read_next_header2(struct archive *,
418
struct archive_entry *);
380
421
* Retrieve the byte offset in UNCOMPRESSED data where last-read
381
422
* header started.
383
__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
424
__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
385
426
/* Read data from the body of an entry. Similar to read(2). */
386
__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
427
__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
390
431
* A zero-copy version of archive_read_data that also exposes the file offset
442
481
/* The "flags" argument selects optional behavior, 'OR' the flags you want. */
444
483
/* Default: Do not try to set owner/group. */
445
#define ARCHIVE_EXTRACT_OWNER (0x0001)
484
#define ARCHIVE_EXTRACT_OWNER (0x0001)
446
485
/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
447
#define ARCHIVE_EXTRACT_PERM (0x0002)
486
#define ARCHIVE_EXTRACT_PERM (0x0002)
448
487
/* Default: Do not restore mtime/atime. */
449
#define ARCHIVE_EXTRACT_TIME (0x0004)
488
#define ARCHIVE_EXTRACT_TIME (0x0004)
450
489
/* Default: Replace existing files. */
451
#define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008)
490
#define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008)
452
491
/* Default: Try create first, unlink only if create fails with EEXIST. */
453
#define ARCHIVE_EXTRACT_UNLINK (0x0010)
492
#define ARCHIVE_EXTRACT_UNLINK (0x0010)
454
493
/* Default: Do not restore ACLs. */
455
#define ARCHIVE_EXTRACT_ACL (0x0020)
494
#define ARCHIVE_EXTRACT_ACL (0x0020)
456
495
/* Default: Do not restore fflags. */
457
#define ARCHIVE_EXTRACT_FFLAGS (0x0040)
496
#define ARCHIVE_EXTRACT_FFLAGS (0x0040)
458
497
/* Default: Do not restore xattrs. */
459
#define ARCHIVE_EXTRACT_XATTR (0x0080)
498
#define ARCHIVE_EXTRACT_XATTR (0x0080)
460
499
/* Default: Do not try to guard against extracts redirected by symlinks. */
461
500
/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
462
#define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100)
501
#define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100)
463
502
/* Default: Do not reject entries with '..' as path elements. */
464
#define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200)
503
#define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200)
465
504
/* Default: Create parent directories as needed. */
466
#define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400)
505
#define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400)
467
506
/* Default: Overwrite files, even if one on disk is newer. */
468
#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800)
507
#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800)
469
508
/* Detect blocks of 0 and write holes instead. */
470
#define ARCHIVE_EXTRACT_SPARSE (0x1000)
509
#define ARCHIVE_EXTRACT_SPARSE (0x1000)
510
/* Default: Do not restore Mac extended metadata. */
511
/* This has no effect except on Mac OS. */
512
#define ARCHIVE_EXTRACT_MAC_METADATA (0x2000)
472
__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
474
__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
475
struct archive * /* dest */);
476
__LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
477
void (*_progress_func)(void *), void *_user_data);
514
__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
516
__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
517
struct archive * /* dest */);
518
__LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
519
void (*_progress_func)(void *), void *_user_data);
479
521
/* Record the dev/ino of a file that will not be written. This is
480
522
* generally set to the dev/ino of the archive being read. */
481
__LA_DECL void archive_read_extract_set_skip_file(struct archive *,
523
__LA_DECL void archive_read_extract_set_skip_file(struct archive *,
524
__LA_INT64_T, __LA_INT64_T);
484
526
/* Close the file and release most resources. */
485
__LA_DECL int archive_read_close(struct archive *);
527
__LA_DECL int archive_read_close(struct archive *);
486
528
/* Release all resources and destroy the object. */
487
/* Note that archive_read_finish will call archive_read_close for you. */
488
#if ARCHIVE_VERSION_NUMBER < 2000000
489
/* Erroneously declared to return void in libarchive 1.x */
490
__LA_DECL void archive_read_finish(struct archive *);
492
__LA_DECL int archive_read_finish(struct archive *);
529
/* Note that archive_read_free will call archive_read_close for you. */
530
__LA_DECL int archive_read_free(struct archive *);
531
#if ARCHIVE_VERSION_NUMBER < 4000000
532
/* Synonym for archive_read_free() for backwards compatibility. */
533
__LA_DECL int archive_read_finish(struct archive *);
496
537
* To create an archive:
497
* 1) Ask archive_write_new for a archive writer object.
538
* 1) Ask archive_write_new for an archive writer object.
498
539
* 2) Set any global properties. In particular, you should set
499
540
* the compression and format to use.
500
541
* 3) Call archive_write_open to open the file (most people
505
546
* - archive_write_header to write the header
506
547
* - archive_write_data to write the entry data
507
548
* 5) archive_write_close to close the output
508
* 6) archive_write_finish to cleanup the writer and release resources
549
* 6) archive_write_free to cleanup the writer and release resources
510
__LA_DECL struct archive *archive_write_new(void);
511
__LA_DECL int archive_write_set_bytes_per_block(struct archive *,
512
int bytes_per_block);
513
__LA_DECL int archive_write_get_bytes_per_block(struct archive *);
551
__LA_DECL struct archive *archive_write_new(void);
552
__LA_DECL int archive_write_set_bytes_per_block(struct archive *,
553
int bytes_per_block);
554
__LA_DECL int archive_write_get_bytes_per_block(struct archive *);
514
555
/* XXX This is badly misnamed; suggestions appreciated. XXX */
515
__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
516
int bytes_in_last_block);
517
__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
556
__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
557
int bytes_in_last_block);
558
__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
519
560
/* The dev/ino of a file that won't be archived. This is used
520
561
* to avoid recursively adding an archive to itself. */
521
__LA_DECL int archive_write_set_skip_file(struct archive *, dev_t, ino_t);
523
__LA_DECL int archive_write_set_compression_bzip2(struct archive *);
524
__LA_DECL int archive_write_set_compression_compress(struct archive *);
525
__LA_DECL int archive_write_set_compression_gzip(struct archive *);
526
__LA_DECL int archive_write_set_compression_lzma(struct archive *);
527
__LA_DECL int archive_write_set_compression_none(struct archive *);
528
__LA_DECL int archive_write_set_compression_program(struct archive *,
530
__LA_DECL int archive_write_set_compression_xz(struct archive *);
562
__LA_DECL int archive_write_set_skip_file(struct archive *,
563
__LA_INT64_T, __LA_INT64_T);
565
#if ARCHIVE_VERSION_NUMBER < 4000000
566
__LA_DECL int archive_write_set_compression_bzip2(struct archive *);
567
__LA_DECL int archive_write_set_compression_compress(struct archive *);
568
__LA_DECL int archive_write_set_compression_gzip(struct archive *);
569
__LA_DECL int archive_write_set_compression_lzip(struct archive *);
570
__LA_DECL int archive_write_set_compression_lzma(struct archive *);
571
__LA_DECL int archive_write_set_compression_none(struct archive *);
572
__LA_DECL int archive_write_set_compression_program(struct archive *,
574
__LA_DECL int archive_write_set_compression_xz(struct archive *);
577
__LA_DECL int archive_write_add_filter_bzip2(struct archive *);
578
__LA_DECL int archive_write_add_filter_compress(struct archive *);
579
__LA_DECL int archive_write_add_filter_gzip(struct archive *);
580
__LA_DECL int archive_write_add_filter_lzip(struct archive *);
581
__LA_DECL int archive_write_add_filter_lzma(struct archive *);
582
__LA_DECL int archive_write_add_filter_none(struct archive *);
583
__LA_DECL int archive_write_add_filter_program(struct archive *,
585
__LA_DECL int archive_write_add_filter_xz(struct archive *);
531
588
/* A convenience function to set the format based on the code or name. */
532
__LA_DECL int archive_write_set_format(struct archive *, int format_code);
533
__LA_DECL int archive_write_set_format_by_name(struct archive *,
589
__LA_DECL int archive_write_set_format(struct archive *, int format_code);
590
__LA_DECL int archive_write_set_format_by_name(struct archive *,
535
592
/* To minimize link pollution, use one or more of the following. */
536
__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
537
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
538
__LA_DECL int archive_write_set_format_cpio(struct archive *);
539
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
540
__LA_DECL int archive_write_set_format_mtree(struct archive *);
593
__LA_DECL int archive_write_set_format_7zip(struct archive *);
594
__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
595
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
596
__LA_DECL int archive_write_set_format_cpio(struct archive *);
597
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
598
__LA_DECL int archive_write_set_format_gnutar(struct archive *);
599
__LA_DECL int archive_write_set_format_iso9660(struct archive *);
600
__LA_DECL int archive_write_set_format_mtree(struct archive *);
541
601
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
542
__LA_DECL int archive_write_set_format_pax(struct archive *);
543
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
544
__LA_DECL int archive_write_set_format_shar(struct archive *);
545
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
546
__LA_DECL int archive_write_set_format_ustar(struct archive *);
547
__LA_DECL int archive_write_set_format_zip(struct archive *);
548
__LA_DECL int archive_write_open(struct archive *, void *,
549
archive_open_callback *, archive_write_callback *,
550
archive_close_callback *);
551
__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
552
__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
602
__LA_DECL int archive_write_set_format_pax(struct archive *);
603
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
604
__LA_DECL int archive_write_set_format_shar(struct archive *);
605
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
606
__LA_DECL int archive_write_set_format_ustar(struct archive *);
607
__LA_DECL int archive_write_set_format_xar(struct archive *);
608
__LA_DECL int archive_write_set_format_zip(struct archive *);
609
__LA_DECL int archive_write_open(struct archive *, void *,
610
archive_open_callback *, archive_write_callback *,
611
archive_close_callback *);
612
__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
613
__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
614
__LA_DECL int archive_write_open_filename_w(struct archive *,
615
const wchar_t *_file);
553
616
/* A deprecated synonym for archive_write_open_filename() */
554
__LA_DECL int archive_write_open_file(struct archive *, const char *_file);
555
__LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
617
__LA_DECL int archive_write_open_file(struct archive *, const char *_file);
618
__LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
556
619
/* _buffSize is the size of the buffer, _used refers to a variable that
557
620
* will be updated after each write into the buffer. */
558
__LA_DECL int archive_write_open_memory(struct archive *,
559
void *_buffer, size_t _buffSize, size_t *_used);
621
__LA_DECL int archive_write_open_memory(struct archive *,
622
void *_buffer, size_t _buffSize, size_t *_used);
562
625
* Note that the library will truncate writes beyond the size provided
563
626
* to archive_write_header or pad if the provided data is short.
565
__LA_DECL int archive_write_header(struct archive *,
566
struct archive_entry *);
567
#if ARCHIVE_VERSION_NUMBER < 2000000
568
/* This was erroneously declared to return "int" in libarchive 1.x. */
569
__LA_DECL int archive_write_data(struct archive *,
570
const void *, size_t);
572
/* Libarchive 2.0 and later return ssize_t here. */
573
__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *,
574
const void *, size_t);
577
#if ARCHIVE_VERSION_NUMBER < 3000000
578
/* Libarchive 1.x and 2.x use off_t for the argument, but that's not
579
* stable on Linux. */
580
__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
581
const void *, size_t, off_t);
583
/* Libarchive 3.0 uses explicit int64_t to ensure consistent 64-bit support. */
584
__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
585
const void *, size_t, __LA_INT64_T);
587
__LA_DECL int archive_write_finish_entry(struct archive *);
588
__LA_DECL int archive_write_close(struct archive *);
589
#if ARCHIVE_VERSION_NUMBER < 2000000
590
/* Return value was incorrect in libarchive 1.x. */
591
__LA_DECL void archive_write_finish(struct archive *);
593
/* Libarchive 2.x and later returns an error if this fails. */
594
/* It can fail if the archive wasn't already closed, in which case
595
* archive_write_finish() will implicitly call archive_write_close(). */
596
__LA_DECL int archive_write_finish(struct archive *);
628
__LA_DECL int archive_write_header(struct archive *,
629
struct archive_entry *);
630
__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *,
631
const void *, size_t);
633
/* This interface is currently only available for archive_write_disk handles. */
634
__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
635
const void *, size_t, __LA_INT64_T);
637
__LA_DECL int archive_write_finish_entry(struct archive *);
638
__LA_DECL int archive_write_close(struct archive *);
639
/* This can fail if the archive wasn't already closed, in which case
640
* archive_write_free() will implicitly call archive_write_close(). */
641
__LA_DECL int archive_write_free(struct archive *);
642
#if ARCHIVE_VERSION_NUMBER < 4000000
643
/* Synonym for archive_write_free() for backwards compatibility. */
644
__LA_DECL int archive_write_finish(struct archive *);
600
648
* Set write options.
602
/* Apply option string to the format only. */
603
__LA_DECL int archive_write_set_format_options(struct archive *_a,
605
/* Apply option string to the compressor only. */
606
__LA_DECL int archive_write_set_compressor_options(struct archive *_a,
608
/* Apply option string to both the format and the compressor. */
609
__LA_DECL int archive_write_set_options(struct archive *_a,
650
/* Apply option to the format only. */
651
__LA_DECL int archive_write_set_format_option(struct archive *_a,
652
const char *m, const char *o,
654
/* Apply option to the filter only. */
655
__LA_DECL int archive_write_set_filter_option(struct archive *_a,
656
const char *m, const char *o,
658
/* Apply option to both the format and the filter. */
659
__LA_DECL int archive_write_set_option(struct archive *_a,
660
const char *m, const char *o,
662
/* Apply option string to both the format and the filter. */
663
__LA_DECL int archive_write_set_options(struct archive *_a,
614
667
* ARCHIVE_WRITE_DISK API
651
704
* particular, these match the specifications of POSIX "pax" and old
654
__LA_DECL int archive_write_disk_set_standard_lookup(struct archive *);
707
__LA_DECL int archive_write_disk_set_standard_lookup(struct archive *);
656
709
* If neither the default (naive) nor the standard (big) functions suit
657
710
* your needs, you can write your own and register them. Be sure to
658
711
* include a cleanup function if you have allocated private data.
660
__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
661
void * /* private_data */,
662
__LA_GID_T (*)(void *, const char *, __LA_GID_T),
663
void (* /* cleanup */)(void *));
664
__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
665
void * /* private_data */,
666
__LA_UID_T (*)(void *, const char *, __LA_UID_T),
667
void (* /* cleanup */)(void *));
713
__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
714
void * /* private_data */,
715
__LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
716
void (* /* cleanup */)(void *));
717
__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
718
void * /* private_data */,
719
__LA_INT64_T (*)(void *, const char *, __LA_INT64_T),
720
void (* /* cleanup */)(void *));
721
__LA_DECL __LA_INT64_T archive_write_disk_gid(struct archive *, const char *, __LA_INT64_T);
722
__LA_DECL __LA_INT64_T archive_write_disk_uid(struct archive *, const char *, __LA_INT64_T);
670
725
* ARCHIVE_READ_DISK API
685
740
struct archive_entry *, int /* fd */, const struct stat *);
686
741
/* Look up gname for gid or uname for uid. */
687
742
/* Default implementations are very, very stupid. */
688
__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_GID_T);
689
__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_UID_T);
743
__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_INT64_T);
744
__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_INT64_T);
690
745
/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
691
746
* results for performance. */
692
__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
747
__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
693
748
/* You can install your own lookups if you like. */
694
__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
695
void * /* private_data */,
696
const char *(* /* lookup_fn */)(void *, __LA_GID_T),
697
void (* /* cleanup_fn */)(void *));
698
__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
699
void * /* private_data */,
700
const char *(* /* lookup_fn */)(void *, __LA_UID_T),
701
void (* /* cleanup_fn */)(void *));
749
__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
750
void * /* private_data */,
751
const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
752
void (* /* cleanup_fn */)(void *));
753
__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
754
void * /* private_data */,
755
const char *(* /* lookup_fn */)(void *, __LA_INT64_T),
756
void (* /* cleanup_fn */)(void *));
757
/* Start traversal. */
758
__LA_DECL int archive_read_disk_open(struct archive *, const char *);
759
__LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *);
761
* Request that current entry be visited. If you invoke it on every
762
* directory, you'll get a physical traversal. This is ignored if the
763
* current entry isn't a directory or a link to a directory. So, if
764
* you invoke this on every returned path, you'll get a full logical
767
__LA_DECL int archive_read_disk_descend(struct archive *);
768
__LA_DECL int archive_read_disk_current_filesystem(struct archive *);
769
__LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *);
770
__LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *);
771
/* Request that the access time of the entry visited by travesal be restored. */
772
__LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
704
775
* Accessor functions to read/set various information in
705
776
* the struct archive object:
707
/* Bytes written after compression or read before decompression. */
708
__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *);
709
/* Bytes written to compressor or read from decompressor. */
710
__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *);
712
__LA_DECL const char *archive_compression_name(struct archive *);
713
__LA_DECL int archive_compression(struct archive *);
714
__LA_DECL int archive_errno(struct archive *);
715
__LA_DECL const char *archive_error_string(struct archive *);
716
__LA_DECL const char *archive_format_name(struct archive *);
717
__LA_DECL int archive_format(struct archive *);
718
__LA_DECL void archive_clear_error(struct archive *);
719
__LA_DECL void archive_set_error(struct archive *, int _err,
720
const char *fmt, ...);
721
__LA_DECL void archive_copy_error(struct archive *dest,
722
struct archive *src);
723
__LA_DECL int archive_file_count(struct archive *);
779
/* Number of filters in the current filter pipeline. */
780
/* Filter #0 is the one closest to the format, -1 is a synonym for the
781
* last filter, which is always the pseudo-filter that wraps the
782
* client callbacks. */
783
__LA_DECL int archive_filter_count(struct archive *);
784
__LA_DECL __LA_INT64_T archive_filter_bytes(struct archive *, int);
785
__LA_DECL int archive_filter_code(struct archive *, int);
786
__LA_DECL const char * archive_filter_name(struct archive *, int);
788
#if ARCHIVE_VERSION_NUMBER < 4000000
789
/* These don't properly handle multiple filters, so are deprecated and
790
* will eventually be removed. */
791
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
792
__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *);
793
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
794
__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *);
795
/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
796
__LA_DECL const char *archive_compression_name(struct archive *);
797
/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
798
__LA_DECL int archive_compression(struct archive *);
801
__LA_DECL int archive_errno(struct archive *);
802
__LA_DECL const char *archive_error_string(struct archive *);
803
__LA_DECL const char *archive_format_name(struct archive *);
804
__LA_DECL int archive_format(struct archive *);
805
__LA_DECL void archive_clear_error(struct archive *);
806
__LA_DECL void archive_set_error(struct archive *, int _err,
807
const char *fmt, ...) __LA_PRINTF(3, 4);
808
__LA_DECL void archive_copy_error(struct archive *dest,
809
struct archive *src);
810
__LA_DECL int archive_file_count(struct archive *);
725
812
#ifdef __cplusplus