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