Blame doc/text/archive_write_open.3.txt

Packit 08bd4c
ARCHIVE_WRITE_OPEN(3)	 BSD Library Functions Manual	 ARCHIVE_WRITE_OPEN(3)
Packit 08bd4c
Packit 08bd4c
NAME
Packit 08bd4c
     archive_write_open, archive_write_open_fd, archive_write_open_FILE,
Packit 08bd4c
     archive_write_open_filename, archive_write_open_memory — functions for
Packit 08bd4c
     creating 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_write_open(struct archive *, void *client_data,
Packit 08bd4c
	 archive_open_callback *, archive_write_callback *,
Packit 08bd4c
	 archive_close_callback *);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_write_open_fd(struct archive *, int fd);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_write_open_FILE(struct archive *, FILE *file);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_write_open_filename(struct archive *, const char *filename);
Packit 08bd4c
Packit 08bd4c
     int
Packit 08bd4c
     archive_write_open_memory(struct archive *, void *buffer,
Packit 08bd4c
	 size_t bufferSize, size_t *outUsed);
Packit 08bd4c
Packit 08bd4c
DESCRIPTION
Packit 08bd4c
     archive_write_open()
Packit 08bd4c
	     Freeze the settings, open the archive, and prepare for writing
Packit 08bd4c
	     entries.  This is the most generic form of this function, which
Packit 08bd4c
	     accepts pointers to three callback functions which will be
Packit 08bd4c
	     invoked by the compression layer to write the constructed ar‐
Packit 08bd4c
	     chive.  This does not alter the default archive padding.
Packit 08bd4c
Packit 08bd4c
     archive_write_open_fd()
Packit 08bd4c
	     A convenience form of archive_write_open() that accepts a file
Packit 08bd4c
	     descriptor.  The archive_write_open_fd() function is safe for use
Packit 08bd4c
	     with tape drives or other block-oriented devices.
Packit 08bd4c
Packit 08bd4c
     archive_write_open_FILE()
Packit 08bd4c
	     A convenience form of archive_write_open() that accepts a FILE *
Packit 08bd4c
	     pointer.  Note that archive_write_open_FILE() is not safe for
Packit 08bd4c
	     writing to tape drives or other devices that require correct
Packit 08bd4c
	     blocking.
Packit 08bd4c
Packit 08bd4c
     archive_write_open_file()
Packit 08bd4c
	     A deprecated synonym for archive_write_open_filename().
Packit 08bd4c
Packit 08bd4c
     archive_write_open_filename()
Packit 08bd4c
	     A convenience form of archive_write_open() that accepts a file‐
Packit 08bd4c
	     name.  A NULL argument indicates that the output should be writ‐
Packit 08bd4c
	     ten to standard output; an argument of “-” will open a file with
Packit 08bd4c
	     that name.  If you have not invoked
Packit 08bd4c
	     archive_write_set_bytes_in_last_block(), then
Packit 08bd4c
	     archive_write_open_filename() will adjust the last-block padding
Packit 08bd4c
	     depending on the file: it will enable padding when writing to
Packit 08bd4c
	     standard output or to a character or block device node, it will
Packit 08bd4c
	     disable padding otherwise.  You can override this by manually
Packit 08bd4c
	     invoking archive_write_set_bytes_in_last_block() before calling
Packit 08bd4c
	     archive_write_open().  The archive_write_open_filename() function
Packit 08bd4c
	     is safe for use with tape drives or other block-oriented devices.
Packit 08bd4c
Packit 08bd4c
     archive_write_open_memory()
Packit 08bd4c
	     A convenience form of archive_write_open() that accepts a pointer
Packit 08bd4c
	     to a block of memory that will receive the archive.  The final
Packit 08bd4c
	     size_t * argument points to a variable that will be updated after
Packit 08bd4c
	     each write to reflect how much of the buffer is currently in use.
Packit 08bd4c
	     You should be careful to ensure that this variable remains allo‐
Packit 08bd4c
	     cated until after the archive is closed.  This function will dis‐
Packit 08bd4c
	     able padding unless you have specifically set the block size.
Packit 08bd4c
     More information about the struct archive object and the overall design
Packit 08bd4c
     of the library can be found in the libarchive(3) overview.
Packit 08bd4c
Packit 08bd4c
     Note that the convenience forms above vary in how they block the output.
Packit 08bd4c
     See archive_write_blocksize(3) if you need to control the block size used
Packit 08bd4c
     for writes or the end-of-file padding behavior.
Packit 08bd4c
Packit 08bd4c
CLIENT CALLBACKS
Packit 08bd4c
     To use this library, you will need to define and register callback func‐
Packit 08bd4c
     tions that will be invoked to write data to the resulting archive.  These
Packit 08bd4c
     functions are registered by calling archive_write_open():
Packit 08bd4c
Packit 08bd4c
	   typedef int archive_open_callback(struct archive *, void
Packit 08bd4c
	   *client_data)
Packit 08bd4c
Packit 08bd4c
     The open callback is invoked by archive_write_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
	   typedef la_ssize_t archive_write_callback(struct archive *,
Packit 08bd4c
	   void *client_data, const void *buffer, size_t length)
Packit 08bd4c
Packit 08bd4c
     The write callback is invoked whenever the library needs to write raw
Packit 08bd4c
     bytes to the archive.  For correct blocking, each call to the write call‐
Packit 08bd4c
     back function should translate into a single write(2) system call.  This
Packit 08bd4c
     is especially critical when writing archives to tape drives.  On success,
Packit 08bd4c
     the write callback should return the number of bytes actually written.
Packit 08bd4c
     On error, the callback should invoke archive_set_error() to register an
Packit 08bd4c
     error code and message and return -1.
Packit 08bd4c
Packit 08bd4c
	   typedef int archive_close_callback(struct archive *, void
Packit 08bd4c
	   *client_data)
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
     Note that if the client-provided write callback function returns a non-
Packit 08bd4c
     zero value, that error will be propagated back to the caller through
Packit 08bd4c
     whatever API function resulted in that call, which may include
Packit 08bd4c
     archive_write_header(), archive_write_data(), archive_write_close(),
Packit 08bd4c
     archive_write_finish(), or archive_write_free().  The client callback can
Packit 08bd4c
     call archive_set_error() to provide values that can then be retrieved by
Packit 08bd4c
     archive_errno() and archive_error_string().
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_write(3), archive_write_blocksize(3),
Packit 08bd4c
     archive_write_filter(3), archive_write_format(3), archive_write_new(3),
Packit 08bd4c
     archive_write_set_options(3), cpio(5), mtree(5), tar(5)
Packit 08bd4c
Packit 08bd4c
BSD			       February 2, 2012 			   BSD