archive.h 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. /*-
  2. * Copyright (c) 2003-2010 Tim Kientzle
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
  15. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  16. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17. * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  19. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. *
  25. * $FreeBSD: src/lib/libarchive/archive.h.in,v 1.50 2008/05/26 17:00:22 kientzle Exp $
  26. */
  27. #ifndef ARCHIVE_H_INCLUDED
  28. #define ARCHIVE_H_INCLUDED
  29. /*
  30. * The version number is expressed as a single integer that makes it
  31. * easy to compare versions at build time: for version a.b.c, the
  32. * version number is printf("%d%03d%03d",a,b,c). For example, if you
  33. * know your application requires version 2.12.108 or later, you can
  34. * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  35. */
  36. /* Note: Compiler will complain if this does not match archive_entry.h! */
  37. #define ARCHIVE_VERSION_NUMBER 3006002
  38. #include <sys/stat.h>
  39. #include <stddef.h> /* for wchar_t */
  40. #include <stdio.h> /* For FILE * */
  41. #include <time.h> /* For time_t */
  42. /*
  43. * Note: archive.h is for use outside of libarchive; the configuration
  44. * headers (config.h, archive_platform.h, etc.) are purely internal.
  45. * Do NOT use HAVE_XXX configuration macros to control the behavior of
  46. * this header! If you must conditionalize, use predefined compiler and/or
  47. * platform macros.
  48. */
  49. #if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
  50. # include <stdint.h>
  51. #elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__) && !defined(__CLANG_INTTYPES_H)
  52. # include <inttypes.h>
  53. #endif
  54. /* Get appropriate definitions of 64-bit integer */
  55. #if !defined(__LA_INT64_T_DEFINED)
  56. /* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
  57. # if ARCHIVE_VERSION_NUMBER < 4000000
  58. #define __LA_INT64_T la_int64_t
  59. # endif
  60. #define __LA_INT64_T_DEFINED
  61. # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
  62. typedef __int64 la_int64_t;
  63. # else
  64. # include <unistd.h> /* ssize_t */
  65. # if defined(_SCO_DS) || defined(__osf__)
  66. typedef long long la_int64_t;
  67. # else
  68. typedef int64_t la_int64_t;
  69. # endif
  70. # endif
  71. #endif
  72. /* The la_ssize_t should match the type used in 'struct stat' */
  73. #if !defined(__LA_SSIZE_T_DEFINED)
  74. /* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
  75. # if ARCHIVE_VERSION_NUMBER < 4000000
  76. #define __LA_SSIZE_T la_ssize_t
  77. # endif
  78. #define __LA_SSIZE_T_DEFINED
  79. # if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
  80. # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
  81. typedef ssize_t la_ssize_t;
  82. # elif defined(_WIN64)
  83. typedef __int64 la_ssize_t;
  84. # else
  85. typedef long la_ssize_t;
  86. # endif
  87. # else
  88. # include <unistd.h> /* ssize_t */
  89. typedef ssize_t la_ssize_t;
  90. # endif
  91. #endif
  92. /* Large file support for Android */
  93. #if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
  94. #include "android_lf.h"
  95. #endif
  96. /*
  97. * On Windows, define LIBARCHIVE_STATIC if you're building or using a
  98. * .lib. The default here assumes you're building a DLL. Only
  99. * libarchive source should ever define __LIBARCHIVE_BUILD.
  100. */
  101. #if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
  102. # ifdef __LIBARCHIVE_BUILD
  103. # ifdef __GNUC__
  104. # define __LA_DECL __attribute__((dllexport)) extern
  105. # else
  106. # define __LA_DECL __declspec(dllexport)
  107. # endif
  108. # else
  109. # ifdef __GNUC__
  110. # define __LA_DECL
  111. # else
  112. # define __LA_DECL __declspec(dllimport)
  113. # endif
  114. # endif
  115. #elif defined __LIBARCHIVE_ENABLE_VISIBILITY
  116. # define __LA_DECL __attribute__((visibility("default")))
  117. #else
  118. /* Static libraries or non-Windows needs no special declaration. */
  119. # define __LA_DECL
  120. #endif
  121. #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
  122. #define __LA_PRINTF(fmtarg, firstvararg) \
  123. __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
  124. #else
  125. #define __LA_PRINTF(fmtarg, firstvararg) /* nothing */
  126. #endif
  127. #if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
  128. # define __LA_DEPRECATED __attribute__((deprecated))
  129. #else
  130. # define __LA_DEPRECATED
  131. #endif
  132. #ifdef __cplusplus
  133. extern "C" {
  134. #endif
  135. /*
  136. * The version number is provided as both a macro and a function.
  137. * The macro identifies the installed header; the function identifies
  138. * the library version (which may not be the same if you're using a
  139. * dynamically-linked version of the library). Of course, if the
  140. * header and library are very different, you should expect some
  141. * strangeness. Don't do that.
  142. */
  143. __LA_DECL int archive_version_number(void);
  144. /*
  145. * Textual name/version of the library, useful for version displays.
  146. */
  147. #define ARCHIVE_VERSION_ONLY_STRING "3.6.2"
  148. #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
  149. __LA_DECL const char * archive_version_string(void);
  150. /*
  151. * Detailed textual name/version of the library and its dependencies.
  152. * This has the form:
  153. * "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
  154. * the list of libraries described here will vary depending on how
  155. * libarchive was compiled.
  156. */
  157. __LA_DECL const char * archive_version_details(void);
  158. /*
  159. * Returns NULL if libarchive was compiled without the associated library.
  160. * Otherwise, returns the version number that libarchive was compiled
  161. * against.
  162. */
  163. __LA_DECL const char * archive_zlib_version(void);
  164. __LA_DECL const char * archive_liblzma_version(void);
  165. __LA_DECL const char * archive_bzlib_version(void);
  166. __LA_DECL const char * archive_liblz4_version(void);
  167. __LA_DECL const char * archive_libzstd_version(void);
  168. /* Declare our basic types. */
  169. struct archive;
  170. struct archive_entry;
  171. /*
  172. * Error codes: Use archive_errno() and archive_error_string()
  173. * to retrieve details. Unless specified otherwise, all functions
  174. * that return 'int' use these codes.
  175. */
  176. #define ARCHIVE_EOF 1 /* Found end of archive. */
  177. #define ARCHIVE_OK 0 /* Operation was successful. */
  178. #define ARCHIVE_RETRY (-10) /* Retry might succeed. */
  179. #define ARCHIVE_WARN (-20) /* Partial success. */
  180. /* For example, if write_header "fails", then you can't push data. */
  181. #define ARCHIVE_FAILED (-25) /* Current operation cannot complete. */
  182. /* But if write_header is "fatal," then this archive is dead and useless. */
  183. #define ARCHIVE_FATAL (-30) /* No more operations are possible. */
  184. /*
  185. * As far as possible, archive_errno returns standard platform errno codes.
  186. * Of course, the details vary by platform, so the actual definitions
  187. * here are stored in "archive_platform.h". The symbols are listed here
  188. * for reference; as a rule, clients should not need to know the exact
  189. * platform-dependent error code.
  190. */
  191. /* Unrecognized or invalid file format. */
  192. /* #define ARCHIVE_ERRNO_FILE_FORMAT */
  193. /* Illegal usage of the library. */
  194. /* #define ARCHIVE_ERRNO_PROGRAMMER_ERROR */
  195. /* Unknown or unclassified error. */
  196. /* #define ARCHIVE_ERRNO_MISC */
  197. /*
  198. * Callbacks are invoked to automatically read/skip/write/open/close the
  199. * archive. You can provide your own for complex tasks (like breaking
  200. * archives across multiple tapes) or use standard ones built into the
  201. * library.
  202. */
  203. /* Returns pointer and size of next block of data from archive. */
  204. typedef la_ssize_t archive_read_callback(struct archive *,
  205. void *_client_data, const void **_buffer);
  206. /* Skips at most request bytes from archive and returns the skipped amount.
  207. * This may skip fewer bytes than requested; it may even skip zero bytes.
  208. * If you do skip fewer bytes than requested, libarchive will invoke your
  209. * read callback and discard data as necessary to make up the full skip.
  210. */
  211. typedef la_int64_t archive_skip_callback(struct archive *,
  212. void *_client_data, la_int64_t request);
  213. /* Seeks to specified location in the file and returns the position.
  214. * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
  215. * Return ARCHIVE_FATAL if the seek fails for any reason.
  216. */
  217. typedef la_int64_t archive_seek_callback(struct archive *,
  218. void *_client_data, la_int64_t offset, int whence);
  219. /* Returns size actually written, zero on EOF, -1 on error. */
  220. typedef la_ssize_t archive_write_callback(struct archive *,
  221. void *_client_data,
  222. const void *_buffer, size_t _length);
  223. typedef int archive_open_callback(struct archive *, void *_client_data);
  224. typedef int archive_close_callback(struct archive *, void *_client_data);
  225. typedef int archive_free_callback(struct archive *, void *_client_data);
  226. /* Switches from one client data object to the next/prev client data object.
  227. * This is useful for reading from different data blocks such as a set of files
  228. * that make up one large file.
  229. */
  230. typedef int archive_switch_callback(struct archive *, void *_client_data1,
  231. void *_client_data2);
  232. /*
  233. * Returns a passphrase used for encryption or decryption, NULL on nothing
  234. * to do and give it up.
  235. */
  236. typedef const char *archive_passphrase_callback(struct archive *,
  237. void *_client_data);
  238. /*
  239. * Codes to identify various stream filters.
  240. */
  241. #define ARCHIVE_FILTER_NONE 0
  242. #define ARCHIVE_FILTER_GZIP 1
  243. #define ARCHIVE_FILTER_BZIP2 2
  244. #define ARCHIVE_FILTER_COMPRESS 3
  245. #define ARCHIVE_FILTER_PROGRAM 4
  246. #define ARCHIVE_FILTER_LZMA 5
  247. #define ARCHIVE_FILTER_XZ 6
  248. #define ARCHIVE_FILTER_UU 7
  249. #define ARCHIVE_FILTER_RPM 8
  250. #define ARCHIVE_FILTER_LZIP 9
  251. #define ARCHIVE_FILTER_LRZIP 10
  252. #define ARCHIVE_FILTER_LZOP 11
  253. #define ARCHIVE_FILTER_GRZIP 12
  254. #define ARCHIVE_FILTER_LZ4 13
  255. #define ARCHIVE_FILTER_ZSTD 14
  256. #if ARCHIVE_VERSION_NUMBER < 4000000
  257. #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE
  258. #define ARCHIVE_COMPRESSION_GZIP ARCHIVE_FILTER_GZIP
  259. #define ARCHIVE_COMPRESSION_BZIP2 ARCHIVE_FILTER_BZIP2
  260. #define ARCHIVE_COMPRESSION_COMPRESS ARCHIVE_FILTER_COMPRESS
  261. #define ARCHIVE_COMPRESSION_PROGRAM ARCHIVE_FILTER_PROGRAM
  262. #define ARCHIVE_COMPRESSION_LZMA ARCHIVE_FILTER_LZMA
  263. #define ARCHIVE_COMPRESSION_XZ ARCHIVE_FILTER_XZ
  264. #define ARCHIVE_COMPRESSION_UU ARCHIVE_FILTER_UU
  265. #define ARCHIVE_COMPRESSION_RPM ARCHIVE_FILTER_RPM
  266. #define ARCHIVE_COMPRESSION_LZIP ARCHIVE_FILTER_LZIP
  267. #define ARCHIVE_COMPRESSION_LRZIP ARCHIVE_FILTER_LRZIP
  268. #endif
  269. /*
  270. * Codes returned by archive_format.
  271. *
  272. * Top 16 bits identifies the format family (e.g., "tar"); lower
  273. * 16 bits indicate the variant. This is updated by read_next_header.
  274. * Note that the lower 16 bits will often vary from entry to entry.
  275. * In some cases, this variation occurs as libarchive learns more about
  276. * the archive (for example, later entries might utilize extensions that
  277. * weren't necessary earlier in the archive; in this case, libarchive
  278. * will change the format code to indicate the extended format that
  279. * was used). In other cases, it's because different tools have
  280. * modified the archive and so different parts of the archive
  281. * actually have slightly different formats. (Both tar and cpio store
  282. * format codes in each entry, so it is quite possible for each
  283. * entry to be in a different format.)
  284. */
  285. #define ARCHIVE_FORMAT_BASE_MASK 0xff0000
  286. #define ARCHIVE_FORMAT_CPIO 0x10000
  287. #define ARCHIVE_FORMAT_CPIO_POSIX (ARCHIVE_FORMAT_CPIO | 1)
  288. #define ARCHIVE_FORMAT_CPIO_BIN_LE (ARCHIVE_FORMAT_CPIO | 2)
  289. #define ARCHIVE_FORMAT_CPIO_BIN_BE (ARCHIVE_FORMAT_CPIO | 3)
  290. #define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4)
  291. #define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5)
  292. #define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6)
  293. #define ARCHIVE_FORMAT_CPIO_PWB (ARCHIVE_FORMAT_CPIO | 7)
  294. #define ARCHIVE_FORMAT_SHAR 0x20000
  295. #define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1)
  296. #define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2)
  297. #define ARCHIVE_FORMAT_TAR 0x30000
  298. #define ARCHIVE_FORMAT_TAR_USTAR (ARCHIVE_FORMAT_TAR | 1)
  299. #define ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE (ARCHIVE_FORMAT_TAR | 2)
  300. #define ARCHIVE_FORMAT_TAR_PAX_RESTRICTED (ARCHIVE_FORMAT_TAR | 3)
  301. #define ARCHIVE_FORMAT_TAR_GNUTAR (ARCHIVE_FORMAT_TAR | 4)
  302. #define ARCHIVE_FORMAT_ISO9660 0x40000
  303. #define ARCHIVE_FORMAT_ISO9660_ROCKRIDGE (ARCHIVE_FORMAT_ISO9660 | 1)
  304. #define ARCHIVE_FORMAT_ZIP 0x50000
  305. #define ARCHIVE_FORMAT_EMPTY 0x60000
  306. #define ARCHIVE_FORMAT_AR 0x70000
  307. #define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1)
  308. #define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2)
  309. #define ARCHIVE_FORMAT_MTREE 0x80000
  310. #define ARCHIVE_FORMAT_RAW 0x90000
  311. #define ARCHIVE_FORMAT_XAR 0xA0000
  312. #define ARCHIVE_FORMAT_LHA 0xB0000
  313. #define ARCHIVE_FORMAT_CAB 0xC0000
  314. #define ARCHIVE_FORMAT_RAR 0xD0000
  315. #define ARCHIVE_FORMAT_7ZIP 0xE0000
  316. #define ARCHIVE_FORMAT_WARC 0xF0000
  317. #define ARCHIVE_FORMAT_RAR_V5 0x100000
  318. /*
  319. * Codes returned by archive_read_format_capabilities().
  320. *
  321. * This list can be extended with values between 0 and 0xffff.
  322. * The original purpose of this list was to let different archive
  323. * format readers expose their general capabilities in terms of
  324. * encryption.
  325. */
  326. #define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
  327. #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */
  328. #define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */
  329. /*
  330. * Codes returned by archive_read_has_encrypted_entries().
  331. *
  332. * In case the archive does not support encryption detection at all
  333. * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
  334. * for some other reason (e.g. not enough bytes read) cannot say if
  335. * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
  336. * is returned.
  337. */
  338. #define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
  339. #define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
  340. /*-
  341. * Basic outline for reading an archive:
  342. * 1) Ask archive_read_new for an archive reader object.
  343. * 2) Update any global properties as appropriate.
  344. * In particular, you'll certainly want to call appropriate
  345. * archive_read_support_XXX functions.
  346. * 3) Call archive_read_open_XXX to open the archive
  347. * 4) Repeatedly call archive_read_next_header to get information about
  348. * successive archive entries. Call archive_read_data to extract
  349. * data for entries of interest.
  350. * 5) Call archive_read_free to end processing.
  351. */
  352. __LA_DECL struct archive *archive_read_new(void);
  353. /*
  354. * The archive_read_support_XXX calls enable auto-detect for this
  355. * archive handle. They also link in the necessary support code.
  356. * For example, if you don't want bzlib linked in, don't invoke
  357. * support_compression_bzip2(). The "all" functions provide the
  358. * obvious shorthand.
  359. */
  360. #if ARCHIVE_VERSION_NUMBER < 4000000
  361. __LA_DECL int archive_read_support_compression_all(struct archive *)
  362. __LA_DEPRECATED;
  363. __LA_DECL int archive_read_support_compression_bzip2(struct archive *)
  364. __LA_DEPRECATED;
  365. __LA_DECL int archive_read_support_compression_compress(struct archive *)
  366. __LA_DEPRECATED;
  367. __LA_DECL int archive_read_support_compression_gzip(struct archive *)
  368. __LA_DEPRECATED;
  369. __LA_DECL int archive_read_support_compression_lzip(struct archive *)
  370. __LA_DEPRECATED;
  371. __LA_DECL int archive_read_support_compression_lzma(struct archive *)
  372. __LA_DEPRECATED;
  373. __LA_DECL int archive_read_support_compression_none(struct archive *)
  374. __LA_DEPRECATED;
  375. __LA_DECL int archive_read_support_compression_program(struct archive *,
  376. const char *command) __LA_DEPRECATED;
  377. __LA_DECL int archive_read_support_compression_program_signature
  378. (struct archive *, const char *,
  379. const void * /* match */, size_t) __LA_DEPRECATED;
  380. __LA_DECL int archive_read_support_compression_rpm(struct archive *)
  381. __LA_DEPRECATED;
  382. __LA_DECL int archive_read_support_compression_uu(struct archive *)
  383. __LA_DEPRECATED;
  384. __LA_DECL int archive_read_support_compression_xz(struct archive *)
  385. __LA_DEPRECATED;
  386. #endif
  387. __LA_DECL int archive_read_support_filter_all(struct archive *);
  388. __LA_DECL int archive_read_support_filter_by_code(struct archive *, int);
  389. __LA_DECL int archive_read_support_filter_bzip2(struct archive *);
  390. __LA_DECL int archive_read_support_filter_compress(struct archive *);
  391. __LA_DECL int archive_read_support_filter_gzip(struct archive *);
  392. __LA_DECL int archive_read_support_filter_grzip(struct archive *);
  393. __LA_DECL int archive_read_support_filter_lrzip(struct archive *);
  394. __LA_DECL int archive_read_support_filter_lz4(struct archive *);
  395. __LA_DECL int archive_read_support_filter_lzip(struct archive *);
  396. __LA_DECL int archive_read_support_filter_lzma(struct archive *);
  397. __LA_DECL int archive_read_support_filter_lzop(struct archive *);
  398. __LA_DECL int archive_read_support_filter_none(struct archive *);
  399. __LA_DECL int archive_read_support_filter_program(struct archive *,
  400. const char *command);
  401. __LA_DECL int archive_read_support_filter_program_signature
  402. (struct archive *, const char * /* cmd */,
  403. const void * /* match */, size_t);
  404. __LA_DECL int archive_read_support_filter_rpm(struct archive *);
  405. __LA_DECL int archive_read_support_filter_uu(struct archive *);
  406. __LA_DECL int archive_read_support_filter_xz(struct archive *);
  407. __LA_DECL int archive_read_support_filter_zstd(struct archive *);
  408. __LA_DECL int archive_read_support_format_7zip(struct archive *);
  409. __LA_DECL int archive_read_support_format_all(struct archive *);
  410. __LA_DECL int archive_read_support_format_ar(struct archive *);
  411. __LA_DECL int archive_read_support_format_by_code(struct archive *, int);
  412. __LA_DECL int archive_read_support_format_cab(struct archive *);
  413. __LA_DECL int archive_read_support_format_cpio(struct archive *);
  414. __LA_DECL int archive_read_support_format_empty(struct archive *);
  415. __LA_DECL int archive_read_support_format_gnutar(struct archive *);
  416. __LA_DECL int archive_read_support_format_iso9660(struct archive *);
  417. __LA_DECL int archive_read_support_format_lha(struct archive *);
  418. __LA_DECL int archive_read_support_format_mtree(struct archive *);
  419. __LA_DECL int archive_read_support_format_rar(struct archive *);
  420. __LA_DECL int archive_read_support_format_rar5(struct archive *);
  421. __LA_DECL int archive_read_support_format_raw(struct archive *);
  422. __LA_DECL int archive_read_support_format_tar(struct archive *);
  423. __LA_DECL int archive_read_support_format_warc(struct archive *);
  424. __LA_DECL int archive_read_support_format_xar(struct archive *);
  425. /* archive_read_support_format_zip() enables both streamable and seekable
  426. * zip readers. */
  427. __LA_DECL int archive_read_support_format_zip(struct archive *);
  428. /* Reads Zip archives as stream from beginning to end. Doesn't
  429. * correctly handle SFX ZIP files or ZIP archives that have been modified
  430. * in-place. */
  431. __LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
  432. /* Reads starting from central directory; requires seekable input. */
  433. __LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
  434. /* Functions to manually set the format and filters to be used. This is
  435. * useful to bypass the bidding process when the format and filters to use
  436. * is known in advance.
  437. */
  438. __LA_DECL int archive_read_set_format(struct archive *, int);
  439. __LA_DECL int archive_read_append_filter(struct archive *, int);
  440. __LA_DECL int archive_read_append_filter_program(struct archive *,
  441. const char *);
  442. __LA_DECL int archive_read_append_filter_program_signature
  443. (struct archive *, const char *, const void * /* match */, size_t);
  444. /* Set various callbacks. */
  445. __LA_DECL int archive_read_set_open_callback(struct archive *,
  446. archive_open_callback *);
  447. __LA_DECL int archive_read_set_read_callback(struct archive *,
  448. archive_read_callback *);
  449. __LA_DECL int archive_read_set_seek_callback(struct archive *,
  450. archive_seek_callback *);
  451. __LA_DECL int archive_read_set_skip_callback(struct archive *,
  452. archive_skip_callback *);
  453. __LA_DECL int archive_read_set_close_callback(struct archive *,
  454. archive_close_callback *);
  455. /* Callback used to switch between one data object to the next */
  456. __LA_DECL int archive_read_set_switch_callback(struct archive *,
  457. archive_switch_callback *);
  458. /* This sets the first data object. */
  459. __LA_DECL int archive_read_set_callback_data(struct archive *, void *);
  460. /* This sets data object at specified index */
  461. __LA_DECL int archive_read_set_callback_data2(struct archive *, void *,
  462. unsigned int);
  463. /* This adds a data object at the specified index. */
  464. __LA_DECL int archive_read_add_callback_data(struct archive *, void *,
  465. unsigned int);
  466. /* This appends a data object to the end of list */
  467. __LA_DECL int archive_read_append_callback_data(struct archive *, void *);
  468. /* This prepends a data object to the beginning of list */
  469. __LA_DECL int archive_read_prepend_callback_data(struct archive *, void *);
  470. /* Opening freezes the callbacks. */
  471. __LA_DECL int archive_read_open1(struct archive *);
  472. /* Convenience wrappers around the above. */
  473. __LA_DECL int archive_read_open(struct archive *, void *_client_data,
  474. archive_open_callback *, archive_read_callback *,
  475. archive_close_callback *);
  476. __LA_DECL int archive_read_open2(struct archive *, void *_client_data,
  477. archive_open_callback *, archive_read_callback *,
  478. archive_skip_callback *, archive_close_callback *);
  479. /*
  480. * A variety of shortcuts that invoke archive_read_open() with
  481. * canned callbacks suitable for common situations. The ones that
  482. * accept a block size handle tape blocking correctly.
  483. */
  484. /* Use this if you know the filename. Note: NULL indicates stdin. */
  485. __LA_DECL int archive_read_open_filename(struct archive *,
  486. const char *_filename, size_t _block_size);
  487. /* Use this for reading multivolume files by filenames.
  488. * NOTE: Must be NULL terminated. Sorting is NOT done. */
  489. __LA_DECL int archive_read_open_filenames(struct archive *,
  490. const char **_filenames, size_t _block_size);
  491. __LA_DECL int archive_read_open_filename_w(struct archive *,
  492. const wchar_t *_filename, size_t _block_size);
  493. /* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
  494. __LA_DECL int archive_read_open_file(struct archive *,
  495. const char *_filename, size_t _block_size) __LA_DEPRECATED;
  496. /* Read an archive that's stored in memory. */
  497. __LA_DECL int archive_read_open_memory(struct archive *,
  498. const void * buff, size_t size);
  499. /* A more involved version that is only used for internal testing. */
  500. __LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
  501. size_t size, size_t read_size);
  502. /* Read an archive that's already open, using the file descriptor. */
  503. __LA_DECL int archive_read_open_fd(struct archive *, int _fd,
  504. size_t _block_size);
  505. /* Read an archive that's already open, using a FILE *. */
  506. /* Note: DO NOT use this with tape drives. */
  507. __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
  508. /* Parses and returns next entry header. */
  509. __LA_DECL int archive_read_next_header(struct archive *,
  510. struct archive_entry **);
  511. /* Parses and returns next entry header using the archive_entry passed in */
  512. __LA_DECL int archive_read_next_header2(struct archive *,
  513. struct archive_entry *);
  514. /*
  515. * Retrieve the byte offset in UNCOMPRESSED data where last-read
  516. * header started.
  517. */
  518. __LA_DECL la_int64_t archive_read_header_position(struct archive *);
  519. /*
  520. * Returns 1 if the archive contains at least one encrypted entry.
  521. * If the archive format not support encryption at all
  522. * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
  523. * If for any other reason (e.g. not enough data read so far)
  524. * we cannot say whether there are encrypted entries, then
  525. * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
  526. * In general, this function will return values below zero when the
  527. * reader is uncertain or totally incapable of encryption support.
  528. * When this function returns 0 you can be sure that the reader
  529. * supports encryption detection but no encrypted entries have
  530. * been found yet.
  531. *
  532. * NOTE: If the metadata/header of an archive is also encrypted, you
  533. * cannot rely on the number of encrypted entries. That is why this
  534. * function does not return the number of encrypted entries but#
  535. * just shows that there are some.
  536. */
  537. __LA_DECL int archive_read_has_encrypted_entries(struct archive *);
  538. /*
  539. * Returns a bitmask of capabilities that are supported by the archive format reader.
  540. * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
  541. */
  542. __LA_DECL int archive_read_format_capabilities(struct archive *);
  543. /* Read data from the body of an entry. Similar to read(2). */
  544. __LA_DECL la_ssize_t archive_read_data(struct archive *,
  545. void *, size_t);
  546. /* Seek within the body of an entry. Similar to lseek(2). */
  547. __LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);
  548. /*
  549. * A zero-copy version of archive_read_data that also exposes the file offset
  550. * of each returned block. Note that the client has no way to specify
  551. * the desired size of the block. The API does guarantee that offsets will
  552. * be strictly increasing and that returned blocks will not overlap.
  553. */
  554. __LA_DECL int archive_read_data_block(struct archive *a,
  555. const void **buff, size_t *size, la_int64_t *offset);
  556. /*-
  557. * Some convenience functions that are built on archive_read_data:
  558. * 'skip': skips entire entry
  559. * 'into_buffer': writes data into memory buffer that you provide
  560. * 'into_fd': writes data to specified filedes
  561. */
  562. __LA_DECL int archive_read_data_skip(struct archive *);
  563. __LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
  564. /*
  565. * Set read options.
  566. */
  567. /* Apply option to the format only. */
  568. __LA_DECL int archive_read_set_format_option(struct archive *_a,
  569. const char *m, const char *o,
  570. const char *v);
  571. /* Apply option to the filter only. */
  572. __LA_DECL int archive_read_set_filter_option(struct archive *_a,
  573. const char *m, const char *o,
  574. const char *v);
  575. /* Apply option to both the format and the filter. */
  576. __LA_DECL int archive_read_set_option(struct archive *_a,
  577. const char *m, const char *o,
  578. const char *v);
  579. /* Apply option string to both the format and the filter. */
  580. __LA_DECL int archive_read_set_options(struct archive *_a,
  581. const char *opts);
  582. /*
  583. * Add a decryption passphrase.
  584. */
  585. __LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
  586. __LA_DECL int archive_read_set_passphrase_callback(struct archive *,
  587. void *client_data, archive_passphrase_callback *);
  588. /*-
  589. * Convenience function to recreate the current entry (whose header
  590. * has just been read) on disk.
  591. *
  592. * This does quite a bit more than just copy data to disk. It also:
  593. * - Creates intermediate directories as required.
  594. * - Manages directory permissions: non-writable directories will
  595. * be initially created with write permission enabled; when the
  596. * archive is closed, dir permissions are edited to the values specified
  597. * in the archive.
  598. * - Checks hardlinks: hardlinks will not be extracted unless the
  599. * linked-to file was also extracted within the same session. (TODO)
  600. */
  601. /* The "flags" argument selects optional behavior, 'OR' the flags you want. */
  602. /* Default: Do not try to set owner/group. */
  603. #define ARCHIVE_EXTRACT_OWNER (0x0001)
  604. /* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
  605. #define ARCHIVE_EXTRACT_PERM (0x0002)
  606. /* Default: Do not restore mtime/atime. */
  607. #define ARCHIVE_EXTRACT_TIME (0x0004)
  608. /* Default: Replace existing files. */
  609. #define ARCHIVE_EXTRACT_NO_OVERWRITE (0x0008)
  610. /* Default: Try create first, unlink only if create fails with EEXIST. */
  611. #define ARCHIVE_EXTRACT_UNLINK (0x0010)
  612. /* Default: Do not restore ACLs. */
  613. #define ARCHIVE_EXTRACT_ACL (0x0020)
  614. /* Default: Do not restore fflags. */
  615. #define ARCHIVE_EXTRACT_FFLAGS (0x0040)
  616. /* Default: Do not restore xattrs. */
  617. #define ARCHIVE_EXTRACT_XATTR (0x0080)
  618. /* Default: Do not try to guard against extracts redirected by symlinks. */
  619. /* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
  620. #define ARCHIVE_EXTRACT_SECURE_SYMLINKS (0x0100)
  621. /* Default: Do not reject entries with '..' as path elements. */
  622. #define ARCHIVE_EXTRACT_SECURE_NODOTDOT (0x0200)
  623. /* Default: Create parent directories as needed. */
  624. #define ARCHIVE_EXTRACT_NO_AUTODIR (0x0400)
  625. /* Default: Overwrite files, even if one on disk is newer. */
  626. #define ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER (0x0800)
  627. /* Detect blocks of 0 and write holes instead. */
  628. #define ARCHIVE_EXTRACT_SPARSE (0x1000)
  629. /* Default: Do not restore Mac extended metadata. */
  630. /* This has no effect except on Mac OS. */
  631. #define ARCHIVE_EXTRACT_MAC_METADATA (0x2000)
  632. /* Default: Use HFS+ compression if it was compressed. */
  633. /* This has no effect except on Mac OS v10.6 or later. */
  634. #define ARCHIVE_EXTRACT_NO_HFS_COMPRESSION (0x4000)
  635. /* Default: Do not use HFS+ compression if it was not compressed. */
  636. /* This has no effect except on Mac OS v10.6 or later. */
  637. #define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000)
  638. /* Default: Do not reject entries with absolute paths */
  639. #define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
  640. /* Default: Do not clear no-change flags when unlinking object */
  641. #define ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS (0x20000)
  642. /* Default: Do not extract atomically (using rename) */
  643. #define ARCHIVE_EXTRACT_SAFE_WRITES (0x40000)
  644. __LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
  645. int flags);
  646. __LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
  647. struct archive * /* dest */);
  648. __LA_DECL void archive_read_extract_set_progress_callback(struct archive *,
  649. void (*_progress_func)(void *), void *_user_data);
  650. /* Record the dev/ino of a file that will not be written. This is
  651. * generally set to the dev/ino of the archive being read. */
  652. __LA_DECL void archive_read_extract_set_skip_file(struct archive *,
  653. la_int64_t, la_int64_t);
  654. /* Close the file and release most resources. */
  655. __LA_DECL int archive_read_close(struct archive *);
  656. /* Release all resources and destroy the object. */
  657. /* Note that archive_read_free will call archive_read_close for you. */
  658. __LA_DECL int archive_read_free(struct archive *);
  659. #if ARCHIVE_VERSION_NUMBER < 4000000
  660. /* Synonym for archive_read_free() for backwards compatibility. */
  661. __LA_DECL int archive_read_finish(struct archive *) __LA_DEPRECATED;
  662. #endif
  663. /*-
  664. * To create an archive:
  665. * 1) Ask archive_write_new for an archive writer object.
  666. * 2) Set any global properties. In particular, you should set
  667. * the compression and format to use.
  668. * 3) Call archive_write_open to open the file (most people
  669. * will use archive_write_open_file or archive_write_open_fd,
  670. * which provide convenient canned I/O callbacks for you).
  671. * 4) For each entry:
  672. * - construct an appropriate struct archive_entry structure
  673. * - archive_write_header to write the header
  674. * - archive_write_data to write the entry data
  675. * 5) archive_write_close to close the output
  676. * 6) archive_write_free to cleanup the writer and release resources
  677. */
  678. __LA_DECL struct archive *archive_write_new(void);
  679. __LA_DECL int archive_write_set_bytes_per_block(struct archive *,
  680. int bytes_per_block);
  681. __LA_DECL int archive_write_get_bytes_per_block(struct archive *);
  682. /* XXX This is badly misnamed; suggestions appreciated. XXX */
  683. __LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
  684. int bytes_in_last_block);
  685. __LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);
  686. /* The dev/ino of a file that won't be archived. This is used
  687. * to avoid recursively adding an archive to itself. */
  688. __LA_DECL int archive_write_set_skip_file(struct archive *,
  689. la_int64_t, la_int64_t);
  690. #if ARCHIVE_VERSION_NUMBER < 4000000
  691. __LA_DECL int archive_write_set_compression_bzip2(struct archive *)
  692. __LA_DEPRECATED;
  693. __LA_DECL int archive_write_set_compression_compress(struct archive *)
  694. __LA_DEPRECATED;
  695. __LA_DECL int archive_write_set_compression_gzip(struct archive *)
  696. __LA_DEPRECATED;
  697. __LA_DECL int archive_write_set_compression_lzip(struct archive *)
  698. __LA_DEPRECATED;
  699. __LA_DECL int archive_write_set_compression_lzma(struct archive *)
  700. __LA_DEPRECATED;
  701. __LA_DECL int archive_write_set_compression_none(struct archive *)
  702. __LA_DEPRECATED;
  703. __LA_DECL int archive_write_set_compression_program(struct archive *,
  704. const char *cmd) __LA_DEPRECATED;
  705. __LA_DECL int archive_write_set_compression_xz(struct archive *)
  706. __LA_DEPRECATED;
  707. #endif
  708. /* A convenience function to set the filter based on the code. */
  709. __LA_DECL int archive_write_add_filter(struct archive *, int filter_code);
  710. __LA_DECL int archive_write_add_filter_by_name(struct archive *,
  711. const char *name);
  712. __LA_DECL int archive_write_add_filter_b64encode(struct archive *);
  713. __LA_DECL int archive_write_add_filter_bzip2(struct archive *);
  714. __LA_DECL int archive_write_add_filter_compress(struct archive *);
  715. __LA_DECL int archive_write_add_filter_grzip(struct archive *);
  716. __LA_DECL int archive_write_add_filter_gzip(struct archive *);
  717. __LA_DECL int archive_write_add_filter_lrzip(struct archive *);
  718. __LA_DECL int archive_write_add_filter_lz4(struct archive *);
  719. __LA_DECL int archive_write_add_filter_lzip(struct archive *);
  720. __LA_DECL int archive_write_add_filter_lzma(struct archive *);
  721. __LA_DECL int archive_write_add_filter_lzop(struct archive *);
  722. __LA_DECL int archive_write_add_filter_none(struct archive *);
  723. __LA_DECL int archive_write_add_filter_program(struct archive *,
  724. const char *cmd);
  725. __LA_DECL int archive_write_add_filter_uuencode(struct archive *);
  726. __LA_DECL int archive_write_add_filter_xz(struct archive *);
  727. __LA_DECL int archive_write_add_filter_zstd(struct archive *);
  728. /* A convenience function to set the format based on the code or name. */
  729. __LA_DECL int archive_write_set_format(struct archive *, int format_code);
  730. __LA_DECL int archive_write_set_format_by_name(struct archive *,
  731. const char *name);
  732. /* To minimize link pollution, use one or more of the following. */
  733. __LA_DECL int archive_write_set_format_7zip(struct archive *);
  734. __LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
  735. __LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
  736. __LA_DECL int archive_write_set_format_cpio(struct archive *);
  737. __LA_DECL int archive_write_set_format_cpio_bin(struct archive *);
  738. __LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
  739. __LA_DECL int archive_write_set_format_cpio_odc(struct archive *);
  740. __LA_DECL int archive_write_set_format_cpio_pwb(struct archive *);
  741. __LA_DECL int archive_write_set_format_gnutar(struct archive *);
  742. __LA_DECL int archive_write_set_format_iso9660(struct archive *);
  743. __LA_DECL int archive_write_set_format_mtree(struct archive *);
  744. __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
  745. /* TODO: int archive_write_set_format_old_tar(struct archive *); */
  746. __LA_DECL int archive_write_set_format_pax(struct archive *);
  747. __LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
  748. __LA_DECL int archive_write_set_format_raw(struct archive *);
  749. __LA_DECL int archive_write_set_format_shar(struct archive *);
  750. __LA_DECL int archive_write_set_format_shar_dump(struct archive *);
  751. __LA_DECL int archive_write_set_format_ustar(struct archive *);
  752. __LA_DECL int archive_write_set_format_v7tar(struct archive *);
  753. __LA_DECL int archive_write_set_format_warc(struct archive *);
  754. __LA_DECL int archive_write_set_format_xar(struct archive *);
  755. __LA_DECL int archive_write_set_format_zip(struct archive *);
  756. __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
  757. __LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
  758. __LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
  759. __LA_DECL int archive_write_zip_set_compression_store(struct archive *);
  760. /* Deprecated; use archive_write_open2 instead */
  761. __LA_DECL int archive_write_open(struct archive *, void *,
  762. archive_open_callback *, archive_write_callback *,
  763. archive_close_callback *);
  764. __LA_DECL int archive_write_open2(struct archive *, void *,
  765. archive_open_callback *, archive_write_callback *,
  766. archive_close_callback *, archive_free_callback *);
  767. __LA_DECL int archive_write_open_fd(struct archive *, int _fd);
  768. __LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
  769. __LA_DECL int archive_write_open_filename_w(struct archive *,
  770. const wchar_t *_file);
  771. /* A deprecated synonym for archive_write_open_filename() */
  772. __LA_DECL int archive_write_open_file(struct archive *, const char *_file)
  773. __LA_DEPRECATED;
  774. __LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
  775. /* _buffSize is the size of the buffer, _used refers to a variable that
  776. * will be updated after each write into the buffer. */
  777. __LA_DECL int archive_write_open_memory(struct archive *,
  778. void *_buffer, size_t _buffSize, size_t *_used);
  779. /*
  780. * Note that the library will truncate writes beyond the size provided
  781. * to archive_write_header or pad if the provided data is short.
  782. */
  783. __LA_DECL int archive_write_header(struct archive *,
  784. struct archive_entry *);
  785. __LA_DECL la_ssize_t archive_write_data(struct archive *,
  786. const void *, size_t);
  787. /* This interface is currently only available for archive_write_disk handles. */
  788. __LA_DECL la_ssize_t archive_write_data_block(struct archive *,
  789. const void *, size_t, la_int64_t);
  790. __LA_DECL int archive_write_finish_entry(struct archive *);
  791. __LA_DECL int archive_write_close(struct archive *);
  792. /* Marks the archive as FATAL so that a subsequent free() operation
  793. * won't try to close() cleanly. Provides a fast abort capability
  794. * when the client discovers that things have gone wrong. */
  795. __LA_DECL int archive_write_fail(struct archive *);
  796. /* This can fail if the archive wasn't already closed, in which case
  797. * archive_write_free() will implicitly call archive_write_close(). */
  798. __LA_DECL int archive_write_free(struct archive *);
  799. #if ARCHIVE_VERSION_NUMBER < 4000000
  800. /* Synonym for archive_write_free() for backwards compatibility. */
  801. __LA_DECL int archive_write_finish(struct archive *) __LA_DEPRECATED;
  802. #endif
  803. /*
  804. * Set write options.
  805. */
  806. /* Apply option to the format only. */
  807. __LA_DECL int archive_write_set_format_option(struct archive *_a,
  808. const char *m, const char *o,
  809. const char *v);
  810. /* Apply option to the filter only. */
  811. __LA_DECL int archive_write_set_filter_option(struct archive *_a,
  812. const char *m, const char *o,
  813. const char *v);
  814. /* Apply option to both the format and the filter. */
  815. __LA_DECL int archive_write_set_option(struct archive *_a,
  816. const char *m, const char *o,
  817. const char *v);
  818. /* Apply option string to both the format and the filter. */
  819. __LA_DECL int archive_write_set_options(struct archive *_a,
  820. const char *opts);
  821. /*
  822. * Set a encryption passphrase.
  823. */
  824. __LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
  825. __LA_DECL int archive_write_set_passphrase_callback(struct archive *,
  826. void *client_data, archive_passphrase_callback *);
  827. /*-
  828. * ARCHIVE_WRITE_DISK API
  829. *
  830. * To create objects on disk:
  831. * 1) Ask archive_write_disk_new for a new archive_write_disk object.
  832. * 2) Set any global properties. In particular, you probably
  833. * want to set the options.
  834. * 3) For each entry:
  835. * - construct an appropriate struct archive_entry structure
  836. * - archive_write_header to create the file/dir/etc on disk
  837. * - archive_write_data to write the entry data
  838. * 4) archive_write_free to cleanup the writer and release resources
  839. *
  840. * In particular, you can use this in conjunction with archive_read()
  841. * to pull entries out of an archive and create them on disk.
  842. */
  843. __LA_DECL struct archive *archive_write_disk_new(void);
  844. /* This file will not be overwritten. */
  845. __LA_DECL int archive_write_disk_set_skip_file(struct archive *,
  846. la_int64_t, la_int64_t);
  847. /* Set flags to control how the next item gets created.
  848. * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
  849. __LA_DECL int archive_write_disk_set_options(struct archive *,
  850. int flags);
  851. /*
  852. * The lookup functions are given uname/uid (or gname/gid) pairs and
  853. * return a uid (gid) suitable for this system. These are used for
  854. * restoring ownership and for setting ACLs. The default functions
  855. * are naive, they just return the uid/gid. These are small, so reasonable
  856. * for applications that don't need to preserve ownership; they
  857. * are probably also appropriate for applications that are doing
  858. * same-system backup and restore.
  859. */
  860. /*
  861. * The "standard" lookup functions use common system calls to lookup
  862. * the uname/gname, falling back to the uid/gid if the names can't be
  863. * found. They cache lookups and are reasonably fast, but can be very
  864. * large, so they are not used unless you ask for them. In
  865. * particular, these match the specifications of POSIX "pax" and old
  866. * POSIX "tar".
  867. */
  868. __LA_DECL int archive_write_disk_set_standard_lookup(struct archive *);
  869. /*
  870. * If neither the default (naive) nor the standard (big) functions suit
  871. * your needs, you can write your own and register them. Be sure to
  872. * include a cleanup function if you have allocated private data.
  873. */
  874. __LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
  875. void * /* private_data */,
  876. la_int64_t (*)(void *, const char *, la_int64_t),
  877. void (* /* cleanup */)(void *));
  878. __LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
  879. void * /* private_data */,
  880. la_int64_t (*)(void *, const char *, la_int64_t),
  881. void (* /* cleanup */)(void *));
  882. __LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t);
  883. __LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t);
  884. /*
  885. * ARCHIVE_READ_DISK API
  886. *
  887. * This is still evolving and somewhat experimental.
  888. */
  889. __LA_DECL struct archive *archive_read_disk_new(void);
  890. /* The names for symlink modes here correspond to an old BSD
  891. * command-line argument convention: -L, -P, -H */
  892. /* Follow all symlinks. */
  893. __LA_DECL int archive_read_disk_set_symlink_logical(struct archive *);
  894. /* Follow no symlinks. */
  895. __LA_DECL int archive_read_disk_set_symlink_physical(struct archive *);
  896. /* Follow symlink initially, then not. */
  897. __LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *);
  898. /* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */
  899. __LA_DECL int archive_read_disk_entry_from_file(struct archive *,
  900. struct archive_entry *, int /* fd */, const struct stat *);
  901. /* Look up gname for gid or uname for uid. */
  902. /* Default implementations are very, very stupid. */
  903. __LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t);
  904. __LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t);
  905. /* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
  906. * results for performance. */
  907. __LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
  908. /* You can install your own lookups if you like. */
  909. __LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
  910. void * /* private_data */,
  911. const char *(* /* lookup_fn */)(void *, la_int64_t),
  912. void (* /* cleanup_fn */)(void *));
  913. __LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
  914. void * /* private_data */,
  915. const char *(* /* lookup_fn */)(void *, la_int64_t),
  916. void (* /* cleanup_fn */)(void *));
  917. /* Start traversal. */
  918. __LA_DECL int archive_read_disk_open(struct archive *, const char *);
  919. __LA_DECL int archive_read_disk_open_w(struct archive *, const wchar_t *);
  920. /*
  921. * Request that current entry be visited. If you invoke it on every
  922. * directory, you'll get a physical traversal. This is ignored if the
  923. * current entry isn't a directory or a link to a directory. So, if
  924. * you invoke this on every returned path, you'll get a full logical
  925. * traversal.
  926. */
  927. __LA_DECL int archive_read_disk_descend(struct archive *);
  928. __LA_DECL int archive_read_disk_can_descend(struct archive *);
  929. __LA_DECL int archive_read_disk_current_filesystem(struct archive *);
  930. __LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *);
  931. __LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *);
  932. /* Request that the access time of the entry visited by traversal be restored. */
  933. __LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
  934. /*
  935. * Set behavior. The "flags" argument selects optional behavior.
  936. */
  937. /* Request that the access time of the entry visited by traversal be restored.
  938. * This is the same as archive_read_disk_set_atime_restored. */
  939. #define ARCHIVE_READDISK_RESTORE_ATIME (0x0001)
  940. /* Default: Do not skip an entry which has nodump flags. */
  941. #define ARCHIVE_READDISK_HONOR_NODUMP (0x0002)
  942. /* Default: Skip a mac resource fork file whose prefix is "._" because of
  943. * using copyfile. */
  944. #define ARCHIVE_READDISK_MAC_COPYFILE (0x0004)
  945. /* Default: Traverse mount points. */
  946. #define ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS (0x0008)
  947. /* Default: Xattrs are read from disk. */
  948. #define ARCHIVE_READDISK_NO_XATTR (0x0010)
  949. /* Default: ACLs are read from disk. */
  950. #define ARCHIVE_READDISK_NO_ACL (0x0020)
  951. /* Default: File flags are read from disk. */
  952. #define ARCHIVE_READDISK_NO_FFLAGS (0x0040)
  953. /* Default: Sparse file information is read from disk. */
  954. #define ARCHIVE_READDISK_NO_SPARSE (0x0080)
  955. __LA_DECL int archive_read_disk_set_behavior(struct archive *,
  956. int flags);
  957. /*
  958. * Set archive_match object that will be used in archive_read_disk to
  959. * know whether an entry should be skipped. The callback function
  960. * _excluded_func will be invoked when an entry is skipped by the result
  961. * of archive_match.
  962. */
  963. __LA_DECL int archive_read_disk_set_matching(struct archive *,
  964. struct archive *_matching, void (*_excluded_func)
  965. (struct archive *, void *, struct archive_entry *),
  966. void *_client_data);
  967. __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
  968. int (*_metadata_filter_func)(struct archive *, void *,
  969. struct archive_entry *), void *_client_data);
  970. /* Simplified cleanup interface;
  971. * This calls archive_read_free() or archive_write_free() as needed. */
  972. __LA_DECL int archive_free(struct archive *);
  973. /*
  974. * Accessor functions to read/set various information in
  975. * the struct archive object:
  976. */
  977. /* Number of filters in the current filter pipeline. */
  978. /* Filter #0 is the one closest to the format, -1 is a synonym for the
  979. * last filter, which is always the pseudo-filter that wraps the
  980. * client callbacks. */
  981. __LA_DECL int archive_filter_count(struct archive *);
  982. __LA_DECL la_int64_t archive_filter_bytes(struct archive *, int);
  983. __LA_DECL int archive_filter_code(struct archive *, int);
  984. __LA_DECL const char * archive_filter_name(struct archive *, int);
  985. #if ARCHIVE_VERSION_NUMBER < 4000000
  986. /* These don't properly handle multiple filters, so are deprecated and
  987. * will eventually be removed. */
  988. /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
  989. __LA_DECL la_int64_t archive_position_compressed(struct archive *)
  990. __LA_DEPRECATED;
  991. /* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
  992. __LA_DECL la_int64_t archive_position_uncompressed(struct archive *)
  993. __LA_DEPRECATED;
  994. /* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
  995. __LA_DECL const char *archive_compression_name(struct archive *)
  996. __LA_DEPRECATED;
  997. /* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
  998. __LA_DECL int archive_compression(struct archive *)
  999. __LA_DEPRECATED;
  1000. #endif
  1001. __LA_DECL int archive_errno(struct archive *);
  1002. __LA_DECL const char *archive_error_string(struct archive *);
  1003. __LA_DECL const char *archive_format_name(struct archive *);
  1004. __LA_DECL int archive_format(struct archive *);
  1005. __LA_DECL void archive_clear_error(struct archive *);
  1006. __LA_DECL void archive_set_error(struct archive *, int _err,
  1007. const char *fmt, ...) __LA_PRINTF(3, 4);
  1008. __LA_DECL void archive_copy_error(struct archive *dest,
  1009. struct archive *src);
  1010. __LA_DECL int archive_file_count(struct archive *);
  1011. /*
  1012. * ARCHIVE_MATCH API
  1013. */
  1014. __LA_DECL struct archive *archive_match_new(void);
  1015. __LA_DECL int archive_match_free(struct archive *);
  1016. /*
  1017. * Test if archive_entry is excluded.
  1018. * This is a convenience function. This is the same as calling all
  1019. * archive_match_path_excluded, archive_match_time_excluded
  1020. * and archive_match_owner_excluded.
  1021. */
  1022. __LA_DECL int archive_match_excluded(struct archive *,
  1023. struct archive_entry *);
  1024. /*
  1025. * Test if pathname is excluded. The conditions are set by following functions.
  1026. */
  1027. __LA_DECL int archive_match_path_excluded(struct archive *,
  1028. struct archive_entry *);
  1029. /* Control recursive inclusion of directory content when directory is included. Default on. */
  1030. __LA_DECL int archive_match_set_inclusion_recursion(struct archive *, int);
  1031. /* Add exclusion pathname pattern. */
  1032. __LA_DECL int archive_match_exclude_pattern(struct archive *, const char *);
  1033. __LA_DECL int archive_match_exclude_pattern_w(struct archive *,
  1034. const wchar_t *);
  1035. /* Add exclusion pathname pattern from file. */
  1036. __LA_DECL int archive_match_exclude_pattern_from_file(struct archive *,
  1037. const char *, int _nullSeparator);
  1038. __LA_DECL int archive_match_exclude_pattern_from_file_w(struct archive *,
  1039. const wchar_t *, int _nullSeparator);
  1040. /* Add inclusion pathname pattern. */
  1041. __LA_DECL int archive_match_include_pattern(struct archive *, const char *);
  1042. __LA_DECL int archive_match_include_pattern_w(struct archive *,
  1043. const wchar_t *);
  1044. /* Add inclusion pathname pattern from file. */
  1045. __LA_DECL int archive_match_include_pattern_from_file(struct archive *,
  1046. const char *, int _nullSeparator);
  1047. __LA_DECL int archive_match_include_pattern_from_file_w(struct archive *,
  1048. const wchar_t *, int _nullSeparator);
  1049. /*
  1050. * How to get statistic information for inclusion patterns.
  1051. */
  1052. /* Return the amount number of unmatched inclusion patterns. */
  1053. __LA_DECL int archive_match_path_unmatched_inclusions(struct archive *);
  1054. /* Return the pattern of unmatched inclusion with ARCHIVE_OK.
  1055. * Return ARCHIVE_EOF if there is no inclusion pattern. */
  1056. __LA_DECL int archive_match_path_unmatched_inclusions_next(
  1057. struct archive *, const char **);
  1058. __LA_DECL int archive_match_path_unmatched_inclusions_next_w(
  1059. struct archive *, const wchar_t **);
  1060. /*
  1061. * Test if a file is excluded by its time stamp.
  1062. * The conditions are set by following functions.
  1063. */
  1064. __LA_DECL int archive_match_time_excluded(struct archive *,
  1065. struct archive_entry *);
  1066. /*
  1067. * Flags to tell a matching type of time stamps. These are used for
  1068. * following functions.
  1069. */
  1070. /* Time flag: mtime to be tested. */
  1071. #define ARCHIVE_MATCH_MTIME (0x0100)
  1072. /* Time flag: ctime to be tested. */
  1073. #define ARCHIVE_MATCH_CTIME (0x0200)
  1074. /* Comparison flag: Match the time if it is newer than. */
  1075. #define ARCHIVE_MATCH_NEWER (0x0001)
  1076. /* Comparison flag: Match the time if it is older than. */
  1077. #define ARCHIVE_MATCH_OLDER (0x0002)
  1078. /* Comparison flag: Match the time if it is equal to. */
  1079. #define ARCHIVE_MATCH_EQUAL (0x0010)
  1080. /* Set inclusion time. */
  1081. __LA_DECL int archive_match_include_time(struct archive *, int _flag,
  1082. time_t _sec, long _nsec);
  1083. /* Set inclusion time by a date string. */
  1084. __LA_DECL int archive_match_include_date(struct archive *, int _flag,
  1085. const char *_datestr);
  1086. __LA_DECL int archive_match_include_date_w(struct archive *, int _flag,
  1087. const wchar_t *_datestr);
  1088. /* Set inclusion time by a particular file. */
  1089. __LA_DECL int archive_match_include_file_time(struct archive *,
  1090. int _flag, const char *_pathname);
  1091. __LA_DECL int archive_match_include_file_time_w(struct archive *,
  1092. int _flag, const wchar_t *_pathname);
  1093. /* Add exclusion entry. */
  1094. __LA_DECL int archive_match_exclude_entry(struct archive *,
  1095. int _flag, struct archive_entry *);
  1096. /*
  1097. * Test if a file is excluded by its uid ,gid, uname or gname.
  1098. * The conditions are set by following functions.
  1099. */
  1100. __LA_DECL int archive_match_owner_excluded(struct archive *,
  1101. struct archive_entry *);
  1102. /* Add inclusion uid, gid, uname and gname. */
  1103. __LA_DECL int archive_match_include_uid(struct archive *, la_int64_t);
  1104. __LA_DECL int archive_match_include_gid(struct archive *, la_int64_t);
  1105. __LA_DECL int archive_match_include_uname(struct archive *, const char *);
  1106. __LA_DECL int archive_match_include_uname_w(struct archive *,
  1107. const wchar_t *);
  1108. __LA_DECL int archive_match_include_gname(struct archive *, const char *);
  1109. __LA_DECL int archive_match_include_gname_w(struct archive *,
  1110. const wchar_t *);
  1111. /* Utility functions */
  1112. /* Convenience function to sort a NULL terminated list of strings */
  1113. __LA_DECL int archive_utility_string_sort(char **);
  1114. #ifdef __cplusplus
  1115. }
  1116. #endif
  1117. /* These are meaningless outside of this header. */
  1118. #undef __LA_DECL
  1119. #endif /* !ARCHIVE_H_INCLUDED */