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