summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/doc/man/archive_util.3
blob: 08b1c95ea5ef8501fea00d356c4d6e14034ef33a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
.TH ARCHIVE_UTIL 3 "February 2, 2012" ""
.SH NAME
.ad l
\fB\%archive_clear_error\fP,
\fB\%archive_compression\fP,
\fB\%archive_compression_name\fP,
\fB\%archive_copy_error\fP,
\fB\%archive_errno\fP,
\fB\%archive_error_string\fP,
\fB\%archive_file_count\fP,
\fB\%archive_filter_code\fP,
\fB\%archive_filter_count\fP,
\fB\%archive_filter_name\fP,
\fB\%archive_format\fP,
\fB\%archive_format_name\fP,
\fB\%archive_position\fP,
\fB\%archive_set_error\fP
\- libarchive utility functions
.SH LIBRARY
.ad l
Streaming Archive Library (libarchive, -larchive)
.SH SYNOPSIS
.ad l
\fB#include <archive.h>\fP
.br
\fIvoid\fP
.br
\fB\%archive_clear_error\fP(\fI\%struct\ archive\ *\fP);
.br
\fIint\fP
.br
\fB\%archive_compression\fP(\fI\%struct\ archive\ *\fP);
.br
\fIconst char *\fP
.br
\fB\%archive_compression_name\fP(\fI\%struct\ archive\ *\fP);
.br
\fIvoid\fP
.br
\fB\%archive_copy_error\fP(\fI\%struct\ archive\ *\fP, \fI\%struct\ archive\ *\fP);
.br
\fIint\fP
.br
\fB\%archive_errno\fP(\fI\%struct\ archive\ *\fP);
.br
\fIconst char *\fP
.br
\fB\%archive_error_string\fP(\fI\%struct\ archive\ *\fP);
.br
\fIint\fP
.br
\fB\%archive_file_count\fP(\fI\%struct\ archive\ *\fP);
.br
\fIint\fP
.br
\fB\%archive_filter_code\fP(\fI\%struct\ archive\ *\fP, \fI\%int\fP);
.br
\fIint\fP
.br
\fB\%archive_filter_count\fP(\fI\%struct\ archive\ *\fP, \fI\%int\fP);
.br
\fIconst char *\fP
.br
\fB\%archive_filter_name\fP(\fI\%struct\ archive\ *\fP, \fI\%int\fP);
.br
\fIint\fP
.br
\fB\%archive_format\fP(\fI\%struct\ archive\ *\fP);
.br
\fIconst char *\fP
.br
\fB\%archive_format_name\fP(\fI\%struct\ archive\ *\fP);
.br
\fIint64_t\fP
.br
\fB\%archive_position\fP(\fI\%struct\ archive\ *\fP, \fI\%int\fP);
.br
\fIvoid\fP
.br
\fB\%archive_set_error\fP(\fI\%struct\ archive\ *\fP, \fI\%int\ error_code\fP, \fI\%const\ char\ *fmt\fP, \fI\%...\fP);
.SH DESCRIPTION
.ad l
These functions provide access to various information about the
Tn struct archive
object used in the
\fBlibarchive\fP(3)
library.
.RS 5
.TP
\fB\%archive_clear_error\fP()
Clears any error information left over from a previous call.
Not generally used in client code.
.TP
\fB\%archive_compression\fP()
Synonym for
\fB\%archive_filter_code\fP(\fI\%a\fP, \fI\%0\fP).
.TP
\fB\%archive_compression_name\fP()
Synonym for
\fB\%archive_filter_name\fP(\fI\%a\fP, \fI\%0\fP).
.TP
\fB\%archive_copy_error\fP()
Copies error information from one archive to another.
.TP
\fB\%archive_errno\fP()
Returns a numeric error code (see
\fBerrno\fP(2))
indicating the reason for the most recent error return.
Note that this can not be reliably used to detect whether an
error has occurred.
It should be used only after another libarchive function
has returned an error status.
.TP
\fB\%archive_error_string\fP()
Returns a textual error message suitable for display.
The error message here is usually more specific than that
obtained from passing the result of
\fB\%archive_errno\fP()
to
\fBstrerror\fP(3).
.TP
\fB\%archive_file_count\fP()
Returns a count of the number of files processed by this archive object.
The count is incremented by calls to
\fBarchive_write_header\fP(3)
or
\fBarchive_read_next_header\fP(3).
.TP
\fB\%archive_filter_code\fP()
Returns a numeric code identifying the indicated filter.
See
\fB\%archive_filter_count\fP()
for details of the numbering.
.TP
\fB\%archive_filter_count\fP()
Returns the number of filters in the current pipeline.
For read archive handles, these filters are added automatically
by the automatic format detection.
For write archive handles, these filters are added by calls to the various
\fB\%archive_write_add_filter_XXX\fP()
functions.
Filters in the resulting pipeline are numbered so that filter 0
is the filter closest to the format handler.
As a convenience, functions that expect a filter number will
accept -1 as a synonym for the highest-numbered filter.
.PP
For example, when reading a uuencoded gzipped tar archive, there
are three filters:
filter 0 is the gunzip filter,
filter 1 is the uudecode filter,
and filter 2 is the pseudo-filter that wraps the archive read functions.
In this case, requesting
\fB\%archive_position\fP(\fI\%a\fP, \fI\%-1\fP)
would be a synonym for
\fB\%archive_position\fP(\fI\%a\fP, \fI\%2\fP)
which would return the number of bytes currently read from the archive, while
\fB\%archive_position\fP(\fI\%a\fP, \fI\%1\fP)
would return the number of bytes after uudecoding, and
\fB\%archive_position\fP(\fI\%a\fP, \fI\%0\fP)
would return the number of bytes after decompression.
.TP
\fB\%archive_filter_name\fP()
Returns a textual name identifying the indicated filter.
See
\fB\%archive_filter_count\fP()
for details of the numbering.
.TP
\fB\%archive_format\fP()
Returns a numeric code indicating the format of the current
archive entry.
This value is set by a successful call to
\fB\%archive_read_next_header\fP().
Note that it is common for this value to change from
entry to entry.
For example, a tar archive might have several entries that
utilize GNU tar extensions and several entries that do not.
These entries will have different format codes.
.TP
\fB\%archive_format_name\fP()
A textual description of the format of the current entry.
.TP
\fB\%archive_position\fP()
Returns the number of bytes read from or written to the indicated filter.
In particular,
\fB\%archive_position\fP(\fI\%a\fP, \fI\%0\fP)
returns the number of bytes read or written by the format handler, while
\fB\%archive_position\fP(\fI\%a\fP, \fI\%-1\fP)
returns the number of bytes read or written to the archive.
See
\fB\%archive_filter_count\fP()
for details of the numbering here.
.TP
\fB\%archive_set_error\fP()
Sets the numeric error code and error description that will be returned
by
\fB\%archive_errno\fP()
and
\fB\%archive_error_string\fP().
This function should be used within I/O callbacks to set system-specific
error codes and error descriptions.
This function accepts a printf-like format string and arguments.
However, you should be careful to use only the following printf
format specifiers:
``%c'',
``%d'',
``%jd'',
``%jo'',
``%ju'',
``%jx'',
``%ld'',
``%lo'',
``%lu'',
``%lx'',
``%o'',
``%u'',
``%s'',
``%x'',
``%%''.
Field-width specifiers and other printf features are
not uniformly supported and should not be used.
.RE
.SH SEE ALSO
.ad l
\fBarchive_read\fP(3),
\fBarchive_write\fP(3),
\fBlibarchive\fP(3),
\fBprintf\fP(3)
.SH HISTORY
.ad l
The
\fB\%libarchive\fP
library first appeared in
FreeBSD 5.3.
.SH AUTHORS
.ad l
-nosplit
The
\fB\%libarchive\fP
library was written by
Tim Kientzle \%<kientzle@acm.org.>