archive.h revision 324417
1228753Smm/*- 2232153Smm * Copyright (c) 2003-2010 Tim Kientzle 3228753Smm * All rights reserved. 4228753Smm * 5228753Smm * Redistribution and use in source and binary forms, with or without 6228753Smm * modification, are permitted provided that the following conditions 7228753Smm * are met: 8228753Smm * 1. Redistributions of source code must retain the above copyright 9228753Smm * notice, this list of conditions and the following disclaimer. 10228753Smm * 2. Redistributions in binary form must reproduce the above copyright 11228753Smm * notice, this list of conditions and the following disclaimer in the 12228753Smm * documentation and/or other materials provided with the distribution. 13228753Smm * 14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24228753Smm * 25228763Smm * $FreeBSD: stable/11/contrib/libarchive/libarchive/archive.h 324417 2017-10-08 20:54:53Z mm $ 26228753Smm */ 27228753Smm 28228753Smm#ifndef ARCHIVE_H_INCLUDED 29228753Smm#define ARCHIVE_H_INCLUDED 30228753Smm 31299529Smm/* 32299529Smm * The version number is expressed as a single integer that makes it 33299529Smm * easy to compare versions at build time: for version a.b.c, the 34299529Smm * version number is printf("%d%03d%03d",a,b,c). For example, if you 35299529Smm * know your application requires version 2.12.108 or later, you can 36299529Smm * assert that ARCHIVE_VERSION_NUMBER >= 2012108. 37299529Smm */ 38299529Smm/* Note: Compiler will complain if this does not match archive_entry.h! */ 39321303Smm#define ARCHIVE_VERSION_NUMBER 3003002 40299529Smm 41232153Smm#include <sys/stat.h> 42232153Smm#include <stddef.h> /* for wchar_t */ 43232153Smm#include <stdio.h> /* For FILE * */ 44299529Smm#include <time.h> /* For time_t */ 45232153Smm 46228753Smm/* 47228753Smm * Note: archive.h is for use outside of libarchive; the configuration 48228753Smm * headers (config.h, archive_platform.h, etc.) are purely internal. 49228753Smm * Do NOT use HAVE_XXX configuration macros to control the behavior of 50228753Smm * this header! If you must conditionalize, use predefined compiler and/or 51228753Smm * platform macros. 52228753Smm */ 53228753Smm#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 54232153Smm# include <stdint.h> 55299529Smm#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) 56232153Smm# include <inttypes.h> 57228753Smm#endif 58228753Smm 59299529Smm/* Get appropriate definitions of 64-bit integer */ 60299529Smm#if !defined(__LA_INT64_T_DEFINED) 61299529Smm/* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */ 62299529Smm# if ARCHIVE_VERSION_NUMBER < 4000000 63299529Smm#define __LA_INT64_T la_int64_t 64299529Smm# endif 65299529Smm#define __LA_INT64_T_DEFINED 66299529Smm# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) 67299529Smmtypedef __int64 la_int64_t; 68228753Smm# else 69299529Smm# include <unistd.h> /* ssize_t */ 70299529Smm# if defined(_SCO_DS) || defined(__osf__) 71299529Smmtypedef long long la_int64_t; 72299529Smm# else 73299529Smmtypedef int64_t la_int64_t; 74299529Smm# endif 75228753Smm# endif 76299529Smm#endif 77299529Smm 78299529Smm/* The la_ssize_t should match the type used in 'struct stat' */ 79299529Smm#if !defined(__LA_SSIZE_T_DEFINED) 80299529Smm/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */ 81299529Smm# if ARCHIVE_VERSION_NUMBER < 4000000 82299529Smm#define __LA_SSIZE_T la_ssize_t 83299529Smm# endif 84299529Smm#define __LA_SSIZE_T_DEFINED 85299529Smm# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) 86299529Smm# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) 87299529Smmtypedef ssize_t la_ssize_t; 88299529Smm# elif defined(_WIN64) 89299529Smmtypedef __int64 la_ssize_t; 90299529Smm# else 91299529Smmtypedef long la_ssize_t; 92299529Smm# endif 93299529Smm# else 94238856Smm# include <unistd.h> /* ssize_t */ 95299529Smmtypedef ssize_t la_ssize_t; 96232153Smm# endif 97228753Smm#endif 98228753Smm 99299529Smm/* Large file support for Android */ 100299529Smm#ifdef __ANDROID__ 101299529Smm#include "android_lf.h" 102299529Smm#endif 103299529Smm 104228753Smm/* 105228753Smm * On Windows, define LIBARCHIVE_STATIC if you're building or using a 106228753Smm * .lib. The default here assumes you're building a DLL. Only 107228753Smm * libarchive source should ever define __LIBARCHIVE_BUILD. 108228753Smm */ 109228753Smm#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC) 110228753Smm# ifdef __LIBARCHIVE_BUILD 111228753Smm# ifdef __GNUC__ 112228753Smm# define __LA_DECL __attribute__((dllexport)) extern 113228753Smm# else 114228753Smm# define __LA_DECL __declspec(dllexport) 115228753Smm# endif 116228753Smm# else 117228753Smm# ifdef __GNUC__ 118232153Smm# define __LA_DECL 119228753Smm# else 120228753Smm# define __LA_DECL __declspec(dllimport) 121228753Smm# endif 122228753Smm# endif 123228753Smm#else 124228753Smm/* Static libraries or non-Windows needs no special declaration. */ 125228753Smm# define __LA_DECL 126228753Smm#endif 127228753Smm 128232153Smm#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__) 129228753Smm#define __LA_PRINTF(fmtarg, firstvararg) \ 130228753Smm __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 131228753Smm#else 132228753Smm#define __LA_PRINTF(fmtarg, firstvararg) /* nothing */ 133228753Smm#endif 134228753Smm 135248616Smm#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1 136248616Smm# define __LA_DEPRECATED __attribute__((deprecated)) 137248616Smm#else 138248616Smm# define __LA_DEPRECATED 139248616Smm#endif 140248616Smm 141228753Smm#ifdef __cplusplus 142228753Smmextern "C" { 143228753Smm#endif 144228753Smm 145228753Smm/* 146228753Smm * The version number is provided as both a macro and a function. 147228753Smm * The macro identifies the installed header; the function identifies 148228753Smm * the library version (which may not be the same if you're using a 149228753Smm * dynamically-linked version of the library). Of course, if the 150228753Smm * header and library are very different, you should expect some 151228753Smm * strangeness. Don't do that. 152228753Smm */ 153228753Smm__LA_DECL int archive_version_number(void); 154228753Smm 155228753Smm/* 156228753Smm * Textual name/version of the library, useful for version displays. 157228753Smm */ 158321303Smm#define ARCHIVE_VERSION_ONLY_STRING "3.3.2" 159299529Smm#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING 160228753Smm__LA_DECL const char * archive_version_string(void); 161228753Smm 162299529Smm/* 163299529Smm * Detailed textual name/version of the library and its dependencies. 164299529Smm * This has the form: 165299529Smm * "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..." 166299529Smm * the list of libraries described here will vary depending on how 167299529Smm * libarchive was compiled. 168299529Smm */ 169299529Smm__LA_DECL const char * archive_version_details(void); 170299529Smm 171299529Smm/* 172299529Smm * Returns NULL if libarchive was compiled without the associated library. 173299529Smm * Otherwise, returns the version number that libarchive was compiled 174299529Smm * against. 175299529Smm */ 176299529Smm__LA_DECL const char * archive_zlib_version(void); 177299529Smm__LA_DECL const char * archive_liblzma_version(void); 178299529Smm__LA_DECL const char * archive_bzlib_version(void); 179299529Smm__LA_DECL const char * archive_liblz4_version(void); 180324417Smm__LA_DECL const char * archive_libzstd_version(void); 181299529Smm 182228753Smm/* Declare our basic types. */ 183228753Smmstruct archive; 184228753Smmstruct archive_entry; 185228753Smm 186228753Smm/* 187228753Smm * Error codes: Use archive_errno() and archive_error_string() 188228753Smm * to retrieve details. Unless specified otherwise, all functions 189228753Smm * that return 'int' use these codes. 190228753Smm */ 191228753Smm#define ARCHIVE_EOF 1 /* Found end of archive. */ 192228753Smm#define ARCHIVE_OK 0 /* Operation was successful. */ 193228753Smm#define ARCHIVE_RETRY (-10) /* Retry might succeed. */ 194228753Smm#define ARCHIVE_WARN (-20) /* Partial success. */ 195228753Smm/* For example, if write_header "fails", then you can't push data. */ 196228753Smm#define ARCHIVE_FAILED (-25) /* Current operation cannot complete. */ 197228753Smm/* But if write_header is "fatal," then this archive is dead and useless. */ 198228753Smm#define ARCHIVE_FATAL (-30) /* No more operations are possible. */ 199228753Smm 200228753Smm/* 201228753Smm * As far as possible, archive_errno returns standard platform errno codes. 202228753Smm * Of course, the details vary by platform, so the actual definitions 203228753Smm * here are stored in "archive_platform.h". The symbols are listed here 204228753Smm * for reference; as a rule, clients should not need to know the exact 205228753Smm * platform-dependent error code. 206228753Smm */ 207228753Smm/* Unrecognized or invalid file format. */ 208228753Smm/* #define ARCHIVE_ERRNO_FILE_FORMAT */ 209228753Smm/* Illegal usage of the library. */ 210228753Smm/* #define ARCHIVE_ERRNO_PROGRAMMER_ERROR */ 211228753Smm/* Unknown or unclassified error. */ 212228753Smm/* #define ARCHIVE_ERRNO_MISC */ 213228753Smm 214228753Smm/* 215228753Smm * Callbacks are invoked to automatically read/skip/write/open/close the 216228753Smm * archive. You can provide your own for complex tasks (like breaking 217228753Smm * archives across multiple tapes) or use standard ones built into the 218228753Smm * library. 219228753Smm */ 220228753Smm 221228753Smm/* Returns pointer and size of next block of data from archive. */ 222299529Smmtypedef la_ssize_t archive_read_callback(struct archive *, 223228753Smm void *_client_data, const void **_buffer); 224228753Smm 225232153Smm/* Skips at most request bytes from archive and returns the skipped amount. 226232153Smm * This may skip fewer bytes than requested; it may even skip zero bytes. 227232153Smm * If you do skip fewer bytes than requested, libarchive will invoke your 228232153Smm * read callback and discard data as necessary to make up the full skip. 229232153Smm */ 230299529Smmtypedef la_int64_t archive_skip_callback(struct archive *, 231299529Smm void *_client_data, la_int64_t request); 232228753Smm 233232153Smm/* Seeks to specified location in the file and returns the position. 234232153Smm * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h. 235232153Smm * Return ARCHIVE_FATAL if the seek fails for any reason. 236232153Smm */ 237299529Smmtypedef la_int64_t archive_seek_callback(struct archive *, 238299529Smm void *_client_data, la_int64_t offset, int whence); 239232153Smm 240228753Smm/* Returns size actually written, zero on EOF, -1 on error. */ 241299529Smmtypedef la_ssize_t archive_write_callback(struct archive *, 242228753Smm void *_client_data, 243228753Smm const void *_buffer, size_t _length); 244228753Smm 245228753Smmtypedef int archive_open_callback(struct archive *, void *_client_data); 246228753Smm 247228753Smmtypedef int archive_close_callback(struct archive *, void *_client_data); 248228753Smm 249248616Smm/* Switches from one client data object to the next/prev client data object. 250248616Smm * This is useful for reading from different data blocks such as a set of files 251248616Smm * that make up one large file. 252248616Smm */ 253248616Smmtypedef int archive_switch_callback(struct archive *, void *_client_data1, 254248616Smm void *_client_data2); 255248616Smm 256228753Smm/* 257299529Smm * Returns a passphrase used for encryption or decryption, NULL on nothing 258299529Smm * to do and give it up. 259299529Smm */ 260299529Smmtypedef const char *archive_passphrase_callback(struct archive *, 261299529Smm void *_client_data); 262299529Smm 263299529Smm/* 264232153Smm * Codes to identify various stream filters. 265228753Smm */ 266232153Smm#define ARCHIVE_FILTER_NONE 0 267232153Smm#define ARCHIVE_FILTER_GZIP 1 268232153Smm#define ARCHIVE_FILTER_BZIP2 2 269232153Smm#define ARCHIVE_FILTER_COMPRESS 3 270232153Smm#define ARCHIVE_FILTER_PROGRAM 4 271232153Smm#define ARCHIVE_FILTER_LZMA 5 272232153Smm#define ARCHIVE_FILTER_XZ 6 273232153Smm#define ARCHIVE_FILTER_UU 7 274232153Smm#define ARCHIVE_FILTER_RPM 8 275232153Smm#define ARCHIVE_FILTER_LZIP 9 276248616Smm#define ARCHIVE_FILTER_LRZIP 10 277248616Smm#define ARCHIVE_FILTER_LZOP 11 278248616Smm#define ARCHIVE_FILTER_GRZIP 12 279299529Smm#define ARCHIVE_FILTER_LZ4 13 280324417Smm#define ARCHIVE_FILTER_ZSTD 14 281228753Smm 282232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 283232153Smm#define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE 284232153Smm#define ARCHIVE_COMPRESSION_GZIP ARCHIVE_FILTER_GZIP 285232153Smm#define ARCHIVE_COMPRESSION_BZIP2 ARCHIVE_FILTER_BZIP2 286232153Smm#define ARCHIVE_COMPRESSION_COMPRESS ARCHIVE_FILTER_COMPRESS 287232153Smm#define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM 288232153Smm#define ARCHIVE_COMPRESSION_LZMA ARCHIVE_FILTER_LZMA 289232153Smm#define ARCHIVE_COMPRESSION_XZ ARCHIVE_FILTER_XZ 290232153Smm#define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU 291232153Smm#define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM 292232153Smm#define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP 293248616Smm#define ARCHIVE_COMPRESSION_LRZIP ARCHIVE_FILTER_LRZIP 294232153Smm#endif 295232153Smm 296228753Smm/* 297228753Smm * Codes returned by archive_format. 298228753Smm * 299228753Smm * Top 16 bits identifies the format family (e.g., "tar"); lower 300228753Smm * 16 bits indicate the variant. This is updated by read_next_header. 301228753Smm * Note that the lower 16 bits will often vary from entry to entry. 302228753Smm * In some cases, this variation occurs as libarchive learns more about 303228753Smm * the archive (for example, later entries might utilize extensions that 304228753Smm * weren't necessary earlier in the archive; in this case, libarchive 305228753Smm * will change the format code to indicate the extended format that 306228753Smm * was used). In other cases, it's because different tools have 307228753Smm * modified the archive and so different parts of the archive 308232153Smm * actually have slightly different formats. (Both tar and cpio store 309228753Smm * format codes in each entry, so it is quite possible for each 310228753Smm * entry to be in a different format.) 311228753Smm */ 312228753Smm#define ARCHIVE_FORMAT_BASE_MASK 0xff0000 313228753Smm#define ARCHIVE_FORMAT_CPIO 0x10000 314228753Smm#define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1) 315228753Smm#define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2) 316228753Smm#define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3) 317228753Smm#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4) 318228753Smm#define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5) 319232153Smm#define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6) 320228753Smm#define ARCHIVE_FORMAT_SHAR 0x20000 321228753Smm#define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1) 322228753Smm#define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2) 323228753Smm#define ARCHIVE_FORMAT_TAR 0x30000 324228753Smm#define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1) 325228753Smm#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2) 326228753Smm#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3) 327228753Smm#define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4) 328228753Smm#define ARCHIVE_FORMAT_ISO9660 0x40000 329228753Smm#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1) 330228753Smm#define ARCHIVE_FORMAT_ZIP 0x50000 331228753Smm#define ARCHIVE_FORMAT_EMPTY 0x60000 332228753Smm#define ARCHIVE_FORMAT_AR 0x70000 333228753Smm#define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1) 334228753Smm#define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2) 335228753Smm#define ARCHIVE_FORMAT_MTREE 0x80000 336228753Smm#define ARCHIVE_FORMAT_RAW 0x90000 337228753Smm#define ARCHIVE_FORMAT_XAR 0xA0000 338232153Smm#define ARCHIVE_FORMAT_LHA 0xB0000 339232153Smm#define ARCHIVE_FORMAT_CAB 0xC0000 340232153Smm#define ARCHIVE_FORMAT_RAR 0xD0000 341232153Smm#define ARCHIVE_FORMAT_7ZIP 0xE0000 342299529Smm#define ARCHIVE_FORMAT_WARC 0xF0000 343228753Smm 344299529Smm/* 345299529Smm * Codes returned by archive_read_format_capabilities(). 346299529Smm * 347299529Smm * This list can be extended with values between 0 and 0xffff. 348299529Smm * The original purpose of this list was to let different archive 349299529Smm * format readers expose their general capabilities in terms of 350299529Smm * encryption. 351299529Smm */ 352299529Smm#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */ 353299529Smm#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */ 354299529Smm#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */ 355299529Smm 356299529Smm/* 357299529Smm * Codes returned by archive_read_has_encrypted_entries(). 358299529Smm * 359299529Smm * In case the archive does not support encryption detection at all 360299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader 361299529Smm * for some other reason (e.g. not enough bytes read) cannot say if 362299529Smm * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW 363299529Smm * is returned. 364299529Smm */ 365299529Smm#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2 366299529Smm#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1 367299529Smm 368228753Smm/*- 369228753Smm * Basic outline for reading an archive: 370228753Smm * 1) Ask archive_read_new for an archive reader object. 371228753Smm * 2) Update any global properties as appropriate. 372228753Smm * In particular, you'll certainly want to call appropriate 373228753Smm * archive_read_support_XXX functions. 374228753Smm * 3) Call archive_read_open_XXX to open the archive 375228753Smm * 4) Repeatedly call archive_read_next_header to get information about 376228753Smm * successive archive entries. Call archive_read_data to extract 377228753Smm * data for entries of interest. 378311041Smm * 5) Call archive_read_free to end processing. 379228753Smm */ 380228753Smm__LA_DECL struct archive *archive_read_new(void); 381228753Smm 382228753Smm/* 383228753Smm * The archive_read_support_XXX calls enable auto-detect for this 384228753Smm * archive handle. They also link in the necessary support code. 385228753Smm * For example, if you don't want bzlib linked in, don't invoke 386228753Smm * support_compression_bzip2(). The "all" functions provide the 387228753Smm * obvious shorthand. 388228753Smm */ 389232153Smm 390232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 391248616Smm__LA_DECL int archive_read_support_compression_all(struct archive *) 392248616Smm __LA_DEPRECATED; 393248616Smm__LA_DECL int archive_read_support_compression_bzip2(struct archive *) 394248616Smm __LA_DEPRECATED; 395248616Smm__LA_DECL int archive_read_support_compression_compress(struct archive *) 396248616Smm __LA_DEPRECATED; 397248616Smm__LA_DECL int archive_read_support_compression_gzip(struct archive *) 398248616Smm __LA_DEPRECATED; 399248616Smm__LA_DECL int archive_read_support_compression_lzip(struct archive *) 400248616Smm __LA_DEPRECATED; 401248616Smm__LA_DECL int archive_read_support_compression_lzma(struct archive *) 402248616Smm __LA_DEPRECATED; 403248616Smm__LA_DECL int archive_read_support_compression_none(struct archive *) 404248616Smm __LA_DEPRECATED; 405232153Smm__LA_DECL int archive_read_support_compression_program(struct archive *, 406248616Smm const char *command) __LA_DEPRECATED; 407232153Smm__LA_DECL int archive_read_support_compression_program_signature 408232153Smm (struct archive *, const char *, 409248616Smm const void * /* match */, size_t) __LA_DEPRECATED; 410228753Smm 411248616Smm__LA_DECL int archive_read_support_compression_rpm(struct archive *) 412248616Smm __LA_DEPRECATED; 413248616Smm__LA_DECL int archive_read_support_compression_uu(struct archive *) 414248616Smm __LA_DEPRECATED; 415248616Smm__LA_DECL int archive_read_support_compression_xz(struct archive *) 416248616Smm __LA_DEPRECATED; 417232153Smm#endif 418228753Smm 419232153Smm__LA_DECL int archive_read_support_filter_all(struct archive *); 420232153Smm__LA_DECL int archive_read_support_filter_bzip2(struct archive *); 421232153Smm__LA_DECL int archive_read_support_filter_compress(struct archive *); 422232153Smm__LA_DECL int archive_read_support_filter_gzip(struct archive *); 423248616Smm__LA_DECL int archive_read_support_filter_grzip(struct archive *); 424248616Smm__LA_DECL int archive_read_support_filter_lrzip(struct archive *); 425299529Smm__LA_DECL int archive_read_support_filter_lz4(struct archive *); 426232153Smm__LA_DECL int archive_read_support_filter_lzip(struct archive *); 427232153Smm__LA_DECL int archive_read_support_filter_lzma(struct archive *); 428248616Smm__LA_DECL int archive_read_support_filter_lzop(struct archive *); 429232153Smm__LA_DECL int archive_read_support_filter_none(struct archive *); 430232153Smm__LA_DECL int archive_read_support_filter_program(struct archive *, 431232153Smm const char *command); 432232153Smm__LA_DECL int archive_read_support_filter_program_signature 433248616Smm (struct archive *, const char * /* cmd */, 434232153Smm const void * /* match */, size_t); 435232153Smm__LA_DECL int archive_read_support_filter_rpm(struct archive *); 436232153Smm__LA_DECL int archive_read_support_filter_uu(struct archive *); 437232153Smm__LA_DECL int archive_read_support_filter_xz(struct archive *); 438324417Smm__LA_DECL int archive_read_support_filter_zstd(struct archive *); 439228753Smm 440232153Smm__LA_DECL int archive_read_support_format_7zip(struct archive *); 441232153Smm__LA_DECL int archive_read_support_format_all(struct archive *); 442232153Smm__LA_DECL int archive_read_support_format_ar(struct archive *); 443232153Smm__LA_DECL int archive_read_support_format_by_code(struct archive *, int); 444232153Smm__LA_DECL int archive_read_support_format_cab(struct archive *); 445232153Smm__LA_DECL int archive_read_support_format_cpio(struct archive *); 446232153Smm__LA_DECL int archive_read_support_format_empty(struct archive *); 447232153Smm__LA_DECL int archive_read_support_format_gnutar(struct archive *); 448232153Smm__LA_DECL int archive_read_support_format_iso9660(struct archive *); 449232153Smm__LA_DECL int archive_read_support_format_lha(struct archive *); 450232153Smm__LA_DECL int archive_read_support_format_mtree(struct archive *); 451232153Smm__LA_DECL int archive_read_support_format_rar(struct archive *); 452232153Smm__LA_DECL int archive_read_support_format_raw(struct archive *); 453232153Smm__LA_DECL int archive_read_support_format_tar(struct archive *); 454299529Smm__LA_DECL int archive_read_support_format_warc(struct archive *); 455232153Smm__LA_DECL int archive_read_support_format_xar(struct archive *); 456299529Smm/* archive_read_support_format_zip() enables both streamable and seekable 457299529Smm * zip readers. */ 458232153Smm__LA_DECL int archive_read_support_format_zip(struct archive *); 459299529Smm/* Reads Zip archives as stream from beginning to end. Doesn't 460299529Smm * correctly handle SFX ZIP files or ZIP archives that have been modified 461299529Smm * in-place. */ 462299529Smm__LA_DECL int archive_read_support_format_zip_streamable(struct archive *); 463299529Smm/* Reads starting from central directory; requires seekable input. */ 464299529Smm__LA_DECL int archive_read_support_format_zip_seekable(struct archive *); 465232153Smm 466248616Smm/* Functions to manually set the format and filters to be used. This is 467248616Smm * useful to bypass the bidding process when the format and filters to use 468248616Smm * is known in advance. 469248616Smm */ 470248616Smm__LA_DECL int archive_read_set_format(struct archive *, int); 471248616Smm__LA_DECL int archive_read_append_filter(struct archive *, int); 472248616Smm__LA_DECL int archive_read_append_filter_program(struct archive *, 473248616Smm const char *); 474248616Smm__LA_DECL int archive_read_append_filter_program_signature 475248616Smm (struct archive *, const char *, const void * /* match */, size_t); 476248616Smm 477232153Smm/* Set various callbacks. */ 478232153Smm__LA_DECL int archive_read_set_open_callback(struct archive *, 479232153Smm archive_open_callback *); 480232153Smm__LA_DECL int archive_read_set_read_callback(struct archive *, 481232153Smm archive_read_callback *); 482232153Smm__LA_DECL int archive_read_set_seek_callback(struct archive *, 483232153Smm archive_seek_callback *); 484232153Smm__LA_DECL int archive_read_set_skip_callback(struct archive *, 485232153Smm archive_skip_callback *); 486232153Smm__LA_DECL int archive_read_set_close_callback(struct archive *, 487232153Smm archive_close_callback *); 488248616Smm/* Callback used to switch between one data object to the next */ 489248616Smm__LA_DECL int archive_read_set_switch_callback(struct archive *, 490248616Smm archive_switch_callback *); 491248616Smm 492248616Smm/* This sets the first data object. */ 493232153Smm__LA_DECL int archive_read_set_callback_data(struct archive *, void *); 494248616Smm/* This sets data object at specified index */ 495248616Smm__LA_DECL int archive_read_set_callback_data2(struct archive *, void *, 496248616Smm unsigned int); 497248616Smm/* This adds a data object at the specified index. */ 498248616Smm__LA_DECL int archive_read_add_callback_data(struct archive *, void *, 499248616Smm unsigned int); 500248616Smm/* This appends a data object to the end of list */ 501248616Smm__LA_DECL int archive_read_append_callback_data(struct archive *, void *); 502248616Smm/* This prepends a data object to the beginning of list */ 503248616Smm__LA_DECL int archive_read_prepend_callback_data(struct archive *, void *); 504248616Smm 505232153Smm/* Opening freezes the callbacks. */ 506232153Smm__LA_DECL int archive_read_open1(struct archive *); 507232153Smm 508232153Smm/* Convenience wrappers around the above. */ 509232153Smm__LA_DECL int archive_read_open(struct archive *, void *_client_data, 510228753Smm archive_open_callback *, archive_read_callback *, 511228753Smm archive_close_callback *); 512232153Smm__LA_DECL int archive_read_open2(struct archive *, void *_client_data, 513228753Smm archive_open_callback *, archive_read_callback *, 514228753Smm archive_skip_callback *, archive_close_callback *); 515228753Smm 516228753Smm/* 517228753Smm * A variety of shortcuts that invoke archive_read_open() with 518228753Smm * canned callbacks suitable for common situations. The ones that 519228753Smm * accept a block size handle tape blocking correctly. 520228753Smm */ 521228753Smm/* Use this if you know the filename. Note: NULL indicates stdin. */ 522232153Smm__LA_DECL int archive_read_open_filename(struct archive *, 523228753Smm const char *_filename, size_t _block_size); 524248616Smm/* Use this for reading multivolume files by filenames. 525248616Smm * NOTE: Must be NULL terminated. Sorting is NOT done. */ 526248616Smm__LA_DECL int archive_read_open_filenames(struct archive *, 527248616Smm const char **_filenames, size_t _block_size); 528232153Smm__LA_DECL int archive_read_open_filename_w(struct archive *, 529232153Smm const wchar_t *_filename, size_t _block_size); 530228753Smm/* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ 531232153Smm__LA_DECL int archive_read_open_file(struct archive *, 532248616Smm const char *_filename, size_t _block_size) __LA_DEPRECATED; 533228753Smm/* Read an archive that's stored in memory. */ 534232153Smm__LA_DECL int archive_read_open_memory(struct archive *, 535299529Smm const void * buff, size_t size); 536228753Smm/* A more involved version that is only used for internal testing. */ 537299529Smm__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff, 538228753Smm size_t size, size_t read_size); 539228753Smm/* Read an archive that's already open, using the file descriptor. */ 540232153Smm__LA_DECL int archive_read_open_fd(struct archive *, int _fd, 541228753Smm size_t _block_size); 542228753Smm/* Read an archive that's already open, using a FILE *. */ 543228753Smm/* Note: DO NOT use this with tape drives. */ 544232153Smm__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file); 545228753Smm 546228753Smm/* Parses and returns next entry header. */ 547232153Smm__LA_DECL int archive_read_next_header(struct archive *, 548228753Smm struct archive_entry **); 549228753Smm 550228753Smm/* Parses and returns next entry header using the archive_entry passed in */ 551232153Smm__LA_DECL int archive_read_next_header2(struct archive *, 552228753Smm struct archive_entry *); 553228753Smm 554228753Smm/* 555228753Smm * Retrieve the byte offset in UNCOMPRESSED data where last-read 556228753Smm * header started. 557228753Smm */ 558299529Smm__LA_DECL la_int64_t archive_read_header_position(struct archive *); 559228753Smm 560299529Smm/* 561299529Smm * Returns 1 if the archive contains at least one encrypted entry. 562299529Smm * If the archive format not support encryption at all 563299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. 564299529Smm * If for any other reason (e.g. not enough data read so far) 565299529Smm * we cannot say whether there are encrypted entries, then 566299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned. 567299529Smm * In general, this function will return values below zero when the 568311041Smm * reader is uncertain or totally incapable of encryption support. 569299529Smm * When this function returns 0 you can be sure that the reader 570299529Smm * supports encryption detection but no encrypted entries have 571299529Smm * been found yet. 572299529Smm * 573299529Smm * NOTE: If the metadata/header of an archive is also encrypted, you 574299529Smm * cannot rely on the number of encrypted entries. That is why this 575299529Smm * function does not return the number of encrypted entries but# 576299529Smm * just shows that there are some. 577299529Smm */ 578299529Smm__LA_DECL int archive_read_has_encrypted_entries(struct archive *); 579299529Smm 580299529Smm/* 581299529Smm * Returns a bitmask of capabilities that are supported by the archive format reader. 582299529Smm * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. 583299529Smm */ 584299529Smm__LA_DECL int archive_read_format_capabilities(struct archive *); 585299529Smm 586228753Smm/* Read data from the body of an entry. Similar to read(2). */ 587299529Smm__LA_DECL la_ssize_t archive_read_data(struct archive *, 588228753Smm void *, size_t); 589228753Smm 590248616Smm/* Seek within the body of an entry. Similar to lseek(2). */ 591299529Smm__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int); 592248616Smm 593228753Smm/* 594228753Smm * A zero-copy version of archive_read_data that also exposes the file offset 595228753Smm * of each returned block. Note that the client has no way to specify 596228753Smm * the desired size of the block. The API does guarantee that offsets will 597228753Smm * be strictly increasing and that returned blocks will not overlap. 598228753Smm */ 599232153Smm__LA_DECL int archive_read_data_block(struct archive *a, 600299529Smm const void **buff, size_t *size, la_int64_t *offset); 601228753Smm 602228753Smm/*- 603228753Smm * Some convenience functions that are built on archive_read_data: 604228753Smm * 'skip': skips entire entry 605228753Smm * 'into_buffer': writes data into memory buffer that you provide 606228753Smm * 'into_fd': writes data to specified filedes 607228753Smm */ 608232153Smm__LA_DECL int archive_read_data_skip(struct archive *); 609232153Smm__LA_DECL int archive_read_data_into_fd(struct archive *, int fd); 610228753Smm 611228753Smm/* 612228753Smm * Set read options. 613228753Smm */ 614232153Smm/* Apply option to the format only. */ 615232153Smm__LA_DECL int archive_read_set_format_option(struct archive *_a, 616232153Smm const char *m, const char *o, 617232153Smm const char *v); 618232153Smm/* Apply option to the filter only. */ 619232153Smm__LA_DECL int archive_read_set_filter_option(struct archive *_a, 620232153Smm const char *m, const char *o, 621232153Smm const char *v); 622232153Smm/* Apply option to both the format and the filter. */ 623232153Smm__LA_DECL int archive_read_set_option(struct archive *_a, 624232153Smm const char *m, const char *o, 625232153Smm const char *v); 626228753Smm/* Apply option string to both the format and the filter. */ 627232153Smm__LA_DECL int archive_read_set_options(struct archive *_a, 628232153Smm const char *opts); 629228753Smm 630299529Smm/* 631299529Smm * Add a decryption passphrase. 632299529Smm */ 633299529Smm__LA_DECL int archive_read_add_passphrase(struct archive *, const char *); 634299529Smm__LA_DECL int archive_read_set_passphrase_callback(struct archive *, 635299529Smm void *client_data, archive_passphrase_callback *); 636299529Smm 637299529Smm 638228753Smm/*- 639228753Smm * Convenience function to recreate the current entry (whose header 640228753Smm * has just been read) on disk. 641228753Smm * 642228753Smm * This does quite a bit more than just copy data to disk. It also: 643228753Smm * - Creates intermediate directories as required. 644228753Smm * - Manages directory permissions: non-writable directories will 645228753Smm * be initially created with write permission enabled; when the 646228753Smm * archive is closed, dir permissions are edited to the values specified 647228753Smm * in the archive. 648228753Smm * - Checks hardlinks: hardlinks will not be extracted unless the 649228753Smm * linked-to file was also extracted within the same session. (TODO) 650228753Smm */ 651228753Smm 652228753Smm/* The "flags" argument selects optional behavior, 'OR' the flags you want. */ 653228753Smm 654228753Smm/* Default: Do not try to set owner/group. */ 655228753Smm#define ARCHIVE_EXTRACT_OWNER (0x0001) 656228753Smm/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */ 657228753Smm#define ARCHIVE_EXTRACT_PERM (0x0002) 658228753Smm/* Default: Do not restore mtime/atime. */ 659228753Smm#define ARCHIVE_EXTRACT_TIME (0x0004) 660228753Smm/* Default: Replace existing files. */ 661228753Smm#define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008) 662228753Smm/* Default: Try create first, unlink only if create fails with EEXIST. */ 663228753Smm#define ARCHIVE_EXTRACT_UNLINK (0x0010) 664228753Smm/* Default: Do not restore ACLs. */ 665228753Smm#define ARCHIVE_EXTRACT_ACL (0x0020) 666228753Smm/* Default: Do not restore fflags. */ 667228753Smm#define ARCHIVE_EXTRACT_FFLAGS (0x0040) 668228753Smm/* Default: Do not restore xattrs. */ 669228753Smm#define ARCHIVE_EXTRACT_XATTR (0x0080) 670228753Smm/* Default: Do not try to guard against extracts redirected by symlinks. */ 671228753Smm/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */ 672228753Smm#define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100) 673228753Smm/* Default: Do not reject entries with '..' as path elements. */ 674228753Smm#define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200) 675228753Smm/* Default: Create parent directories as needed. */ 676228753Smm#define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400) 677228753Smm/* Default: Overwrite files, even if one on disk is newer. */ 678228753Smm#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800) 679228753Smm/* Detect blocks of 0 and write holes instead. */ 680228753Smm#define ARCHIVE_EXTRACT_SPARSE (0x1000) 681232153Smm/* Default: Do not restore Mac extended metadata. */ 682232153Smm/* This has no effect except on Mac OS. */ 683232153Smm#define ARCHIVE_EXTRACT_MAC_METADATA (0x2000) 684248616Smm/* Default: Use HFS+ compression if it was compressed. */ 685248616Smm/* This has no effect except on Mac OS v10.6 or later. */ 686248616Smm#define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000) 687248616Smm/* Default: Do not use HFS+ compression if it was not compressed. */ 688248616Smm/* This has no effect except on Mac OS v10.6 or later. */ 689248616Smm#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000) 690299529Smm/* Default: Do not reject entries with absolute paths */ 691299529Smm#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000) 692299529Smm/* Default: Do not clear no-change flags when unlinking object */ 693299529Smm#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000) 694228753Smm 695232153Smm__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *, 696228753Smm int flags); 697232153Smm__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *, 698228753Smm struct archive * /* dest */); 699228753Smm__LA_DECL void archive_read_extract_set_progress_callback(struct archive *, 700228753Smm void (*_progress_func)(void *), void *_user_data); 701228753Smm 702228753Smm/* Record the dev/ino of a file that will not be written. This is 703228753Smm * generally set to the dev/ino of the archive being read. */ 704228753Smm__LA_DECL void archive_read_extract_set_skip_file(struct archive *, 705299529Smm la_int64_t, la_int64_t); 706228753Smm 707228753Smm/* Close the file and release most resources. */ 708228753Smm__LA_DECL int archive_read_close(struct archive *); 709228753Smm/* Release all resources and destroy the object. */ 710228773Smm/* Note that archive_read_free will call archive_read_close for you. */ 711228773Smm__LA_DECL int archive_read_free(struct archive *); 712228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000 713228773Smm/* Synonym for archive_read_free() for backwards compatibility. */ 714248616Smm__LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED; 715228753Smm#endif 716228753Smm 717228753Smm/*- 718228753Smm * To create an archive: 719232153Smm * 1) Ask archive_write_new for an archive writer object. 720228753Smm * 2) Set any global properties. In particular, you should set 721228753Smm * the compression and format to use. 722228753Smm * 3) Call archive_write_open to open the file (most people 723228753Smm * will use archive_write_open_file or archive_write_open_fd, 724228753Smm * which provide convenient canned I/O callbacks for you). 725228753Smm * 4) For each entry: 726228753Smm * - construct an appropriate struct archive_entry structure 727228753Smm * - archive_write_header to write the header 728228753Smm * - archive_write_data to write the entry data 729228753Smm * 5) archive_write_close to close the output 730228773Smm * 6) archive_write_free to cleanup the writer and release resources 731228753Smm */ 732228753Smm__LA_DECL struct archive *archive_write_new(void); 733232153Smm__LA_DECL int archive_write_set_bytes_per_block(struct archive *, 734228753Smm int bytes_per_block); 735232153Smm__LA_DECL int archive_write_get_bytes_per_block(struct archive *); 736228753Smm/* XXX This is badly misnamed; suggestions appreciated. XXX */ 737232153Smm__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *, 738228753Smm int bytes_in_last_block); 739232153Smm__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *); 740228753Smm 741228753Smm/* The dev/ino of a file that won't be archived. This is used 742228753Smm * to avoid recursively adding an archive to itself. */ 743232153Smm__LA_DECL int archive_write_set_skip_file(struct archive *, 744299529Smm la_int64_t, la_int64_t); 745228753Smm 746232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 747248616Smm__LA_DECL int archive_write_set_compression_bzip2(struct archive *) 748248616Smm __LA_DEPRECATED; 749248616Smm__LA_DECL int archive_write_set_compression_compress(struct archive *) 750248616Smm __LA_DEPRECATED; 751248616Smm__LA_DECL int archive_write_set_compression_gzip(struct archive *) 752248616Smm __LA_DEPRECATED; 753248616Smm__LA_DECL int archive_write_set_compression_lzip(struct archive *) 754248616Smm __LA_DEPRECATED; 755248616Smm__LA_DECL int archive_write_set_compression_lzma(struct archive *) 756248616Smm __LA_DEPRECATED; 757248616Smm__LA_DECL int archive_write_set_compression_none(struct archive *) 758248616Smm __LA_DEPRECATED; 759232153Smm__LA_DECL int archive_write_set_compression_program(struct archive *, 760248616Smm const char *cmd) __LA_DEPRECATED; 761248616Smm__LA_DECL int archive_write_set_compression_xz(struct archive *) 762248616Smm __LA_DEPRECATED; 763232153Smm#endif 764232153Smm 765238856Smm/* A convenience function to set the filter based on the code. */ 766238856Smm__LA_DECL int archive_write_add_filter(struct archive *, int filter_code); 767248616Smm__LA_DECL int archive_write_add_filter_by_name(struct archive *, 768248616Smm const char *name); 769248616Smm__LA_DECL int archive_write_add_filter_b64encode(struct archive *); 770232153Smm__LA_DECL int archive_write_add_filter_bzip2(struct archive *); 771232153Smm__LA_DECL int archive_write_add_filter_compress(struct archive *); 772248616Smm__LA_DECL int archive_write_add_filter_grzip(struct archive *); 773232153Smm__LA_DECL int archive_write_add_filter_gzip(struct archive *); 774248616Smm__LA_DECL int archive_write_add_filter_lrzip(struct archive *); 775299529Smm__LA_DECL int archive_write_add_filter_lz4(struct archive *); 776232153Smm__LA_DECL int archive_write_add_filter_lzip(struct archive *); 777232153Smm__LA_DECL int archive_write_add_filter_lzma(struct archive *); 778248616Smm__LA_DECL int archive_write_add_filter_lzop(struct archive *); 779232153Smm__LA_DECL int archive_write_add_filter_none(struct archive *); 780232153Smm__LA_DECL int archive_write_add_filter_program(struct archive *, 781232153Smm const char *cmd); 782248616Smm__LA_DECL int archive_write_add_filter_uuencode(struct archive *); 783232153Smm__LA_DECL int archive_write_add_filter_xz(struct archive *); 784324417Smm__LA_DECL int archive_write_add_filter_zstd(struct archive *); 785232153Smm 786232153Smm 787228753Smm/* A convenience function to set the format based on the code or name. */ 788232153Smm__LA_DECL int archive_write_set_format(struct archive *, int format_code); 789232153Smm__LA_DECL int archive_write_set_format_by_name(struct archive *, 790228753Smm const char *name); 791228753Smm/* To minimize link pollution, use one or more of the following. */ 792232153Smm__LA_DECL int archive_write_set_format_7zip(struct archive *); 793232153Smm__LA_DECL int archive_write_set_format_ar_bsd(struct archive *); 794232153Smm__LA_DECL int archive_write_set_format_ar_svr4(struct archive *); 795232153Smm__LA_DECL int archive_write_set_format_cpio(struct archive *); 796232153Smm__LA_DECL int archive_write_set_format_cpio_newc(struct archive *); 797232153Smm__LA_DECL int archive_write_set_format_gnutar(struct archive *); 798232153Smm__LA_DECL int archive_write_set_format_iso9660(struct archive *); 799232153Smm__LA_DECL int archive_write_set_format_mtree(struct archive *); 800248616Smm__LA_DECL int archive_write_set_format_mtree_classic(struct archive *); 801228753Smm/* TODO: int archive_write_set_format_old_tar(struct archive *); */ 802232153Smm__LA_DECL int archive_write_set_format_pax(struct archive *); 803232153Smm__LA_DECL int archive_write_set_format_pax_restricted(struct archive *); 804299529Smm__LA_DECL int archive_write_set_format_raw(struct archive *); 805232153Smm__LA_DECL int archive_write_set_format_shar(struct archive *); 806232153Smm__LA_DECL int archive_write_set_format_shar_dump(struct archive *); 807232153Smm__LA_DECL int archive_write_set_format_ustar(struct archive *); 808248616Smm__LA_DECL int archive_write_set_format_v7tar(struct archive *); 809299529Smm__LA_DECL int archive_write_set_format_warc(struct archive *); 810232153Smm__LA_DECL int archive_write_set_format_xar(struct archive *); 811232153Smm__LA_DECL int archive_write_set_format_zip(struct archive *); 812299529Smm__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename); 813299529Smm__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext); 814248616Smm__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *); 815248616Smm__LA_DECL int archive_write_zip_set_compression_store(struct archive *); 816232153Smm__LA_DECL int archive_write_open(struct archive *, void *, 817228753Smm archive_open_callback *, archive_write_callback *, 818228753Smm archive_close_callback *); 819232153Smm__LA_DECL int archive_write_open_fd(struct archive *, int _fd); 820232153Smm__LA_DECL int archive_write_open_filename(struct archive *, const char *_file); 821232153Smm__LA_DECL int archive_write_open_filename_w(struct archive *, 822232153Smm const wchar_t *_file); 823228753Smm/* A deprecated synonym for archive_write_open_filename() */ 824248616Smm__LA_DECL int archive_write_open_file(struct archive *, const char *_file) 825248616Smm __LA_DEPRECATED; 826232153Smm__LA_DECL int archive_write_open_FILE(struct archive *, FILE *); 827228753Smm/* _buffSize is the size of the buffer, _used refers to a variable that 828228753Smm * will be updated after each write into the buffer. */ 829232153Smm__LA_DECL int archive_write_open_memory(struct archive *, 830228753Smm void *_buffer, size_t _buffSize, size_t *_used); 831228753Smm 832228753Smm/* 833228753Smm * Note that the library will truncate writes beyond the size provided 834228753Smm * to archive_write_header or pad if the provided data is short. 835228753Smm */ 836232153Smm__LA_DECL int archive_write_header(struct archive *, 837228753Smm struct archive_entry *); 838299529Smm__LA_DECL la_ssize_t archive_write_data(struct archive *, 839228753Smm const void *, size_t); 840228753Smm 841232153Smm/* This interface is currently only available for archive_write_disk handles. */ 842299529Smm__LA_DECL la_ssize_t archive_write_data_block(struct archive *, 843299529Smm const void *, size_t, la_int64_t); 844232153Smm 845228753Smm__LA_DECL int archive_write_finish_entry(struct archive *); 846228753Smm__LA_DECL int archive_write_close(struct archive *); 847248616Smm/* Marks the archive as FATAL so that a subsequent free() operation 848248616Smm * won't try to close() cleanly. Provides a fast abort capability 849248616Smm * when the client discovers that things have gone wrong. */ 850248616Smm__LA_DECL int archive_write_fail(struct archive *); 851228773Smm/* This can fail if the archive wasn't already closed, in which case 852228773Smm * archive_write_free() will implicitly call archive_write_close(). */ 853228773Smm__LA_DECL int archive_write_free(struct archive *); 854228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000 855228773Smm/* Synonym for archive_write_free() for backwards compatibility. */ 856248616Smm__LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED; 857228753Smm#endif 858228753Smm 859228753Smm/* 860228753Smm * Set write options. 861228753Smm */ 862232153Smm/* Apply option to the format only. */ 863232153Smm__LA_DECL int archive_write_set_format_option(struct archive *_a, 864232153Smm const char *m, const char *o, 865232153Smm const char *v); 866232153Smm/* Apply option to the filter only. */ 867232153Smm__LA_DECL int archive_write_set_filter_option(struct archive *_a, 868232153Smm const char *m, const char *o, 869232153Smm const char *v); 870232153Smm/* Apply option to both the format and the filter. */ 871232153Smm__LA_DECL int archive_write_set_option(struct archive *_a, 872232153Smm const char *m, const char *o, 873232153Smm const char *v); 874232153Smm/* Apply option string to both the format and the filter. */ 875232153Smm__LA_DECL int archive_write_set_options(struct archive *_a, 876232153Smm const char *opts); 877228753Smm 878299529Smm/* 879299529Smm * Set a encryption passphrase. 880299529Smm */ 881299529Smm__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p); 882299529Smm__LA_DECL int archive_write_set_passphrase_callback(struct archive *, 883299529Smm void *client_data, archive_passphrase_callback *); 884299529Smm 885228753Smm/*- 886228753Smm * ARCHIVE_WRITE_DISK API 887228753Smm * 888228753Smm * To create objects on disk: 889228753Smm * 1) Ask archive_write_disk_new for a new archive_write_disk object. 890228753Smm * 2) Set any global properties. In particular, you probably 891228753Smm * want to set the options. 892228753Smm * 3) For each entry: 893228753Smm * - construct an appropriate struct archive_entry structure 894228753Smm * - archive_write_header to create the file/dir/etc on disk 895228753Smm * - archive_write_data to write the entry data 896228773Smm * 4) archive_write_free to cleanup the writer and release resources 897228753Smm * 898228753Smm * In particular, you can use this in conjunction with archive_read() 899228753Smm * to pull entries out of an archive and create them on disk. 900228753Smm */ 901228753Smm__LA_DECL struct archive *archive_write_disk_new(void); 902228753Smm/* This file will not be overwritten. */ 903232153Smm__LA_DECL int archive_write_disk_set_skip_file(struct archive *, 904299529Smm la_int64_t, la_int64_t); 905228753Smm/* Set flags to control how the next item gets created. 906228753Smm * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */ 907228753Smm__LA_DECL int archive_write_disk_set_options(struct archive *, 908228753Smm int flags); 909228753Smm/* 910228753Smm * The lookup functions are given uname/uid (or gname/gid) pairs and 911228753Smm * return a uid (gid) suitable for this system. These are used for 912228753Smm * restoring ownership and for setting ACLs. The default functions 913228753Smm * are naive, they just return the uid/gid. These are small, so reasonable 914228753Smm * for applications that don't need to preserve ownership; they 915228753Smm * are probably also appropriate for applications that are doing 916228753Smm * same-system backup and restore. 917228753Smm */ 918228753Smm/* 919228753Smm * The "standard" lookup functions use common system calls to lookup 920228753Smm * the uname/gname, falling back to the uid/gid if the names can't be 921228753Smm * found. They cache lookups and are reasonably fast, but can be very 922228753Smm * large, so they are not used unless you ask for them. In 923228753Smm * particular, these match the specifications of POSIX "pax" and old 924228753Smm * POSIX "tar". 925228753Smm */ 926228753Smm__LA_DECL int archive_write_disk_set_standard_lookup(struct archive *); 927228753Smm/* 928228753Smm * If neither the default (naive) nor the standard (big) functions suit 929228753Smm * your needs, you can write your own and register them. Be sure to 930228753Smm * include a cleanup function if you have allocated private data. 931228753Smm */ 932232153Smm__LA_DECL int archive_write_disk_set_group_lookup(struct archive *, 933232153Smm void * /* private_data */, 934299529Smm la_int64_t (*)(void *, const char *, la_int64_t), 935232153Smm void (* /* cleanup */)(void *)); 936232153Smm__LA_DECL int archive_write_disk_set_user_lookup(struct archive *, 937232153Smm void * /* private_data */, 938299529Smm la_int64_t (*)(void *, const char *, la_int64_t), 939232153Smm void (* /* cleanup */)(void *)); 940299529Smm__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t); 941299529Smm__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t); 942228753Smm 943228753Smm/* 944228753Smm * ARCHIVE_READ_DISK API 945228753Smm * 946228753Smm * This is still evolving and somewhat experimental. 947228753Smm */ 948228753Smm__LA_DECL struct archive *archive_read_disk_new(void); 949228753Smm/* The names for symlink modes here correspond to an old BSD 950228753Smm * command-line argument convention: -L, -P, -H */ 951228753Smm/* Follow all symlinks. */ 952228753Smm__LA_DECL int archive_read_disk_set_symlink_logical(struct archive *); 953228753Smm/* Follow no symlinks. */ 954228753Smm__LA_DECL int archive_read_disk_set_symlink_physical(struct archive *); 955228753Smm/* Follow symlink initially, then not. */ 956228753Smm__LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *); 957228753Smm/* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */ 958228753Smm__LA_DECL int archive_read_disk_entry_from_file(struct archive *, 959228753Smm struct archive_entry *, int /* fd */, const struct stat *); 960228753Smm/* Look up gname for gid or uname for uid. */ 961228753Smm/* Default implementations are very, very stupid. */ 962299529Smm__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t); 963299529Smm__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t); 964228753Smm/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the 965228753Smm * results for performance. */ 966228753Smm__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *); 967228753Smm/* You can install your own lookups if you like. */ 968228753Smm__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, 969228753Smm void * /* private_data */, 970299529Smm const char *(* /* lookup_fn */)(void *, la_int64_t), 971228753Smm void (* /* cleanup_fn */)(void *)); 972228753Smm__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, 973228753Smm void * /* private_data */, 974299529Smm const char *(* /* lookup_fn */)(void *, la_int64_t), 975228753Smm void (* /* cleanup_fn */)(void *)); 976232153Smm/* Start traversal. */ 977232153Smm__LA_DECL int archive_read_disk_open(struct archive *, const char *); 978232153Smm__LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *); 979232153Smm/* 980232153Smm * Request that current entry be visited. If you invoke it on every 981232153Smm * directory, you'll get a physical traversal. This is ignored if the 982232153Smm * current entry isn't a directory or a link to a directory. So, if 983232153Smm * you invoke this on every returned path, you'll get a full logical 984232153Smm * traversal. 985232153Smm */ 986232153Smm__LA_DECL int archive_read_disk_descend(struct archive *); 987238856Smm__LA_DECL int archive_read_disk_can_descend(struct archive *); 988232153Smm__LA_DECL int archive_read_disk_current_filesystem(struct archive *); 989232153Smm__LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *); 990232153Smm__LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *); 991311041Smm/* Request that the access time of the entry visited by traversal be restored. */ 992232153Smm__LA_DECL int archive_read_disk_set_atime_restored(struct archive *); 993238856Smm/* 994238856Smm * Set behavior. The "flags" argument selects optional behavior. 995238856Smm */ 996311041Smm/* Request that the access time of the entry visited by traversal be restored. 997238856Smm * This is the same as archive_read_disk_set_atime_restored. */ 998238856Smm#define ARCHIVE_READDISK_RESTORE_ATIME (0x0001) 999238856Smm/* Default: Do not skip an entry which has nodump flags. */ 1000238856Smm#define ARCHIVE_READDISK_HONOR_NODUMP (0x0002) 1001238856Smm/* Default: Skip a mac resource fork file whose prefix is "._" because of 1002238856Smm * using copyfile. */ 1003238856Smm#define ARCHIVE_READDISK_MAC_COPYFILE (0x0004) 1004299529Smm/* Default: Traverse mount points. */ 1005238856Smm#define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008) 1006299529Smm/* Default: Xattrs are read from disk. */ 1007299529Smm#define ARCHIVE_READDISK_NO_XATTR (0x0010) 1008315432Smm/* Default: ACLs are read from disk. */ 1009315432Smm#define ARCHIVE_READDISK_NO_ACL (0x0020) 1010315432Smm/* Default: File flags are read from disk. */ 1011315432Smm#define ARCHIVE_READDISK_NO_FFLAGS (0x0040) 1012228753Smm 1013238856Smm__LA_DECL int archive_read_disk_set_behavior(struct archive *, 1014238856Smm int flags); 1015238856Smm 1016228753Smm/* 1017238856Smm * Set archive_match object that will be used in archive_read_disk to 1018238856Smm * know whether an entry should be skipped. The callback function 1019238856Smm * _excluded_func will be invoked when an entry is skipped by the result 1020238856Smm * of archive_match. 1021238856Smm */ 1022238856Smm__LA_DECL int archive_read_disk_set_matching(struct archive *, 1023238856Smm struct archive *_matching, void (*_excluded_func) 1024238856Smm (struct archive *, void *, struct archive_entry *), 1025238856Smm void *_client_data); 1026238856Smm__LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, 1027238856Smm int (*_metadata_filter_func)(struct archive *, void *, 1028238856Smm struct archive_entry *), void *_client_data); 1029238856Smm 1030299529Smm/* Simplified cleanup interface; 1031299529Smm * This calls archive_read_free() or archive_write_free() as needed. */ 1032299529Smm__LA_DECL int archive_free(struct archive *); 1033299529Smm 1034238856Smm/* 1035228753Smm * Accessor functions to read/set various information in 1036228753Smm * the struct archive object: 1037228753Smm */ 1038232153Smm 1039232153Smm/* Number of filters in the current filter pipeline. */ 1040232153Smm/* Filter #0 is the one closest to the format, -1 is a synonym for the 1041232153Smm * last filter, which is always the pseudo-filter that wraps the 1042232153Smm * client callbacks. */ 1043232153Smm__LA_DECL int archive_filter_count(struct archive *); 1044299529Smm__LA_DECL la_int64_t archive_filter_bytes(struct archive *, int); 1045232153Smm__LA_DECL int archive_filter_code(struct archive *, int); 1046232153Smm__LA_DECL const char * archive_filter_name(struct archive *, int); 1047232153Smm 1048232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 1049232153Smm/* These don't properly handle multiple filters, so are deprecated and 1050232153Smm * will eventually be removed. */ 1051232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */ 1052299529Smm__LA_DECL la_int64_t archive_position_compressed(struct archive *) 1053248616Smm __LA_DEPRECATED; 1054232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */ 1055299529Smm__LA_DECL la_int64_t archive_position_uncompressed(struct archive *) 1056248616Smm __LA_DEPRECATED; 1057232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */ 1058248616Smm__LA_DECL const char *archive_compression_name(struct archive *) 1059248616Smm __LA_DEPRECATED; 1060232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */ 1061248616Smm__LA_DECL int archive_compression(struct archive *) 1062248616Smm __LA_DEPRECATED; 1063232153Smm#endif 1064232153Smm 1065228753Smm__LA_DECL int archive_errno(struct archive *); 1066228753Smm__LA_DECL const char *archive_error_string(struct archive *); 1067228753Smm__LA_DECL const char *archive_format_name(struct archive *); 1068228753Smm__LA_DECL int archive_format(struct archive *); 1069228753Smm__LA_DECL void archive_clear_error(struct archive *); 1070228753Smm__LA_DECL void archive_set_error(struct archive *, int _err, 1071228753Smm const char *fmt, ...) __LA_PRINTF(3, 4); 1072228753Smm__LA_DECL void archive_copy_error(struct archive *dest, 1073228753Smm struct archive *src); 1074228753Smm__LA_DECL int archive_file_count(struct archive *); 1075228753Smm 1076238856Smm/* 1077238856Smm * ARCHIVE_MATCH API 1078238856Smm */ 1079238856Smm__LA_DECL struct archive *archive_match_new(void); 1080238856Smm__LA_DECL int archive_match_free(struct archive *); 1081238856Smm 1082238856Smm/* 1083238856Smm * Test if archive_entry is excluded. 1084238856Smm * This is a convenience function. This is the same as calling all 1085238856Smm * archive_match_path_excluded, archive_match_time_excluded 1086238856Smm * and archive_match_owner_excluded. 1087238856Smm */ 1088238856Smm__LA_DECL int archive_match_excluded(struct archive *, 1089238856Smm struct archive_entry *); 1090238856Smm 1091238856Smm/* 1092238856Smm * Test if pathname is excluded. The conditions are set by following functions. 1093238856Smm */ 1094238856Smm__LA_DECL int archive_match_path_excluded(struct archive *, 1095238856Smm struct archive_entry *); 1096238856Smm/* Add exclusion pathname pattern. */ 1097238856Smm__LA_DECL int archive_match_exclude_pattern(struct archive *, const char *); 1098238856Smm__LA_DECL int archive_match_exclude_pattern_w(struct archive *, 1099238856Smm const wchar_t *); 1100238856Smm/* Add exclusion pathname pattern from file. */ 1101238856Smm__LA_DECL int archive_match_exclude_pattern_from_file(struct archive *, 1102238856Smm const char *, int _nullSeparator); 1103238856Smm__LA_DECL int archive_match_exclude_pattern_from_file_w(struct archive *, 1104238856Smm const wchar_t *, int _nullSeparator); 1105238856Smm/* Add inclusion pathname pattern. */ 1106238856Smm__LA_DECL int archive_match_include_pattern(struct archive *, const char *); 1107238856Smm__LA_DECL int archive_match_include_pattern_w(struct archive *, 1108238856Smm const wchar_t *); 1109238856Smm/* Add inclusion pathname pattern from file. */ 1110238856Smm__LA_DECL int archive_match_include_pattern_from_file(struct archive *, 1111238856Smm const char *, int _nullSeparator); 1112238856Smm__LA_DECL int archive_match_include_pattern_from_file_w(struct archive *, 1113238856Smm const wchar_t *, int _nullSeparator); 1114238856Smm/* 1115238856Smm * How to get statistic information for inclusion patterns. 1116238856Smm */ 1117238856Smm/* Return the amount number of unmatched inclusion patterns. */ 1118238856Smm__LA_DECL int archive_match_path_unmatched_inclusions(struct archive *); 1119238856Smm/* Return the pattern of unmatched inclusion with ARCHIVE_OK. 1120238856Smm * Return ARCHIVE_EOF if there is no inclusion pattern. */ 1121238856Smm__LA_DECL int archive_match_path_unmatched_inclusions_next( 1122238856Smm struct archive *, const char **); 1123238856Smm__LA_DECL int archive_match_path_unmatched_inclusions_next_w( 1124238856Smm struct archive *, const wchar_t **); 1125238856Smm 1126238856Smm/* 1127238856Smm * Test if a file is excluded by its time stamp. 1128238856Smm * The conditions are set by following functions. 1129238856Smm */ 1130238856Smm__LA_DECL int archive_match_time_excluded(struct archive *, 1131238856Smm struct archive_entry *); 1132238856Smm 1133238856Smm/* 1134238856Smm * Flags to tell a matching type of time stamps. These are used for 1135311041Smm * following functions. 1136238856Smm */ 1137238856Smm/* Time flag: mtime to be tested. */ 1138238856Smm#define ARCHIVE_MATCH_MTIME (0x0100) 1139238856Smm/* Time flag: ctime to be tested. */ 1140238856Smm#define ARCHIVE_MATCH_CTIME (0x0200) 1141238856Smm/* Comparison flag: Match the time if it is newer than. */ 1142238856Smm#define ARCHIVE_MATCH_NEWER (0x0001) 1143238856Smm/* Comparison flag: Match the time if it is older than. */ 1144238856Smm#define ARCHIVE_MATCH_OLDER (0x0002) 1145238856Smm/* Comparison flag: Match the time if it is equal to. */ 1146238856Smm#define ARCHIVE_MATCH_EQUAL (0x0010) 1147238856Smm/* Set inclusion time. */ 1148238856Smm__LA_DECL int archive_match_include_time(struct archive *, int _flag, 1149238856Smm time_t _sec, long _nsec); 1150238856Smm/* Set inclusion time by a date string. */ 1151238856Smm__LA_DECL int archive_match_include_date(struct archive *, int _flag, 1152238856Smm const char *_datestr); 1153238856Smm__LA_DECL int archive_match_include_date_w(struct archive *, int _flag, 1154238856Smm const wchar_t *_datestr); 1155311041Smm/* Set inclusion time by a particular file. */ 1156238856Smm__LA_DECL int archive_match_include_file_time(struct archive *, 1157238856Smm int _flag, const char *_pathname); 1158238856Smm__LA_DECL int archive_match_include_file_time_w(struct archive *, 1159238856Smm int _flag, const wchar_t *_pathname); 1160238856Smm/* Add exclusion entry. */ 1161238856Smm__LA_DECL int archive_match_exclude_entry(struct archive *, 1162238856Smm int _flag, struct archive_entry *); 1163238856Smm 1164238856Smm/* 1165238856Smm * Test if a file is excluded by its uid ,gid, uname or gname. 1166238856Smm * The conditions are set by following functions. 1167238856Smm */ 1168238856Smm__LA_DECL int archive_match_owner_excluded(struct archive *, 1169238856Smm struct archive_entry *); 1170238856Smm/* Add inclusion uid, gid, uname and gname. */ 1171299529Smm__LA_DECL int archive_match_include_uid(struct archive *, la_int64_t); 1172299529Smm__LA_DECL int archive_match_include_gid(struct archive *, la_int64_t); 1173238856Smm__LA_DECL int archive_match_include_uname(struct archive *, const char *); 1174238856Smm__LA_DECL int archive_match_include_uname_w(struct archive *, 1175238856Smm const wchar_t *); 1176238856Smm__LA_DECL int archive_match_include_gname(struct archive *, const char *); 1177238856Smm__LA_DECL int archive_match_include_gname_w(struct archive *, 1178238856Smm const wchar_t *); 1179238856Smm 1180299529Smm/* Utility functions */ 1181299529Smm/* Convenience function to sort a NULL terminated list of strings */ 1182299529Smm__LA_DECL int archive_utility_string_sort(char **); 1183299529Smm 1184228753Smm#ifdef __cplusplus 1185228753Smm} 1186228753Smm#endif 1187228753Smm 1188228753Smm/* These are meaningless outside of this header. */ 1189228753Smm#undef __LA_DECL 1190228753Smm 1191228753Smm#endif /* !ARCHIVE_H_INCLUDED */ 1192