archive_read_format.3 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. .\" Copyright (c) 2003-2011 Tim Kientzle
  2. .\" All rights reserved.
  3. .\"
  4. .\" Redistribution and use in source and binary forms, with or without
  5. .\" modification, are permitted provided that the following conditions
  6. .\" are met:
  7. .\" 1. Redistributions of source code must retain the above copyright
  8. .\" notice, this list of conditions and the following disclaimer.
  9. .\" 2. Redistributions in binary form must reproduce the above copyright
  10. .\" notice, this list of conditions and the following disclaimer in the
  11. .\" documentation and/or other materials provided with the distribution.
  12. .\"
  13. .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. .\" SUCH DAMAGE.
  24. .\"
  25. .Dd February 2, 2012
  26. .Dt ARCHIVE_READ_FORMAT 3
  27. .Os
  28. .Sh NAME
  29. .Nm archive_read_support_format_7zip ,
  30. .Nm archive_read_support_format_all ,
  31. .Nm archive_read_support_format_ar ,
  32. .Nm archive_read_support_format_by_code ,
  33. .Nm archive_read_support_format_cab ,
  34. .Nm archive_read_support_format_cpio ,
  35. .Nm archive_read_support_format_empty ,
  36. .Nm archive_read_support_format_iso9660 ,
  37. .Nm archive_read_support_format_lha ,
  38. .Nm archive_read_support_format_mtree ,
  39. .Nm archive_read_support_format_rar ,
  40. .Nm archive_read_support_format_rar5 ,
  41. .Nm archive_read_support_format_raw ,
  42. .Nm archive_read_support_format_tar ,
  43. .Nm archive_read_support_format_warc ,
  44. .Nm archive_read_support_format_xar ,
  45. .Nm archive_read_support_format_zip
  46. .Nd functions for reading streaming archives
  47. .\"
  48. .Sh LIBRARY
  49. Streaming Archive Library (libarchive, -larchive)
  50. .Sh SYNOPSIS
  51. .In archive.h
  52. .Ft int
  53. .Fn archive_read_support_format_7zip "struct archive *"
  54. .Ft int
  55. .Fn archive_read_support_format_all "struct archive *"
  56. .Ft int
  57. .Fn archive_read_support_format_ar "struct archive *"
  58. .Ft int
  59. .Fn archive_read_support_format_by_code "struct archive *" "int"
  60. .Ft int
  61. .Fn archive_read_support_format_cab "struct archive *"
  62. .Ft int
  63. .Fn archive_read_support_format_cpio "struct archive *"
  64. .Ft int
  65. .Fn archive_read_support_format_empty "struct archive *"
  66. .Ft int
  67. .Fn archive_read_support_format_iso9660 "struct archive *"
  68. .Ft int
  69. .Fn archive_read_support_format_lha "struct archive *"
  70. .Ft int
  71. .Fn archive_read_support_format_mtree "struct archive *"
  72. .Ft int
  73. .Fn archive_read_support_format_rar "struct archive *"
  74. .Ft int
  75. .Fn archive_read_support_format_rar5 "struct archive *"
  76. .Ft int
  77. .Fn archive_read_support_format_raw "struct archive *"
  78. .Ft int
  79. .Fn archive_read_support_format_tar "struct archive *"
  80. .Ft int
  81. .Fn archive_read_support_format_warc "struct archive *"
  82. .Ft int
  83. .Fn archive_read_support_format_xar "struct archive *"
  84. .Ft int
  85. .Fn archive_read_support_format_zip "struct archive *"
  86. .\"
  87. .Sh DESCRIPTION
  88. .Bl -tag -compact -width indent
  89. .It Xo
  90. .Fn archive_read_support_format_7zip ,
  91. .Fn archive_read_support_format_ar ,
  92. .Fn archive_read_support_format_cab ,
  93. .Fn archive_read_support_format_cpio ,
  94. .Fn archive_read_support_format_iso9660 ,
  95. .Fn archive_read_support_format_lha ,
  96. .Fn archive_read_support_format_mtree ,
  97. .Fn archive_read_support_format_rar ,
  98. .Fn archive_read_support_format_rar5 ,
  99. .Fn archive_read_support_format_raw ,
  100. .Fn archive_read_support_format_tar ,
  101. .Fn archive_read_support_format_warc ,
  102. .Fn archive_read_support_format_xar ,
  103. .Fn archive_read_support_format_zip
  104. .Xc
  105. Enables support---including auto-detection code---for the
  106. specified archive format.
  107. For example,
  108. .Fn archive_read_support_format_tar
  109. enables support for a variety of standard tar formats, old-style tar,
  110. ustar, pax interchange format, and many common variants.
  111. .Fn archive_read_support_format_zip
  112. enables support for both the streaming and the seeking zip readers,
  113. which can separately be enabled by respectively
  114. .Fn archive_read_support_format_zip_streamable
  115. and
  116. .Fn archive_read_support_format_zip_seekable
  117. .
  118. .It Fn archive_read_support_format_all
  119. Enables support for all available formats except the
  120. .Dq raw
  121. format (see below).
  122. .It Fn archive_read_support_format_by_code
  123. Enables a single format specified by the format code.
  124. This can be useful when reading a single archive twice;
  125. use
  126. .Fn archive_format
  127. after reading the first time and pass the resulting code
  128. to this function to selectively enable only the necessary
  129. format support.
  130. Note: In statically-linked executables, this will cause
  131. your program to include support for every format.
  132. If executable size is a concern, you may wish to avoid
  133. using this function.
  134. .It Fn archive_read_support_format_empty
  135. Enables support for treating empty files as empty archives.
  136. Because empty files are valid for several different formats,
  137. it is not possible to accurately determine a format for
  138. an empty file based purely on contents.
  139. So empty files are treated by libarchive as a distinct
  140. format.
  141. .It Fn archive_read_support_format_raw
  142. The
  143. .Dq raw
  144. format handler allows libarchive to be used to read arbitrary data.
  145. It treats any data stream as an archive with a single entry.
  146. The pathname of this entry is
  147. .Dq data ;
  148. all other entry fields are unset.
  149. This is not enabled by
  150. .Fn archive_read_support_format_all
  151. in order to avoid erroneous handling of damaged archives.
  152. .El
  153. .\" .Sh EXAMPLE
  154. .Sh RETURN VALUES
  155. These functions return
  156. .Cm ARCHIVE_OK
  157. on success, or
  158. .Cm ARCHIVE_FATAL .
  159. .\"
  160. .Sh ERRORS
  161. Detailed error codes and textual descriptions are available from the
  162. .Fn archive_errno
  163. and
  164. .Fn archive_error_string
  165. functions.
  166. .\"
  167. .Sh SEE ALSO
  168. .Xr tar 1 ,
  169. .Xr archive_read_data 3 ,
  170. .Xr archive_read_filter 3 ,
  171. .Xr archive_read_set_options 3 ,
  172. .Xr archive_util 3 ,
  173. .Xr libarchive 3 ,
  174. .Xr tar 5
  175. .Sh BUGS
  176. Many traditional archiver programs treat
  177. empty files as valid empty archives.
  178. For example, many implementations of
  179. .Xr tar 1
  180. allow you to append entries to an empty file.
  181. Of course, it is impossible to determine the format of an empty file
  182. by inspecting the contents, so this library treats empty files as
  183. having a special
  184. .Dq empty
  185. format.
  186. .Pp
  187. Using the
  188. .Dq raw
  189. handler together with any other handler will often work
  190. but can produce surprising results.