1ARCHIVE_READ_OPEN(3)     BSD Library Functions Manual     ARCHIVE_READ_OPEN(3)
2

NAME

4     archive_read_open, archive_read_open2, archive_read_open_fd,
5     archive_read_open_FILE, archive_read_open_filename,
6     archive_read_open_memory — functions for reading streaming archives
7

LIBRARY

9     Streaming Archive Library (libarchive, -larchive)
10

SYNOPSIS

12     #include <archive.h>
13
14     int
15     archive_read_open(struct archive *, void *client_data,
16         archive_open_callback *, archive_read_callback *,
17         archive_close_callback *);
18
19     int
20     archive_read_open2(struct archive *, void *client_data,
21         archive_open_callback *, archive_read_callback *,
22         archive_skip_callback *, archive_close_callback *);
23
24     int
25     archive_read_open_FILE(struct archive *, FILE *file);
26
27     int
28     archive_read_open_fd(struct archive *, int fd, size_t block_size);
29
30     int
31     archive_read_open_filename(struct archive *, const char *filename,
32         size_t block_size);
33
34     int
35     archive_read_open_memory(struct archive *, const void *buff,
36         size_t size);
37

DESCRIPTION

39     archive_read_open()
40             The same as archive_read_open2(), except that the skip callback
41             is assumed to be NULL.
42     archive_read_open2()
43             Freeze the settings, open the archive, and prepare for reading
44             entries.  This is the most generic version of this call, which
45             accepts four callback functions.  Most clients will want to use
46             archive_read_open_filename(), archive_read_open_FILE(),
47             archive_read_open_fd(), or archive_read_open_memory() instead.
48             The library invokes the client-provided functions to obtain raw
49             bytes from the archive.
50     archive_read_open_FILE()
51             Like archive_read_open(), except that it accepts a FILE *
52             pointer.  This function should not be used with tape drives or
53             other devices that require strict I/O blocking.
54     archive_read_open_fd()
55             Like archive_read_open(), except that it accepts a file descrip‐
56             tor and block size rather than a set of function pointers.  Note
57             that the file descriptor will not be automatically closed at end-
58             of-archive.  This function is safe for use with tape drives or
59             other blocked devices.
60     archive_read_open_file()
61             This is a deprecated synonym for archive_read_open_filename().
62     archive_read_open_filename()
63             Like archive_read_open(), except that it accepts a simple file‐
64             name and a block size.  A NULL filename represents standard
65             input.  This function is safe for use with tape drives or other
66             blocked devices.
67     archive_read_open_memory()
68             Like archive_read_open(), except that it accepts a pointer and
69             size of a block of memory containing the archive data.
70
71     A complete description of the struct archive and struct archive_entry
72     objects can be found in the overview manual page for libarchive(3).
73

CLIENT CALLBACKS

75     The callback functions must match the following prototypes:
76
77           typedef la_ssize_t archive_read_callback(struct archive *,
78           void *client_data, const void **buffer)
79
80           typedef la_int64_t archive_skip_callback(struct archive *,
81           void *client_data, off_t request)
82
83           typedef int archive_open_callback(struct archive *, void
84           *client_data)
85
86           typedef int archive_close_callback(struct archive *, void
87           *client_data)
88
89     The open callback is invoked by archive_open().  It should return
90     ARCHIVE_OK if the underlying file or data source is successfully opened.
91     If the open fails, it should call archive_set_error() to register an
92     error code and message and return ARCHIVE_FATAL.
93
94     The read callback is invoked whenever the library requires raw bytes from
95     the archive.  The read callback should read data into a buffer, set the
96     const void **buffer argument to point to the available data, and return a
97     count of the number of bytes available.  The library will invoke the read
98     callback again only after it has consumed this data.  The library imposes
99     no constraints on the size of the data blocks returned.  On end-of-file,
100     the read callback should return zero.  On error, the read callback should
101     invoke archive_set_error() to register an error code and message and
102     return -1.
103
104     The skip callback is invoked when the library wants to ignore a block of
105     data.  The return value is the number of bytes actually skipped, which
106     may differ from the request.  If the callback cannot skip data, it should
107     return zero.  If the skip callback is not provided (the function pointer
108     is NULL ), the library will invoke the read function instead and simply
109     discard the result.  A skip callback can provide significant performance
110     gains when reading uncompressed archives from slow disk drives or other
111     media that can skip quickly.
112
113     The close callback is invoked by archive_close when the archive process‐
114     ing is complete.  The callback should return ARCHIVE_OK on success.  On
115     failure, the callback should invoke archive_set_error() to register an
116     error code and message and return ARCHIVE_FATAL.
117

RETURN VALUES

119     These functions return ARCHIVE_OK on success, or ARCHIVE_FATAL.
120

ERRORS

122     Detailed error codes and textual descriptions are available from the
123     archive_errno() and archive_error_string() functions.
124

SEE ALSO

126     tar(1), archive_read(3), archive_read_data(3), archive_read_filter(3),
127     archive_read_format(3), archive_read_set_options(3), archive_util(3),
128     libarchive(3), tar(5)
129
130BSD                            February 2, 2012                            BSD
Impressum