Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:08

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 3007006
0038 
0039 #include <sys/stat.h>
0040 #include <stddef.h>  /* for wchar_t */
0041 #include <stdio.h> /* For FILE * */
0042 #include <time.h> /* For time_t */
0043 
0044 /*
0045  * Note: archive.h is for use outside of libarchive; the configuration
0046  * headers (config.h, archive_platform.h, etc.) are purely internal.
0047  * Do NOT use HAVE_XXX configuration macros to control the behavior of
0048  * this header!  If you must conditionalize, use predefined compiler and/or
0049  * platform macros.
0050  */
0051 #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
0052 # include <stdint.h>
0053 #elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H)
0054 # include <inttypes.h>
0055 #endif
0056 
0057 /* Get appropriate definitions of 64-bit integer */
0058 #if !defined(__LA_INT64_T_DEFINED)
0059 /* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
0060 # if ARCHIVE_VERSION_NUMBER < 4000000
0061 #define __LA_INT64_T la_int64_t
0062 # endif
0063 #define __LA_INT64_T_DEFINED
0064 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
0065 typedef __int64 la_int64_t;
0066 # else
0067 # include <unistd.h>  /* ssize_t */
0068 #  if defined(_SCO_DS) || defined(__osf__)
0069 typedef long long la_int64_t;
0070 #  else
0071 typedef int64_t la_int64_t;
0072 #  endif
0073 # endif
0074 #endif
0075 
0076 /* The la_ssize_t should match the type used in 'struct stat' */
0077 #if !defined(__LA_SSIZE_T_DEFINED)
0078 /* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
0079 # if ARCHIVE_VERSION_NUMBER < 4000000
0080 #define __LA_SSIZE_T la_ssize_t
0081 # endif
0082 #define __LA_SSIZE_T_DEFINED
0083 # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
0084 #  if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
0085 typedef ssize_t la_ssize_t;
0086 #  elif defined(_WIN64)
0087 typedef __int64 la_ssize_t;
0088 #  else
0089 typedef long la_ssize_t;
0090 #  endif
0091 # else
0092 # include <unistd.h>  /* ssize_t */
0093 typedef ssize_t la_ssize_t;
0094 # endif
0095 #endif
0096 
0097 /* Large file support for Android */
0098 #if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
0099 #include "android_lf.h"
0100 #endif
0101 
0102 /*
0103  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
0104  * .lib.  The default here assumes you're building a DLL.  Only
0105  * libarchive source should ever define __LIBARCHIVE_BUILD.
0106  */
0107 #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
0108 # ifdef __LIBARCHIVE_BUILD
0109 #  ifdef __GNUC__
0110 #   define __LA_DECL    __attribute__((dllexport)) extern
0111 #  else
0112 #   define __LA_DECL    __declspec(dllexport)
0113 #  endif
0114 # else
0115 #  ifdef __GNUC__
0116 #   define __LA_DECL
0117 #  else
0118 #   define __LA_DECL    __declspec(dllimport)
0119 #  endif
0120 # endif
0121 #elif defined __LIBARCHIVE_ENABLE_VISIBILITY
0122 #  define __LA_DECL __attribute__((visibility("default")))
0123 #else
0124 /* Static libraries or non-Windows needs no special declaration. */
0125 # define __LA_DECL
0126 #endif
0127 
0128 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
0129 #define __LA_PRINTF(fmtarg, firstvararg) \
0130     __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
0131 #else
0132 #define __LA_PRINTF(fmtarg, firstvararg)    /* nothing */
0133 #endif
0134 
0135 #if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
0136 # define __LA_DEPRECATED __attribute__((deprecated))
0137 #else
0138 # define __LA_DEPRECATED
0139 #endif
0140 
0141 #ifdef __cplusplus
0142 extern "C" {
0143 #endif
0144 
0145 /*
0146  * The version number is provided as both a macro and a function.
0147  * The macro identifies the installed header; the function identifies
0148  * the library version (which may not be the same if you're using a
0149  * dynamically-linked version of the library).  Of course, if the
0150  * header and library are very different, you should expect some
0151  * strangeness.  Don't do that.
0152  */
0153 __LA_DECL int       archive_version_number(void);
0154 
0155 /*
0156  * Textual name/version of the library, useful for version displays.
0157  */
0158 #define ARCHIVE_VERSION_ONLY_STRING "3.7.6"
0159 #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
0160 __LA_DECL const char *  archive_version_string(void);
0161 
0162 /*
0163  * Detailed textual name/version of the library and its dependencies.
0164  * This has the form:
0165  *    "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
0166  * the list of libraries described here will vary depending on how
0167  * libarchive was compiled.
0168  */
0169 __LA_DECL const char *  archive_version_details(void);
0170 
0171 /*
0172  * Returns NULL if libarchive was compiled without the associated library.
0173  * Otherwise, returns the version number that libarchive was compiled
0174  * against.
0175  */
0176 __LA_DECL const char *  archive_zlib_version(void);
0177 __LA_DECL const char *  archive_liblzma_version(void);
0178 __LA_DECL const char *  archive_bzlib_version(void);
0179 __LA_DECL const char *  archive_liblz4_version(void);
0180 __LA_DECL const char *  archive_libzstd_version(void);
0181 
0182 /* Declare our basic types. */
0183 struct archive;
0184 struct archive_entry;
0185 
0186 /*
0187  * Error codes: Use archive_errno() and archive_error_string()
0188  * to retrieve details.  Unless specified otherwise, all functions
0189  * that return 'int' use these codes.
0190  */
0191 #define ARCHIVE_EOF   1 /* Found end of archive. */
0192 #define ARCHIVE_OK    0 /* Operation was successful. */
0193 #define ARCHIVE_RETRY   (-10)   /* Retry might succeed. */
0194 #define ARCHIVE_WARN    (-20)   /* Partial success. */
0195 /* For example, if write_header "fails", then you can't push data. */
0196 #define ARCHIVE_FAILED  (-25)   /* Current operation cannot complete. */
0197 /* But if write_header is "fatal," then this archive is dead and useless. */
0198 #define ARCHIVE_FATAL   (-30)   /* No more operations are possible. */
0199 
0200 /*
0201  * As far as possible, archive_errno returns standard platform errno codes.
0202  * Of course, the details vary by platform, so the actual definitions
0203  * here are stored in "archive_platform.h".  The symbols are listed here
0204  * for reference; as a rule, clients should not need to know the exact
0205  * platform-dependent error code.
0206  */
0207 /* Unrecognized or invalid file format. */
0208 /* #define  ARCHIVE_ERRNO_FILE_FORMAT */
0209 /* Illegal usage of the library. */
0210 /* #define  ARCHIVE_ERRNO_PROGRAMMER_ERROR */
0211 /* Unknown or unclassified error. */
0212 /* #define  ARCHIVE_ERRNO_MISC */
0213 
0214 /*
0215  * Callbacks are invoked to automatically read/skip/write/open/close the
0216  * archive. You can provide your own for complex tasks (like breaking
0217  * archives across multiple tapes) or use standard ones built into the
0218  * library.
0219  */
0220 
0221 /* Returns pointer and size of next block of data from archive. */
0222 typedef la_ssize_t  archive_read_callback(struct archive *,
0223                 void *_client_data, const void **_buffer);
0224 
0225 /* Skips at most request bytes from archive and returns the skipped amount.
0226  * This may skip fewer bytes than requested; it may even skip zero bytes.
0227  * If you do skip fewer bytes than requested, libarchive will invoke your
0228  * read callback and discard data as necessary to make up the full skip.
0229  */
0230 typedef la_int64_t  archive_skip_callback(struct archive *,
0231                 void *_client_data, la_int64_t request);
0232 
0233 /* Seeks to specified location in the file and returns the position.
0234  * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
0235  * Return ARCHIVE_FATAL if the seek fails for any reason.
0236  */
0237 typedef la_int64_t  archive_seek_callback(struct archive *,
0238     void *_client_data, la_int64_t offset, int whence);
0239 
0240 /* Returns size actually written, zero on EOF, -1 on error. */
0241 typedef la_ssize_t  archive_write_callback(struct archive *,
0242                 void *_client_data,
0243                 const void *_buffer, size_t _length);
0244 
0245 typedef int archive_open_callback(struct archive *, void *_client_data);
0246 
0247 typedef int archive_close_callback(struct archive *, void *_client_data);
0248 
0249 typedef int archive_free_callback(struct archive *, void *_client_data);
0250 
0251 /* Switches from one client data object to the next/prev client data object.
0252  * This is useful for reading from different data blocks such as a set of files
0253  * that make up one large file.
0254  */
0255 typedef int archive_switch_callback(struct archive *, void *_client_data1,
0256                 void *_client_data2);
0257 
0258 /*
0259  * Returns a passphrase used for encryption or decryption, NULL on nothing
0260  * to do and give it up.
0261  */
0262 typedef const char *archive_passphrase_callback(struct archive *,
0263                 void *_client_data);
0264 
0265 /*
0266  * Codes to identify various stream filters.
0267  */
0268 #define ARCHIVE_FILTER_NONE 0
0269 #define ARCHIVE_FILTER_GZIP 1
0270 #define ARCHIVE_FILTER_BZIP2    2
0271 #define ARCHIVE_FILTER_COMPRESS 3
0272 #define ARCHIVE_FILTER_PROGRAM  4
0273 #define ARCHIVE_FILTER_LZMA 5
0274 #define ARCHIVE_FILTER_XZ   6
0275 #define ARCHIVE_FILTER_UU   7
0276 #define ARCHIVE_FILTER_RPM  8
0277 #define ARCHIVE_FILTER_LZIP 9
0278 #define ARCHIVE_FILTER_LRZIP    10
0279 #define ARCHIVE_FILTER_LZOP 11
0280 #define ARCHIVE_FILTER_GRZIP    12
0281 #define ARCHIVE_FILTER_LZ4  13
0282 #define ARCHIVE_FILTER_ZSTD 14
0283 
0284 #if ARCHIVE_VERSION_NUMBER < 4000000
0285 #define ARCHIVE_COMPRESSION_NONE    ARCHIVE_FILTER_NONE
0286 #define ARCHIVE_COMPRESSION_GZIP    ARCHIVE_FILTER_GZIP
0287 #define ARCHIVE_COMPRESSION_BZIP2   ARCHIVE_FILTER_BZIP2
0288 #define ARCHIVE_COMPRESSION_COMPRESS    ARCHIVE_FILTER_COMPRESS
0289 #define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM
0290 #define ARCHIVE_COMPRESSION_LZMA    ARCHIVE_FILTER_LZMA
0291 #define ARCHIVE_COMPRESSION_XZ      ARCHIVE_FILTER_XZ
0292 #define ARCHIVE_COMPRESSION_UU      ARCHIVE_FILTER_UU
0293 #define ARCHIVE_COMPRESSION_RPM     ARCHIVE_FILTER_RPM
0294 #define ARCHIVE_COMPRESSION_LZIP    ARCHIVE_FILTER_LZIP
0295 #define ARCHIVE_COMPRESSION_LRZIP   ARCHIVE_FILTER_LRZIP
0296 #endif
0297 
0298 /*
0299  * Codes returned by archive_format.
0300  *
0301  * Top 16 bits identifies the format family (e.g., "tar"); lower
0302  * 16 bits indicate the variant.  This is updated by read_next_header.
0303  * Note that the lower 16 bits will often vary from entry to entry.
0304  * In some cases, this variation occurs as libarchive learns more about
0305  * the archive (for example, later entries might utilize extensions that
0306  * weren't necessary earlier in the archive; in this case, libarchive
0307  * will change the format code to indicate the extended format that
0308  * was used).  In other cases, it's because different tools have
0309  * modified the archive and so different parts of the archive
0310  * actually have slightly different formats.  (Both tar and cpio store
0311  * format codes in each entry, so it is quite possible for each
0312  * entry to be in a different format.)
0313  */
0314 #define ARCHIVE_FORMAT_BASE_MASK        0xff0000
0315 #define ARCHIVE_FORMAT_CPIO         0x10000
0316 #define ARCHIVE_FORMAT_CPIO_POSIX       (ARCHIVE_FORMAT_CPIO | 1)
0317 #define ARCHIVE_FORMAT_CPIO_BIN_LE      (ARCHIVE_FORMAT_CPIO | 2)
0318 #define ARCHIVE_FORMAT_CPIO_BIN_BE      (ARCHIVE_FORMAT_CPIO | 3)
0319 #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC      (ARCHIVE_FORMAT_CPIO | 4)
0320 #define ARCHIVE_FORMAT_CPIO_SVR4_CRC        (ARCHIVE_FORMAT_CPIO | 5)
0321 #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE      (ARCHIVE_FORMAT_CPIO | 6)
0322 #define ARCHIVE_FORMAT_CPIO_PWB         (ARCHIVE_FORMAT_CPIO | 7)
0323 #define ARCHIVE_FORMAT_SHAR         0x20000
0324 #define ARCHIVE_FORMAT_SHAR_BASE        (ARCHIVE_FORMAT_SHAR | 1)
0325 #define ARCHIVE_FORMAT_SHAR_DUMP        (ARCHIVE_FORMAT_SHAR | 2)
0326 #define ARCHIVE_FORMAT_TAR          0x30000
0327 #define ARCHIVE_FORMAT_TAR_USTAR        (ARCHIVE_FORMAT_TAR | 1)
0328 #define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE  (ARCHIVE_FORMAT_TAR | 2)
0329 #define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED   (ARCHIVE_FORMAT_TAR | 3)
0330 #define ARCHIVE_FORMAT_TAR_GNUTAR       (ARCHIVE_FORMAT_TAR | 4)
0331 #define ARCHIVE_FORMAT_ISO9660          0x40000
0332 #define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE    (ARCHIVE_FORMAT_ISO9660 | 1)
0333 #define ARCHIVE_FORMAT_ZIP          0x50000
0334 #define ARCHIVE_FORMAT_EMPTY            0x60000
0335 #define ARCHIVE_FORMAT_AR           0x70000
0336 #define ARCHIVE_FORMAT_AR_GNU           (ARCHIVE_FORMAT_AR | 1)
0337 #define ARCHIVE_FORMAT_AR_BSD           (ARCHIVE_FORMAT_AR | 2)
0338 #define ARCHIVE_FORMAT_MTREE            0x80000
0339 #define ARCHIVE_FORMAT_RAW          0x90000
0340 #define ARCHIVE_FORMAT_XAR          0xA0000
0341 #define ARCHIVE_FORMAT_LHA          0xB0000
0342 #define ARCHIVE_FORMAT_CAB          0xC0000
0343 #define ARCHIVE_FORMAT_RAR          0xD0000
0344 #define ARCHIVE_FORMAT_7ZIP         0xE0000
0345 #define ARCHIVE_FORMAT_WARC         0xF0000
0346 #define ARCHIVE_FORMAT_RAR_V5           0x100000
0347 
0348 /*
0349  * Codes returned by archive_read_format_capabilities().
0350  *
0351  * This list can be extended with values between 0 and 0xffff.
0352  * The original purpose of this list was to let different archive
0353  * format readers expose their general capabilities in terms of
0354  * encryption.
0355  */
0356 #define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
0357 #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0)  /* reader can detect encrypted data */
0358 #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1)  /* reader can detect encryptable metadata (pathname, mtime, etc.) */
0359 
0360 /*
0361  * Codes returned by archive_read_has_encrypted_entries().
0362  *
0363  * In case the archive does not support encryption detection at all
0364  * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
0365  * for some other reason (e.g. not enough bytes read) cannot say if
0366  * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
0367  * is returned.
0368  */
0369 #define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
0370 #define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
0371 
0372 /*-
0373  * Basic outline for reading an archive:
0374  *   1) Ask archive_read_new for an archive reader object.
0375  *   2) Update any global properties as appropriate.
0376  *      In particular, you'll certainly want to call appropriate
0377  *      archive_read_support_XXX functions.
0378  *   3) Call archive_read_open_XXX to open the archive
0379  *   4) Repeatedly call archive_read_next_header to get information about
0380  *      successive archive entries.  Call archive_read_data to extract
0381  *      data for entries of interest.
0382  *   5) Call archive_read_free to end processing.
0383  */
0384 __LA_DECL struct archive    *archive_read_new(void);
0385 
0386 /*
0387  * The archive_read_support_XXX calls enable auto-detect for this
0388  * archive handle.  They also link in the necessary support code.
0389  * For example, if you don't want bzlib linked in, don't invoke
0390  * support_compression_bzip2().  The "all" functions provide the
0391  * obvious shorthand.
0392  */
0393 
0394 #if ARCHIVE_VERSION_NUMBER < 4000000
0395 __LA_DECL int archive_read_support_compression_all(struct archive *)
0396         __LA_DEPRECATED;
0397 __LA_DECL int archive_read_support_compression_bzip2(struct archive *)
0398         __LA_DEPRECATED;
0399 __LA_DECL int archive_read_support_compression_compress(struct archive *)
0400         __LA_DEPRECATED;
0401 __LA_DECL int archive_read_support_compression_gzip(struct archive *)
0402         __LA_DEPRECATED;
0403 __LA_DECL int archive_read_support_compression_lzip(struct archive *)
0404         __LA_DEPRECATED;
0405 __LA_DECL int archive_read_support_compression_lzma(struct archive *)
0406         __LA_DEPRECATED;
0407 __LA_DECL int archive_read_support_compression_none(struct archive *)
0408         __LA_DEPRECATED;
0409 __LA_DECL int archive_read_support_compression_program(struct archive *,
0410              const char *command) __LA_DEPRECATED;
0411 __LA_DECL int archive_read_support_compression_program_signature
0412         (struct archive *, const char *,
0413          const void * /* match */, size_t) __LA_DEPRECATED;
0414 
0415 __LA_DECL int archive_read_support_compression_rpm(struct archive *)
0416         __LA_DEPRECATED;
0417 __LA_DECL int archive_read_support_compression_uu(struct archive *)
0418         __LA_DEPRECATED;
0419 __LA_DECL int archive_read_support_compression_xz(struct archive *)
0420         __LA_DEPRECATED;
0421 #endif
0422 
0423 __LA_DECL int archive_read_support_filter_all(struct archive *);
0424 __LA_DECL int archive_read_support_filter_by_code(struct archive *, int);
0425 __LA_DECL int archive_read_support_filter_bzip2(struct archive *);
0426 __LA_DECL int archive_read_support_filter_compress(struct archive *);
0427 __LA_DECL int archive_read_support_filter_gzip(struct archive *);
0428 __LA_DECL int archive_read_support_filter_grzip(struct archive *);
0429 __LA_DECL int archive_read_support_filter_lrzip(struct archive *);
0430 __LA_DECL int archive_read_support_filter_lz4(struct archive *);
0431 __LA_DECL int archive_read_support_filter_lzip(struct archive *);
0432 __LA_DECL int archive_read_support_filter_lzma(struct archive *);
0433 __LA_DECL int archive_read_support_filter_lzop(struct archive *);
0434 __LA_DECL int archive_read_support_filter_none(struct archive *);
0435 __LA_DECL int archive_read_support_filter_program(struct archive *,
0436              const char *command);
0437 __LA_DECL int archive_read_support_filter_program_signature
0438         (struct archive *, const char * /* cmd */,
0439                     const void * /* match */, size_t);
0440 __LA_DECL int archive_read_support_filter_rpm(struct archive *);
0441 __LA_DECL int archive_read_support_filter_uu(struct archive *);
0442 __LA_DECL int archive_read_support_filter_xz(struct archive *);
0443 __LA_DECL int archive_read_support_filter_zstd(struct archive *);
0444 
0445 __LA_DECL int archive_read_support_format_7zip(struct archive *);
0446 __LA_DECL int archive_read_support_format_all(struct archive *);
0447 __LA_DECL int archive_read_support_format_ar(struct archive *);
0448 __LA_DECL int archive_read_support_format_by_code(struct archive *, int);
0449 __LA_DECL int archive_read_support_format_cab(struct archive *);
0450 __LA_DECL int archive_read_support_format_cpio(struct archive *);
0451 __LA_DECL int archive_read_support_format_empty(struct archive *);
0452 __LA_DECL int archive_read_support_format_gnutar(struct archive *);
0453 __LA_DECL int archive_read_support_format_iso9660(struct archive *);
0454 __LA_DECL int archive_read_support_format_lha(struct archive *);
0455 __LA_DECL int archive_read_support_format_mtree(struct archive *);
0456 __LA_DECL int archive_read_support_format_rar(struct archive *);
0457 __LA_DECL int archive_read_support_format_rar5(struct archive *);
0458 __LA_DECL int archive_read_support_format_raw(struct archive *);
0459 __LA_DECL int archive_read_support_format_tar(struct archive *);
0460 __LA_DECL int archive_read_support_format_warc(struct archive *);
0461 __LA_DECL int archive_read_support_format_xar(struct archive *);
0462 /* archive_read_support_format_zip() enables both streamable and seekable
0463  * zip readers. */
0464 __LA_DECL int archive_read_support_format_zip(struct archive *);
0465 /* Reads Zip archives as stream from beginning to end.  Doesn't
0466  * correctly handle SFX ZIP files or ZIP archives that have been modified
0467  * in-place. */
0468 __LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
0469 /* Reads starting from central directory; requires seekable input. */
0470 __LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
0471 
0472 /* Functions to manually set the format and filters to be used. This is
0473  * useful to bypass the bidding process when the format and filters to use
0474  * is known in advance.
0475  */
0476 __LA_DECL int archive_read_set_format(struct archive *, int);
0477 __LA_DECL int archive_read_append_filter(struct archive *, int);
0478 __LA_DECL int archive_read_append_filter_program(struct archive *,
0479     const char *);
0480 __LA_DECL int archive_read_append_filter_program_signature
0481     (struct archive *, const char *, const void * /* match */, size_t);
0482 
0483 /* Set various callbacks. */
0484 __LA_DECL int archive_read_set_open_callback(struct archive *,
0485     archive_open_callback *);
0486 __LA_DECL int archive_read_set_read_callback(struct archive *,
0487     archive_read_callback *);
0488 __LA_DECL int archive_read_set_seek_callback(struct archive *,
0489     archive_seek_callback *);
0490 __LA_DECL int archive_read_set_skip_callback(struct archive *,
0491     archive_skip_callback *);
0492 __LA_DECL int archive_read_set_close_callback(struct archive *,
0493     archive_close_callback *);
0494 /* Callback used to switch between one data object to the next */
0495 __LA_DECL int archive_read_set_switch_callback(struct archive *,
0496     archive_switch_callback *);
0497 
0498 /* This sets the first data object. */
0499 __LA_DECL int archive_read_set_callback_data(struct archive *, void *);
0500 /* This sets data object at specified index */
0501 __LA_DECL int archive_read_set_callback_data2(struct archive *, void *,
0502     unsigned int);
0503 /* This adds a data object at the specified index. */
0504 __LA_DECL int archive_read_add_callback_data(struct archive *, void *,
0505     unsigned int);
0506 /* This appends a data object to the end of list */
0507 __LA_DECL int archive_read_append_callback_data(struct archive *, void *);
0508 /* This prepends a data object to the beginning of list */
0509 __LA_DECL int archive_read_prepend_callback_data(struct archive *, void *);
0510 
0511 /* Opening freezes the callbacks. */
0512 __LA_DECL int archive_read_open1(struct archive *);
0513 
0514 /* Convenience wrappers around the above. */
0515 __LA_DECL int archive_read_open(struct archive *, void *_client_data,
0516              archive_open_callback *, archive_read_callback *,
0517              archive_close_callback *);
0518 __LA_DECL int archive_read_open2(struct archive *, void *_client_data,
0519              archive_open_callback *, archive_read_callback *,
0520              archive_skip_callback *, archive_close_callback *);
0521 
0522 /*
0523  * A variety of shortcuts that invoke archive_read_open() with
0524  * canned callbacks suitable for common situations.  The ones that
0525  * accept a block size handle tape blocking correctly.
0526  */
0527 /* Use this if you know the filename.  Note: NULL indicates stdin. */
0528 __LA_DECL int archive_read_open_filename(struct archive *,
0529              const char *_filename, size_t _block_size);
0530 /* Use this for reading multivolume files by filenames.
0531  * NOTE: Must be NULL terminated. Sorting is NOT done. */
0532 __LA_DECL int archive_read_open_filenames(struct archive *,
0533              const char **_filenames, size_t _block_size);
0534 __LA_DECL int archive_read_open_filename_w(struct archive *,
0535              const wchar_t *_filename, size_t _block_size);
0536 #if defined(_WIN32) && !defined(__CYGWIN__)
0537 __LA_DECL int archive_read_open_filenames_w(struct archive *,
0538              const wchar_t **_filenames, size_t _block_size);
0539 #endif
0540 /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
0541 __LA_DECL int archive_read_open_file(struct archive *,
0542              const char *_filename, size_t _block_size) __LA_DEPRECATED;
0543 /* Read an archive that's stored in memory. */
0544 __LA_DECL int archive_read_open_memory(struct archive *,
0545              const void * buff, size_t size);
0546 /* A more involved version that is only used for internal testing. */
0547 __LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
0548              size_t size, size_t read_size);
0549 /* Read an archive that's already open, using the file descriptor. */
0550 __LA_DECL int archive_read_open_fd(struct archive *, int _fd,
0551              size_t _block_size);
0552 /* Read an archive that's already open, using a FILE *. */
0553 /* Note: DO NOT use this with tape drives. */
0554 __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
0555 
0556 /* Parses and returns next entry header. */
0557 __LA_DECL int archive_read_next_header(struct archive *,
0558              struct archive_entry **);
0559 
0560 /* Parses and returns next entry header using the archive_entry passed in */
0561 __LA_DECL int archive_read_next_header2(struct archive *,
0562              struct archive_entry *);
0563 
0564 /*
0565  * Retrieve the byte offset in UNCOMPRESSED data where last-read
0566  * header started.
0567  */
0568 __LA_DECL la_int64_t         archive_read_header_position(struct archive *);
0569 
0570 /*
0571  * Returns 1 if the archive contains at least one encrypted entry.
0572  * If the archive format not support encryption at all
0573  * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
0574  * If for any other reason (e.g. not enough data read so far)
0575  * we cannot say whether there are encrypted entries, then
0576  * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
0577  * In general, this function will return values below zero when the
0578  * reader is uncertain or totally incapable of encryption support.
0579  * When this function returns 0 you can be sure that the reader
0580  * supports encryption detection but no encrypted entries have
0581  * been found yet.
0582  *
0583  * NOTE: If the metadata/header of an archive is also encrypted, you
0584  * cannot rely on the number of encrypted entries. That is why this
0585  * function does not return the number of encrypted entries but#
0586  * just shows that there are some.
0587  */
0588 __LA_DECL int   archive_read_has_encrypted_entries(struct archive *);
0589 
0590 /*
0591  * Returns a bitmask of capabilities that are supported by the archive format reader.
0592  * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
0593  */
0594 __LA_DECL int        archive_read_format_capabilities(struct archive *);
0595 
0596 /* Read data from the body of an entry.  Similar to read(2). */
0597 __LA_DECL la_ssize_t         archive_read_data(struct archive *,
0598                     void *, size_t);
0599 
0600 /* Seek within the body of an entry.  Similar to lseek(2). */
0601 __LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);
0602 
0603 /*
0604  * A zero-copy version of archive_read_data that also exposes the file offset
0605  * of each returned block.  Note that the client has no way to specify
0606  * the desired size of the block.  The API does guarantee that offsets will
0607  * be strictly increasing and that returned blocks will not overlap.
0608  */
0609 __LA_DECL int archive_read_data_block(struct archive *a,
0610             const void **buff, size_t *size, la_int64_t *offset);
0611 
0612 /*-
0613  * Some convenience functions that are built on archive_read_data:
0614  *  'skip': skips entire entry
0615  *  'into_buffer': writes data into memory buffer that you provide
0616  *  'into_fd': writes data to specified filedes
0617  */
0618 __LA_DECL int archive_read_data_skip(struct archive *);
0619 __LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
0620 
0621 /*
0622  * Set read options.
0623  */
0624 /* Apply option to the format only. */
0625 __LA_DECL int archive_read_set_format_option(struct archive *_a,
0626                 const char *m, const char *o,
0627                 const char *v);
0628 /* Apply option to the filter only. */
0629 __LA_DECL int archive_read_set_filter_option(struct archive *_a,
0630                 const char *m, const char *o,
0631                 const char *v);
0632 /* Apply option to both the format and the filter. */
0633 __LA_DECL int archive_read_set_option(struct archive *_a,
0634                 const char *m, const char *o,
0635                 const char *v);
0636 /* Apply option string to both the format and the filter. */
0637 __LA_DECL int archive_read_set_options(struct archive *_a,
0638                 const char *opts);
0639 
0640 /*
0641  * Add a decryption passphrase.
0642  */
0643 __LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
0644 __LA_DECL int archive_read_set_passphrase_callback(struct archive *,
0645                 void *client_data, archive_passphrase_callback *);
0646 
0647 
0648 /*-
0649  * Convenience function to recreate the current entry (whose header
0650  * has just been read) on disk.
0651  *
0652  * This does quite a bit more than just copy data to disk. It also:
0653  *  - Creates intermediate directories as required.
0654  *  - Manages directory permissions:  non-writable directories will
0655  *    be initially created with write permission enabled; when the
0656  *    archive is closed, dir permissions are edited to the values specified
0657  *    in the archive.
0658  *  - Checks hardlinks:  hardlinks will not be extracted unless the
0659  *    linked-to file was also extracted within the same session. (TODO)
0660  */
0661 
0662 /* The "flags" argument selects optional behavior, 'OR' the flags you want. */
0663 
0664 /* Default: Do not try to set owner/group. */
0665 #define ARCHIVE_EXTRACT_OWNER           (0x0001)
0666 /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
0667 #define ARCHIVE_EXTRACT_PERM            (0x0002)
0668 /* Default: Do not restore mtime/atime. */
0669 #define ARCHIVE_EXTRACT_TIME            (0x0004)
0670 /* Default: Replace existing files. */
0671 #define ARCHIVE_EXTRACT_NO_OVERWRITE        (0x0008)
0672 /* Default: Try create first, unlink only if create fails with EEXIST. */
0673 #define ARCHIVE_EXTRACT_UNLINK          (0x0010)
0674 /* Default: Do not restore ACLs. */
0675 #define ARCHIVE_EXTRACT_ACL         (0x0020)
0676 /* Default: Do not restore fflags. */
0677 #define ARCHIVE_EXTRACT_FFLAGS          (0x0040)
0678 /* Default: Do not restore xattrs. */
0679 #define ARCHIVE_EXTRACT_XATTR           (0x0080)
0680 /* Default: Do not try to guard against extracts redirected by symlinks. */
0681 /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
0682 #define ARCHIVE_EXTRACT_SECURE_SYMLINKS     (0x0100)
0683 /* Default: Do not reject entries with '..' as path elements. */
0684 #define ARCHIVE_EXTRACT_SECURE_NODOTDOT     (0x0200)
0685 /* Default: Create parent directories as needed. */
0686 #define ARCHIVE_EXTRACT_NO_AUTODIR      (0x0400)
0687 /* Default: Overwrite files, even if one on disk is newer. */
0688 #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER  (0x0800)
0689 /* Detect blocks of 0 and write holes instead. */
0690 #define ARCHIVE_EXTRACT_SPARSE          (0x1000)
0691 /* Default: Do not restore Mac extended metadata. */
0692 /* This has no effect except on Mac OS. */
0693 #define ARCHIVE_EXTRACT_MAC_METADATA        (0x2000)
0694 /* Default: Use HFS+ compression if it was compressed. */
0695 /* This has no effect except on Mac OS v10.6 or later. */
0696 #define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION  (0x4000)
0697 /* Default: Do not use HFS+ compression if it was not compressed. */
0698 /* This has no effect except on Mac OS v10.6 or later. */
0699 #define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED  (0x8000)
0700 /* Default: Do not reject entries with absolute paths */
0701 #define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
0702 /* Default: Do not clear no-change flags when unlinking object */
0703 #define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS   (0x20000)
0704 /* Default: Do not extract atomically (using rename) */
0705 #define ARCHIVE_EXTRACT_SAFE_WRITES     (0x40000)
0706 
0707 __LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
0708              int flags);
0709 __LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
0710              struct archive * /* dest */);
0711 __LA_DECL void   archive_read_extract_set_progress_callback(struct archive *,
0712              void (*_progress_func)(void *), void *_user_data);
0713 
0714 /* Record the dev/ino of a file that will not be written.  This is
0715  * generally set to the dev/ino of the archive being read. */
0716 __LA_DECL void      archive_read_extract_set_skip_file(struct archive *,
0717              la_int64_t, la_int64_t);
0718 
0719 /* Close the file and release most resources. */
0720 __LA_DECL int        archive_read_close(struct archive *);
0721 /* Release all resources and destroy the object. */
0722 /* Note that archive_read_free will call archive_read_close for you. */
0723 __LA_DECL int        archive_read_free(struct archive *);
0724 #if ARCHIVE_VERSION_NUMBER < 4000000
0725 /* Synonym for archive_read_free() for backwards compatibility. */
0726 __LA_DECL int        archive_read_finish(struct archive *) __LA_DEPRECATED;
0727 #endif
0728 
0729 /*-
0730  * To create an archive:
0731  *   1) Ask archive_write_new for an archive writer object.
0732  *   2) Set any global properties.  In particular, you should set
0733  *      the compression and format to use.
0734  *   3) Call archive_write_open to open the file (most people
0735  *       will use archive_write_open_file or archive_write_open_fd,
0736  *       which provide convenient canned I/O callbacks for you).
0737  *   4) For each entry:
0738  *      - construct an appropriate struct archive_entry structure
0739  *      - archive_write_header to write the header
0740  *      - archive_write_data to write the entry data
0741  *   5) archive_write_close to close the output
0742  *   6) archive_write_free to cleanup the writer and release resources
0743  */
0744 __LA_DECL struct archive    *archive_write_new(void);
0745 __LA_DECL int archive_write_set_bytes_per_block(struct archive *,
0746              int bytes_per_block);
0747 __LA_DECL int archive_write_get_bytes_per_block(struct archive *);
0748 /* XXX This is badly misnamed; suggestions appreciated. XXX */
0749 __LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
0750              int bytes_in_last_block);
0751 __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
0752 
0753 /* The dev/ino of a file that won't be archived.  This is used
0754  * to avoid recursively adding an archive to itself. */
0755 __LA_DECL int archive_write_set_skip_file(struct archive *,
0756     la_int64_t, la_int64_t);
0757 
0758 #if ARCHIVE_VERSION_NUMBER < 4000000
0759 __LA_DECL int archive_write_set_compression_bzip2(struct archive *)
0760         __LA_DEPRECATED;
0761 __LA_DECL int archive_write_set_compression_compress(struct archive *)
0762         __LA_DEPRECATED;
0763 __LA_DECL int archive_write_set_compression_gzip(struct archive *)
0764         __LA_DEPRECATED;
0765 __LA_DECL int archive_write_set_compression_lzip(struct archive *)
0766         __LA_DEPRECATED;
0767 __LA_DECL int archive_write_set_compression_lzma(struct archive *)
0768         __LA_DEPRECATED;
0769 __LA_DECL int archive_write_set_compression_none(struct archive *)
0770         __LA_DEPRECATED;
0771 __LA_DECL int archive_write_set_compression_program(struct archive *,
0772              const char *cmd) __LA_DEPRECATED;
0773 __LA_DECL int archive_write_set_compression_xz(struct archive *)
0774         __LA_DEPRECATED;
0775 #endif
0776 
0777 /* A convenience function to set the filter based on the code. */
0778 __LA_DECL int archive_write_add_filter(struct archive *, int filter_code);
0779 __LA_DECL int archive_write_add_filter_by_name(struct archive *,
0780              const char *name);
0781 __LA_DECL int archive_write_add_filter_b64encode(struct archive *);
0782 __LA_DECL int archive_write_add_filter_bzip2(struct archive *);
0783 __LA_DECL int archive_write_add_filter_compress(struct archive *);
0784 __LA_DECL int archive_write_add_filter_grzip(struct archive *);
0785 __LA_DECL int archive_write_add_filter_gzip(struct archive *);
0786 __LA_DECL int archive_write_add_filter_lrzip(struct archive *);
0787 __LA_DECL int archive_write_add_filter_lz4(struct archive *);
0788 __LA_DECL int archive_write_add_filter_lzip(struct archive *);
0789 __LA_DECL int archive_write_add_filter_lzma(struct archive *);
0790 __LA_DECL int archive_write_add_filter_lzop(struct archive *);
0791 __LA_DECL int archive_write_add_filter_none(struct archive *);
0792 __LA_DECL int archive_write_add_filter_program(struct archive *,
0793              const char *cmd);
0794 __LA_DECL int archive_write_add_filter_uuencode(struct archive *);
0795 __LA_DECL int archive_write_add_filter_xz(struct archive *);
0796 __LA_DECL int archive_write_add_filter_zstd(struct archive *);
0797 
0798 
0799 /* A convenience function to set the format based on the code or name. */
0800 __LA_DECL int archive_write_set_format(struct archive *, int format_code);
0801 __LA_DECL int archive_write_set_format_by_name(struct archive *,
0802              const char *name);
0803 /* To minimize link pollution, use one or more of the following. */
0804 __LA_DECL int archive_write_set_format_7zip(struct archive *);
0805 __LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
0806 __LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
0807 __LA_DECL int archive_write_set_format_cpio(struct archive *);
0808 __LA_DECL int archive_write_set_format_cpio_bin(struct archive *);
0809 __LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
0810 __LA_DECL int archive_write_set_format_cpio_odc(struct archive *);
0811 __LA_DECL int archive_write_set_format_cpio_pwb(struct archive *);
0812 __LA_DECL int archive_write_set_format_gnutar(struct archive *);
0813 __LA_DECL int archive_write_set_format_iso9660(struct archive *);
0814 __LA_DECL int archive_write_set_format_mtree(struct archive *);
0815 __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
0816 /* TODO: int archive_write_set_format_old_tar(struct archive *); */
0817 __LA_DECL int archive_write_set_format_pax(struct archive *);
0818 __LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
0819 __LA_DECL int archive_write_set_format_raw(struct archive *);
0820 __LA_DECL int archive_write_set_format_shar(struct archive *);
0821 __LA_DECL int archive_write_set_format_shar_dump(struct archive *);
0822 __LA_DECL int archive_write_set_format_ustar(struct archive *);
0823 __LA_DECL int archive_write_set_format_v7tar(struct archive *);
0824 __LA_DECL int archive_write_set_format_warc(struct archive *);
0825 __LA_DECL int archive_write_set_format_xar(struct archive *);
0826 __LA_DECL int archive_write_set_format_zip(struct archive *);
0827 __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
0828 __LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
0829 __LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
0830 __LA_DECL int archive_write_zip_set_compression_store(struct archive *);
0831 /* Deprecated; use archive_write_open2 instead */
0832 __LA_DECL int archive_write_open(struct archive *, void *,
0833              archive_open_callback *, archive_write_callback *,
0834              archive_close_callback *);
0835 __LA_DECL int archive_write_open2(struct archive *, void *,
0836              archive_open_callback *, archive_write_callback *,
0837              archive_close_callback *, archive_free_callback *);
0838 __LA_DECL int archive_write_open_fd(struct archive *, int _fd);
0839 __LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
0840 __LA_DECL int archive_write_open_filename_w(struct archive *,
0841              const wchar_t *_file);
0842 /* A deprecated synonym for archive_write_open_filename() */
0843 __LA_DECL int archive_write_open_file(struct archive *, const char *_file)
0844         __LA_DEPRECATED;
0845 __LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
0846 /* _buffSize is the size of the buffer, _used refers to a variable that
0847  * will be updated after each write into the buffer. */
0848 __LA_DECL int archive_write_open_memory(struct archive *,
0849             void *_buffer, size_t _buffSize, size_t *_used);
0850 
0851 /*
0852  * Note that the library will truncate writes beyond the size provided
0853  * to archive_write_header or pad if the provided data is short.
0854  */
0855 __LA_DECL int archive_write_header(struct archive *,
0856              struct archive_entry *);
0857 __LA_DECL la_ssize_t    archive_write_data(struct archive *,
0858                 const void *, size_t);
0859 
0860 /* This interface is currently only available for archive_write_disk handles.  */
0861 __LA_DECL la_ssize_t     archive_write_data_block(struct archive *,
0862                     const void *, size_t, la_int64_t);
0863 
0864 __LA_DECL int        archive_write_finish_entry(struct archive *);
0865 __LA_DECL int        archive_write_close(struct archive *);
0866 /* Marks the archive as FATAL so that a subsequent free() operation
0867  * won't try to close() cleanly.  Provides a fast abort capability
0868  * when the client discovers that things have gone wrong. */
0869 __LA_DECL int            archive_write_fail(struct archive *);
0870 /* This can fail if the archive wasn't already closed, in which case
0871  * archive_write_free() will implicitly call archive_write_close(). */
0872 __LA_DECL int        archive_write_free(struct archive *);
0873 #if ARCHIVE_VERSION_NUMBER < 4000000
0874 /* Synonym for archive_write_free() for backwards compatibility. */
0875 __LA_DECL int        archive_write_finish(struct archive *) __LA_DEPRECATED;
0876 #endif
0877 
0878 /*
0879  * Set write options.
0880  */
0881 /* Apply option to the format only. */
0882 __LA_DECL int archive_write_set_format_option(struct archive *_a,
0883                 const char *m, const char *o,
0884                 const char *v);
0885 /* Apply option to the filter only. */
0886 __LA_DECL int archive_write_set_filter_option(struct archive *_a,
0887                 const char *m, const char *o,
0888                 const char *v);
0889 /* Apply option to both the format and the filter. */
0890 __LA_DECL int archive_write_set_option(struct archive *_a,
0891                 const char *m, const char *o,
0892                 const char *v);
0893 /* Apply option string to both the format and the filter. */
0894 __LA_DECL int archive_write_set_options(struct archive *_a,
0895                 const char *opts);
0896 
0897 /*
0898  * Set an encryption passphrase.
0899  */
0900 __LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
0901 __LA_DECL int archive_write_set_passphrase_callback(struct archive *,
0902                 void *client_data, archive_passphrase_callback *);
0903 
0904 /*-
0905  * ARCHIVE_WRITE_DISK API
0906  *
0907  * To create objects on disk:
0908  *   1) Ask archive_write_disk_new for a new archive_write_disk object.
0909  *   2) Set any global properties.  In particular, you probably
0910  *      want to set the options.
0911  *   3) For each entry:
0912  *      - construct an appropriate struct archive_entry structure
0913  *      - archive_write_header to create the file/dir/etc on disk
0914  *      - archive_write_data to write the entry data
0915  *   4) archive_write_free to cleanup the writer and release resources
0916  *
0917  * In particular, you can use this in conjunction with archive_read()
0918  * to pull entries out of an archive and create them on disk.
0919  */
0920 __LA_DECL struct archive    *archive_write_disk_new(void);
0921 /* This file will not be overwritten. */
0922 __LA_DECL int archive_write_disk_set_skip_file(struct archive *,
0923     la_int64_t, la_int64_t);
0924 /* Set flags to control how the next item gets created.
0925  * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
0926 __LA_DECL int        archive_write_disk_set_options(struct archive *,
0927              int flags);
0928 /*
0929  * The lookup functions are given uname/uid (or gname/gid) pairs and
0930  * return a uid (gid) suitable for this system.  These are used for
0931  * restoring ownership and for setting ACLs.  The default functions
0932  * are naive, they just return the uid/gid.  These are small, so reasonable
0933  * for applications that don't need to preserve ownership; they
0934  * are probably also appropriate for applications that are doing
0935  * same-system backup and restore.
0936  */
0937 /*
0938  * The "standard" lookup functions use common system calls to lookup
0939  * the uname/gname, falling back to the uid/gid if the names can't be
0940  * found.  They cache lookups and are reasonably fast, but can be very
0941  * large, so they are not used unless you ask for them.  In
0942  * particular, these match the specifications of POSIX "pax" and old
0943  * POSIX "tar".
0944  */
0945 __LA_DECL int    archive_write_disk_set_standard_lookup(struct archive *);
0946 /*
0947  * If neither the default (naive) nor the standard (big) functions suit
0948  * your needs, you can write your own and register them.  Be sure to
0949  * include a cleanup function if you have allocated private data.
0950  */
0951 __LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
0952     void * /* private_data */,
0953     la_int64_t (*)(void *, const char *, la_int64_t),
0954     void (* /* cleanup */)(void *));
0955 __LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
0956     void * /* private_data */,
0957     la_int64_t (*)(void *, const char *, la_int64_t),
0958     void (* /* cleanup */)(void *));
0959 __LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t);
0960 __LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t);
0961 
0962 /*
0963  * ARCHIVE_READ_DISK API
0964  *
0965  * This is still evolving and somewhat experimental.
0966  */
0967 __LA_DECL struct archive *archive_read_disk_new(void);
0968 /* The names for symlink modes here correspond to an old BSD
0969  * command-line argument convention: -L, -P, -H */
0970 /* Follow all symlinks. */
0971 __LA_DECL int archive_read_disk_set_symlink_logical(struct archive *);
0972 /* Follow no symlinks. */
0973 __LA_DECL int archive_read_disk_set_symlink_physical(struct archive *);
0974 /* Follow symlink initially, then not. */
0975 __LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *);
0976 /* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */
0977 __LA_DECL int archive_read_disk_entry_from_file(struct archive *,
0978     struct archive_entry *, int /* fd */, const struct stat *);
0979 /* Look up gname for gid or uname for uid. */
0980 /* Default implementations are very, very stupid. */
0981 __LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t);
0982 __LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t);
0983 /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
0984  * results for performance. */
0985 __LA_DECL int   archive_read_disk_set_standard_lookup(struct archive *);
0986 /* You can install your own lookups if you like. */
0987 __LA_DECL int   archive_read_disk_set_gname_lookup(struct archive *,
0988     void * /* private_data */,
0989     const char *(* /* lookup_fn */)(void *, la_int64_t),
0990     void (* /* cleanup_fn */)(void *));
0991 __LA_DECL int   archive_read_disk_set_uname_lookup(struct archive *,
0992     void * /* private_data */,
0993     const char *(* /* lookup_fn */)(void *, la_int64_t),
0994     void (* /* cleanup_fn */)(void *));
0995 /* Start traversal. */
0996 __LA_DECL int   archive_read_disk_open(struct archive *, const char *);
0997 __LA_DECL int   archive_read_disk_open_w(struct archive *, const wchar_t *);
0998 /*
0999  * Request that current entry be visited.  If you invoke it on every
1000  * directory, you'll get a physical traversal.  This is ignored if the
1001  * current entry isn't a directory or a link to a directory.  So, if
1002  * you invoke this on every returned path, you'll get a full logical
1003  * traversal.
1004  */
1005 __LA_DECL int   archive_read_disk_descend(struct archive *);
1006 __LA_DECL int   archive_read_disk_can_descend(struct archive *);
1007 __LA_DECL int   archive_read_disk_current_filesystem(struct archive *);
1008 __LA_DECL int   archive_read_disk_current_filesystem_is_synthetic(struct archive *);
1009 __LA_DECL int   archive_read_disk_current_filesystem_is_remote(struct archive *);
1010 /* Request that the access time of the entry visited by traversal be restored. */
1011 __LA_DECL int  archive_read_disk_set_atime_restored(struct archive *);
1012 /*
1013  * Set behavior. The "flags" argument selects optional behavior.
1014  */
1015 /* Request that the access time of the entry visited by traversal be restored.
1016  * This is the same as archive_read_disk_set_atime_restored. */
1017 #define ARCHIVE_READDISK_RESTORE_ATIME      (0x0001)
1018 /* Default: Do not skip an entry which has nodump flags. */
1019 #define ARCHIVE_READDISK_HONOR_NODUMP       (0x0002)
1020 /* Default: Skip a mac resource fork file whose prefix is "._" because of
1021  * using copyfile. */
1022 #define ARCHIVE_READDISK_MAC_COPYFILE       (0x0004)
1023 /* Default: Traverse mount points. */
1024 #define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008)
1025 /* Default: Xattrs are read from disk. */
1026 #define ARCHIVE_READDISK_NO_XATTR       (0x0010)
1027 /* Default: ACLs are read from disk. */
1028 #define ARCHIVE_READDISK_NO_ACL         (0x0020)
1029 /* Default: File flags are read from disk. */
1030 #define ARCHIVE_READDISK_NO_FFLAGS      (0x0040)
1031 /* Default: Sparse file information is read from disk. */
1032 #define ARCHIVE_READDISK_NO_SPARSE      (0x0080)
1033 
1034 __LA_DECL int  archive_read_disk_set_behavior(struct archive *,
1035             int flags);
1036 
1037 /*
1038  * Set archive_match object that will be used in archive_read_disk to
1039  * know whether an entry should be skipped. The callback function
1040  * _excluded_func will be invoked when an entry is skipped by the result
1041  * of archive_match.
1042  */
1043 __LA_DECL int   archive_read_disk_set_matching(struct archive *,
1044             struct archive *_matching, void (*_excluded_func)
1045             (struct archive *, void *, struct archive_entry *),
1046             void *_client_data);
1047 __LA_DECL int   archive_read_disk_set_metadata_filter_callback(struct archive *,
1048             int (*_metadata_filter_func)(struct archive *, void *,
1049                 struct archive_entry *), void *_client_data);
1050 
1051 /* Simplified cleanup interface;
1052  * This calls archive_read_free() or archive_write_free() as needed. */
1053 __LA_DECL int   archive_free(struct archive *);
1054 
1055 /*
1056  * Accessor functions to read/set various information in
1057  * the struct archive object:
1058  */
1059 
1060 /* Number of filters in the current filter pipeline. */
1061 /* Filter #0 is the one closest to the format, -1 is a synonym for the
1062  * last filter, which is always the pseudo-filter that wraps the
1063  * client callbacks. */
1064 __LA_DECL int        archive_filter_count(struct archive *);
1065 __LA_DECL la_int64_t     archive_filter_bytes(struct archive *, int);
1066 __LA_DECL int        archive_filter_code(struct archive *, int);
1067 __LA_DECL const char *   archive_filter_name(struct archive *, int);
1068 
1069 #if ARCHIVE_VERSION_NUMBER < 4000000
1070 /* These don't properly handle multiple filters, so are deprecated and
1071  * will eventually be removed. */
1072 /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
1073 __LA_DECL la_int64_t     archive_position_compressed(struct archive *)
1074                 __LA_DEPRECATED;
1075 /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
1076 __LA_DECL la_int64_t     archive_position_uncompressed(struct archive *)
1077                 __LA_DEPRECATED;
1078 /* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
1079 __LA_DECL const char    *archive_compression_name(struct archive *)
1080                 __LA_DEPRECATED;
1081 /* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
1082 __LA_DECL int        archive_compression(struct archive *)
1083                 __LA_DEPRECATED;
1084 #endif
1085 
1086 __LA_DECL int        archive_errno(struct archive *);
1087 __LA_DECL const char    *archive_error_string(struct archive *);
1088 __LA_DECL const char    *archive_format_name(struct archive *);
1089 __LA_DECL int        archive_format(struct archive *);
1090 __LA_DECL void       archive_clear_error(struct archive *);
1091 __LA_DECL void       archive_set_error(struct archive *, int _err,
1092                 const char *fmt, ...) __LA_PRINTF(3, 4);
1093 __LA_DECL void       archive_copy_error(struct archive *dest,
1094                 struct archive *src);
1095 __LA_DECL int        archive_file_count(struct archive *);
1096 
1097 /*
1098  * ARCHIVE_MATCH API
1099  */
1100 __LA_DECL struct archive *archive_match_new(void);
1101 __LA_DECL int   archive_match_free(struct archive *);
1102 
1103 /*
1104  * Test if archive_entry is excluded.
1105  * This is a convenience function. This is the same as calling all
1106  * archive_match_path_excluded, archive_match_time_excluded
1107  * and archive_match_owner_excluded.
1108  */
1109 __LA_DECL int   archive_match_excluded(struct archive *,
1110             struct archive_entry *);
1111 
1112 /*
1113  * Test if pathname is excluded. The conditions are set by following functions.
1114  */
1115 __LA_DECL int   archive_match_path_excluded(struct archive *,
1116             struct archive_entry *);
1117 /* Control recursive inclusion of directory content when directory is included. Default on. */
1118 __LA_DECL int   archive_match_set_inclusion_recursion(struct archive *, int);
1119 /* Add exclusion pathname pattern. */
1120 __LA_DECL int   archive_match_exclude_pattern(struct archive *, const char *);
1121 __LA_DECL int   archive_match_exclude_pattern_w(struct archive *,
1122             const wchar_t *);
1123 /* Add exclusion pathname pattern from file. */
1124 __LA_DECL int   archive_match_exclude_pattern_from_file(struct archive *,
1125             const char *, int _nullSeparator);
1126 __LA_DECL int   archive_match_exclude_pattern_from_file_w(struct archive *,
1127             const wchar_t *, int _nullSeparator);
1128 /* Add inclusion pathname pattern. */
1129 __LA_DECL int   archive_match_include_pattern(struct archive *, const char *);
1130 __LA_DECL int   archive_match_include_pattern_w(struct archive *,
1131             const wchar_t *);
1132 /* Add inclusion pathname pattern from file. */
1133 __LA_DECL int   archive_match_include_pattern_from_file(struct archive *,
1134             const char *, int _nullSeparator);
1135 __LA_DECL int   archive_match_include_pattern_from_file_w(struct archive *,
1136             const wchar_t *, int _nullSeparator);
1137 /*
1138  * How to get statistic information for inclusion patterns.
1139  */
1140 /* Return the amount number of unmatched inclusion patterns. */
1141 __LA_DECL int   archive_match_path_unmatched_inclusions(struct archive *);
1142 /* Return the pattern of unmatched inclusion with ARCHIVE_OK.
1143  * Return ARCHIVE_EOF if there is no inclusion pattern. */
1144 __LA_DECL int   archive_match_path_unmatched_inclusions_next(
1145             struct archive *, const char **);
1146 __LA_DECL int   archive_match_path_unmatched_inclusions_next_w(
1147             struct archive *, const wchar_t **);
1148 
1149 /*
1150  * Test if a file is excluded by its time stamp.
1151  * The conditions are set by following functions.
1152  */
1153 __LA_DECL int   archive_match_time_excluded(struct archive *,
1154             struct archive_entry *);
1155 
1156 /*
1157  * Flags to tell a matching type of time stamps. These are used for
1158  * following functions.
1159  */
1160 /* Time flag: mtime to be tested. */
1161 #define ARCHIVE_MATCH_MTIME (0x0100)
1162 /* Time flag: ctime to be tested. */
1163 #define ARCHIVE_MATCH_CTIME (0x0200)
1164 /* Comparison flag: Match the time if it is newer than. */
1165 #define ARCHIVE_MATCH_NEWER (0x0001)
1166 /* Comparison flag: Match the time if it is older than. */
1167 #define ARCHIVE_MATCH_OLDER (0x0002)
1168 /* Comparison flag: Match the time if it is equal to. */
1169 #define ARCHIVE_MATCH_EQUAL (0x0010)
1170 /* Set inclusion time. */
1171 __LA_DECL int   archive_match_include_time(struct archive *, int _flag,
1172             time_t _sec, long _nsec);
1173 /* Set inclusion time by a date string. */
1174 __LA_DECL int   archive_match_include_date(struct archive *, int _flag,
1175             const char *_datestr);
1176 __LA_DECL int   archive_match_include_date_w(struct archive *, int _flag,
1177             const wchar_t *_datestr);
1178 /* Set inclusion time by a particular file. */
1179 __LA_DECL int   archive_match_include_file_time(struct archive *,
1180             int _flag, const char *_pathname);
1181 __LA_DECL int   archive_match_include_file_time_w(struct archive *,
1182             int _flag, const wchar_t *_pathname);
1183 /* Add exclusion entry. */
1184 __LA_DECL int   archive_match_exclude_entry(struct archive *,
1185             int _flag, struct archive_entry *);
1186 
1187 /*
1188  * Test if a file is excluded by its uid ,gid, uname or gname.
1189  * The conditions are set by following functions.
1190  */
1191 __LA_DECL int   archive_match_owner_excluded(struct archive *,
1192             struct archive_entry *);
1193 /* Add inclusion uid, gid, uname and gname. */
1194 __LA_DECL int   archive_match_include_uid(struct archive *, la_int64_t);
1195 __LA_DECL int   archive_match_include_gid(struct archive *, la_int64_t);
1196 __LA_DECL int   archive_match_include_uname(struct archive *, const char *);
1197 __LA_DECL int   archive_match_include_uname_w(struct archive *,
1198             const wchar_t *);
1199 __LA_DECL int   archive_match_include_gname(struct archive *, const char *);
1200 __LA_DECL int   archive_match_include_gname_w(struct archive *,
1201             const wchar_t *);
1202 
1203 /* Utility functions */
1204 /* Convenience function to sort a NULL terminated list of strings */
1205 __LA_DECL int archive_utility_string_sort(char **);
1206 
1207 #ifdef __cplusplus
1208 }
1209 #endif
1210 
1211 /* These are meaningless outside of this header. */
1212 #undef __LA_DECL
1213 
1214 #endif /* !ARCHIVE_H_INCLUDED */