1 .\" Copyright (c) 2003-2011 Tim Kientzle
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
28 .Dt ARCHIVE_READ_DATA 3
31 .Nm archive_read_data ,
32 .Nm archive_read_data_block ,
33 .Nm archive_read_data_skip ,
34 .Nm archive_read_data_into_fd
35 .Nd functions for reading streaming archives
37 Streaming Archive Library (libarchive, -larchive)
41 .Fn archive_read_data "struct archive *" "void *buff" "size_t len"
43 .Fo archive_read_data_block
44 .Fa "struct archive *"
45 .Fa "const void **buff"
50 .Fn archive_read_data_skip "struct archive *"
52 .Fn archive_read_data_into_fd "struct archive *" "int fd"
55 .Bl -tag -compact -width indent
56 .It Fn archive_read_data
57 Read data associated with the header just read.
58 Internally, this is a convenience function that calls
59 .Fn archive_read_data_block
60 and fills any gaps with nulls so that callers see a single
61 continuous stream of data.
62 .It Fn archive_read_data_block
63 Return the next available block of data for this entry.
65 .Fn archive_read_data ,
67 .Fn archive_read_data_block
68 function avoids copying data and allows you to correctly handle
69 sparse files, as supported by some archive formats.
70 The library guarantees that offsets will increase and that blocks
72 Note that the blocks returned from this function can be much larger
73 than the block size read from disk, due to compression
74 and internal buffer optimizations.
75 .It Fn archive_read_data_skip
76 A convenience function that repeatedly calls
77 .Fn archive_read_data_block
78 to skip all of the data for this archive entry.
79 Note that this function is invoked automatically by
80 .Fn archive_read_next_header2
81 if the previous entry was not completely consumed.
82 .It Fn archive_read_data_into_fd
83 A convenience function that repeatedly calls
84 .Fn archive_read_data_block
85 to copy the entire entry to the provided file descriptor.
89 Most functions return zero on success, non-zero on error.
90 The possible return codes include:
92 (the operation succeeded),
94 (the operation succeeded but a non-critical error was encountered),
96 (end-of-archive was encountered),
98 (the operation failed but can be retried),
101 (there was a fatal error; the archive should be closed immediately).
103 .Fn archive_read_data
104 returns a count of bytes actually read or zero at the end of the entry.
113 Detailed error codes and textual descriptions are available from the
116 .Fn archive_error_string
123 .Xr archive_read_extract 3 ,
124 .Xr archive_read_filter 3 ,
125 .Xr archive_read_format 3 ,
126 .Xr archive_read_header 3 ,
127 .Xr archive_read_open 3 ,
128 .Xr archive_read_set_options 3 ,