1 ARCHIVE_READ_OPEN(3) manual page
3 '''archive_read_open''',
4 '''archive_read_open2''',
5 '''archive_read_open_fd''',
6 '''archive_read_open_FILE''',
7 '''archive_read_open_filename''',
8 '''archive_read_open_memory''',
9 - functions for reading streaming archives
11 Streaming Archive Library (libarchive, -larchive)
13 '''<nowiki>#include <archive.h></nowiki>'''
17 '''archive_read_open'''(''struct archive *'', ''void *client_data'', ''archive_open_callback *'', ''archive_read_callback *'', ''archive_close_callback *'');
21 '''archive_read_open2'''(''struct archive *'', ''void *client_data'', ''archive_open_callback *'', ''archive_read_callback *'', ''archive_skip_callback *'', ''archive_close_callback *'');
25 '''archive_read_open_FILE'''(''struct archive *'', ''FILE *file'');
29 '''archive_read_open_fd'''(''struct archive *'', ''int fd'', ''size_t block_size'');
33 '''archive_read_open_filename'''(''struct archive *'', ''const char *filename'', ''size_t block_size'');
37 '''archive_read_open_memory'''(''struct archive *'', ''void *buff'', ''size_t size'');
40 <dt>'''archive_read_open'''()</dt><dd>
42 '''archive_read_open2'''(),
43 except that the skip callback is assumed to be
45 </dd><dt>'''archive_read_open2'''()</dt><dd>
46 Freeze the settings, open the archive, and prepare for reading entries.
47 This is the most generic version of this call, which accepts
48 four callback functions.
49 Most clients will want to use
50 '''archive_read_open_filename'''(),
51 '''archive_read_open_FILE'''(),
52 '''archive_read_open_fd'''(),
54 '''archive_read_open_memory'''()
56 The library invokes the client-provided functions to obtain
57 raw bytes from the archive.
58 </dd><dt>'''archive_read_open_FILE'''()</dt><dd>
60 '''archive_read_open'''(),
61 except that it accepts a
64 This function should not be used with tape drives or other devices
65 that require strict I/O blocking.
66 </dd><dt>'''archive_read_open_fd'''()</dt><dd>
68 '''archive_read_open'''(),
69 except that it accepts a file descriptor and block size rather than
70 a set of function pointers.
71 Note that the file descriptor will not be automatically closed at
73 This function is safe for use with tape drives or other blocked devices.
74 </dd><dt>'''archive_read_open_file'''()</dt><dd>
75 This is a deprecated synonym for
76 '''archive_read_open_filename'''().
77 </dd><dt>'''archive_read_open_filename'''()</dt><dd>
79 '''archive_read_open'''(),
80 except that it accepts a simple filename and a block size.
81 A NULL filename represents standard input.
82 This function is safe for use with tape drives or other blocked devices.
83 </dd><dt>'''archive_read_open_memory'''()</dt><dd>
85 '''archive_read_open'''(),
86 except that it accepts a pointer and size of a block of
87 memory containing the archive data.
90 A complete description of the
93 '''struct archive_entry'''
94 objects can be found in the overview manual page for
95 [[ManPageLibarchive3]].
96 == CLIENT CALLBACKS ==
97 The callback functions must match the following prototypes:
100 ''typedef la_ssize_t''
101 '''archive_read_callback'''(''struct archive *'', ''void *client_data'', ''const void **buffer'')
103 ''typedef la_int64_t''
104 '''archive_skip_callback'''(''struct archive *'', ''void *client_data'', ''off_t request'')
107 '''archive_open_callback'''(''struct archive *'', ''void *client_data'')
110 '''archive_close_callback'''(''struct archive *'', ''void *client_data'')
113 The open callback is invoked by
114 '''archive_open'''().
117 if the underlying file or data source is successfully
119 If the open fails, it should call
120 '''archive_set_error'''()
121 to register an error code and message and return
124 The read callback is invoked whenever the library
125 requires raw bytes from the archive.
126 The read callback should read data into a buffer,
131 argument to point to the available data, and
132 return a count of the number of bytes available.
133 The library will invoke the read callback again
134 only after it has consumed this data.
135 The library imposes no constraints on the size
136 of the data blocks returned.
137 On end-of-file, the read callback should
139 On error, the read callback should invoke
140 '''archive_set_error'''()
141 to register an error code and message and
144 The skip callback is invoked when the
145 library wants to ignore a block of data.
146 The return value is the number of bytes actually
147 skipped, which may differ from the request.
148 If the callback cannot skip data, it should return
150 If the skip callback is not provided (the
153 the library will invoke the read function
154 instead and simply discard the result.
155 A skip callback can provide significant
156 performance gains when reading uncompressed
157 archives from slow disk drives or other media
158 that can skip quickly.
160 The close callback is invoked by archive_close when
161 the archive processing is complete.
162 The callback should return
165 On failure, the callback should invoke
166 '''archive_set_error'''()
167 to register an error code and message and
171 These functions return
176 Detailed error codes and textual descriptions are available from the
177 '''archive_errno'''()
179 '''archive_error_string'''()
183 [[ManPageLibarchive3]],
184 [[ManPageArchiveRead3]],
185 [[ManPageArchiveReadData3]],
186 [[ManPageArchiveReadFilter3]],
187 [[ManPageArchiveReadFormat3]],
188 [[ManPageArchiveReadSetOptions3]],
189 [[ManPageArchiveUtil3]],