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_raw ,
41.Nm archive_read_support_format_tar ,
42.Nm archive_read_support_format_xar ,
43.Nm archive_read_support_format_zip
44.Nd functions for reading streaming archives
45.\"
46.Sh LIBRARY
47Streaming Archive Library (libarchive, -larchive)
48.Sh SYNOPSIS
49.In archive.h
50.Ft int
51.Fn archive_read_support_format_7zip "struct archive *"
52.Ft int
53.Fn archive_read_support_format_all "struct archive *"
54.Ft int
55.Fn archive_read_support_format_ar "struct archive *"
56.Ft int
57.Fn archive_read_support_format_by_code "struct archive *" "int"
58.Ft int
59.Fn archive_read_support_format_cab "struct archive *"
60.Ft int
61.Fn archive_read_support_format_cpio "struct archive *"
62.Ft int
63.Fn archive_read_support_format_empty "struct archive *"
64.Ft int
65.Fn archive_read_support_format_iso9660 "struct archive *"
66.Ft int
67.Fn archive_read_support_format_lha "struct archive *"
68.Ft int
69.Fn archive_read_support_format_mtree "struct archive *"
70.Ft int
71.Fn archive_read_support_format_rar "struct archive *"
72.Ft int
73.Fn archive_read_support_format_raw "struct archive *"
74.Ft int
75.Fn archive_read_support_format_tar "struct archive *"
76.Ft int
77.Fn archive_read_support_format_xar "struct archive *"
78.Ft int
79.Fn archive_read_support_format_zip "struct archive *"
80.\"
81.Sh DESCRIPTION
82.Bl -tag -compact -width indent
83.It Xo
84.Fn archive_read_support_format_7zip ,
85.Fn archive_read_support_format_ar ,
86.Fn archive_read_support_format_cab ,
87.Fn archive_read_support_format_cpio ,
88.Fn archive_read_support_format_iso9660 ,
89.Fn archive_read_support_format_lha ,
90.Fn archive_read_support_format_mtree ,
91.Fn archive_read_support_format_rar ,
92.Fn archive_read_support_format_raw ,
93.Fn archive_read_support_format_tar ,
94.Fn archive_read_support_format_xar ,
95.Fn archive_read_support_format_zip
96.Xc
97Enables support---including auto-detection code---for the
98specified archive format.
99For example,
100.Fn archive_read_support_format_tar
101enables support for a variety of standard tar formats, old-style tar,
102ustar, pax interchange format, and many common variants.
103.It Fn archive_read_support_format_all
104Enables support for all available formats except the
105.Dq raw
106format (see below).
107.It Fn archive_read_support_format_by_code
108Enables a single format specified by the format code.
109This can be useful when reading a single archive twice;
110use
111.Fn archive_format
112after reading the first time and pass the resulting code
113to this function to selectively enable only the necessary
114format support.
115Note:  In statically-linked executables, this will cause
116your program to include support for every format.
117If executable size is a concern, you may wish to avoid
118using this function.
119.It Fn archive_read_support_format_empty
120Enables support for treating empty files as empty archives.
121Because empty files are valid for several different formats,
122it is not possible to accurately determine a format for
123an empty file based purely on contents.
124So empty files are treated by libarchive as a distinct
125format.
126.It Fn archive_read_support_format_raw
127The
128.Dq raw
129format handler allows libarchive to be used to read arbitrary data.
130It treats any data stream as an archive with a single entry.
131The pathname of this entry is
132.Dq data ;
133all other entry fields are unset.
134This is not enabled by
135.Fn archive_read_support_format_all
136in order to avoid erroneous handling of damaged archives.
137.El
138.\" .Sh EXAMPLE
139.Sh RETURN VALUES
140These functions return
141.Cm ARCHIVE_OK
142on success, or
143.Cm ARCHIVE_FATAL .
144.\"
145.Sh ERRORS
146Detailed error codes and textual descriptions are available from the
147.Fn archive_errno
148and
149.Fn archive_error_string
150functions.
151.\"
152.Sh SEE ALSO
153.Xr tar 1 ,
154.Xr archive_read_data 3 ,
155.Xr archive_read_filter 3 ,
156.Xr archive_read_set_options 3 ,
157.Xr archive_util 3 ,
158.Xr libarchive 3 ,
159.Xr tar 5
160.Sh BUGS
161Many traditional archiver programs treat
162empty files as valid empty archives.
163For example, many implementations of
164.Xr tar 1
165allow you to append entries to an empty file.
166Of course, it is impossible to determine the format of an empty file
167by inspecting the contents, so this library treats empty files as
168having a special
169.Dq empty
170format.
171.Pp
172Using the
173.Dq raw
174handler together with any other handler will often work
175but can produce surprising results.
176