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 *, void *buff, size_t size);
36

DESCRIPTION

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

CLIENT CALLBACKS

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

RETURN VALUES

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

ERRORS

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

SEE ALSO

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