1 ARCHIVE_UTIL(3) manual page
3 '''archive_clear_error''',
4 '''archive_compression''',
5 '''archive_compression_name''',
6 '''archive_copy_error''',
8 '''archive_error_string''',
9 '''archive_file_count''',
10 '''archive_filter_code''',
11 '''archive_filter_count''',
12 '''archive_filter_name''',
14 '''archive_format_name''',
15 '''archive_position''',
16 '''archive_set_error'''
17 - libarchive utility functions
19 Streaming Archive Library (libarchive, -larchive)
21 '''<nowiki>#include <archive.h></nowiki>'''
25 '''archive_clear_error'''(''struct archive *'');
29 '''archive_compression'''(''struct archive *'');
33 '''archive_compression_name'''(''struct archive *'');
37 '''archive_copy_error'''(''struct archive *'', ''struct archive *'');
41 '''archive_errno'''(''struct archive *'');
45 '''archive_error_string'''(''struct archive *'');
49 '''archive_file_count'''(''struct archive *'');
53 '''archive_filter_code'''(''struct archive *'', ''int'');
57 '''archive_filter_count'''(''struct archive *'', ''int'');
61 '''archive_filter_name'''(''struct archive *'', ''int'');
65 '''archive_format'''(''struct archive *'');
69 '''archive_format_name'''(''struct archive *'');
73 '''archive_position'''(''struct archive *'', ''int'');
77 '''archive_set_error'''(''struct archive *'', ''int error_code'', ''const char *fmt'', ''...'');
79 These functions provide access to various information about the
82 [[ManPageLibarchive3]]
85 <dt>'''archive_clear_error'''()</dt><dd>
86 Clears any error information left over from a previous call.
87 Not generally used in client code.
88 </dd><dt>'''archive_compression'''()</dt><dd>
90 '''archive_filter_code(a,'''(''0)'').
91 </dd><dt>'''archive_compression_name'''()</dt><dd>
93 '''archive_filter_name(a,'''(''0)'').
94 </dd><dt>'''archive_copy_error'''()</dt><dd>
95 Copies error information from one archive to another.
96 </dd><dt>'''archive_errno'''()</dt><dd>
97 Returns a numeric error code (see
98 [[errno(2)|http://www.freebsd.org/cgi/man.cgi?query=errno&sektion=2]])
99 indicating the reason for the most recent error return.
100 Note that this can not be reliably used to detect whether an
102 It should be used only after another libarchive function
103 has returned an error status.
104 </dd><dt>'''archive_error_string'''()</dt><dd>
105 Returns a textual error message suitable for display.
106 The error message here is usually more specific than that
107 obtained from passing the result of
108 '''archive_errno'''()
110 [[strerror(3)|http://www.freebsd.org/cgi/man.cgi?query=strerror&sektion=3]].
111 </dd><dt>'''archive_file_count'''()</dt><dd>
112 Returns a count of the number of files processed by this archive object.
113 The count is incremented by calls to
114 [[ManPageArchiveWriteHeader3]]
116 [[ManPageArchiveReadNextHeader3]].
117 </dd><dt>'''archive_filter_code'''()</dt><dd>
118 Returns a numeric code identifying the indicated filter.
120 '''archive_filter_count'''()
121 for details of the numbering.
122 </dd><dt>'''archive_filter_count'''()</dt><dd>
123 Returns the number of filters in the current pipeline.
124 For read archive handles, these filters are added automatically
125 by the automatic format detection.
126 For write archive handles, these filters are added by calls to the various
127 '''archive_write_add_filter_XXX'''()
129 Filters in the resulting pipeline are numbered so that filter 0
130 is the filter closest to the format handler.
131 As a convenience, functions that expect a filter number will
132 accept -1 as a synonym for the highest-numbered filter.
134 For example, when reading a uuencoded gzipped tar archive, there
136 filter 0 is the gunzip filter,
137 filter 1 is the uudecode filter,
138 and filter 2 is the pseudo-filter that wraps the archive read functions.
139 In this case, requesting
140 '''archive_position(a,'''(''-1)'')
141 would be a synonym for
142 '''archive_position(a,'''(''2)'')
143 which would return the number of bytes currently read from the archive, while
144 '''archive_position(a,'''(''1)'')
145 would return the number of bytes after uudecoding, and
146 '''archive_position(a,'''(''0)'')
147 would return the number of bytes after decompression.
148 </dd><dt>'''archive_filter_name'''()</dt><dd>
149 Returns a textual name identifying the indicated filter.
151 '''archive_filter_count'''()
152 for details of the numbering.
153 </dd><dt>'''archive_format'''()</dt><dd>
154 Returns a numeric code indicating the format of the current
156 This value is set by a successful call to
157 '''archive_read_next_header'''().
158 Note that it is common for this value to change from
160 For example, a tar archive might have several entries that
161 utilize GNU tar extensions and several entries that do not.
162 These entries will have different format codes.
163 </dd><dt>'''archive_format_name'''()</dt><dd>
164 A textual description of the format of the current entry.
165 </dd><dt>'''archive_position'''()</dt><dd>
166 Returns the number of bytes read from or written to the indicated filter.
168 '''archive_position(a,'''(''0)'')
169 returns the number of bytes read or written by the format handler, while
170 '''archive_position(a,'''(''-1)'')
171 returns the number of bytes read or written to the archive.
173 '''archive_filter_count'''()
174 for details of the numbering here.
175 </dd><dt>'''archive_set_error'''()</dt><dd>
176 Sets the numeric error code and error description that will be returned
178 '''archive_errno'''()
180 '''archive_error_string'''().
181 This function should be used within I/O callbacks to set system-specific
182 error codes and error descriptions.
183 This function accepts a printf-like format string and arguments.
184 However, you should be careful to use only the following printf
201 Field-width specifiers and other printf features are
202 not uniformly supported and should not be used.
205 [[ManPageArchiveRead3]],
206 [[ManPageArchiveWrite3]],
207 [[ManPageLibarchive3]],
208 [[printf(3)|http://www.freebsd.org/cgi/man.cgi?query=printf&sektion=3]]
212 library first appeared in
217 library was written by
218 Tim Kientzle <kientzle@acm.org.>