archive.h revision 368707
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 368707 2020-12-16 22:25:20Z 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! */ 39368707Smm#define ARCHIVE_VERSION_NUMBER 3005000 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> 55353376Smm#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H) 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 */ 158368707Smm#define ARCHIVE_VERSION_ONLY_STRING "3.5.0" 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 249368707Smmtypedef int archive_free_callback(struct archive *, void *_client_data); 250368707Smm 251248616Smm/* Switches from one client data object to the next/prev client data object. 252248616Smm * This is useful for reading from different data blocks such as a set of files 253248616Smm * that make up one large file. 254248616Smm */ 255248616Smmtypedef int archive_switch_callback(struct archive *, void *_client_data1, 256248616Smm void *_client_data2); 257248616Smm 258228753Smm/* 259299529Smm * Returns a passphrase used for encryption or decryption, NULL on nothing 260299529Smm * to do and give it up. 261299529Smm */ 262299529Smmtypedef const char *archive_passphrase_callback(struct archive *, 263299529Smm void *_client_data); 264299529Smm 265299529Smm/* 266232153Smm * Codes to identify various stream filters. 267228753Smm */ 268232153Smm#define ARCHIVE_FILTER_NONE 0 269232153Smm#define ARCHIVE_FILTER_GZIP 1 270232153Smm#define ARCHIVE_FILTER_BZIP2 2 271232153Smm#define ARCHIVE_FILTER_COMPRESS 3 272232153Smm#define ARCHIVE_FILTER_PROGRAM 4 273232153Smm#define ARCHIVE_FILTER_LZMA 5 274232153Smm#define ARCHIVE_FILTER_XZ 6 275232153Smm#define ARCHIVE_FILTER_UU 7 276232153Smm#define ARCHIVE_FILTER_RPM 8 277232153Smm#define ARCHIVE_FILTER_LZIP 9 278248616Smm#define ARCHIVE_FILTER_LRZIP 10 279248616Smm#define ARCHIVE_FILTER_LZOP 11 280248616Smm#define ARCHIVE_FILTER_GRZIP 12 281299529Smm#define ARCHIVE_FILTER_LZ4 13 282324417Smm#define ARCHIVE_FILTER_ZSTD 14 283228753Smm 284232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 285232153Smm#define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE 286232153Smm#define ARCHIVE_COMPRESSION_GZIP ARCHIVE_FILTER_GZIP 287232153Smm#define ARCHIVE_COMPRESSION_BZIP2 ARCHIVE_FILTER_BZIP2 288232153Smm#define ARCHIVE_COMPRESSION_COMPRESS ARCHIVE_FILTER_COMPRESS 289232153Smm#define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM 290232153Smm#define ARCHIVE_COMPRESSION_LZMA ARCHIVE_FILTER_LZMA 291232153Smm#define ARCHIVE_COMPRESSION_XZ ARCHIVE_FILTER_XZ 292232153Smm#define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU 293232153Smm#define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM 294232153Smm#define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP 295248616Smm#define ARCHIVE_COMPRESSION_LRZIP ARCHIVE_FILTER_LRZIP 296232153Smm#endif 297232153Smm 298228753Smm/* 299228753Smm * Codes returned by archive_format. 300228753Smm * 301228753Smm * Top 16 bits identifies the format family (e.g., "tar"); lower 302228753Smm * 16 bits indicate the variant. This is updated by read_next_header. 303228753Smm * Note that the lower 16 bits will often vary from entry to entry. 304228753Smm * In some cases, this variation occurs as libarchive learns more about 305228753Smm * the archive (for example, later entries might utilize extensions that 306228753Smm * weren't necessary earlier in the archive; in this case, libarchive 307228753Smm * will change the format code to indicate the extended format that 308228753Smm * was used). In other cases, it's because different tools have 309228753Smm * modified the archive and so different parts of the archive 310232153Smm * actually have slightly different formats. (Both tar and cpio store 311228753Smm * format codes in each entry, so it is quite possible for each 312228753Smm * entry to be in a different format.) 313228753Smm */ 314228753Smm#define ARCHIVE_FORMAT_BASE_MASK 0xff0000 315228753Smm#define ARCHIVE_FORMAT_CPIO 0x10000 316228753Smm#define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1) 317228753Smm#define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2) 318228753Smm#define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3) 319228753Smm#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4) 320228753Smm#define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5) 321232153Smm#define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6) 322228753Smm#define ARCHIVE_FORMAT_SHAR 0x20000 323228753Smm#define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1) 324228753Smm#define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2) 325228753Smm#define ARCHIVE_FORMAT_TAR 0x30000 326228753Smm#define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1) 327228753Smm#define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2) 328228753Smm#define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3) 329228753Smm#define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4) 330228753Smm#define ARCHIVE_FORMAT_ISO9660 0x40000 331228753Smm#define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1) 332228753Smm#define ARCHIVE_FORMAT_ZIP 0x50000 333228753Smm#define ARCHIVE_FORMAT_EMPTY 0x60000 334228753Smm#define ARCHIVE_FORMAT_AR 0x70000 335228753Smm#define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1) 336228753Smm#define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2) 337228753Smm#define ARCHIVE_FORMAT_MTREE 0x80000 338228753Smm#define ARCHIVE_FORMAT_RAW 0x90000 339228753Smm#define ARCHIVE_FORMAT_XAR 0xA0000 340232153Smm#define ARCHIVE_FORMAT_LHA 0xB0000 341232153Smm#define ARCHIVE_FORMAT_CAB 0xC0000 342232153Smm#define ARCHIVE_FORMAT_RAR 0xD0000 343232153Smm#define ARCHIVE_FORMAT_7ZIP 0xE0000 344299529Smm#define ARCHIVE_FORMAT_WARC 0xF0000 345348607Smm#define ARCHIVE_FORMAT_RAR_V5 0x100000 346228753Smm 347299529Smm/* 348299529Smm * Codes returned by archive_read_format_capabilities(). 349299529Smm * 350299529Smm * This list can be extended with values between 0 and 0xffff. 351299529Smm * The original purpose of this list was to let different archive 352299529Smm * format readers expose their general capabilities in terms of 353299529Smm * encryption. 354299529Smm */ 355299529Smm#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */ 356299529Smm#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */ 357299529Smm#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */ 358299529Smm 359299529Smm/* 360299529Smm * Codes returned by archive_read_has_encrypted_entries(). 361299529Smm * 362299529Smm * In case the archive does not support encryption detection at all 363299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader 364299529Smm * for some other reason (e.g. not enough bytes read) cannot say if 365299529Smm * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW 366299529Smm * is returned. 367299529Smm */ 368299529Smm#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2 369299529Smm#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1 370299529Smm 371228753Smm/*- 372228753Smm * Basic outline for reading an archive: 373228753Smm * 1) Ask archive_read_new for an archive reader object. 374228753Smm * 2) Update any global properties as appropriate. 375228753Smm * In particular, you'll certainly want to call appropriate 376228753Smm * archive_read_support_XXX functions. 377228753Smm * 3) Call archive_read_open_XXX to open the archive 378228753Smm * 4) Repeatedly call archive_read_next_header to get information about 379228753Smm * successive archive entries. Call archive_read_data to extract 380228753Smm * data for entries of interest. 381311041Smm * 5) Call archive_read_free to end processing. 382228753Smm */ 383228753Smm__LA_DECL struct archive *archive_read_new(void); 384228753Smm 385228753Smm/* 386228753Smm * The archive_read_support_XXX calls enable auto-detect for this 387228753Smm * archive handle. They also link in the necessary support code. 388228753Smm * For example, if you don't want bzlib linked in, don't invoke 389228753Smm * support_compression_bzip2(). The "all" functions provide the 390228753Smm * obvious shorthand. 391228753Smm */ 392232153Smm 393232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 394248616Smm__LA_DECL int archive_read_support_compression_all(struct archive *) 395248616Smm __LA_DEPRECATED; 396248616Smm__LA_DECL int archive_read_support_compression_bzip2(struct archive *) 397248616Smm __LA_DEPRECATED; 398248616Smm__LA_DECL int archive_read_support_compression_compress(struct archive *) 399248616Smm __LA_DEPRECATED; 400248616Smm__LA_DECL int archive_read_support_compression_gzip(struct archive *) 401248616Smm __LA_DEPRECATED; 402248616Smm__LA_DECL int archive_read_support_compression_lzip(struct archive *) 403248616Smm __LA_DEPRECATED; 404248616Smm__LA_DECL int archive_read_support_compression_lzma(struct archive *) 405248616Smm __LA_DEPRECATED; 406248616Smm__LA_DECL int archive_read_support_compression_none(struct archive *) 407248616Smm __LA_DEPRECATED; 408232153Smm__LA_DECL int archive_read_support_compression_program(struct archive *, 409248616Smm const char *command) __LA_DEPRECATED; 410232153Smm__LA_DECL int archive_read_support_compression_program_signature 411232153Smm (struct archive *, const char *, 412248616Smm const void * /* match */, size_t) __LA_DEPRECATED; 413228753Smm 414248616Smm__LA_DECL int archive_read_support_compression_rpm(struct archive *) 415248616Smm __LA_DEPRECATED; 416248616Smm__LA_DECL int archive_read_support_compression_uu(struct archive *) 417248616Smm __LA_DEPRECATED; 418248616Smm__LA_DECL int archive_read_support_compression_xz(struct archive *) 419248616Smm __LA_DEPRECATED; 420232153Smm#endif 421228753Smm 422232153Smm__LA_DECL int archive_read_support_filter_all(struct archive *); 423368707Smm__LA_DECL int archive_read_support_filter_by_code(struct archive *, int); 424232153Smm__LA_DECL int archive_read_support_filter_bzip2(struct archive *); 425232153Smm__LA_DECL int archive_read_support_filter_compress(struct archive *); 426232153Smm__LA_DECL int archive_read_support_filter_gzip(struct archive *); 427248616Smm__LA_DECL int archive_read_support_filter_grzip(struct archive *); 428248616Smm__LA_DECL int archive_read_support_filter_lrzip(struct archive *); 429299529Smm__LA_DECL int archive_read_support_filter_lz4(struct archive *); 430232153Smm__LA_DECL int archive_read_support_filter_lzip(struct archive *); 431232153Smm__LA_DECL int archive_read_support_filter_lzma(struct archive *); 432248616Smm__LA_DECL int archive_read_support_filter_lzop(struct archive *); 433232153Smm__LA_DECL int archive_read_support_filter_none(struct archive *); 434232153Smm__LA_DECL int archive_read_support_filter_program(struct archive *, 435232153Smm const char *command); 436232153Smm__LA_DECL int archive_read_support_filter_program_signature 437248616Smm (struct archive *, const char * /* cmd */, 438232153Smm const void * /* match */, size_t); 439232153Smm__LA_DECL int archive_read_support_filter_rpm(struct archive *); 440232153Smm__LA_DECL int archive_read_support_filter_uu(struct archive *); 441232153Smm__LA_DECL int archive_read_support_filter_xz(struct archive *); 442324417Smm__LA_DECL int archive_read_support_filter_zstd(struct archive *); 443228753Smm 444232153Smm__LA_DECL int archive_read_support_format_7zip(struct archive *); 445232153Smm__LA_DECL int archive_read_support_format_all(struct archive *); 446232153Smm__LA_DECL int archive_read_support_format_ar(struct archive *); 447232153Smm__LA_DECL int archive_read_support_format_by_code(struct archive *, int); 448232153Smm__LA_DECL int archive_read_support_format_cab(struct archive *); 449232153Smm__LA_DECL int archive_read_support_format_cpio(struct archive *); 450232153Smm__LA_DECL int archive_read_support_format_empty(struct archive *); 451232153Smm__LA_DECL int archive_read_support_format_gnutar(struct archive *); 452232153Smm__LA_DECL int archive_read_support_format_iso9660(struct archive *); 453232153Smm__LA_DECL int archive_read_support_format_lha(struct archive *); 454232153Smm__LA_DECL int archive_read_support_format_mtree(struct archive *); 455232153Smm__LA_DECL int archive_read_support_format_rar(struct archive *); 456342360Smm__LA_DECL int archive_read_support_format_rar5(struct archive *); 457232153Smm__LA_DECL int archive_read_support_format_raw(struct archive *); 458232153Smm__LA_DECL int archive_read_support_format_tar(struct archive *); 459299529Smm__LA_DECL int archive_read_support_format_warc(struct archive *); 460232153Smm__LA_DECL int archive_read_support_format_xar(struct archive *); 461299529Smm/* archive_read_support_format_zip() enables both streamable and seekable 462299529Smm * zip readers. */ 463232153Smm__LA_DECL int archive_read_support_format_zip(struct archive *); 464299529Smm/* Reads Zip archives as stream from beginning to end. Doesn't 465299529Smm * correctly handle SFX ZIP files or ZIP archives that have been modified 466299529Smm * in-place. */ 467299529Smm__LA_DECL int archive_read_support_format_zip_streamable(struct archive *); 468299529Smm/* Reads starting from central directory; requires seekable input. */ 469299529Smm__LA_DECL int archive_read_support_format_zip_seekable(struct archive *); 470232153Smm 471248616Smm/* Functions to manually set the format and filters to be used. This is 472248616Smm * useful to bypass the bidding process when the format and filters to use 473248616Smm * is known in advance. 474248616Smm */ 475248616Smm__LA_DECL int archive_read_set_format(struct archive *, int); 476248616Smm__LA_DECL int archive_read_append_filter(struct archive *, int); 477248616Smm__LA_DECL int archive_read_append_filter_program(struct archive *, 478248616Smm const char *); 479248616Smm__LA_DECL int archive_read_append_filter_program_signature 480248616Smm (struct archive *, const char *, const void * /* match */, size_t); 481248616Smm 482232153Smm/* Set various callbacks. */ 483232153Smm__LA_DECL int archive_read_set_open_callback(struct archive *, 484232153Smm archive_open_callback *); 485232153Smm__LA_DECL int archive_read_set_read_callback(struct archive *, 486232153Smm archive_read_callback *); 487232153Smm__LA_DECL int archive_read_set_seek_callback(struct archive *, 488232153Smm archive_seek_callback *); 489232153Smm__LA_DECL int archive_read_set_skip_callback(struct archive *, 490232153Smm archive_skip_callback *); 491232153Smm__LA_DECL int archive_read_set_close_callback(struct archive *, 492232153Smm archive_close_callback *); 493248616Smm/* Callback used to switch between one data object to the next */ 494248616Smm__LA_DECL int archive_read_set_switch_callback(struct archive *, 495248616Smm archive_switch_callback *); 496248616Smm 497248616Smm/* This sets the first data object. */ 498232153Smm__LA_DECL int archive_read_set_callback_data(struct archive *, void *); 499248616Smm/* This sets data object at specified index */ 500248616Smm__LA_DECL int archive_read_set_callback_data2(struct archive *, void *, 501248616Smm unsigned int); 502248616Smm/* This adds a data object at the specified index. */ 503248616Smm__LA_DECL int archive_read_add_callback_data(struct archive *, void *, 504248616Smm unsigned int); 505248616Smm/* This appends a data object to the end of list */ 506248616Smm__LA_DECL int archive_read_append_callback_data(struct archive *, void *); 507248616Smm/* This prepends a data object to the beginning of list */ 508248616Smm__LA_DECL int archive_read_prepend_callback_data(struct archive *, void *); 509248616Smm 510232153Smm/* Opening freezes the callbacks. */ 511232153Smm__LA_DECL int archive_read_open1(struct archive *); 512232153Smm 513232153Smm/* Convenience wrappers around the above. */ 514232153Smm__LA_DECL int archive_read_open(struct archive *, void *_client_data, 515228753Smm archive_open_callback *, archive_read_callback *, 516228753Smm archive_close_callback *); 517232153Smm__LA_DECL int archive_read_open2(struct archive *, void *_client_data, 518228753Smm archive_open_callback *, archive_read_callback *, 519228753Smm archive_skip_callback *, archive_close_callback *); 520228753Smm 521228753Smm/* 522228753Smm * A variety of shortcuts that invoke archive_read_open() with 523228753Smm * canned callbacks suitable for common situations. The ones that 524228753Smm * accept a block size handle tape blocking correctly. 525228753Smm */ 526228753Smm/* Use this if you know the filename. Note: NULL indicates stdin. */ 527232153Smm__LA_DECL int archive_read_open_filename(struct archive *, 528228753Smm const char *_filename, size_t _block_size); 529248616Smm/* Use this for reading multivolume files by filenames. 530248616Smm * NOTE: Must be NULL terminated. Sorting is NOT done. */ 531248616Smm__LA_DECL int archive_read_open_filenames(struct archive *, 532248616Smm const char **_filenames, size_t _block_size); 533232153Smm__LA_DECL int archive_read_open_filename_w(struct archive *, 534232153Smm const wchar_t *_filename, size_t _block_size); 535228753Smm/* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */ 536232153Smm__LA_DECL int archive_read_open_file(struct archive *, 537248616Smm const char *_filename, size_t _block_size) __LA_DEPRECATED; 538228753Smm/* Read an archive that's stored in memory. */ 539232153Smm__LA_DECL int archive_read_open_memory(struct archive *, 540299529Smm const void * buff, size_t size); 541228753Smm/* A more involved version that is only used for internal testing. */ 542299529Smm__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff, 543228753Smm size_t size, size_t read_size); 544228753Smm/* Read an archive that's already open, using the file descriptor. */ 545232153Smm__LA_DECL int archive_read_open_fd(struct archive *, int _fd, 546228753Smm size_t _block_size); 547228753Smm/* Read an archive that's already open, using a FILE *. */ 548228753Smm/* Note: DO NOT use this with tape drives. */ 549232153Smm__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file); 550228753Smm 551228753Smm/* Parses and returns next entry header. */ 552232153Smm__LA_DECL int archive_read_next_header(struct archive *, 553228753Smm struct archive_entry **); 554228753Smm 555228753Smm/* Parses and returns next entry header using the archive_entry passed in */ 556232153Smm__LA_DECL int archive_read_next_header2(struct archive *, 557228753Smm struct archive_entry *); 558228753Smm 559228753Smm/* 560228753Smm * Retrieve the byte offset in UNCOMPRESSED data where last-read 561228753Smm * header started. 562228753Smm */ 563299529Smm__LA_DECL la_int64_t archive_read_header_position(struct archive *); 564228753Smm 565299529Smm/* 566299529Smm * Returns 1 if the archive contains at least one encrypted entry. 567299529Smm * If the archive format not support encryption at all 568299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. 569299529Smm * If for any other reason (e.g. not enough data read so far) 570299529Smm * we cannot say whether there are encrypted entries, then 571299529Smm * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned. 572299529Smm * In general, this function will return values below zero when the 573311041Smm * reader is uncertain or totally incapable of encryption support. 574299529Smm * When this function returns 0 you can be sure that the reader 575299529Smm * supports encryption detection but no encrypted entries have 576299529Smm * been found yet. 577299529Smm * 578299529Smm * NOTE: If the metadata/header of an archive is also encrypted, you 579299529Smm * cannot rely on the number of encrypted entries. That is why this 580299529Smm * function does not return the number of encrypted entries but# 581299529Smm * just shows that there are some. 582299529Smm */ 583299529Smm__LA_DECL int archive_read_has_encrypted_entries(struct archive *); 584299529Smm 585299529Smm/* 586299529Smm * Returns a bitmask of capabilities that are supported by the archive format reader. 587299529Smm * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. 588299529Smm */ 589299529Smm__LA_DECL int archive_read_format_capabilities(struct archive *); 590299529Smm 591228753Smm/* Read data from the body of an entry. Similar to read(2). */ 592299529Smm__LA_DECL la_ssize_t archive_read_data(struct archive *, 593228753Smm void *, size_t); 594228753Smm 595248616Smm/* Seek within the body of an entry. Similar to lseek(2). */ 596299529Smm__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int); 597248616Smm 598228753Smm/* 599228753Smm * A zero-copy version of archive_read_data that also exposes the file offset 600228753Smm * of each returned block. Note that the client has no way to specify 601228753Smm * the desired size of the block. The API does guarantee that offsets will 602228753Smm * be strictly increasing and that returned blocks will not overlap. 603228753Smm */ 604232153Smm__LA_DECL int archive_read_data_block(struct archive *a, 605299529Smm const void **buff, size_t *size, la_int64_t *offset); 606228753Smm 607228753Smm/*- 608228753Smm * Some convenience functions that are built on archive_read_data: 609228753Smm * 'skip': skips entire entry 610228753Smm * 'into_buffer': writes data into memory buffer that you provide 611228753Smm * 'into_fd': writes data to specified filedes 612228753Smm */ 613232153Smm__LA_DECL int archive_read_data_skip(struct archive *); 614232153Smm__LA_DECL int archive_read_data_into_fd(struct archive *, int fd); 615228753Smm 616228753Smm/* 617228753Smm * Set read options. 618228753Smm */ 619232153Smm/* Apply option to the format only. */ 620232153Smm__LA_DECL int archive_read_set_format_option(struct archive *_a, 621232153Smm const char *m, const char *o, 622232153Smm const char *v); 623232153Smm/* Apply option to the filter only. */ 624232153Smm__LA_DECL int archive_read_set_filter_option(struct archive *_a, 625232153Smm const char *m, const char *o, 626232153Smm const char *v); 627232153Smm/* Apply option to both the format and the filter. */ 628232153Smm__LA_DECL int archive_read_set_option(struct archive *_a, 629232153Smm const char *m, const char *o, 630232153Smm const char *v); 631228753Smm/* Apply option string to both the format and the filter. */ 632232153Smm__LA_DECL int archive_read_set_options(struct archive *_a, 633232153Smm const char *opts); 634228753Smm 635299529Smm/* 636299529Smm * Add a decryption passphrase. 637299529Smm */ 638299529Smm__LA_DECL int archive_read_add_passphrase(struct archive *, const char *); 639299529Smm__LA_DECL int archive_read_set_passphrase_callback(struct archive *, 640299529Smm void *client_data, archive_passphrase_callback *); 641299529Smm 642299529Smm 643228753Smm/*- 644228753Smm * Convenience function to recreate the current entry (whose header 645228753Smm * has just been read) on disk. 646228753Smm * 647228753Smm * This does quite a bit more than just copy data to disk. It also: 648228753Smm * - Creates intermediate directories as required. 649228753Smm * - Manages directory permissions: non-writable directories will 650228753Smm * be initially created with write permission enabled; when the 651228753Smm * archive is closed, dir permissions are edited to the values specified 652228753Smm * in the archive. 653228753Smm * - Checks hardlinks: hardlinks will not be extracted unless the 654228753Smm * linked-to file was also extracted within the same session. (TODO) 655228753Smm */ 656228753Smm 657228753Smm/* The "flags" argument selects optional behavior, 'OR' the flags you want. */ 658228753Smm 659228753Smm/* Default: Do not try to set owner/group. */ 660228753Smm#define ARCHIVE_EXTRACT_OWNER (0x0001) 661228753Smm/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */ 662228753Smm#define ARCHIVE_EXTRACT_PERM (0x0002) 663228753Smm/* Default: Do not restore mtime/atime. */ 664228753Smm#define ARCHIVE_EXTRACT_TIME (0x0004) 665228753Smm/* Default: Replace existing files. */ 666228753Smm#define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008) 667228753Smm/* Default: Try create first, unlink only if create fails with EEXIST. */ 668228753Smm#define ARCHIVE_EXTRACT_UNLINK (0x0010) 669228753Smm/* Default: Do not restore ACLs. */ 670228753Smm#define ARCHIVE_EXTRACT_ACL (0x0020) 671228753Smm/* Default: Do not restore fflags. */ 672228753Smm#define ARCHIVE_EXTRACT_FFLAGS (0x0040) 673228753Smm/* Default: Do not restore xattrs. */ 674228753Smm#define ARCHIVE_EXTRACT_XATTR (0x0080) 675228753Smm/* Default: Do not try to guard against extracts redirected by symlinks. */ 676228753Smm/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */ 677228753Smm#define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100) 678228753Smm/* Default: Do not reject entries with '..' as path elements. */ 679228753Smm#define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200) 680228753Smm/* Default: Create parent directories as needed. */ 681228753Smm#define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400) 682228753Smm/* Default: Overwrite files, even if one on disk is newer. */ 683228753Smm#define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800) 684228753Smm/* Detect blocks of 0 and write holes instead. */ 685228753Smm#define ARCHIVE_EXTRACT_SPARSE (0x1000) 686232153Smm/* Default: Do not restore Mac extended metadata. */ 687232153Smm/* This has no effect except on Mac OS. */ 688232153Smm#define ARCHIVE_EXTRACT_MAC_METADATA (0x2000) 689248616Smm/* Default: Use HFS+ compression if it was compressed. */ 690248616Smm/* This has no effect except on Mac OS v10.6 or later. */ 691248616Smm#define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000) 692248616Smm/* Default: Do not use HFS+ compression if it was not compressed. */ 693248616Smm/* This has no effect except on Mac OS v10.6 or later. */ 694248616Smm#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000) 695299529Smm/* Default: Do not reject entries with absolute paths */ 696299529Smm#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000) 697299529Smm/* Default: Do not clear no-change flags when unlinking object */ 698299529Smm#define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000) 699358088Smm/* Default: Do not extract atomically (using rename) */ 700358088Smm#define ARCHIVE_EXTRACT_SAFE_WRITES (0x40000) 701228753Smm 702232153Smm__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *, 703228753Smm int flags); 704232153Smm__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *, 705228753Smm struct archive * /* dest */); 706228753Smm__LA_DECL void archive_read_extract_set_progress_callback(struct archive *, 707228753Smm void (*_progress_func)(void *), void *_user_data); 708228753Smm 709228753Smm/* Record the dev/ino of a file that will not be written. This is 710228753Smm * generally set to the dev/ino of the archive being read. */ 711228753Smm__LA_DECL void archive_read_extract_set_skip_file(struct archive *, 712299529Smm la_int64_t, la_int64_t); 713228753Smm 714228753Smm/* Close the file and release most resources. */ 715228753Smm__LA_DECL int archive_read_close(struct archive *); 716228753Smm/* Release all resources and destroy the object. */ 717228773Smm/* Note that archive_read_free will call archive_read_close for you. */ 718228773Smm__LA_DECL int archive_read_free(struct archive *); 719228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000 720228773Smm/* Synonym for archive_read_free() for backwards compatibility. */ 721248616Smm__LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED; 722228753Smm#endif 723228753Smm 724228753Smm/*- 725228753Smm * To create an archive: 726232153Smm * 1) Ask archive_write_new for an archive writer object. 727228753Smm * 2) Set any global properties. In particular, you should set 728228753Smm * the compression and format to use. 729228753Smm * 3) Call archive_write_open to open the file (most people 730228753Smm * will use archive_write_open_file or archive_write_open_fd, 731228753Smm * which provide convenient canned I/O callbacks for you). 732228753Smm * 4) For each entry: 733228753Smm * - construct an appropriate struct archive_entry structure 734228753Smm * - archive_write_header to write the header 735228753Smm * - archive_write_data to write the entry data 736228753Smm * 5) archive_write_close to close the output 737228773Smm * 6) archive_write_free to cleanup the writer and release resources 738228753Smm */ 739228753Smm__LA_DECL struct archive *archive_write_new(void); 740232153Smm__LA_DECL int archive_write_set_bytes_per_block(struct archive *, 741228753Smm int bytes_per_block); 742232153Smm__LA_DECL int archive_write_get_bytes_per_block(struct archive *); 743228753Smm/* XXX This is badly misnamed; suggestions appreciated. XXX */ 744232153Smm__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *, 745228753Smm int bytes_in_last_block); 746232153Smm__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *); 747228753Smm 748228753Smm/* The dev/ino of a file that won't be archived. This is used 749228753Smm * to avoid recursively adding an archive to itself. */ 750232153Smm__LA_DECL int archive_write_set_skip_file(struct archive *, 751299529Smm la_int64_t, la_int64_t); 752228753Smm 753232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 754248616Smm__LA_DECL int archive_write_set_compression_bzip2(struct archive *) 755248616Smm __LA_DEPRECATED; 756248616Smm__LA_DECL int archive_write_set_compression_compress(struct archive *) 757248616Smm __LA_DEPRECATED; 758248616Smm__LA_DECL int archive_write_set_compression_gzip(struct archive *) 759248616Smm __LA_DEPRECATED; 760248616Smm__LA_DECL int archive_write_set_compression_lzip(struct archive *) 761248616Smm __LA_DEPRECATED; 762248616Smm__LA_DECL int archive_write_set_compression_lzma(struct archive *) 763248616Smm __LA_DEPRECATED; 764248616Smm__LA_DECL int archive_write_set_compression_none(struct archive *) 765248616Smm __LA_DEPRECATED; 766232153Smm__LA_DECL int archive_write_set_compression_program(struct archive *, 767248616Smm const char *cmd) __LA_DEPRECATED; 768248616Smm__LA_DECL int archive_write_set_compression_xz(struct archive *) 769248616Smm __LA_DEPRECATED; 770232153Smm#endif 771232153Smm 772238856Smm/* A convenience function to set the filter based on the code. */ 773238856Smm__LA_DECL int archive_write_add_filter(struct archive *, int filter_code); 774248616Smm__LA_DECL int archive_write_add_filter_by_name(struct archive *, 775248616Smm const char *name); 776248616Smm__LA_DECL int archive_write_add_filter_b64encode(struct archive *); 777232153Smm__LA_DECL int archive_write_add_filter_bzip2(struct archive *); 778232153Smm__LA_DECL int archive_write_add_filter_compress(struct archive *); 779248616Smm__LA_DECL int archive_write_add_filter_grzip(struct archive *); 780232153Smm__LA_DECL int archive_write_add_filter_gzip(struct archive *); 781248616Smm__LA_DECL int archive_write_add_filter_lrzip(struct archive *); 782299529Smm__LA_DECL int archive_write_add_filter_lz4(struct archive *); 783232153Smm__LA_DECL int archive_write_add_filter_lzip(struct archive *); 784232153Smm__LA_DECL int archive_write_add_filter_lzma(struct archive *); 785248616Smm__LA_DECL int archive_write_add_filter_lzop(struct archive *); 786232153Smm__LA_DECL int archive_write_add_filter_none(struct archive *); 787232153Smm__LA_DECL int archive_write_add_filter_program(struct archive *, 788232153Smm const char *cmd); 789248616Smm__LA_DECL int archive_write_add_filter_uuencode(struct archive *); 790232153Smm__LA_DECL int archive_write_add_filter_xz(struct archive *); 791324417Smm__LA_DECL int archive_write_add_filter_zstd(struct archive *); 792232153Smm 793232153Smm 794228753Smm/* A convenience function to set the format based on the code or name. */ 795232153Smm__LA_DECL int archive_write_set_format(struct archive *, int format_code); 796232153Smm__LA_DECL int archive_write_set_format_by_name(struct archive *, 797228753Smm const char *name); 798228753Smm/* To minimize link pollution, use one or more of the following. */ 799232153Smm__LA_DECL int archive_write_set_format_7zip(struct archive *); 800232153Smm__LA_DECL int archive_write_set_format_ar_bsd(struct archive *); 801232153Smm__LA_DECL int archive_write_set_format_ar_svr4(struct archive *); 802232153Smm__LA_DECL int archive_write_set_format_cpio(struct archive *); 803232153Smm__LA_DECL int archive_write_set_format_cpio_newc(struct archive *); 804232153Smm__LA_DECL int archive_write_set_format_gnutar(struct archive *); 805232153Smm__LA_DECL int archive_write_set_format_iso9660(struct archive *); 806232153Smm__LA_DECL int archive_write_set_format_mtree(struct archive *); 807248616Smm__LA_DECL int archive_write_set_format_mtree_classic(struct archive *); 808228753Smm/* TODO: int archive_write_set_format_old_tar(struct archive *); */ 809232153Smm__LA_DECL int archive_write_set_format_pax(struct archive *); 810232153Smm__LA_DECL int archive_write_set_format_pax_restricted(struct archive *); 811299529Smm__LA_DECL int archive_write_set_format_raw(struct archive *); 812232153Smm__LA_DECL int archive_write_set_format_shar(struct archive *); 813232153Smm__LA_DECL int archive_write_set_format_shar_dump(struct archive *); 814232153Smm__LA_DECL int archive_write_set_format_ustar(struct archive *); 815248616Smm__LA_DECL int archive_write_set_format_v7tar(struct archive *); 816299529Smm__LA_DECL int archive_write_set_format_warc(struct archive *); 817232153Smm__LA_DECL int archive_write_set_format_xar(struct archive *); 818232153Smm__LA_DECL int archive_write_set_format_zip(struct archive *); 819299529Smm__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename); 820299529Smm__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext); 821248616Smm__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *); 822248616Smm__LA_DECL int archive_write_zip_set_compression_store(struct archive *); 823368707Smm/* Deprecated; use archive_write_open2 instead */ 824232153Smm__LA_DECL int archive_write_open(struct archive *, void *, 825228753Smm archive_open_callback *, archive_write_callback *, 826228753Smm archive_close_callback *); 827368707Smm__LA_DECL int archive_write_open2(struct archive *, void *, 828368707Smm archive_open_callback *, archive_write_callback *, 829368707Smm archive_close_callback *, archive_free_callback *); 830232153Smm__LA_DECL int archive_write_open_fd(struct archive *, int _fd); 831232153Smm__LA_DECL int archive_write_open_filename(struct archive *, const char *_file); 832232153Smm__LA_DECL int archive_write_open_filename_w(struct archive *, 833232153Smm const wchar_t *_file); 834228753Smm/* A deprecated synonym for archive_write_open_filename() */ 835248616Smm__LA_DECL int archive_write_open_file(struct archive *, const char *_file) 836248616Smm __LA_DEPRECATED; 837232153Smm__LA_DECL int archive_write_open_FILE(struct archive *, FILE *); 838228753Smm/* _buffSize is the size of the buffer, _used refers to a variable that 839228753Smm * will be updated after each write into the buffer. */ 840232153Smm__LA_DECL int archive_write_open_memory(struct archive *, 841228753Smm void *_buffer, size_t _buffSize, size_t *_used); 842228753Smm 843228753Smm/* 844228753Smm * Note that the library will truncate writes beyond the size provided 845228753Smm * to archive_write_header or pad if the provided data is short. 846228753Smm */ 847232153Smm__LA_DECL int archive_write_header(struct archive *, 848228753Smm struct archive_entry *); 849299529Smm__LA_DECL la_ssize_t archive_write_data(struct archive *, 850228753Smm const void *, size_t); 851228753Smm 852232153Smm/* This interface is currently only available for archive_write_disk handles. */ 853299529Smm__LA_DECL la_ssize_t archive_write_data_block(struct archive *, 854299529Smm const void *, size_t, la_int64_t); 855232153Smm 856228753Smm__LA_DECL int archive_write_finish_entry(struct archive *); 857228753Smm__LA_DECL int archive_write_close(struct archive *); 858248616Smm/* Marks the archive as FATAL so that a subsequent free() operation 859248616Smm * won't try to close() cleanly. Provides a fast abort capability 860248616Smm * when the client discovers that things have gone wrong. */ 861248616Smm__LA_DECL int archive_write_fail(struct archive *); 862228773Smm/* This can fail if the archive wasn't already closed, in which case 863228773Smm * archive_write_free() will implicitly call archive_write_close(). */ 864228773Smm__LA_DECL int archive_write_free(struct archive *); 865228773Smm#if ARCHIVE_VERSION_NUMBER < 4000000 866228773Smm/* Synonym for archive_write_free() for backwards compatibility. */ 867248616Smm__LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED; 868228753Smm#endif 869228753Smm 870228753Smm/* 871228753Smm * Set write options. 872228753Smm */ 873232153Smm/* Apply option to the format only. */ 874232153Smm__LA_DECL int archive_write_set_format_option(struct archive *_a, 875232153Smm const char *m, const char *o, 876232153Smm const char *v); 877232153Smm/* Apply option to the filter only. */ 878232153Smm__LA_DECL int archive_write_set_filter_option(struct archive *_a, 879232153Smm const char *m, const char *o, 880232153Smm const char *v); 881232153Smm/* Apply option to both the format and the filter. */ 882232153Smm__LA_DECL int archive_write_set_option(struct archive *_a, 883232153Smm const char *m, const char *o, 884232153Smm const char *v); 885232153Smm/* Apply option string to both the format and the filter. */ 886232153Smm__LA_DECL int archive_write_set_options(struct archive *_a, 887232153Smm const char *opts); 888228753Smm 889299529Smm/* 890299529Smm * Set a encryption passphrase. 891299529Smm */ 892299529Smm__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p); 893299529Smm__LA_DECL int archive_write_set_passphrase_callback(struct archive *, 894299529Smm void *client_data, archive_passphrase_callback *); 895299529Smm 896228753Smm/*- 897228753Smm * ARCHIVE_WRITE_DISK API 898228753Smm * 899228753Smm * To create objects on disk: 900228753Smm * 1) Ask archive_write_disk_new for a new archive_write_disk object. 901228753Smm * 2) Set any global properties. In particular, you probably 902228753Smm * want to set the options. 903228753Smm * 3) For each entry: 904228753Smm * - construct an appropriate struct archive_entry structure 905228753Smm * - archive_write_header to create the file/dir/etc on disk 906228753Smm * - archive_write_data to write the entry data 907228773Smm * 4) archive_write_free to cleanup the writer and release resources 908228753Smm * 909228753Smm * In particular, you can use this in conjunction with archive_read() 910228753Smm * to pull entries out of an archive and create them on disk. 911228753Smm */ 912228753Smm__LA_DECL struct archive *archive_write_disk_new(void); 913228753Smm/* This file will not be overwritten. */ 914232153Smm__LA_DECL int archive_write_disk_set_skip_file(struct archive *, 915299529Smm la_int64_t, la_int64_t); 916228753Smm/* Set flags to control how the next item gets created. 917228753Smm * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */ 918228753Smm__LA_DECL int archive_write_disk_set_options(struct archive *, 919228753Smm int flags); 920228753Smm/* 921228753Smm * The lookup functions are given uname/uid (or gname/gid) pairs and 922228753Smm * return a uid (gid) suitable for this system. These are used for 923228753Smm * restoring ownership and for setting ACLs. The default functions 924228753Smm * are naive, they just return the uid/gid. These are small, so reasonable 925228753Smm * for applications that don't need to preserve ownership; they 926228753Smm * are probably also appropriate for applications that are doing 927228753Smm * same-system backup and restore. 928228753Smm */ 929228753Smm/* 930228753Smm * The "standard" lookup functions use common system calls to lookup 931228753Smm * the uname/gname, falling back to the uid/gid if the names can't be 932228753Smm * found. They cache lookups and are reasonably fast, but can be very 933228753Smm * large, so they are not used unless you ask for them. In 934228753Smm * particular, these match the specifications of POSIX "pax" and old 935228753Smm * POSIX "tar". 936228753Smm */ 937228753Smm__LA_DECL int archive_write_disk_set_standard_lookup(struct archive *); 938228753Smm/* 939228753Smm * If neither the default (naive) nor the standard (big) functions suit 940228753Smm * your needs, you can write your own and register them. Be sure to 941228753Smm * include a cleanup function if you have allocated private data. 942228753Smm */ 943232153Smm__LA_DECL int archive_write_disk_set_group_lookup(struct archive *, 944232153Smm void * /* private_data */, 945299529Smm la_int64_t (*)(void *, const char *, la_int64_t), 946232153Smm void (* /* cleanup */)(void *)); 947232153Smm__LA_DECL int archive_write_disk_set_user_lookup(struct archive *, 948232153Smm void * /* private_data */, 949299529Smm la_int64_t (*)(void *, const char *, la_int64_t), 950232153Smm void (* /* cleanup */)(void *)); 951299529Smm__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t); 952299529Smm__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t); 953228753Smm 954228753Smm/* 955228753Smm * ARCHIVE_READ_DISK API 956228753Smm * 957228753Smm * This is still evolving and somewhat experimental. 958228753Smm */ 959228753Smm__LA_DECL struct archive *archive_read_disk_new(void); 960228753Smm/* The names for symlink modes here correspond to an old BSD 961228753Smm * command-line argument convention: -L, -P, -H */ 962228753Smm/* Follow all symlinks. */ 963228753Smm__LA_DECL int archive_read_disk_set_symlink_logical(struct archive *); 964228753Smm/* Follow no symlinks. */ 965228753Smm__LA_DECL int archive_read_disk_set_symlink_physical(struct archive *); 966228753Smm/* Follow symlink initially, then not. */ 967228753Smm__LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *); 968228753Smm/* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */ 969228753Smm__LA_DECL int archive_read_disk_entry_from_file(struct archive *, 970228753Smm struct archive_entry *, int /* fd */, const struct stat *); 971228753Smm/* Look up gname for gid or uname for uid. */ 972228753Smm/* Default implementations are very, very stupid. */ 973299529Smm__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t); 974299529Smm__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t); 975228753Smm/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the 976228753Smm * results for performance. */ 977228753Smm__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *); 978228753Smm/* You can install your own lookups if you like. */ 979228753Smm__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *, 980228753Smm void * /* private_data */, 981299529Smm const char *(* /* lookup_fn */)(void *, la_int64_t), 982228753Smm void (* /* cleanup_fn */)(void *)); 983228753Smm__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *, 984228753Smm void * /* private_data */, 985299529Smm const char *(* /* lookup_fn */)(void *, la_int64_t), 986228753Smm void (* /* cleanup_fn */)(void *)); 987232153Smm/* Start traversal. */ 988232153Smm__LA_DECL int archive_read_disk_open(struct archive *, const char *); 989232153Smm__LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *); 990232153Smm/* 991232153Smm * Request that current entry be visited. If you invoke it on every 992232153Smm * directory, you'll get a physical traversal. This is ignored if the 993232153Smm * current entry isn't a directory or a link to a directory. So, if 994232153Smm * you invoke this on every returned path, you'll get a full logical 995232153Smm * traversal. 996232153Smm */ 997232153Smm__LA_DECL int archive_read_disk_descend(struct archive *); 998238856Smm__LA_DECL int archive_read_disk_can_descend(struct archive *); 999232153Smm__LA_DECL int archive_read_disk_current_filesystem(struct archive *); 1000232153Smm__LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *); 1001232153Smm__LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *); 1002311041Smm/* Request that the access time of the entry visited by traversal be restored. */ 1003232153Smm__LA_DECL int archive_read_disk_set_atime_restored(struct archive *); 1004238856Smm/* 1005238856Smm * Set behavior. The "flags" argument selects optional behavior. 1006238856Smm */ 1007311041Smm/* Request that the access time of the entry visited by traversal be restored. 1008238856Smm * This is the same as archive_read_disk_set_atime_restored. */ 1009238856Smm#define ARCHIVE_READDISK_RESTORE_ATIME (0x0001) 1010238856Smm/* Default: Do not skip an entry which has nodump flags. */ 1011238856Smm#define ARCHIVE_READDISK_HONOR_NODUMP (0x0002) 1012238856Smm/* Default: Skip a mac resource fork file whose prefix is "._" because of 1013238856Smm * using copyfile. */ 1014238856Smm#define ARCHIVE_READDISK_MAC_COPYFILE (0x0004) 1015299529Smm/* Default: Traverse mount points. */ 1016238856Smm#define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008) 1017299529Smm/* Default: Xattrs are read from disk. */ 1018299529Smm#define ARCHIVE_READDISK_NO_XATTR (0x0010) 1019315432Smm/* Default: ACLs are read from disk. */ 1020315432Smm#define ARCHIVE_READDISK_NO_ACL (0x0020) 1021315432Smm/* Default: File flags are read from disk. */ 1022315432Smm#define ARCHIVE_READDISK_NO_FFLAGS (0x0040) 1023228753Smm 1024238856Smm__LA_DECL int archive_read_disk_set_behavior(struct archive *, 1025238856Smm int flags); 1026238856Smm 1027228753Smm/* 1028238856Smm * Set archive_match object that will be used in archive_read_disk to 1029238856Smm * know whether an entry should be skipped. The callback function 1030238856Smm * _excluded_func will be invoked when an entry is skipped by the result 1031238856Smm * of archive_match. 1032238856Smm */ 1033238856Smm__LA_DECL int archive_read_disk_set_matching(struct archive *, 1034238856Smm struct archive *_matching, void (*_excluded_func) 1035238856Smm (struct archive *, void *, struct archive_entry *), 1036238856Smm void *_client_data); 1037238856Smm__LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, 1038238856Smm int (*_metadata_filter_func)(struct archive *, void *, 1039238856Smm struct archive_entry *), void *_client_data); 1040238856Smm 1041299529Smm/* Simplified cleanup interface; 1042299529Smm * This calls archive_read_free() or archive_write_free() as needed. */ 1043299529Smm__LA_DECL int archive_free(struct archive *); 1044299529Smm 1045238856Smm/* 1046228753Smm * Accessor functions to read/set various information in 1047228753Smm * the struct archive object: 1048228753Smm */ 1049232153Smm 1050232153Smm/* Number of filters in the current filter pipeline. */ 1051232153Smm/* Filter #0 is the one closest to the format, -1 is a synonym for the 1052232153Smm * last filter, which is always the pseudo-filter that wraps the 1053232153Smm * client callbacks. */ 1054232153Smm__LA_DECL int archive_filter_count(struct archive *); 1055299529Smm__LA_DECL la_int64_t archive_filter_bytes(struct archive *, int); 1056232153Smm__LA_DECL int archive_filter_code(struct archive *, int); 1057232153Smm__LA_DECL const char * archive_filter_name(struct archive *, int); 1058232153Smm 1059232153Smm#if ARCHIVE_VERSION_NUMBER < 4000000 1060232153Smm/* These don't properly handle multiple filters, so are deprecated and 1061232153Smm * will eventually be removed. */ 1062232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */ 1063299529Smm__LA_DECL la_int64_t archive_position_compressed(struct archive *) 1064248616Smm __LA_DEPRECATED; 1065232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */ 1066299529Smm__LA_DECL la_int64_t archive_position_uncompressed(struct archive *) 1067248616Smm __LA_DEPRECATED; 1068232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */ 1069248616Smm__LA_DECL const char *archive_compression_name(struct archive *) 1070248616Smm __LA_DEPRECATED; 1071232153Smm/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */ 1072248616Smm__LA_DECL int archive_compression(struct archive *) 1073248616Smm __LA_DEPRECATED; 1074232153Smm#endif 1075232153Smm 1076228753Smm__LA_DECL int archive_errno(struct archive *); 1077228753Smm__LA_DECL const char *archive_error_string(struct archive *); 1078228753Smm__LA_DECL const char *archive_format_name(struct archive *); 1079228753Smm__LA_DECL int archive_format(struct archive *); 1080228753Smm__LA_DECL void archive_clear_error(struct archive *); 1081228753Smm__LA_DECL void archive_set_error(struct archive *, int _err, 1082228753Smm const char *fmt, ...) __LA_PRINTF(3, 4); 1083228753Smm__LA_DECL void archive_copy_error(struct archive *dest, 1084228753Smm struct archive *src); 1085228753Smm__LA_DECL int archive_file_count(struct archive *); 1086228753Smm 1087238856Smm/* 1088238856Smm * ARCHIVE_MATCH API 1089238856Smm */ 1090238856Smm__LA_DECL struct archive *archive_match_new(void); 1091238856Smm__LA_DECL int archive_match_free(struct archive *); 1092238856Smm 1093238856Smm/* 1094238856Smm * Test if archive_entry is excluded. 1095238856Smm * This is a convenience function. This is the same as calling all 1096238856Smm * archive_match_path_excluded, archive_match_time_excluded 1097238856Smm * and archive_match_owner_excluded. 1098238856Smm */ 1099238856Smm__LA_DECL int archive_match_excluded(struct archive *, 1100238856Smm struct archive_entry *); 1101238856Smm 1102238856Smm/* 1103238856Smm * Test if pathname is excluded. The conditions are set by following functions. 1104238856Smm */ 1105238856Smm__LA_DECL int archive_match_path_excluded(struct archive *, 1106238856Smm struct archive_entry *); 1107348607Smm/* Control recursive inclusion of directory content when directory is included. Default on. */ 1108348607Smm__LA_DECL int archive_match_set_inclusion_recursion(struct archive *, int); 1109238856Smm/* Add exclusion pathname pattern. */ 1110238856Smm__LA_DECL int archive_match_exclude_pattern(struct archive *, const char *); 1111238856Smm__LA_DECL int archive_match_exclude_pattern_w(struct archive *, 1112238856Smm const wchar_t *); 1113238856Smm/* Add exclusion pathname pattern from file. */ 1114238856Smm__LA_DECL int archive_match_exclude_pattern_from_file(struct archive *, 1115238856Smm const char *, int _nullSeparator); 1116238856Smm__LA_DECL int archive_match_exclude_pattern_from_file_w(struct archive *, 1117238856Smm const wchar_t *, int _nullSeparator); 1118238856Smm/* Add inclusion pathname pattern. */ 1119238856Smm__LA_DECL int archive_match_include_pattern(struct archive *, const char *); 1120238856Smm__LA_DECL int archive_match_include_pattern_w(struct archive *, 1121238856Smm const wchar_t *); 1122238856Smm/* Add inclusion pathname pattern from file. */ 1123238856Smm__LA_DECL int archive_match_include_pattern_from_file(struct archive *, 1124238856Smm const char *, int _nullSeparator); 1125238856Smm__LA_DECL int archive_match_include_pattern_from_file_w(struct archive *, 1126238856Smm const wchar_t *, int _nullSeparator); 1127238856Smm/* 1128238856Smm * How to get statistic information for inclusion patterns. 1129238856Smm */ 1130238856Smm/* Return the amount number of unmatched inclusion patterns. */ 1131238856Smm__LA_DECL int archive_match_path_unmatched_inclusions(struct archive *); 1132238856Smm/* Return the pattern of unmatched inclusion with ARCHIVE_OK. 1133238856Smm * Return ARCHIVE_EOF if there is no inclusion pattern. */ 1134238856Smm__LA_DECL int archive_match_path_unmatched_inclusions_next( 1135238856Smm struct archive *, const char **); 1136238856Smm__LA_DECL int archive_match_path_unmatched_inclusions_next_w( 1137238856Smm struct archive *, const wchar_t **); 1138238856Smm 1139238856Smm/* 1140238856Smm * Test if a file is excluded by its time stamp. 1141238856Smm * The conditions are set by following functions. 1142238856Smm */ 1143238856Smm__LA_DECL int archive_match_time_excluded(struct archive *, 1144238856Smm struct archive_entry *); 1145238856Smm 1146238856Smm/* 1147238856Smm * Flags to tell a matching type of time stamps. These are used for 1148311041Smm * following functions. 1149238856Smm */ 1150238856Smm/* Time flag: mtime to be tested. */ 1151238856Smm#define ARCHIVE_MATCH_MTIME (0x0100) 1152238856Smm/* Time flag: ctime to be tested. */ 1153238856Smm#define ARCHIVE_MATCH_CTIME (0x0200) 1154238856Smm/* Comparison flag: Match the time if it is newer than. */ 1155238856Smm#define ARCHIVE_MATCH_NEWER (0x0001) 1156238856Smm/* Comparison flag: Match the time if it is older than. */ 1157238856Smm#define ARCHIVE_MATCH_OLDER (0x0002) 1158238856Smm/* Comparison flag: Match the time if it is equal to. */ 1159238856Smm#define ARCHIVE_MATCH_EQUAL (0x0010) 1160238856Smm/* Set inclusion time. */ 1161238856Smm__LA_DECL int archive_match_include_time(struct archive *, int _flag, 1162238856Smm time_t _sec, long _nsec); 1163238856Smm/* Set inclusion time by a date string. */ 1164238856Smm__LA_DECL int archive_match_include_date(struct archive *, int _flag, 1165238856Smm const char *_datestr); 1166238856Smm__LA_DECL int archive_match_include_date_w(struct archive *, int _flag, 1167238856Smm const wchar_t *_datestr); 1168311041Smm/* Set inclusion time by a particular file. */ 1169238856Smm__LA_DECL int archive_match_include_file_time(struct archive *, 1170238856Smm int _flag, const char *_pathname); 1171238856Smm__LA_DECL int archive_match_include_file_time_w(struct archive *, 1172238856Smm int _flag, const wchar_t *_pathname); 1173238856Smm/* Add exclusion entry. */ 1174238856Smm__LA_DECL int archive_match_exclude_entry(struct archive *, 1175238856Smm int _flag, struct archive_entry *); 1176238856Smm 1177238856Smm/* 1178238856Smm * Test if a file is excluded by its uid ,gid, uname or gname. 1179238856Smm * The conditions are set by following functions. 1180238856Smm */ 1181238856Smm__LA_DECL int archive_match_owner_excluded(struct archive *, 1182238856Smm struct archive_entry *); 1183238856Smm/* Add inclusion uid, gid, uname and gname. */ 1184299529Smm__LA_DECL int archive_match_include_uid(struct archive *, la_int64_t); 1185299529Smm__LA_DECL int archive_match_include_gid(struct archive *, la_int64_t); 1186238856Smm__LA_DECL int archive_match_include_uname(struct archive *, const char *); 1187238856Smm__LA_DECL int archive_match_include_uname_w(struct archive *, 1188238856Smm const wchar_t *); 1189238856Smm__LA_DECL int archive_match_include_gname(struct archive *, const char *); 1190238856Smm__LA_DECL int archive_match_include_gname_w(struct archive *, 1191238856Smm const wchar_t *); 1192238856Smm 1193299529Smm/* Utility functions */ 1194299529Smm/* Convenience function to sort a NULL terminated list of strings */ 1195299529Smm__LA_DECL int archive_utility_string_sort(char **); 1196299529Smm 1197228753Smm#ifdef __cplusplus 1198228753Smm} 1199228753Smm#endif 1200228753Smm 1201228753Smm/* These are meaningless outside of this header. */ 1202228753Smm#undef __LA_DECL 1203228753Smm 1204228753Smm#endif /* !ARCHIVE_H_INCLUDED */ 1205