Blame doc/text/archive_read_open.3.txt

Packit 08bd4c
ARCHIVE_READ_OPEN(3)	 BSD Library Functions Manual	  ARCHIVE_READ_OPEN(3)
Packit 08bd4c
Packit 08bd4c
NAME
Packit 08bd4c
     archive_read_open, archive_read_open2, archive_read_open_fd,
Packit 08bd4c
     archive_read_open_FILE, archive_read_open_filename,
Packit 08bd4c
     archive_read_open_memory — functions for reading streaming archives
Packit 08bd4c
Packit 08bd4c
LIBRARY
Packit 08bd4c
     Streaming Archive Library (libarchive, -larchive)
Packit 08bd4c
Packit 08bd4c
SYNOPSIS
Packit 08bd4c
     #include <archive.h>
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_read_open(struct archive *, void *client_data,
Packit 08bd4c
	 archive_open_callback *, archive_read_callback *,
Packit 08bd4c
	 archive_close_callback *);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_read_open2(struct archive *, void *client_data,
Packit 08bd4c
	 archive_open_callback *, archive_read_callback *,
Packit 08bd4c
	 archive_skip_callback *, archive_close_callback *);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_read_open_FILE(struct archive *, FILE *file);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_read_open_fd(struct archive *, int fd, size_t block_size);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_read_open_filename(struct archive *, const char *filename,
Packit 08bd4c
	 size_t block_size);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_read_open_memory(struct archive *, const void *buff,
Packit 08bd4c
	 size_t size);
Packit 08bd4c
Packit 08bd4c
DESCRIPTION
Packit 08bd4c
     archive_read_open()
Packit 08bd4c
	     The same as archive_read_open2(), except that the skip callback
Packit 08bd4c
	     is assumed to be NULL.
Packit 08bd4c
     archive_read_open2()
Packit 08bd4c
	     Freeze the settings, open the archive, and prepare for reading
Packit 08bd4c
	     entries.  This is the most generic version of this call, which
Packit 08bd4c
	     accepts four callback functions.  Most clients will want to use
Packit 08bd4c
	     archive_read_open_filename(), archive_read_open_FILE(),
Packit 08bd4c
	     archive_read_open_fd(), or archive_read_open_memory() instead.
Packit 08bd4c
	     The library invokes the client-provided functions to obtain raw
Packit 08bd4c
	     bytes from the archive.
Packit 08bd4c
     archive_read_open_FILE()
Packit 08bd4c
	     Like archive_read_open(), except that it accepts a FILE *
Packit 08bd4c
	     pointer.  This function should not be used with tape drives or
Packit 08bd4c
	     other devices that require strict I/O blocking.
Packit 08bd4c
     archive_read_open_fd()
Packit 08bd4c
	     Like archive_read_open(), except that it accepts a file descrip‐
Packit 08bd4c
	     tor and block size rather than a set of function pointers.  Note
Packit 08bd4c
	     that the file descriptor will not be automatically closed at end-
Packit 08bd4c
	     of-archive.  This function is safe for use with tape drives or
Packit 08bd4c
	     other blocked devices.
Packit 08bd4c
     archive_read_open_file()
Packit 08bd4c
	     This is a deprecated synonym for archive_read_open_filename().
Packit 08bd4c
     archive_read_open_filename()
Packit 08bd4c
	     Like archive_read_open(), except that it accepts a simple file‐
Packit 08bd4c
	     name and a block size.  A NULL filename represents standard
Packit 08bd4c
	     input.  This function is safe for use with tape drives or other
Packit 08bd4c
	     blocked devices.
Packit 08bd4c
     archive_read_open_memory()
Packit 08bd4c
	     Like archive_read_open(), except that it accepts a pointer and
Packit 08bd4c
	     size of a block of memory containing the archive data.
Packit 08bd4c
Packit 08bd4c
     A complete description of the struct archive and struct archive_entry
Packit 08bd4c
     objects can be found in the overview manual page for libarchive(3).
Packit 08bd4c
Packit 08bd4c
CLIENT CALLBACKS
Packit 08bd4c
     The callback functions must match the following prototypes:
Packit 08bd4c
Packit 08bd4c
	   typedef la_ssize_t archive_read_callback(struct archive *,
Packit 08bd4c
	   void *client_data, const void **buffer)
Packit 08bd4c
Packit 08bd4c
	   typedef la_int64_t archive_skip_callback(struct archive *,
Packit 08bd4c
	   void *client_data, off_t request)
Packit 08bd4c
Packit 08bd4c
	   typedef int archive_open_callback(struct archive *, void
Packit 08bd4c
	   *client_data)
Packit 08bd4c
Packit 08bd4c
	   typedef int archive_close_callback(struct archive *, void
Packit 08bd4c
	   *client_data)
Packit 08bd4c
Packit 08bd4c
     The open callback is invoked by archive_open().  It should return
Packit 08bd4c
     ARCHIVE_OK if the underlying file or data source is successfully opened.
Packit 08bd4c
     If the open fails, it should call archive_set_error() to register an
Packit 08bd4c
     error code and message and return ARCHIVE_FATAL.
Packit 08bd4c
Packit 08bd4c
     The read callback is invoked whenever the library requires raw bytes from
Packit 08bd4c
     the archive.  The read callback should read data into a buffer, set the
Packit 08bd4c
     const void **buffer argument to point to the available data, and return a
Packit 08bd4c
     count of the number of bytes available.  The library will invoke the read
Packit 08bd4c
     callback again only after it has consumed this data.  The library imposes
Packit 08bd4c
     no constraints on the size of the data blocks returned.  On end-of-file,
Packit 08bd4c
     the read callback should return zero.  On error, the read callback should
Packit 08bd4c
     invoke archive_set_error() to register an error code and message and
Packit 08bd4c
     return -1.
Packit 08bd4c
Packit 08bd4c
     The skip callback is invoked when the library wants to ignore a block of
Packit 08bd4c
     data.  The return value is the number of bytes actually skipped, which
Packit 08bd4c
     may differ from the request.  If the callback cannot skip data, it should
Packit 08bd4c
     return zero.  If the skip callback is not provided (the function pointer
Packit 08bd4c
     is NULL ), the library will invoke the read function instead and simply
Packit 08bd4c
     discard the result.  A skip callback can provide significant performance
Packit 08bd4c
     gains when reading uncompressed archives from slow disk drives or other
Packit 08bd4c
     media that can skip quickly.
Packit 08bd4c
Packit 08bd4c
     The close callback is invoked by archive_close when the archive process‐
Packit 08bd4c
     ing is complete.  The callback should return ARCHIVE_OK on success.  On
Packit 08bd4c
     failure, the callback should invoke archive_set_error() to register an
Packit 08bd4c
     error code and message and return ARCHIVE_FATAL.
Packit 08bd4c
Packit 08bd4c
RETURN VALUES
Packit 08bd4c
     These functions return ARCHIVE_OK on success, or ARCHIVE_FATAL.
Packit 08bd4c
Packit 08bd4c
ERRORS
Packit 08bd4c
     Detailed error codes and textual descriptions are available from the
Packit 08bd4c
     archive_errno() and archive_error_string() functions.
Packit 08bd4c
Packit 08bd4c
SEE ALSO
Packit 08bd4c
     tar(1), libarchive(3), archive_read(3), archive_read_data(3),
Packit 08bd4c
     archive_read_filter(3), archive_read_format(3),
Packit 08bd4c
     archive_read_set_options(3), archive_util(3), tar(5)
Packit 08bd4c
Packit 08bd4c
BSD			       February 2, 2012 			   BSD