Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:38:48

0001 /*-
0002  * Copyright (c) 2003-2010 Tim Kientzle
0003  * All rights reserved.
0004  *
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  * 1. Redistributions of source code must retain the above copyright
0009  *    notice, this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright
0011  *    notice, this list of conditions and the following disclaimer in the
0012  *    documentation and/or other materials provided with the distribution.
0013  *
0014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
0015  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0016  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0017  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
0018  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0019  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0020  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0021  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0023  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0024  */
0025 
0026 #ifndef ARCHIVE_H_INCLUDED
0027 #define ARCHIVE_H_INCLUDED
0028 
0029 /*
0030  * The version number is expressed as a single integer that makes it
0031  * easy to compare versions at build time: for version a.b.c, the
0032  * version number is printf("%d%03d%03d",a,b,c).  For example, if you
0033  * know your application requires version 2.12.108 or later, you can
0034  * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
0035  */
0036 /* Note: Compiler will complain if this does not match archive_entry.h! */
0037 #define ARCHIVE_VERSION_NUMBER 3008000
0038 
0039 #include <sys/stat.h>
0040 #include <stddef.h>  /* for wchar_t */
0041 #include <stdio.h> /* For FILE * */
0042 #if ARCHIVE_VERSION_NUMBER < 4000000
0043 /* time_t is slated to be removed from public includes in 4.0 */
0044 #include <time.h> /* For time_t */
0045 #endif
0046 
0047 /*
0048  * Note: archive.h is for use outside of libarchive; the configuration
0049  * headers (config.h, archive_platform.h, etc.) are purely internal.
0050  * Do NOT use HAVE_XXX configuration macros to control the behavior of
0051  * this header!  If you must conditionalize, use predefined compiler and/or
0052  * platform macros.
0053  */
0054 #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
0055 # include <stdint.h>
0056 #elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H)
0057 # include <inttypes.h>
0058 #endif
0059 
0060 /* Get appropriate definitions of 64-bit integer */
0061 #if !defined(__LA_INT64_T_DEFINED)
0062 /* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
0063 # if ARCHIVE_VERSION_NUMBER < 4000000
0064 #define __LA_INT64_T la_int64_t
0065 # endif
0066 #define __LA_INT64_T_DEFINED
0067 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
0068 typedef __int64 la_int64_t;
0069 typedef unsigned __int64 la_uint64_t;
0070 # else
0071 # include <unistd.h>  /* ssize_t */
0072 #  if defined(_SCO_DS) || defined(__osf__)
0073 typedef long long la_int64_t;
0074 typedef unsigned long long la_uint64_t;
0075 #  else
0076 typedef int64_t la_int64_t;
0077 typedef uint64_t la_uint64_t;
0078 #  endif
0079 # endif
0080 #endif
0081 
0082 /* The la_ssize_t should match the type used in 'struct stat' */
0083 #if !defined(__LA_SSIZE_T_DEFINED)
0084 /* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
0085 # if ARCHIVE_VERSION_NUMBER < 4000000
0086 #define __LA_SSIZE_T la_ssize_t
0087 # endif
0088 #define __LA_SSIZE_T_DEFINED
0089 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
0090 #  if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
0091 typedef ssize_t la_ssize_t;
0092 #  elif defined(_WIN64)
0093 typedef __int64 la_ssize_t;
0094 #  else
0095 typedef long la_ssize_t;
0096 #  endif
0097 # else
0098 # include <unistd.h>  /* ssize_t */
0099 typedef ssize_t la_ssize_t;
0100 # endif
0101 #endif
0102 
0103 #if ARCHIVE_VERSION_NUMBER < 4000000
0104 /* Use the platform types for time_t */
0105 #define __LA_TIME_T time_t
0106 #else
0107 /* Use 64-bits integer types for time_t */
0108 #define __LA_TIME_T la_int64_t
0109 #endif
0110 
0111 #if ARCHIVE_VERSION_NUMBER < 4000000
0112 /* Use the platform types for dev_t */
0113 #define __LA_DEV_T dev_t
0114 #else
0115 /* Use 64-bits integer types for dev_t */
0116 #define __LA_DEV_T la_int64_t
0117 #endif
0118 
0119 /* Large file support for Android */
0120 #if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
0121 #include "android_lf.h"
0122 #endif
0123 
0124 /*
0125  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
0126  * .lib.  The default here assumes you're building a DLL.  Only
0127  * libarchive source should ever define __LIBARCHIVE_BUILD.
0128  */
0129 #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
0130 # ifdef __LIBARCHIVE_BUILD
0131 #  ifdef __GNUC__
0132 #   define __LA_DECL    __attribute__((dllexport)) extern
0133 #  else
0134 #   define __LA_DECL    __declspec(dllexport)
0135 #  endif
0136 # else
0137 #  ifdef __GNUC__
0138 #   define __LA_DECL
0139 #  else
0140 #   define __LA_DECL    __declspec(dllimport)
0141 #  endif
0142 # endif
0143 #elif defined __LIBARCHIVE_ENABLE_VISIBILITY
0144 #  define __LA_DECL __attribute__((visibility("default")))
0145 #else
0146 /* Static libraries or non-Windows needs no special declaration. */
0147 # define __LA_DECL
0148 #endif
0149 
0150 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
0151 #define __LA_PRINTF(fmtarg, firstvararg) \
0152     __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
0153 #else
0154 #define __LA_PRINTF(fmtarg, firstvararg)    /* nothing */
0155 #endif
0156 
0157 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
0158 # define __LA_DEPRECATED __attribute__((deprecated))
0159 #else
0160 # define __LA_DEPRECATED
0161 #endif
0162 
0163 #ifdef __cplusplus
0164 extern "C" {
0165 #endif
0166 
0167 /*
0168  * The version number is provided as both a macro and a function.
0169  * The macro identifies the installed header; the function identifies
0170  * the library version (which may not be the same if you're using a
0171  * dynamically-linked version of the library).  Of course, if the
0172  * header and library are very different, you should expect some
0173  * strangeness.  Don't do that.
0174  */
0175 __LA_DECL int       archive_version_number(void);
0176 
0177 /*
0178  * Textual name/version of the library, useful for version displays.
0179  */
0180 #define ARCHIVE_VERSION_ONLY_STRING "3.8.0"
0181 #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
0182 __LA_DECL const char *  archive_version_string(void);
0183 
0184 /*
0185  * Detailed textual name/version of the library and its dependencies.
0186  * This has the form:
0187  *    "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
0188  * the list of libraries described here will vary depending on how
0189  * libarchive was compiled.
0190  */
0191 __LA_DECL const char *  archive_version_details(void);
0192 
0193 /*
0194  * Returns NULL if libarchive was compiled without the associated library.
0195  * Otherwise, returns the version number that libarchive was compiled
0196  * against.
0197  */
0198 __LA_DECL const char *  archive_zlib_version(void);
0199 __LA_DECL const char *  archive_liblzma_version(void);
0200 __LA_DECL const char *  archive_bzlib_version(void);
0201 __LA_DECL const char *  archive_liblz4_version(void);
0202 __LA_DECL const char *  archive_libzstd_version(void);
0203 __LA_DECL const char *  archive_liblzo2_version(void);
0204 __LA_DECL const char *  archive_libexpat_version(void);
0205 __LA_DECL const char *  archive_libbsdxml_version(void);
0206 __LA_DECL const char *  archive_libxml2_version(void);
0207 __LA_DECL const char *  archive_mbedtls_version(void);
0208 __LA_DECL const char *  archive_nettle_version(void);
0209 __LA_DECL const char *  archive_openssl_version(void);
0210 __LA_DECL const char *  archive_libmd_version(void);
0211 __LA_DECL const char *  archive_commoncrypto_version(void);
0212 __LA_DECL const char *  archive_cng_version(void);
0213 __LA_DECL const char *  archive_wincrypt_version(void);
0214 __LA_DECL const char *  archive_librichacl_version(void);
0215 __LA_DECL const char *  archive_libacl_version(void);
0216 __LA_DECL const char *  archive_libattr_version(void);
0217 __LA_DECL const char *  archive_libiconv_version(void);
0218 __LA_DECL const char *  archive_libpcre_version(void);
0219 __LA_DECL const char *  archive_libpcre2_version(void);
0220 
0221 /* Declare our basic types. */
0222 struct archive;
0223 struct archive_entry;
0224 
0225 /*
0226  * Error codes: Use archive_errno() and archive_error_string()
0227  * to retrieve details.  Unless specified otherwise, all functions
0228  * that return 'int' use these codes.
0229  */
0230 #define ARCHIVE_EOF   1 /* Found end of archive. */
0231 #define ARCHIVE_OK    0 /* Operation was successful. */
0232 #define ARCHIVE_RETRY   (-10)   /* Retry might succeed. */
0233 #define ARCHIVE_WARN    (-20)   /* Partial success. */
0234 /* For example, if write_header "fails", then you can't push data. */
0235 #define ARCHIVE_FAILED  (-25)   /* Current operation cannot complete. */
0236 /* But if write_header is "fatal," then this archive is dead and useless. */
0237 #define ARCHIVE_FATAL   (-30)   /* No more operations are possible. */
0238 
0239 /*
0240  * As far as possible, archive_errno returns standard platform errno codes.
0241  * Of course, the details vary by platform, so the actual definitions
0242  * here are stored in "archive_platform.h".  The symbols are listed here
0243  * for reference; as a rule, clients should not need to know the exact
0244  * platform-dependent error code.
0245  */
0246 /* Unrecognized or invalid file format. */
0247 /* #define  ARCHIVE_ERRNO_FILE_FORMAT */
0248 /* Illegal usage of the library. */
0249 /* #define  ARCHIVE_ERRNO_PROGRAMMER_ERROR */
0250 /* Unknown or unclassified error. */
0251 /* #define  ARCHIVE_ERRNO_MISC */
0252 
0253 /*
0254  * Callbacks are invoked to automatically read/skip/write/open/close the
0255  * archive. You can provide your own for complex tasks (like breaking
0256  * archives across multiple tapes) or use standard ones built into the
0257  * library.
0258  */
0259 
0260 /* Returns pointer and size of next block of data from archive. */
0261 typedef la_ssize_t  archive_read_callback(struct archive *,
0262                 void *_client_data, const void **_buffer);
0263 
0264 /* Skips at most request bytes from archive and returns the skipped amount.
0265  * This may skip fewer bytes than requested; it may even skip zero bytes.
0266  * If you do skip fewer bytes than requested, libarchive will invoke your
0267  * read callback and discard data as necessary to make up the full skip.
0268  */
0269 typedef la_int64_t  archive_skip_callback(struct archive *,
0270                 void *_client_data, la_int64_t request);
0271 
0272 /* Seeks to specified location in the file and returns the position.
0273  * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
0274  * Return ARCHIVE_FATAL if the seek fails for any reason.
0275  */
0276 typedef la_int64_t  archive_seek_callback(struct archive *,
0277     void *_client_data, la_int64_t offset, int whence);
0278 
0279 /* Returns size actually written, zero on EOF, -1 on error. */
0280 typedef la_ssize_t  archive_write_callback(struct archive *,
0281                 void *_client_data,
0282                 const void *_buffer, size_t _length);
0283 
0284 typedef int archive_open_callback(struct archive *, void *_client_data);
0285 
0286 typedef int archive_close_callback(struct archive *, void *_client_data);
0287 
0288 typedef int archive_free_callback(struct archive *, void *_client_data);
0289 
0290 /* Switches from one client data object to the next/prev client data object.
0291  * This is useful for reading from different data blocks such as a set of files
0292  * that make up one large file.
0293  */
0294 typedef int archive_switch_callback(struct archive *, void *_client_data1,
0295                 void *_client_data2);
0296 
0297 /*
0298  * Returns a passphrase used for encryption or decryption, NULL on nothing
0299  * to do and give it up.
0300  */
0301 typedef const char *archive_passphrase_callback(struct archive *,
0302                 void *_client_data);
0303 
0304 /*
0305  * Codes to identify various stream filters.
0306  */
0307 #define ARCHIVE_FILTER_NONE 0
0308 #define ARCHIVE_FILTER_GZIP 1
0309 #define ARCHIVE_FILTER_BZIP2    2
0310 #define ARCHIVE_FILTER_COMPRESS 3
0311 #define ARCHIVE_FILTER_PROGRAM  4
0312 #define ARCHIVE_FILTER_LZMA 5
0313 #define ARCHIVE_FILTER_XZ   6
0314 #define ARCHIVE_FILTER_UU   7
0315 #define ARCHIVE_FILTER_RPM  8
0316 #define ARCHIVE_FILTER_LZIP 9
0317 #define ARCHIVE_FILTER_LRZIP    10
0318 #define ARCHIVE_FILTER_LZOP 11
0319 #define ARCHIVE_FILTER_GRZIP    12
0320 #define ARCHIVE_FILTER_LZ4  13
0321 #define ARCHIVE_FILTER_ZSTD 14
0322 
0323 #if ARCHIVE_VERSION_NUMBER < 4000000
0324 #define ARCHIVE_COMPRESSION_NONE    ARCHIVE_FILTER_NONE
0325 #define ARCHIVE_COMPRESSION_GZIP    ARCHIVE_FILTER_GZIP
0326 #define ARCHIVE_COMPRESSION_BZIP2   ARCHIVE_FILTER_BZIP2
0327 #define ARCHIVE_COMPRESSION_COMPRESS    ARCHIVE_FILTER_COMPRESS
0328 #define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM
0329 #define ARCHIVE_COMPRESSION_LZMA    ARCHIVE_FILTER_LZMA
0330 #define ARCHIVE_COMPRESSION_XZ      ARCHIVE_FILTER_XZ
0331 #define ARCHIVE_COMPRESSION_UU      ARCHIVE_FILTER_UU
0332 #define ARCHIVE_COMPRESSION_RPM     ARCHIVE_FILTER_RPM
0333 #define ARCHIVE_COMPRESSION_LZIP    ARCHIVE_FILTER_LZIP
0334 #define ARCHIVE_COMPRESSION_LRZIP   ARCHIVE_FILTER_LRZIP
0335 #endif
0336 
0337 /*
0338  * Codes returned by archive_format.
0339  *
0340  * Top 16 bits identifies the format family (e.g., "tar"); lower
0341  * 16 bits indicate the variant.  This is updated by read_next_header.
0342  * Note that the lower 16 bits will often vary from entry to entry.
0343  * In some cases, this variation occurs as libarchive learns more about
0344  * the archive (for example, later entries might utilize extensions that
0345  * weren't necessary earlier in the archive; in this case, libarchive
0346  * will change the format code to indicate the extended format that
0347  * was used).  In other cases, it's because different tools have
0348  * modified the archive and so different parts of the archive
0349  * actually have slightly different formats.  (Both tar and cpio store
0350  * format codes in each entry, so it is quite possible for each
0351  * entry to be in a different format.)
0352  */
0353 #define ARCHIVE_FORMAT_BASE_MASK        0xff0000
0354 #define ARCHIVE_FORMAT_CPIO         0x10000
0355 #define ARCHIVE_FORMAT_CPIO_POSIX       (ARCHIVE_FORMAT_CPIO | 1)
0356 #define ARCHIVE_FORMAT_CPIO_BIN_LE      (ARCHIVE_FORMAT_CPIO | 2)
0357 #define ARCHIVE_FORMAT_CPIO_BIN_BE      (ARCHIVE_FORMAT_CPIO | 3)
0358 #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC      (ARCHIVE_FORMAT_CPIO | 4)
0359 #define ARCHIVE_FORMAT_CPIO_SVR4_CRC        (ARCHIVE_FORMAT_CPIO | 5)
0360 #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE      (ARCHIVE_FORMAT_CPIO | 6)
0361 #define ARCHIVE_FORMAT_CPIO_PWB         (ARCHIVE_FORMAT_CPIO | 7)
0362 #define ARCHIVE_FORMAT_SHAR         0x20000
0363 #define ARCHIVE_FORMAT_SHAR_BASE        (ARCHIVE_FORMAT_SHAR | 1)
0364 #define ARCHIVE_FORMAT_SHAR_DUMP        (ARCHIVE_FORMAT_SHAR | 2)
0365 #define ARCHIVE_FORMAT_TAR          0x30000
0366 #define ARCHIVE_FORMAT_TAR_USTAR        (ARCHIVE_FORMAT_TAR | 1)
0367 #define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE  (ARCHIVE_FORMAT_TAR | 2)
0368 #define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED   (ARCHIVE_FORMAT_TAR | 3)
0369 #define ARCHIVE_FORMAT_TAR_GNUTAR       (ARCHIVE_FORMAT_TAR | 4)
0370 #define ARCHIVE_FORMAT_ISO9660          0x40000
0371 #define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE    (ARCHIVE_FORMAT_ISO9660 | 1)
0372 #define ARCHIVE_FORMAT_ZIP          0x50000
0373 #define ARCHIVE_FORMAT_EMPTY            0x60000
0374 #define ARCHIVE_FORMAT_AR           0x70000
0375 #define ARCHIVE_FORMAT_AR_GNU           (ARCHIVE_FORMAT_AR | 1)
0376 #define ARCHIVE_FORMAT_AR_BSD           (ARCHIVE_FORMAT_AR | 2)
0377 #define ARCHIVE_FORMAT_MTREE            0x80000
0378 #define ARCHIVE_FORMAT_RAW          0x90000
0379 #define ARCHIVE_FORMAT_XAR          0xA0000
0380 #define ARCHIVE_FORMAT_LHA          0xB0000
0381 #define ARCHIVE_FORMAT_CAB          0xC0000
0382 #define ARCHIVE_FORMAT_RAR          0xD0000
0383 #define ARCHIVE_FORMAT_7ZIP         0xE0000
0384 #define ARCHIVE_FORMAT_WARC         0xF0000
0385 #define ARCHIVE_FORMAT_RAR_V5           0x100000
0386 
0387 /*
0388  * Codes returned by archive_read_format_capabilities().
0389  *
0390  * This list can be extended with values between 0 and 0xffff.
0391  * The original purpose of this list was to let different archive
0392  * format readers expose their general capabilities in terms of
0393  * encryption.
0394  */
0395 #define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
0396 #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0)  /* reader can detect encrypted data */
0397 #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1)  /* reader can detect encryptable metadata (pathname, mtime, etc.) */
0398 
0399 /*
0400  * Codes returned by archive_read_has_encrypted_entries().
0401  *
0402  * In case the archive does not support encryption detection at all
0403  * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
0404  * for some other reason (e.g. not enough bytes read) cannot say if
0405  * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
0406  * is returned.
0407  */
0408 #define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
0409 #define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
0410 
0411 /*-
0412  * Basic outline for reading an archive:
0413  *   1) Ask archive_read_new for an archive reader object.
0414  *   2) Update any global properties as appropriate.
0415  *      In particular, you'll certainly want to call appropriate
0416  *      archive_read_support_XXX functions.
0417  *   3) Call archive_read_open_XXX to open the archive
0418  *   4) Repeatedly call archive_read_next_header to get information about
0419  *      successive archive entries.  Call archive_read_data to extract
0420  *      data for entries of interest.
0421  *   5) Call archive_read_free to end processing.
0422  */
0423 __LA_DECL struct archive    *archive_read_new(void);
0424 
0425 /*
0426  * The archive_read_support_XXX calls enable auto-detect for this
0427  * archive handle.  They also link in the necessary support code.
0428  * For example, if you don't want bzlib linked in, don't invoke
0429  * support_compression_bzip2().  The "all" functions provide the
0430  * obvious shorthand.
0431  */
0432 
0433 #if ARCHIVE_VERSION_NUMBER < 4000000
0434 __LA_DECL int archive_read_support_compression_all(struct archive *)
0435         __LA_DEPRECATED;
0436 __LA_DECL int archive_read_support_compression_bzip2(struct archive *)
0437         __LA_DEPRECATED;
0438 __LA_DECL int archive_read_support_compression_compress(struct archive *)
0439         __LA_DEPRECATED;
0440 __LA_DECL int archive_read_support_compression_gzip(struct archive *)
0441         __LA_DEPRECATED;
0442 __LA_DECL int archive_read_support_compression_lzip(struct archive *)
0443         __LA_DEPRECATED;
0444 __LA_DECL int archive_read_support_compression_lzma(struct archive *)
0445         __LA_DEPRECATED;
0446 __LA_DECL int archive_read_support_compression_none(struct archive *)
0447         __LA_DEPRECATED;
0448 __LA_DECL int archive_read_support_compression_program(struct archive *,
0449              const char *command) __LA_DEPRECATED;
0450 __LA_DECL int archive_read_support_compression_program_signature
0451         (struct archive *, const char *,
0452          const void * /* match */, size_t) __LA_DEPRECATED;
0453 
0454 __LA_DECL int archive_read_support_compression_rpm(struct archive *)
0455         __LA_DEPRECATED;
0456 __LA_DECL int archive_read_support_compression_uu(struct archive *)
0457         __LA_DEPRECATED;
0458 __LA_DECL int archive_read_support_compression_xz(struct archive *)
0459         __LA_DEPRECATED;
0460 #endif
0461 
0462 __LA_DECL int archive_read_support_filter_all(struct archive *);
0463 __LA_DECL int archive_read_support_filter_by_code(struct archive *, int);
0464 __LA_DECL int archive_read_support_filter_bzip2(struct archive *);
0465 __LA_DECL int archive_read_support_filter_compress(struct archive *);
0466 __LA_DECL int archive_read_support_filter_gzip(struct archive *);
0467 __LA_DECL int archive_read_support_filter_grzip(struct archive *);
0468 __LA_DECL int archive_read_support_filter_lrzip(struct archive *);
0469 __LA_DECL int archive_read_support_filter_lz4(struct archive *);
0470 __LA_DECL int archive_read_support_filter_lzip(struct archive *);
0471 __LA_DECL int archive_read_support_filter_lzma(struct archive *);
0472 __LA_DECL int archive_read_support_filter_lzop(struct archive *);
0473 __LA_DECL int archive_read_support_filter_none(struct archive *);
0474 __LA_DECL int archive_read_support_filter_program(struct archive *,
0475              const char *command);
0476 __LA_DECL int archive_read_support_filter_program_signature
0477         (struct archive *, const char * /* cmd */,
0478                     const void * /* match */, size_t);
0479 __LA_DECL int archive_read_support_filter_rpm(struct archive *);
0480 __LA_DECL int archive_read_support_filter_uu(struct archive *);
0481 __LA_DECL int archive_read_support_filter_xz(struct archive *);
0482 __LA_DECL int archive_read_support_filter_zstd(struct archive *);
0483 
0484 __LA_DECL int archive_read_support_format_7zip(struct archive *);
0485 __LA_DECL int archive_read_support_format_all(struct archive *);
0486 __LA_DECL int archive_read_support_format_ar(struct archive *);
0487 __LA_DECL int archive_read_support_format_by_code(struct archive *, int);
0488 __LA_DECL int archive_read_support_format_cab(struct archive *);
0489 __LA_DECL int archive_read_support_format_cpio(struct archive *);
0490 __LA_DECL int archive_read_support_format_empty(struct archive *);
0491 /* archive_read_support_format_gnutar() is an alias for historical reasons
0492  * of archive_read_support_format_tar(). */
0493 __LA_DECL int archive_read_support_format_gnutar(struct archive *);
0494 __LA_DECL int archive_read_support_format_iso9660(struct archive *);
0495 __LA_DECL int archive_read_support_format_lha(struct archive *);
0496 __LA_DECL int archive_read_support_format_mtree(struct archive *);
0497 __LA_DECL int archive_read_support_format_rar(struct archive *);
0498 __LA_DECL int archive_read_support_format_rar5(struct archive *);
0499 __LA_DECL int archive_read_support_format_raw(struct archive *);
0500 __LA_DECL int archive_read_support_format_tar(struct archive *);
0501 __LA_DECL int archive_read_support_format_warc(struct archive *);
0502 __LA_DECL int archive_read_support_format_xar(struct archive *);
0503 /* archive_read_support_format_zip() enables both streamable and seekable
0504  * zip readers. */
0505 __LA_DECL int archive_read_support_format_zip(struct archive *);
0506 /* Reads Zip archives as stream from beginning to end.  Doesn't
0507  * correctly handle SFX ZIP files or ZIP archives that have been modified
0508  * in-place. */
0509 __LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
0510 /* Reads starting from central directory; requires seekable input. */
0511 __LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
0512 
0513 /* Functions to manually set the format and filters to be used. This is
0514  * useful to bypass the bidding process when the format and filters to use
0515  * is known in advance.
0516  */
0517 __LA_DECL int archive_read_set_format(struct archive *, int);
0518 __LA_DECL int archive_read_append_filter(struct archive *, int);
0519 __LA_DECL int archive_read_append_filter_program(struct archive *,
0520     const char *);
0521 __LA_DECL int archive_read_append_filter_program_signature
0522     (struct archive *, const char *, const void * /* match */, size_t);
0523 
0524 /* Set various callbacks. */
0525 __LA_DECL int archive_read_set_open_callback(struct archive *,
0526     archive_open_callback *);
0527 __LA_DECL int archive_read_set_read_callback(struct archive *,
0528     archive_read_callback *);
0529 __LA_DECL int archive_read_set_seek_callback(struct archive *,
0530     archive_seek_callback *);
0531 __LA_DECL int archive_read_set_skip_callback(struct archive *,
0532     archive_skip_callback *);
0533 __LA_DECL int archive_read_set_close_callback(struct archive *,
0534     archive_close_callback *);
0535 /* Callback used to switch between one data object to the next */
0536 __LA_DECL int archive_read_set_switch_callback(struct archive *,
0537     archive_switch_callback *);
0538 
0539 /* This sets the first data object. */
0540 __LA_DECL int archive_read_set_callback_data(struct archive *, void *);
0541 /* This sets data object at specified index */
0542 __LA_DECL int archive_read_set_callback_data2(struct archive *, void *,
0543     unsigned int);
0544 /* This adds a data object at the specified index. */
0545 __LA_DECL int archive_read_add_callback_data(struct archive *, void *,
0546     unsigned int);
0547 /* This appends a data object to the end of list */
0548 __LA_DECL int archive_read_append_callback_data(struct archive *, void *);
0549 /* This prepends a data object to the beginning of list */
0550 __LA_DECL int archive_read_prepend_callback_data(struct archive *, void *);
0551 
0552 /* Opening freezes the callbacks. */
0553 __LA_DECL int archive_read_open1(struct archive *);
0554 
0555 /* Convenience wrappers around the above. */
0556 __LA_DECL int archive_read_open(struct archive *, void *_client_data,
0557              archive_open_callback *, archive_read_callback *,
0558              archive_close_callback *);
0559 __LA_DECL int archive_read_open2(struct archive *, void *_client_data,
0560              archive_open_callback *, archive_read_callback *,
0561              archive_skip_callback *, archive_close_callback *);
0562 
0563 /*
0564  * A variety of shortcuts that invoke archive_read_open() with
0565  * canned callbacks suitable for common situations.  The ones that
0566  * accept a block size handle tape blocking correctly.
0567  */
0568 /* Use this if you know the filename.  Note: NULL indicates stdin. */
0569 __LA_DECL int archive_read_open_filename(struct archive *,
0570              const char *_filename, size_t _block_size);
0571 /* Use this for reading multivolume files by filenames.
0572  * NOTE: Must be NULL terminated. Sorting is NOT done. */
0573 __LA_DECL int archive_read_open_filenames(struct archive *,
0574              const char **_filenames, size_t _block_size);
0575 __LA_DECL int archive_read_open_filename_w(struct archive *,
0576              const wchar_t *_filename, size_t _block_size);
0577 #if defined(_WIN32) && !defined(__CYGWIN__)
0578 __LA_DECL int archive_read_open_filenames_w(struct archive *,
0579              const wchar_t **_filenames, size_t _block_size);
0580 #endif
0581 /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
0582 __LA_DECL int archive_read_open_file(struct archive *,
0583              const char *_filename, size_t _block_size) __LA_DEPRECATED;
0584 /* Read an archive that's stored in memory. */
0585 __LA_DECL int archive_read_open_memory(struct archive *,
0586              const void * buff, size_t size);
0587 /* A more involved version that is only used for internal testing. */
0588 __LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
0589              size_t size, size_t read_size);
0590 /* Read an archive that's already open, using the file descriptor. */
0591 __LA_DECL int archive_read_open_fd(struct archive *, int _fd,
0592              size_t _block_size);
0593 /* Read an archive that's already open, using a FILE *. */
0594 /* Note: DO NOT use this with tape drives. */
0595 __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
0596 
0597 /* Parses and returns next entry header. */
0598 __LA_DECL int archive_read_next_header(struct archive *,
0599              struct archive_entry **);
0600 
0601 /* Parses and returns next entry header using the archive_entry passed in */
0602 __LA_DECL int archive_read_next_header2(struct archive *,
0603              struct archive_entry *);
0604 
0605 /*
0606  * Retrieve the byte offset in UNCOMPRESSED data where last-read
0607  * header started.
0608  */
0609 __LA_DECL la_int64_t         archive_read_header_position(struct archive *);
0610 
0611 /*
0612  * Returns 1 if the archive contains at least one encrypted entry.
0613  * If the archive format not support encryption at all
0614  * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
0615  * If for any other reason (e.g. not enough data read so far)
0616  * we cannot say whether there are encrypted entries, then
0617  * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
0618  * In general, this function will return values below zero when the
0619  * reader is uncertain or totally incapable of encryption support.
0620  * When this function returns 0 you can be sure that the reader
0621  * supports encryption detection but no encrypted entries have
0622  * been found yet.
0623  *
0624  * NOTE: If the metadata/header of an archive is also encrypted, you
0625  * cannot rely on the number of encrypted entries. That is why this
0626  * function does not return the number of encrypted entries but#
0627  * just shows that there are some.
0628  */
0629 __LA_DECL int   archive_read_has_encrypted_entries(struct archive *);
0630 
0631 /*
0632  * Returns a bitmask of capabilities that are supported by the archive format reader.
0633  * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
0634  */
0635 __LA_DECL int        archive_read_format_capabilities(struct archive *);
0636 
0637 /* Read data from the body of an entry.  Similar to read(2). */
0638 __LA_DECL la_ssize_t         archive_read_data(struct archive *,
0639                     void *, size_t);
0640 
0641 /* Seek within the body of an entry.  Similar to lseek(2). */
0642 __LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);
0643 
0644 /*
0645  * A zero-copy version of archive_read_data that also exposes the file offset
0646  * of each returned block.  Note that the client has no way to specify
0647  * the desired size of the block.  The API does guarantee that offsets will
0648  * be strictly increasing and that returned blocks will not overlap.
0649  */
0650 __LA_DECL int archive_read_data_block(struct archive *a,
0651             const void **buff, size_t *size, la_int64_t *offset);
0652 
0653 /*-
0654  * Some convenience functions that are built on archive_read_data:
0655  *  'skip': skips entire entry
0656  *  'into_buffer': writes data into memory buffer that you provide
0657  *  'into_fd': writes data to specified filedes
0658  */
0659 __LA_DECL int archive_read_data_skip(struct archive *);
0660 __LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
0661 
0662 /*
0663  * Set read options.
0664  */
0665 /* Apply option to the format only. */
0666 __LA_DECL int archive_read_set_format_option(struct archive *_a,
0667                 const char *m, const char *o,
0668                 const char *v);
0669 /* Apply option to the filter only. */
0670 __LA_DECL int archive_read_set_filter_option(struct archive *_a,
0671                 const char *m, const char *o,
0672                 const char *v);
0673 /* Apply option to both the format and the filter. */
0674 __LA_DECL int archive_read_set_option(struct archive *_a,
0675                 const char *m, const char *o,
0676                 const char *v);
0677 /* Apply option string to both the format and the filter. */
0678 __LA_DECL int archive_read_set_options(struct archive *_a,
0679                 const char *opts);
0680 
0681 /*
0682  * Add a decryption passphrase.
0683  */
0684 __LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
0685 __LA_DECL int archive_read_set_passphrase_callback(struct archive *,
0686                 void *client_data, archive_passphrase_callback *);
0687 
0688 
0689 /*-
0690  * Convenience function to recreate the current entry (whose header
0691  * has just been read) on disk.
0692  *
0693  * This does quite a bit more than just copy data to disk. It also:
0694  *  - Creates intermediate directories as required.
0695  *  - Manages directory permissions:  non-writable directories will
0696  *    be initially created with write permission enabled; when the
0697  *    archive is closed, dir permissions are edited to the values specified
0698  *    in the archive.
0699  *  - Checks hardlinks:  hardlinks will not be extracted unless the
0700  *    linked-to file was also extracted within the same session. (TODO)
0701  */
0702 
0703 /* The "flags" argument selects optional behavior, 'OR' the flags you want. */
0704 
0705 /* Default: Do not try to set owner/group. */
0706 #define ARCHIVE_EXTRACT_OWNER           (0x0001)
0707 /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
0708 #define ARCHIVE_EXTRACT_PERM            (0x0002)
0709 /* Default: Do not restore mtime/atime. */
0710 #define ARCHIVE_EXTRACT_TIME            (0x0004)
0711 /* Default: Replace existing files. */
0712 #define ARCHIVE_EXTRACT_NO_OVERWRITE        (0x0008)
0713 /* Default: Try create first, unlink only if create fails with EEXIST. */
0714 #define ARCHIVE_EXTRACT_UNLINK          (0x0010)
0715 /* Default: Do not restore ACLs. */
0716 #define ARCHIVE_EXTRACT_ACL         (0x0020)
0717 /* Default: Do not restore fflags. */
0718 #define ARCHIVE_EXTRACT_FFLAGS          (0x0040)
0719 /* Default: Do not restore xattrs. */
0720 #define ARCHIVE_EXTRACT_XATTR           (0x0080)
0721 /* Default: Do not try to guard against extracts redirected by symlinks. */
0722 /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
0723 #define ARCHIVE_EXTRACT_SECURE_SYMLINKS     (0x0100)
0724 /* Default: Do not reject entries with '..' as path elements. */
0725 #define ARCHIVE_EXTRACT_SECURE_NODOTDOT     (0x0200)
0726 /* Default: Create parent directories as needed. */
0727 #define ARCHIVE_EXTRACT_NO_AUTODIR      (0x0400)
0728 /* Default: Overwrite files, even if one on disk is newer. */
0729 #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER  (0x0800)
0730 /* Detect blocks of 0 and write holes instead. */
0731 #define ARCHIVE_EXTRACT_SPARSE          (0x1000)
0732 /* Default: Do not restore Mac extended metadata. */
0733 /* This has no effect except on Mac OS. */
0734 #define ARCHIVE_EXTRACT_MAC_METADATA        (0x2000)
0735 /* Default: Use HFS+ compression if it was compressed. */
0736 /* This has no effect except on Mac OS v10.6 or later. */
0737 #define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION  (0x4000)
0738 /* Default: Do not use HFS+ compression if it was not compressed. */
0739 /* This has no effect except on Mac OS v10.6 or later. */
0740 #define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED  (0x8000)
0741 /* Default: Do not reject entries with absolute paths */
0742 #define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
0743 /* Default: Do not clear no-change flags when unlinking object */
0744 #define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS   (0x20000)
0745 /* Default: Do not extract atomically (using rename) */
0746 #define ARCHIVE_EXTRACT_SAFE_WRITES     (0x40000)
0747 
0748 __LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
0749              int flags);
0750 __LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
0751              struct archive * /* dest */);
0752 __LA_DECL void   archive_read_extract_set_progress_callback(struct archive *,
0753              void (*_progress_func)(void *), void *_user_data);
0754 
0755 /* Record the dev/ino of a file that will not be written.  This is
0756  * generally set to the dev/ino of the archive being read. */
0757 __LA_DECL void      archive_read_extract_set_skip_file(struct archive *,
0758              la_int64_t, la_int64_t);
0759 
0760 /* Close the file and release most resources. */
0761 __LA_DECL int        archive_read_close(struct archive *);
0762 /* Release all resources and destroy the object. */
0763 /* Note that archive_read_free will call archive_read_close for you. */
0764 __LA_DECL int        archive_read_free(struct archive *);
0765 #if ARCHIVE_VERSION_NUMBER < 4000000
0766 /* Synonym for archive_read_free() for backwards compatibility. */
0767 __LA_DECL int        archive_read_finish(struct archive *) __LA_DEPRECATED;
0768 #endif
0769 
0770 /*-
0771  * To create an archive:
0772  *   1) Ask archive_write_new for an archive writer object.
0773  *   2) Set any global properties.  In particular, you should set
0774  *      the compression and format to use.
0775  *   3) Call archive_write_open to open the file (most people
0776  *       will use archive_write_open_file or archive_write_open_fd,
0777  *       which provide convenient canned I/O callbacks for you).
0778  *   4) For each entry:
0779  *      - construct an appropriate struct archive_entry structure
0780  *      - archive_write_header to write the header
0781  *      - archive_write_data to write the entry data
0782  *   5) archive_write_close to close the output
0783  *   6) archive_write_free to cleanup the writer and release resources
0784  */
0785 __LA_DECL struct archive    *archive_write_new(void);
0786 __LA_DECL int archive_write_set_bytes_per_block(struct archive *,
0787              int bytes_per_block);
0788 __LA_DECL int archive_write_get_bytes_per_block(struct archive *);
0789 /* XXX This is badly misnamed; suggestions appreciated. XXX */
0790 __LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
0791              int bytes_in_last_block);
0792 __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
0793 
0794 /* The dev/ino of a file that won't be archived.  This is used
0795  * to avoid recursively adding an archive to itself. */
0796 __LA_DECL int archive_write_set_skip_file(struct archive *,
0797     la_int64_t, la_int64_t);
0798 
0799 #if ARCHIVE_VERSION_NUMBER < 4000000
0800 __LA_DECL int archive_write_set_compression_bzip2(struct archive *)
0801         __LA_DEPRECATED;
0802 __LA_DECL int archive_write_set_compression_compress(struct archive *)
0803         __LA_DEPRECATED;
0804 __LA_DECL int archive_write_set_compression_gzip(struct archive *)
0805         __LA_DEPRECATED;
0806 __LA_DECL int archive_write_set_compression_lzip(struct archive *)
0807         __LA_DEPRECATED;
0808 __LA_DECL int archive_write_set_compression_lzma(struct archive *)
0809         __LA_DEPRECATED;
0810 __LA_DECL int archive_write_set_compression_none(struct archive *)
0811         __LA_DEPRECATED;
0812 __LA_DECL int archive_write_set_compression_program(struct archive *,
0813              const char *cmd) __LA_DEPRECATED;
0814 __LA_DECL int archive_write_set_compression_xz(struct archive *)
0815         __LA_DEPRECATED;
0816 #endif
0817 
0818 /* A convenience function to set the filter based on the code. */
0819 __LA_DECL int archive_write_add_filter(struct archive *, int filter_code);
0820 __LA_DECL int archive_write_add_filter_by_name(struct archive *,
0821              const char *name);
0822 __LA_DECL int archive_write_add_filter_b64encode(struct archive *);
0823 __LA_DECL int archive_write_add_filter_bzip2(struct archive *);
0824 __LA_DECL int archive_write_add_filter_compress(struct archive *);
0825 __LA_DECL int archive_write_add_filter_grzip(struct archive *);
0826 __LA_DECL int archive_write_add_filter_gzip(struct archive *);
0827 __LA_DECL int archive_write_add_filter_lrzip(struct archive *);
0828 __LA_DECL int archive_write_add_filter_lz4(struct archive *);
0829 __LA_DECL int archive_write_add_filter_lzip(struct archive *);
0830 __LA_DECL int archive_write_add_filter_lzma(struct archive *);
0831 __LA_DECL int archive_write_add_filter_lzop(struct archive *);
0832 __LA_DECL int archive_write_add_filter_none(struct archive *);
0833 __LA_DECL int archive_write_add_filter_program(struct archive *,
0834              const char *cmd);
0835 __LA_DECL int archive_write_add_filter_uuencode(struct archive *);
0836 __LA_DECL int archive_write_add_filter_xz(struct archive *);
0837 __LA_DECL int archive_write_add_filter_zstd(struct archive *);
0838 
0839 
0840 /* A convenience function to set the format based on the code or name. */
0841 __LA_DECL int archive_write_set_format(struct archive *, int format_code);
0842 __LA_DECL int archive_write_set_format_by_name(struct archive *,
0843              const char *name);
0844 /* To minimize link pollution, use one or more of the following. */
0845 __LA_DECL int archive_write_set_format_7zip(struct archive *);
0846 __LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
0847 __LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
0848 __LA_DECL int archive_write_set_format_cpio(struct archive *);
0849 __LA_DECL int archive_write_set_format_cpio_bin(struct archive *);
0850 __LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
0851 __LA_DECL int archive_write_set_format_cpio_odc(struct archive *);
0852 __LA_DECL int archive_write_set_format_cpio_pwb(struct archive *);
0853 __LA_DECL int archive_write_set_format_gnutar(struct archive *);
0854 __LA_DECL int archive_write_set_format_iso9660(struct archive *);
0855 __LA_DECL int archive_write_set_format_mtree(struct archive *);
0856 __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
0857 /* TODO: int archive_write_set_format_old_tar(struct archive *); */
0858 __LA_DECL int archive_write_set_format_pax(struct archive *);
0859 __LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
0860 __LA_DECL int archive_write_set_format_raw(struct archive *);
0861 __LA_DECL int archive_write_set_format_shar(struct archive *);
0862 __LA_DECL int archive_write_set_format_shar_dump(struct archive *);
0863 __LA_DECL int archive_write_set_format_ustar(struct archive *);
0864 __LA_DECL int archive_write_set_format_v7tar(struct archive *);
0865 __LA_DECL int archive_write_set_format_warc(struct archive *);
0866 __LA_DECL int archive_write_set_format_xar(struct archive *);
0867 __LA_DECL int archive_write_set_format_zip(struct archive *);
0868 __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
0869 __LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
0870 __LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
0871 __LA_DECL int archive_write_zip_set_compression_store(struct archive *);
0872 __LA_DECL int archive_write_zip_set_compression_lzma(struct archive *);
0873 __LA_DECL int archive_write_zip_set_compression_xz(struct archive *);
0874 __LA_DECL int archive_write_zip_set_compression_bzip2(struct archive *);
0875 __LA_DECL int archive_write_zip_set_compression_zstd(struct archive *);
0876 /* Deprecated; use archive_write_open2 instead */
0877 __LA_DECL int archive_write_open(struct archive *, void *,
0878              archive_open_callback *, archive_write_callback *,
0879              archive_close_callback *);
0880 __LA_DECL int archive_write_open2(struct archive *, void *,
0881              archive_open_callback *, archive_write_callback *,
0882              archive_close_callback *, archive_free_callback *);
0883 __LA_DECL int archive_write_open_fd(struct archive *, int _fd);
0884 __LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
0885 __LA_DECL int archive_write_open_filename_w(struct archive *,
0886              const wchar_t *_file);
0887 /* A deprecated synonym for archive_write_open_filename() */
0888 __LA_DECL int archive_write_open_file(struct archive *, const char *_file)
0889         __LA_DEPRECATED;
0890 __LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
0891 /* _buffSize is the size of the buffer, _used refers to a variable that
0892  * will be updated after each write into the buffer. */
0893 __LA_DECL int archive_write_open_memory(struct archive *,
0894             void *_buffer, size_t _buffSize, size_t *_used);
0895 
0896 /*
0897  * Note that the library will truncate writes beyond the size provided
0898  * to archive_write_header or pad if the provided data is short.
0899  */
0900 __LA_DECL int archive_write_header(struct archive *,
0901              struct archive_entry *);
0902 __LA_DECL la_ssize_t    archive_write_data(struct archive *,
0903                 const void *, size_t);
0904 
0905 /* This interface is currently only available for archive_write_disk handles.  */
0906 __LA_DECL la_ssize_t     archive_write_data_block(struct archive *,
0907                     const void *, size_t, la_int64_t);
0908 
0909 __LA_DECL int        archive_write_finish_entry(struct archive *);
0910 __LA_DECL int        archive_write_close(struct archive *);
0911 /* Marks the archive as FATAL so that a subsequent free() operation
0912  * won't try to close() cleanly.  Provides a fast abort capability
0913  * when the client discovers that things have gone wrong. */
0914 __LA_DECL int            archive_write_fail(struct archive *);
0915 /* This can fail if the archive wasn't already closed, in which case
0916  * archive_write_free() will implicitly call archive_write_close(). */
0917 __LA_DECL int        archive_write_free(struct archive *);
0918 #if ARCHIVE_VERSION_NUMBER < 4000000
0919 /* Synonym for archive_write_free() for backwards compatibility. */
0920 __LA_DECL int        archive_write_finish(struct archive *) __LA_DEPRECATED;
0921 #endif
0922 
0923 /*
0924  * Set write options.
0925  */
0926 /* Apply option to the format only. */
0927 __LA_DECL int archive_write_set_format_option(struct archive *_a,
0928                 const char *m, const char *o,
0929                 const char *v);
0930 /* Apply option to the filter only. */
0931 __LA_DECL int archive_write_set_filter_option(struct archive *_a,
0932                 const char *m, const char *o,
0933                 const char *v);
0934 /* Apply option to both the format and the filter. */
0935 __LA_DECL int archive_write_set_option(struct archive *_a,
0936                 const char *m, const char *o,
0937                 const char *v);
0938 /* Apply option string to both the format and the filter. */
0939 __LA_DECL int archive_write_set_options(struct archive *_a,
0940                 const char *opts);
0941 
0942 /*
0943  * Set an encryption passphrase.
0944  */
0945 __LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
0946 __LA_DECL int archive_write_set_passphrase_callback(struct archive *,
0947                 void *client_data, archive_passphrase_callback *);
0948 
0949 /*-
0950  * ARCHIVE_WRITE_DISK API
0951  *
0952  * To create objects on disk:
0953  *   1) Ask archive_write_disk_new for a new archive_write_disk object.
0954  *   2) Set any global properties.  In particular, you probably
0955  *      want to set the options.
0956  *   3) For each entry:
0957  *      - construct an appropriate struct archive_entry structure
0958  *      - archive_write_header to create the file/dir/etc on disk
0959  *      - archive_write_data to write the entry data
0960  *   4) archive_write_free to cleanup the writer and release resources
0961  *
0962  * In particular, you can use this in conjunction with archive_read()
0963  * to pull entries out of an archive and create them on disk.
0964  */
0965 __LA_DECL struct archive    *archive_write_disk_new(void);
0966 /* This file will not be overwritten. */
0967 __LA_DECL int archive_write_disk_set_skip_file(struct archive *,
0968     la_int64_t, la_int64_t);
0969 /* Set flags to control how the next item gets created.
0970  * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
0971 __LA_DECL int        archive_write_disk_set_options(struct archive *,
0972              int flags);
0973 /*
0974  * The lookup functions are given uname/uid (or gname/gid) pairs and
0975  * return a uid (gid) suitable for this system.  These are used for
0976  * restoring ownership and for setting ACLs.  The default functions
0977  * are naive, they just return the uid/gid.  These are small, so reasonable
0978  * for applications that don't need to preserve ownership; they
0979  * are probably also appropriate for applications that are doing
0980  * same-system backup and restore.
0981  */
0982 /*
0983  * The "standard" lookup functions use common system calls to lookup
0984  * the uname/gname, falling back to the uid/gid if the names can't be
0985  * found.  They cache lookups and are reasonably fast, but can be very
0986  * large, so they are not used unless you ask for them.  In
0987  * particular, these match the specifications of POSIX "pax" and old
0988  * POSIX "tar".
0989  */
0990 __LA_DECL int    archive_write_disk_set_standard_lookup(struct archive *);
0991 /*
0992  * If neither the default (naive) nor the standard (big) functions suit
0993  * your needs, you can write your own and register them.  Be sure to
0994  * include a cleanup function if you have allocated private data.
0995  */
0996 __LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
0997     void * /* private_data */,
0998     la_int64_t (*)(void *, const char *, la_int64_t),
0999     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 /* Convenience function to sort a NULL terminated list of strings */
1254 __LA_DECL int archive_utility_string_sort(char **);
1255 
1256 #ifdef __cplusplus
1257 }
1258 #endif
1259 
1260 /* These are meaningless outside of this header. */
1261 #undef __LA_DECL
1262 
1263 #endif /* !ARCHIVE_H_INCLUDED */