archive.h revision 342360
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 342360 2018-12-21 23:33:05Z 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! */ 39338795Smm#define ARCHIVE_VERSION_NUMBER 3003003 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 */ 158338795Smm#define ARCHIVE_VERSION_ONLY_STRING "3.3.3" 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 341342360Smm#define ARCHIVE_FORMAT_RAR_V5 (ARCHIVE_FORMAT_RAR | 1) 342232153Smm#define ARCHIVE_FORMAT_7ZIP 0xE0000 343299529Smm#define ARCHIVE_FORMAT_WARC 0xF0000 344228753Smm 345299529Smm/* 346299529Smm * Codes returned by archive_read_format_capabilities(). 347299529Smm * 348299529Smm * This list can be extended with values between 0 and 0xffff. 349299529Smm * The original purpose of this list was to let different archive 350299529Smm * format readers expose their general capabilities in terms of 351299529Smm * encryption. 352299529Smm */ 353299529Smm#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */ 354299529Smm#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */ 355299529Smm#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */ 356299529Smm 357299529Smm/* 358299529Smm * Codes returned by archive_read_has_encrypted_entries(). 359299529Smm * 360299529Smm * In case the archive does not support encryption detection at all 361299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader 362299529Smm * for some other reason (e.g. not enough bytes read) cannot say if 363299529Smm * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW 364299529Smm * is returned. 365299529Smm */ 366299529Smm#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2 367299529Smm#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1 368299529Smm 369228753Smm/*- 370228753Smm * Basic outline for reading an archive: 371228753Smm * 1) Ask archive_read_new for an archive reader object. 372228753Smm * 2) Update any global properties as appropriate. 373228753Smm * In particular, you'll certainly want to call appropriate 374228753Smm * archive_read_support_XXX functions. 375228753Smm * 3) Call archive_read_open_XXX to open the archive 376228753Smm * 4) Repeatedly call archive_read_next_header to get information about 377228753Smm * successive archive entries. Call archive_read_data to extract 378228753Smm * data for entries of interest. 379311041Smm * 5) Call archive_read_free to end processing. 380228753Smm */ 381228753Smm__LA_DECL struct archive *archive_read_new(void); 382228753Smm 383228753Smm/* 384228753Smm * The archive_read_support_XXX calls enable auto-detect for this 385228753Smm * archive handle. They also link in the necessary support code. 386228753Smm * For example, if you don't want bzlib linked in, don't invoke 387228753Smm * support_compression_bzip2(). The "all" functions provide the 388228753Smm * obvious shorthand. 389228753Smm */ 390232153Smm 391232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 392248616Smm__LA_DECL int archive_read_support_compression_all(struct archive *) 393248616Smm __LA_DEPRECATED; 394248616Smm__LA_DECL int archive_read_support_compression_bzip2(struct archive *) 395248616Smm __LA_DEPRECATED; 396248616Smm__LA_DECL int archive_read_support_compression_compress(struct archive *) 397248616Smm __LA_DEPRECATED; 398248616Smm__LA_DECL int archive_read_support_compression_gzip(struct archive *) 399248616Smm __LA_DEPRECATED; 400248616Smm__LA_DECL int archive_read_support_compression_lzip(struct archive *) 401248616Smm __LA_DEPRECATED; 402248616Smm__LA_DECL int archive_read_support_compression_lzma(struct archive *) 403248616Smm __LA_DEPRECATED; 404248616Smm__LA_DECL int archive_read_support_compression_none(struct archive *) 405248616Smm __LA_DEPRECATED; 406232153Smm__LA_DECL int archive_read_support_compression_program(struct archive *, 407248616Smm const char *command) __LA_DEPRECATED; 408232153Smm__LA_DECL int archive_read_support_compression_program_signature 409232153Smm (struct archive *, const char *, 410248616Smm const void * /* match */, size_t) __LA_DEPRECATED; 411228753Smm 412248616Smm__LA_DECL int archive_read_support_compression_rpm(struct archive *) 413248616Smm __LA_DEPRECATED; 414248616Smm__LA_DECL int archive_read_support_compression_uu(struct archive *) 415248616Smm __LA_DEPRECATED; 416248616Smm__LA_DECL int archive_read_support_compression_xz(struct archive *) 417248616Smm __LA_DEPRECATED; 418232153Smm#endif 419228753Smm 420232153Smm__LA_DECL int archive_read_support_filter_all(struct archive *); 421232153Smm__LA_DECL int archive_read_support_filter_bzip2(struct archive *); 422232153Smm__LA_DECL int archive_read_support_filter_compress(struct archive *); 423232153Smm__LA_DECL int archive_read_support_filter_gzip(struct archive *); 424248616Smm__LA_DECL int archive_read_support_filter_grzip(struct archive *); 425248616Smm__LA_DECL int archive_read_support_filter_lrzip(struct archive *); 426299529Smm__LA_DECL int archive_read_support_filter_lz4(struct archive *); 427232153Smm__LA_DECL int archive_read_support_filter_lzip(struct archive *); 428232153Smm__LA_DECL int archive_read_support_filter_lzma(struct archive *); 429248616Smm__LA_DECL int archive_read_support_filter_lzop(struct archive *); 430232153Smm__LA_DECL int archive_read_support_filter_none(struct archive *); 431232153Smm__LA_DECL int archive_read_support_filter_program(struct archive *, 432232153Smm const char *command); 433232153Smm__LA_DECL int archive_read_support_filter_program_signature 434248616Smm (struct archive *, const char * /* cmd */, 435232153Smm const void * /* match */, size_t); 436232153Smm__LA_DECL int archive_read_support_filter_rpm(struct archive *); 437232153Smm__LA_DECL int archive_read_support_filter_uu(struct archive *); 438232153Smm__LA_DECL int archive_read_support_filter_xz(struct archive *); 439324417Smm__LA_DECL int archive_read_support_filter_zstd(struct archive *); 440228753Smm 441232153Smm__LA_DECL int archive_read_support_format_7zip(struct archive *); 442232153Smm__LA_DECL int archive_read_support_format_all(struct archive *); 443232153Smm__LA_DECL int archive_read_support_format_ar(struct archive *); 444232153Smm__LA_DECL int archive_read_support_format_by_code(struct archive *, int); 445232153Smm__LA_DECL int archive_read_support_format_cab(struct archive *); 446232153Smm__LA_DECL int archive_read_support_format_cpio(struct archive *); 447232153Smm__LA_DECL int archive_read_support_format_empty(struct archive *); 448232153Smm__LA_DECL int archive_read_support_format_gnutar(struct archive *); 449232153Smm__LA_DECL int archive_read_support_format_iso9660(struct archive *); 450232153Smm__LA_DECL int archive_read_support_format_lha(struct archive *); 451232153Smm__LA_DECL int archive_read_support_format_mtree(struct archive *); 452232153Smm__LA_DECL int archive_read_support_format_rar(struct archive *); 453342360Smm__LA_DECL int archive_read_support_format_rar5(struct archive *); 454232153Smm__LA_DECL int archive_read_support_format_raw(struct archive *); 455232153Smm__LA_DECL int archive_read_support_format_tar(struct archive *); 456299529Smm__LA_DECL int archive_read_support_format_warc(struct archive *); 457232153Smm__LA_DECL int archive_read_support_format_xar(struct archive *); 458299529Smm/* archive_read_support_format_zip() enables both streamable and seekable 459299529Smm * zip readers. */ 460232153Smm__LA_DECL int archive_read_support_format_zip(struct archive *); 461299529Smm/* Reads Zip archives as stream from beginning to end. Doesn't 462299529Smm * correctly handle SFX ZIP files or ZIP archives that have been modified 463299529Smm * in-place. */ 464299529Smm__LA_DECL int archive_read_support_format_zip_streamable(struct archive *); 465299529Smm/* Reads starting from central directory; requires seekable input. */ 466299529Smm__LA_DECL int archive_read_support_format_zip_seekable(struct archive *); 467232153Smm 468248616Smm/* Functions to manually set the format and filters to be used. This is 469248616Smm * useful to bypass the bidding process when the format and filters to use 470248616Smm * is known in advance. 471248616Smm */ 472248616Smm__LA_DECL int archive_read_set_format(struct archive *, int); 473248616Smm__LA_DECL int archive_read_append_filter(struct archive *, int); 474248616Smm__LA_DECL int archive_read_append_filter_program(struct archive *, 475248616Smm const char *); 476248616Smm__LA_DECL int archive_read_append_filter_program_signature 477248616Smm (struct archive *, const char *, const void * /* match */, size_t); 478248616Smm 479232153Smm/* Set various callbacks. */ 480232153Smm__LA_DECL int archive_read_set_open_callback(struct archive *, 481232153Smm archive_open_callback *); 482232153Smm__LA_DECL int archive_read_set_read_callback(struct archive *, 483232153Smm archive_read_callback *); 484232153Smm__LA_DECL int archive_read_set_seek_callback(struct archive *, 485232153Smm archive_seek_callback *); 486232153Smm__LA_DECL int archive_read_set_skip_callback(struct archive *, 487232153Smm archive_skip_callback *); 488232153Smm__LA_DECL int archive_read_set_close_callback(struct archive *, 489232153Smm archive_close_callback *); 490248616Smm/* Callback used to switch between one data object to the next */ 491248616Smm__LA_DECL int archive_read_set_switch_callback(struct archive *, 492248616Smm archive_switch_callback *); 493248616Smm 494248616Smm/* This sets the first data object. */ 495232153Smm__LA_DECL int archive_read_set_callback_data(struct archive *, void *); 496248616Smm/* This sets data object at specified index */ 497248616Smm__LA_DECL int archive_read_set_callback_data2(struct archive *, void *, 498248616Smm unsigned int); 499248616Smm/* This adds a data object at the specified index. */ 500248616Smm__LA_DECL int archive_read_add_callback_data(struct archive *, void *, 501248616Smm unsigned int); 502248616Smm/* This appends a data object to the end of list */ 503248616Smm__LA_DECL int archive_read_append_callback_data(struct archive *, void *); 504248616Smm/* This prepends a data object to the beginning of list */ 505248616Smm__LA_DECL int archive_read_prepend_callback_data(struct archive *, void *); 506248616Smm 507232153Smm/* Opening freezes the callbacks. */ 508232153Smm__LA_DECL int archive_read_open1(struct archive *); 509232153Smm 510232153Smm/* Convenience wrappers around the above. */ 511232153Smm__LA_DECL int archive_read_open(struct archive *, void *_client_data, 512228753Smm archive_open_callback *, archive_read_callback *, 513228753Smm archive_close_callback *); 514232153Smm__LA_DECL int archive_read_open2(struct archive *, void *_client_data, 515228753Smm archive_open_callback *, archive_read_callback *, 516228753Smm archive_skip_callback *, archive_close_callback *); 517228753Smm 518228753Smm/* 519228753Smm * A variety of shortcuts that invoke archive_read_open() with 520228753Smm * canned callbacks suitable for common situations. The ones that 521228753Smm * accept a block size handle tape blocking correctly. 522228753Smm */ 523228753Smm/* Use this if you know the filename. Note: NULL indicates stdin. */ 524232153Smm__LA_DECL int archive_read_open_filename(struct archive *, 525228753Smm const char *_filename, size_t _block_size); 526248616Smm/* Use this for reading multivolume files by filenames. 527248616Smm * NOTE: Must be NULL terminated. Sorting is NOT done. */ 528248616Smm__LA_DECL int archive_read_open_filenames(struct archive *, 529248616Smm const char **_filenames, size_t _block_size); 530232153Smm__LA_DECL int archive_read_open_filename_w(struct archive *, 531232153Smm const wchar_t *_filename, size_t _block_size); 532228753Smm/* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ 533232153Smm__LA_DECL int archive_read_open_file(struct archive *, 534248616Smm const char *_filename, size_t _block_size) __LA_DEPRECATED; 535228753Smm/* Read an archive that's stored in memory. */ 536232153Smm__LA_DECL int archive_read_open_memory(struct archive *, 537299529Smm const void * buff, size_t size); 538228753Smm/* A more involved version that is only used for internal testing. */ 539299529Smm__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff, 540228753Smm size_t size, size_t read_size); 541228753Smm/* Read an archive that's already open, using the file descriptor. */ 542232153Smm__LA_DECL int archive_read_open_fd(struct archive *, int _fd, 543228753Smm size_t _block_size); 544228753Smm/* Read an archive that's already open, using a FILE *. */ 545228753Smm/* Note: DO NOT use this with tape drives. */ 546232153Smm__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file); 547228753Smm 548228753Smm/* Parses and returns next entry header. */ 549232153Smm__LA_DECL int archive_read_next_header(struct archive *, 550228753Smm struct archive_entry **); 551228753Smm 552228753Smm/* Parses and returns next entry header using the archive_entry passed in */ 553232153Smm__LA_DECL int archive_read_next_header2(struct archive *, 554228753Smm struct archive_entry *); 555228753Smm 556228753Smm/* 557228753Smm * Retrieve the byte offset in UNCOMPRESSED data where last-read 558228753Smm * header started. 559228753Smm */ 560299529Smm__LA_DECL la_int64_t archive_read_header_position(struct archive *); 561228753Smm 562299529Smm/* 563299529Smm * Returns 1 if the archive contains at least one encrypted entry. 564299529Smm * If the archive format not support encryption at all 565299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. 566299529Smm * If for any other reason (e.g. not enough data read so far) 567299529Smm * we cannot say whether there are encrypted entries, then 568299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned. 569299529Smm * In general, this function will return values below zero when the 570311041Smm * reader is uncertain or totally incapable of encryption support. 571299529Smm * When this function returns 0 you can be sure that the reader 572299529Smm * supports encryption detection but no encrypted entries have 573299529Smm * been found yet. 574299529Smm * 575299529Smm * NOTE: If the metadata/header of an archive is also encrypted, you 576299529Smm * cannot rely on the number of encrypted entries. That is why this 577299529Smm * function does not return the number of encrypted entries but# 578299529Smm * just shows that there are some. 579299529Smm */ 580299529Smm__LA_DECL int archive_read_has_encrypted_entries(struct archive *); 581299529Smm 582299529Smm/* 583299529Smm * Returns a bitmask of capabilities that are supported by the archive format reader. 584299529Smm * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. 585299529Smm */ 586299529Smm__LA_DECL int archive_read_format_capabilities(struct archive *); 587299529Smm 588228753Smm/* Read data from the body of an entry. Similar to read(2). */ 589299529Smm__LA_DECL la_ssize_t archive_read_data(struct archive *, 590228753Smm void *, size_t); 591228753Smm 592248616Smm/* Seek within the body of an entry. Similar to lseek(2). */ 593299529Smm__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int); 594248616Smm 595228753Smm/* 596228753Smm * A zero-copy version of archive_read_data that also exposes the file offset 597228753Smm * of each returned block. Note that the client has no way to specify 598228753Smm * the desired size of the block. The API does guarantee that offsets will 599228753Smm * be strictly increasing and that returned blocks will not overlap. 600228753Smm */ 601232153Smm__LA_DECL int archive_read_data_block(struct archive *a, 602299529Smm const void **buff, size_t *size, la_int64_t *offset); 603228753Smm 604228753Smm/*- 605228753Smm * Some convenience functions that are built on archive_read_data: 606228753Smm * 'skip': skips entire entry 607228753Smm * 'into_buffer': writes data into memory buffer that you provide 608228753Smm * 'into_fd': writes data to specified filedes 609228753Smm */ 610232153Smm__LA_DECL int archive_read_data_skip(struct archive *); 611232153Smm__LA_DECL int archive_read_data_into_fd(struct archive *, int fd); 612228753Smm 613228753Smm/* 614228753Smm * Set read options. 615228753Smm */ 616232153Smm/* Apply option to the format only. */ 617232153Smm__LA_DECL int archive_read_set_format_option(struct archive *_a, 618232153Smm const char *m, const char *o, 619232153Smm const char *v); 620232153Smm/* Apply option to the filter only. */ 621232153Smm__LA_DECL int archive_read_set_filter_option(struct archive *_a, 622232153Smm const char *m, const char *o, 623232153Smm const char *v); 624232153Smm/* Apply option to both the format and the filter. */ 625232153Smm__LA_DECL int archive_read_set_option(struct archive *_a, 626232153Smm const char *m, const char *o, 627232153Smm const char *v); 628228753Smm/* Apply option string to both the format and the filter. */ 629232153Smm__LA_DECL int archive_read_set_options(struct archive *_a, 630232153Smm const char *opts); 631228753Smm 632299529Smm/* 633299529Smm * Add a decryption passphrase. 634299529Smm */ 635299529Smm__LA_DECL int archive_read_add_passphrase(struct archive *, const char *); 636299529Smm__LA_DECL int archive_read_set_passphrase_callback(struct archive *, 637299529Smm void *client_data, archive_passphrase_callback *); 638299529Smm 639299529Smm 640228753Smm/*- 641228753Smm * Convenience function to recreate the current entry (whose header 642228753Smm * has just been read) on disk. 643228753Smm * 644228753Smm * This does quite a bit more than just copy data to disk. It also: 645228753Smm * - Creates intermediate directories as required. 646228753Smm * - Manages directory permissions: non-writable directories will 647228753Smm * be initially created with write permission enabled; when the 648228753Smm * archive is closed, dir permissions are edited to the values specified 649228753Smm * in the archive. 650228753Smm * - Checks hardlinks: hardlinks will not be extracted unless the 651228753Smm * linked-to file was also extracted within the same session. (TODO) 652228753Smm */ 653228753Smm 654228753Smm/* The "flags" argument selects optional behavior, 'OR' the flags you want. */ 655228753Smm 656228753Smm/* Default: Do not try to set owner/group. */ 657228753Smm#define ARCHIVE_EXTRACT_OWNER (0x0001) 658228753Smm/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */ 659228753Smm#define ARCHIVE_EXTRACT_PERM (0x0002) 660228753Smm/* Default: Do not restore mtime/atime. */ 661228753Smm#define ARCHIVE_EXTRACT_TIME (0x0004) 662228753Smm/* Default: Replace existing files. */ 663228753Smm#define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008) 664228753Smm/* Default: Try create first, unlink only if create fails with EEXIST. */ 665228753Smm#define ARCHIVE_EXTRACT_UNLINK (0x0010) 666228753Smm/* Default: Do not restore ACLs. */ 667228753Smm#define ARCHIVE_EXTRACT_ACL (0x0020) 668228753Smm/* Default: Do not restore fflags. */ 669228753Smm#define ARCHIVE_EXTRACT_FFLAGS (0x0040) 670228753Smm/* Default: Do not restore xattrs. */ 671228753Smm#define ARCHIVE_EXTRACT_XATTR (0x0080) 672228753Smm/* Default: Do not try to guard against extracts redirected by symlinks. */ 673228753Smm/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */ 674228753Smm#define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100) 675228753Smm/* Default: Do not reject entries with '..' as path elements. */ 676228753Smm#define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200) 677228753Smm/* Default: Create parent directories as needed. */ 678228753Smm#define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400) 679228753Smm/* Default: Overwrite files, even if one on disk is newer. */ 680228753Smm#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800) 681228753Smm/* Detect blocks of 0 and write holes instead. */ 682228753Smm#define ARCHIVE_EXTRACT_SPARSE (0x1000) 683232153Smm/* Default: Do not restore Mac extended metadata. */ 684232153Smm/* This has no effect except on Mac OS. */ 685232153Smm#define ARCHIVE_EXTRACT_MAC_METADATA (0x2000) 686248616Smm/* Default: Use HFS+ compression if it was compressed. */ 687248616Smm/* This has no effect except on Mac OS v10.6 or later. */ 688248616Smm#define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000) 689248616Smm/* Default: Do not use HFS+ compression if it was not compressed. */ 690248616Smm/* This has no effect except on Mac OS v10.6 or later. */ 691248616Smm#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000) 692299529Smm/* Default: Do not reject entries with absolute paths */ 693299529Smm#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000) 694299529Smm/* Default: Do not clear no-change flags when unlinking object */ 695299529Smm#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000) 696228753Smm 697232153Smm__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *, 698228753Smm int flags); 699232153Smm__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *, 700228753Smm struct archive * /* dest */); 701228753Smm__LA_DECL void archive_read_extract_set_progress_callback(struct archive *, 702228753Smm void (*_progress_func)(void *), void *_user_data); 703228753Smm 704228753Smm/* Record the dev/ino of a file that will not be written. This is 705228753Smm * generally set to the dev/ino of the archive being read. */ 706228753Smm__LA_DECL void archive_read_extract_set_skip_file(struct archive *, 707299529Smm la_int64_t, la_int64_t); 708228753Smm 709228753Smm/* Close the file and release most resources. */ 710228753Smm__LA_DECL int archive_read_close(struct archive *); 711228753Smm/* Release all resources and destroy the object. */ 712228773Smm/* Note that archive_read_free will call archive_read_close for you. */ 713228773Smm__LA_DECL int archive_read_free(struct archive *); 714228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000 715228773Smm/* Synonym for archive_read_free() for backwards compatibility. */ 716248616Smm__LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED; 717228753Smm#endif 718228753Smm 719228753Smm/*- 720228753Smm * To create an archive: 721232153Smm * 1) Ask archive_write_new for an archive writer object. 722228753Smm * 2) Set any global properties. In particular, you should set 723228753Smm * the compression and format to use. 724228753Smm * 3) Call archive_write_open to open the file (most people 725228753Smm * will use archive_write_open_file or archive_write_open_fd, 726228753Smm * which provide convenient canned I/O callbacks for you). 727228753Smm * 4) For each entry: 728228753Smm * - construct an appropriate struct archive_entry structure 729228753Smm * - archive_write_header to write the header 730228753Smm * - archive_write_data to write the entry data 731228753Smm * 5) archive_write_close to close the output 732228773Smm * 6) archive_write_free to cleanup the writer and release resources 733228753Smm */ 734228753Smm__LA_DECL struct archive *archive_write_new(void); 735232153Smm__LA_DECL int archive_write_set_bytes_per_block(struct archive *, 736228753Smm int bytes_per_block); 737232153Smm__LA_DECL int archive_write_get_bytes_per_block(struct archive *); 738228753Smm/* XXX This is badly misnamed; suggestions appreciated. XXX */ 739232153Smm__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *, 740228753Smm int bytes_in_last_block); 741232153Smm__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *); 742228753Smm 743228753Smm/* The dev/ino of a file that won't be archived. This is used 744228753Smm * to avoid recursively adding an archive to itself. */ 745232153Smm__LA_DECL int archive_write_set_skip_file(struct archive *, 746299529Smm la_int64_t, la_int64_t); 747228753Smm 748232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 749248616Smm__LA_DECL int archive_write_set_compression_bzip2(struct archive *) 750248616Smm __LA_DEPRECATED; 751248616Smm__LA_DECL int archive_write_set_compression_compress(struct archive *) 752248616Smm __LA_DEPRECATED; 753248616Smm__LA_DECL int archive_write_set_compression_gzip(struct archive *) 754248616Smm __LA_DEPRECATED; 755248616Smm__LA_DECL int archive_write_set_compression_lzip(struct archive *) 756248616Smm __LA_DEPRECATED; 757248616Smm__LA_DECL int archive_write_set_compression_lzma(struct archive *) 758248616Smm __LA_DEPRECATED; 759248616Smm__LA_DECL int archive_write_set_compression_none(struct archive *) 760248616Smm __LA_DEPRECATED; 761232153Smm__LA_DECL int archive_write_set_compression_program(struct archive *, 762248616Smm const char *cmd) __LA_DEPRECATED; 763248616Smm__LA_DECL int archive_write_set_compression_xz(struct archive *) 764248616Smm __LA_DEPRECATED; 765232153Smm#endif 766232153Smm 767238856Smm/* A convenience function to set the filter based on the code. */ 768238856Smm__LA_DECL int archive_write_add_filter(struct archive *, int filter_code); 769248616Smm__LA_DECL int archive_write_add_filter_by_name(struct archive *, 770248616Smm const char *name); 771248616Smm__LA_DECL int archive_write_add_filter_b64encode(struct archive *); 772232153Smm__LA_DECL int archive_write_add_filter_bzip2(struct archive *); 773232153Smm__LA_DECL int archive_write_add_filter_compress(struct archive *); 774248616Smm__LA_DECL int archive_write_add_filter_grzip(struct archive *); 775232153Smm__LA_DECL int archive_write_add_filter_gzip(struct archive *); 776248616Smm__LA_DECL int archive_write_add_filter_lrzip(struct archive *); 777299529Smm__LA_DECL int archive_write_add_filter_lz4(struct archive *); 778232153Smm__LA_DECL int archive_write_add_filter_lzip(struct archive *); 779232153Smm__LA_DECL int archive_write_add_filter_lzma(struct archive *); 780248616Smm__LA_DECL int archive_write_add_filter_lzop(struct archive *); 781232153Smm__LA_DECL int archive_write_add_filter_none(struct archive *); 782232153Smm__LA_DECL int archive_write_add_filter_program(struct archive *, 783232153Smm const char *cmd); 784248616Smm__LA_DECL int archive_write_add_filter_uuencode(struct archive *); 785232153Smm__LA_DECL int archive_write_add_filter_xz(struct archive *); 786324417Smm__LA_DECL int archive_write_add_filter_zstd(struct archive *); 787232153Smm 788232153Smm 789228753Smm/* A convenience function to set the format based on the code or name. */ 790232153Smm__LA_DECL int archive_write_set_format(struct archive *, int format_code); 791232153Smm__LA_DECL int archive_write_set_format_by_name(struct archive *, 792228753Smm const char *name); 793228753Smm/* To minimize link pollution, use one or more of the following. */ 794232153Smm__LA_DECL int archive_write_set_format_7zip(struct archive *); 795232153Smm__LA_DECL int archive_write_set_format_ar_bsd(struct archive *); 796232153Smm__LA_DECL int archive_write_set_format_ar_svr4(struct archive *); 797232153Smm__LA_DECL int archive_write_set_format_cpio(struct archive *); 798232153Smm__LA_DECL int archive_write_set_format_cpio_newc(struct archive *); 799232153Smm__LA_DECL int archive_write_set_format_gnutar(struct archive *); 800232153Smm__LA_DECL int archive_write_set_format_iso9660(struct archive *); 801232153Smm__LA_DECL int archive_write_set_format_mtree(struct archive *); 802248616Smm__LA_DECL int archive_write_set_format_mtree_classic(struct archive *); 803228753Smm/* TODO: int archive_write_set_format_old_tar(struct archive *); */ 804232153Smm__LA_DECL int archive_write_set_format_pax(struct archive *); 805232153Smm__LA_DECL int archive_write_set_format_pax_restricted(struct archive *); 806299529Smm__LA_DECL int archive_write_set_format_raw(struct archive *); 807232153Smm__LA_DECL int archive_write_set_format_shar(struct archive *); 808232153Smm__LA_DECL int archive_write_set_format_shar_dump(struct archive *); 809232153Smm__LA_DECL int archive_write_set_format_ustar(struct archive *); 810248616Smm__LA_DECL int archive_write_set_format_v7tar(struct archive *); 811299529Smm__LA_DECL int archive_write_set_format_warc(struct archive *); 812232153Smm__LA_DECL int archive_write_set_format_xar(struct archive *); 813232153Smm__LA_DECL int archive_write_set_format_zip(struct archive *); 814299529Smm__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename); 815299529Smm__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext); 816248616Smm__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *); 817248616Smm__LA_DECL int archive_write_zip_set_compression_store(struct archive *); 818232153Smm__LA_DECL int archive_write_open(struct archive *, void *, 819228753Smm archive_open_callback *, archive_write_callback *, 820228753Smm archive_close_callback *); 821232153Smm__LA_DECL int archive_write_open_fd(struct archive *, int _fd); 822232153Smm__LA_DECL int archive_write_open_filename(struct archive *, const char *_file); 823232153Smm__LA_DECL int archive_write_open_filename_w(struct archive *, 824232153Smm const wchar_t *_file); 825228753Smm/* A deprecated synonym for archive_write_open_filename() */ 826248616Smm__LA_DECL int archive_write_open_file(struct archive *, const char *_file) 827248616Smm __LA_DEPRECATED; 828232153Smm__LA_DECL int archive_write_open_FILE(struct archive *, FILE *); 829228753Smm/* _buffSize is the size of the buffer, _used refers to a variable that 830228753Smm * will be updated after each write into the buffer. */ 831232153Smm__LA_DECL int archive_write_open_memory(struct archive *, 832228753Smm void *_buffer, size_t _buffSize, size_t *_used); 833228753Smm 834228753Smm/* 835228753Smm * Note that the library will truncate writes beyond the size provided 836228753Smm * to archive_write_header or pad if the provided data is short. 837228753Smm */ 838232153Smm__LA_DECL int archive_write_header(struct archive *, 839228753Smm struct archive_entry *); 840299529Smm__LA_DECL la_ssize_t archive_write_data(struct archive *, 841228753Smm const void *, size_t); 842228753Smm 843232153Smm/* This interface is currently only available for archive_write_disk handles. */ 844299529Smm__LA_DECL la_ssize_t archive_write_data_block(struct archive *, 845299529Smm const void *, size_t, la_int64_t); 846232153Smm 847228753Smm__LA_DECL int archive_write_finish_entry(struct archive *); 848228753Smm__LA_DECL int archive_write_close(struct archive *); 849248616Smm/* Marks the archive as FATAL so that a subsequent free() operation 850248616Smm * won't try to close() cleanly. Provides a fast abort capability 851248616Smm * when the client discovers that things have gone wrong. */ 852248616Smm__LA_DECL int archive_write_fail(struct archive *); 853228773Smm/* This can fail if the archive wasn't already closed, in which case 854228773Smm * archive_write_free() will implicitly call archive_write_close(). */ 855228773Smm__LA_DECL int archive_write_free(struct archive *); 856228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000 857228773Smm/* Synonym for archive_write_free() for backwards compatibility. */ 858248616Smm__LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED; 859228753Smm#endif 860228753Smm 861228753Smm/* 862228753Smm * Set write options. 863228753Smm */ 864232153Smm/* Apply option to the format only. */ 865232153Smm__LA_DECL int archive_write_set_format_option(struct archive *_a, 866232153Smm const char *m, const char *o, 867232153Smm const char *v); 868232153Smm/* Apply option to the filter only. */ 869232153Smm__LA_DECL int archive_write_set_filter_option(struct archive *_a, 870232153Smm const char *m, const char *o, 871232153Smm const char *v); 872232153Smm/* Apply option to both the format and the filter. */ 873232153Smm__LA_DECL int archive_write_set_option(struct archive *_a, 874232153Smm const char *m, const char *o, 875232153Smm const char *v); 876232153Smm/* Apply option string to both the format and the filter. */ 877232153Smm__LA_DECL int archive_write_set_options(struct archive *_a, 878232153Smm const char *opts); 879228753Smm 880299529Smm/* 881299529Smm * Set a encryption passphrase. 882299529Smm */ 883299529Smm__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p); 884299529Smm__LA_DECL int archive_write_set_passphrase_callback(struct archive *, 885299529Smm void *client_data, archive_passphrase_callback *); 886299529Smm 887228753Smm/*- 888228753Smm * ARCHIVE_WRITE_DISK API 889228753Smm * 890228753Smm * To create objects on disk: 891228753Smm * 1) Ask archive_write_disk_new for a new archive_write_disk object. 892228753Smm * 2) Set any global properties. In particular, you probably 893228753Smm * want to set the options. 894228753Smm * 3) For each entry: 895228753Smm * - construct an appropriate struct archive_entry structure 896228753Smm * - archive_write_header to create the file/dir/etc on disk 897228753Smm * - archive_write_data to write the entry data 898228773Smm * 4) archive_write_free to cleanup the writer and release resources 899228753Smm * 900228753Smm * In particular, you can use this in conjunction with archive_read() 901228753Smm * to pull entries out of an archive and create them on disk. 902228753Smm */ 903228753Smm__LA_DECL struct archive *archive_write_disk_new(void); 904228753Smm/* This file will not be overwritten. */ 905232153Smm__LA_DECL int archive_write_disk_set_skip_file(struct archive *, 906299529Smm la_int64_t, la_int64_t); 907228753Smm/* Set flags to control how the next item gets created. 908228753Smm * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */ 909228753Smm__LA_DECL int archive_write_disk_set_options(struct archive *, 910228753Smm int flags); 911228753Smm/* 912228753Smm * The lookup functions are given uname/uid (or gname/gid) pairs and 913228753Smm * return a uid (gid) suitable for this system. These are used for 914228753Smm * restoring ownership and for setting ACLs. The default functions 915228753Smm * are naive, they just return the uid/gid. These are small, so reasonable 916228753Smm * for applications that don't need to preserve ownership; they 917228753Smm * are probably also appropriate for applications that are doing 918228753Smm * same-system backup and restore. 919228753Smm */ 920228753Smm/* 921228753Smm * The "standard" lookup functions use common system calls to lookup 922228753Smm * the uname/gname, falling back to the uid/gid if the names can't be 923228753Smm * found. They cache lookups and are reasonably fast, but can be very 924228753Smm * large, so they are not used unless you ask for them. In 925228753Smm * particular, these match the specifications of POSIX "pax" and old 926228753Smm * POSIX "tar". 927228753Smm */ 928228753Smm__LA_DECL int archive_write_disk_set_standard_lookup(struct archive *); 929228753Smm/* 930228753Smm * If neither the default (naive) nor the standard (big) functions suit 931228753Smm * your needs, you can write your own and register them. Be sure to 932228753Smm * include a cleanup function if you have allocated private data. 933228753Smm */ 934232153Smm__LA_DECL int archive_write_disk_set_group_lookup(struct archive *, 935232153Smm void * /* private_data */, 936299529Smm la_int64_t (*)(void *, const char *, la_int64_t), 937232153Smm void (* /* cleanup */)(void *)); 938232153Smm__LA_DECL int archive_write_disk_set_user_lookup(struct archive *, 939232153Smm void * /* private_data */, 940299529Smm la_int64_t (*)(void *, const char *, la_int64_t), 941232153Smm void (* /* cleanup */)(void *)); 942299529Smm__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t); 943299529Smm__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t); 944228753Smm 945228753Smm/* 946228753Smm * ARCHIVE_READ_DISK API 947228753Smm * 948228753Smm * This is still evolving and somewhat experimental. 949228753Smm */ 950228753Smm__LA_DECL struct archive *archive_read_disk_new(void); 951228753Smm/* The names for symlink modes here correspond to an old BSD 952228753Smm * command-line argument convention: -L, -P, -H */ 953228753Smm/* Follow all symlinks. */ 954228753Smm__LA_DECL int archive_read_disk_set_symlink_logical(struct archive *); 955228753Smm/* Follow no symlinks. */ 956228753Smm__LA_DECL int archive_read_disk_set_symlink_physical(struct archive *); 957228753Smm/* Follow symlink initially, then not. */ 958228753Smm__LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *); 959228753Smm/* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */ 960228753Smm__LA_DECL int archive_read_disk_entry_from_file(struct archive *, 961228753Smm struct archive_entry *, int /* fd */, const struct stat *); 962228753Smm/* Look up gname for gid or uname for uid. */ 963228753Smm/* Default implementations are very, very stupid. */ 964299529Smm__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t); 965299529Smm__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t); 966228753Smm/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the 967228753Smm * results for performance. */ 968228753Smm__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *); 969228753Smm/* You can install your own lookups if you like. */ 970228753Smm__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, 971228753Smm void * /* private_data */, 972299529Smm const char *(* /* lookup_fn */)(void *, la_int64_t), 973228753Smm void (* /* cleanup_fn */)(void *)); 974228753Smm__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, 975228753Smm void * /* private_data */, 976299529Smm const char *(* /* lookup_fn */)(void *, la_int64_t), 977228753Smm void (* /* cleanup_fn */)(void *)); 978232153Smm/* Start traversal. */ 979232153Smm__LA_DECL int archive_read_disk_open(struct archive *, const char *); 980232153Smm__LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *); 981232153Smm/* 982232153Smm * Request that current entry be visited. If you invoke it on every 983232153Smm * directory, you'll get a physical traversal. This is ignored if the 984232153Smm * current entry isn't a directory or a link to a directory. So, if 985232153Smm * you invoke this on every returned path, you'll get a full logical 986232153Smm * traversal. 987232153Smm */ 988232153Smm__LA_DECL int archive_read_disk_descend(struct archive *); 989238856Smm__LA_DECL int archive_read_disk_can_descend(struct archive *); 990232153Smm__LA_DECL int archive_read_disk_current_filesystem(struct archive *); 991232153Smm__LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *); 992232153Smm__LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *); 993311041Smm/* Request that the access time of the entry visited by traversal be restored. */ 994232153Smm__LA_DECL int archive_read_disk_set_atime_restored(struct archive *); 995238856Smm/* 996238856Smm * Set behavior. The "flags" argument selects optional behavior. 997238856Smm */ 998311041Smm/* Request that the access time of the entry visited by traversal be restored. 999238856Smm * This is the same as archive_read_disk_set_atime_restored. */ 1000238856Smm#define ARCHIVE_READDISK_RESTORE_ATIME (0x0001) 1001238856Smm/* Default: Do not skip an entry which has nodump flags. */ 1002238856Smm#define ARCHIVE_READDISK_HONOR_NODUMP (0x0002) 1003238856Smm/* Default: Skip a mac resource fork file whose prefix is "._" because of 1004238856Smm * using copyfile. */ 1005238856Smm#define ARCHIVE_READDISK_MAC_COPYFILE (0x0004) 1006299529Smm/* Default: Traverse mount points. */ 1007238856Smm#define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008) 1008299529Smm/* Default: Xattrs are read from disk. */ 1009299529Smm#define ARCHIVE_READDISK_NO_XATTR (0x0010) 1010315432Smm/* Default: ACLs are read from disk. */ 1011315432Smm#define ARCHIVE_READDISK_NO_ACL (0x0020) 1012315432Smm/* Default: File flags are read from disk. */ 1013315432Smm#define ARCHIVE_READDISK_NO_FFLAGS (0x0040) 1014228753Smm 1015238856Smm__LA_DECL int archive_read_disk_set_behavior(struct archive *, 1016238856Smm int flags); 1017238856Smm 1018228753Smm/* 1019238856Smm * Set archive_match object that will be used in archive_read_disk to 1020238856Smm * know whether an entry should be skipped. The callback function 1021238856Smm * _excluded_func will be invoked when an entry is skipped by the result 1022238856Smm * of archive_match. 1023238856Smm */ 1024238856Smm__LA_DECL int archive_read_disk_set_matching(struct archive *, 1025238856Smm struct archive *_matching, void (*_excluded_func) 1026238856Smm (struct archive *, void *, struct archive_entry *), 1027238856Smm void *_client_data); 1028238856Smm__LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, 1029238856Smm int (*_metadata_filter_func)(struct archive *, void *, 1030238856Smm struct archive_entry *), void *_client_data); 1031238856Smm 1032299529Smm/* Simplified cleanup interface; 1033299529Smm * This calls archive_read_free() or archive_write_free() as needed. */ 1034299529Smm__LA_DECL int archive_free(struct archive *); 1035299529Smm 1036238856Smm/* 1037228753Smm * Accessor functions to read/set various information in 1038228753Smm * the struct archive object: 1039228753Smm */ 1040232153Smm 1041232153Smm/* Number of filters in the current filter pipeline. */ 1042232153Smm/* Filter #0 is the one closest to the format, -1 is a synonym for the 1043232153Smm * last filter, which is always the pseudo-filter that wraps the 1044232153Smm * client callbacks. */ 1045232153Smm__LA_DECL int archive_filter_count(struct archive *); 1046299529Smm__LA_DECL la_int64_t archive_filter_bytes(struct archive *, int); 1047232153Smm__LA_DECL int archive_filter_code(struct archive *, int); 1048232153Smm__LA_DECL const char * archive_filter_name(struct archive *, int); 1049232153Smm 1050232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 1051232153Smm/* These don't properly handle multiple filters, so are deprecated and 1052232153Smm * will eventually be removed. */ 1053232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */ 1054299529Smm__LA_DECL la_int64_t archive_position_compressed(struct archive *) 1055248616Smm __LA_DEPRECATED; 1056232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */ 1057299529Smm__LA_DECL la_int64_t archive_position_uncompressed(struct archive *) 1058248616Smm __LA_DEPRECATED; 1059232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */ 1060248616Smm__LA_DECL const char *archive_compression_name(struct archive *) 1061248616Smm __LA_DEPRECATED; 1062232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */ 1063248616Smm__LA_DECL int archive_compression(struct archive *) 1064248616Smm __LA_DEPRECATED; 1065232153Smm#endif 1066232153Smm 1067228753Smm__LA_DECL int archive_errno(struct archive *); 1068228753Smm__LA_DECL const char *archive_error_string(struct archive *); 1069228753Smm__LA_DECL const char *archive_format_name(struct archive *); 1070228753Smm__LA_DECL int archive_format(struct archive *); 1071228753Smm__LA_DECL void archive_clear_error(struct archive *); 1072228753Smm__LA_DECL void archive_set_error(struct archive *, int _err, 1073228753Smm const char *fmt, ...) __LA_PRINTF(3, 4); 1074228753Smm__LA_DECL void archive_copy_error(struct archive *dest, 1075228753Smm struct archive *src); 1076228753Smm__LA_DECL int archive_file_count(struct archive *); 1077228753Smm 1078238856Smm/* 1079238856Smm * ARCHIVE_MATCH API 1080238856Smm */ 1081238856Smm__LA_DECL struct archive *archive_match_new(void); 1082238856Smm__LA_DECL int archive_match_free(struct archive *); 1083238856Smm 1084238856Smm/* 1085238856Smm * Test if archive_entry is excluded. 1086238856Smm * This is a convenience function. This is the same as calling all 1087238856Smm * archive_match_path_excluded, archive_match_time_excluded 1088238856Smm * and archive_match_owner_excluded. 1089238856Smm */ 1090238856Smm__LA_DECL int archive_match_excluded(struct archive *, 1091238856Smm struct archive_entry *); 1092238856Smm 1093238856Smm/* 1094238856Smm * Test if pathname is excluded. The conditions are set by following functions. 1095238856Smm */ 1096238856Smm__LA_DECL int archive_match_path_excluded(struct archive *, 1097238856Smm struct archive_entry *); 1098238856Smm/* Add exclusion pathname pattern. */ 1099238856Smm__LA_DECL int archive_match_exclude_pattern(struct archive *, const char *); 1100238856Smm__LA_DECL int archive_match_exclude_pattern_w(struct archive *, 1101238856Smm const wchar_t *); 1102238856Smm/* Add exclusion pathname pattern from file. */ 1103238856Smm__LA_DECL int archive_match_exclude_pattern_from_file(struct archive *, 1104238856Smm const char *, int _nullSeparator); 1105238856Smm__LA_DECL int archive_match_exclude_pattern_from_file_w(struct archive *, 1106238856Smm const wchar_t *, int _nullSeparator); 1107238856Smm/* Add inclusion pathname pattern. */ 1108238856Smm__LA_DECL int archive_match_include_pattern(struct archive *, const char *); 1109238856Smm__LA_DECL int archive_match_include_pattern_w(struct archive *, 1110238856Smm const wchar_t *); 1111238856Smm/* Add inclusion pathname pattern from file. */ 1112238856Smm__LA_DECL int archive_match_include_pattern_from_file(struct archive *, 1113238856Smm const char *, int _nullSeparator); 1114238856Smm__LA_DECL int archive_match_include_pattern_from_file_w(struct archive *, 1115238856Smm const wchar_t *, int _nullSeparator); 1116238856Smm/* 1117238856Smm * How to get statistic information for inclusion patterns. 1118238856Smm */ 1119238856Smm/* Return the amount number of unmatched inclusion patterns. */ 1120238856Smm__LA_DECL int archive_match_path_unmatched_inclusions(struct archive *); 1121238856Smm/* Return the pattern of unmatched inclusion with ARCHIVE_OK. 1122238856Smm * Return ARCHIVE_EOF if there is no inclusion pattern. */ 1123238856Smm__LA_DECL int archive_match_path_unmatched_inclusions_next( 1124238856Smm struct archive *, const char **); 1125238856Smm__LA_DECL int archive_match_path_unmatched_inclusions_next_w( 1126238856Smm struct archive *, const wchar_t **); 1127238856Smm 1128238856Smm/* 1129238856Smm * Test if a file is excluded by its time stamp. 1130238856Smm * The conditions are set by following functions. 1131238856Smm */ 1132238856Smm__LA_DECL int archive_match_time_excluded(struct archive *, 1133238856Smm struct archive_entry *); 1134238856Smm 1135238856Smm/* 1136238856Smm * Flags to tell a matching type of time stamps. These are used for 1137311041Smm * following functions. 1138238856Smm */ 1139238856Smm/* Time flag: mtime to be tested. */ 1140238856Smm#define ARCHIVE_MATCH_MTIME (0x0100) 1141238856Smm/* Time flag: ctime to be tested. */ 1142238856Smm#define ARCHIVE_MATCH_CTIME (0x0200) 1143238856Smm/* Comparison flag: Match the time if it is newer than. */ 1144238856Smm#define ARCHIVE_MATCH_NEWER (0x0001) 1145238856Smm/* Comparison flag: Match the time if it is older than. */ 1146238856Smm#define ARCHIVE_MATCH_OLDER (0x0002) 1147238856Smm/* Comparison flag: Match the time if it is equal to. */ 1148238856Smm#define ARCHIVE_MATCH_EQUAL (0x0010) 1149238856Smm/* Set inclusion time. */ 1150238856Smm__LA_DECL int archive_match_include_time(struct archive *, int _flag, 1151238856Smm time_t _sec, long _nsec); 1152238856Smm/* Set inclusion time by a date string. */ 1153238856Smm__LA_DECL int archive_match_include_date(struct archive *, int _flag, 1154238856Smm const char *_datestr); 1155238856Smm__LA_DECL int archive_match_include_date_w(struct archive *, int _flag, 1156238856Smm const wchar_t *_datestr); 1157311041Smm/* Set inclusion time by a particular file. */ 1158238856Smm__LA_DECL int archive_match_include_file_time(struct archive *, 1159238856Smm int _flag, const char *_pathname); 1160238856Smm__LA_DECL int archive_match_include_file_time_w(struct archive *, 1161238856Smm int _flag, const wchar_t *_pathname); 1162238856Smm/* Add exclusion entry. */ 1163238856Smm__LA_DECL int archive_match_exclude_entry(struct archive *, 1164238856Smm int _flag, struct archive_entry *); 1165238856Smm 1166238856Smm/* 1167238856Smm * Test if a file is excluded by its uid ,gid, uname or gname. 1168238856Smm * The conditions are set by following functions. 1169238856Smm */ 1170238856Smm__LA_DECL int archive_match_owner_excluded(struct archive *, 1171238856Smm struct archive_entry *); 1172238856Smm/* Add inclusion uid, gid, uname and gname. */ 1173299529Smm__LA_DECL int archive_match_include_uid(struct archive *, la_int64_t); 1174299529Smm__LA_DECL int archive_match_include_gid(struct archive *, la_int64_t); 1175238856Smm__LA_DECL int archive_match_include_uname(struct archive *, const char *); 1176238856Smm__LA_DECL int archive_match_include_uname_w(struct archive *, 1177238856Smm const wchar_t *); 1178238856Smm__LA_DECL int archive_match_include_gname(struct archive *, const char *); 1179238856Smm__LA_DECL int archive_match_include_gname_w(struct archive *, 1180238856Smm const wchar_t *); 1181238856Smm 1182299529Smm/* Utility functions */ 1183299529Smm/* Convenience function to sort a NULL terminated list of strings */ 1184299529Smm__LA_DECL int archive_utility_string_sort(char **); 1185299529Smm 1186228753Smm#ifdef __cplusplus 1187228753Smm} 1188228753Smm#endif 1189228753Smm 1190228753Smm/* These are meaningless outside of this header. */ 1191228753Smm#undef __LA_DECL 1192228753Smm 1193228753Smm#endif /* !ARCHIVE_H_INCLUDED */ 1194