archive.h 45 KB

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