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