archive.h 51 KB

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