archive.h 45 KB

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