Blame libarchive/archive_util.3

Packit Service 1d0348
.\" Copyright (c) 2003-2007 Tim Kientzle
Packit Service 1d0348
.\" All rights reserved.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" Redistribution and use in source and binary forms, with or without
Packit Service 1d0348
.\" modification, are permitted provided that the following conditions
Packit Service 1d0348
.\" are met:
Packit Service 1d0348
.\" 1. Redistributions of source code must retain the above copyright
Packit Service 1d0348
.\"    notice, this list of conditions and the following disclaimer.
Packit Service 1d0348
.\" 2. Redistributions in binary form must reproduce the above copyright
Packit Service 1d0348
.\"    notice, this list of conditions and the following disclaimer in the
Packit Service 1d0348
.\"    documentation and/or other materials provided with the distribution.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit Service 1d0348
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 1d0348
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit Service 1d0348
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit Service 1d0348
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 1d0348
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit Service 1d0348
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit Service 1d0348
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit Service 1d0348
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit Service 1d0348
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit Service 1d0348
.\" SUCH DAMAGE.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" $FreeBSD$
Packit Service 1d0348
.\"
Packit Service 1d0348
.Dd February 2, 2012
Packit Service 1d0348
.Dt ARCHIVE_UTIL 3
Packit Service 1d0348
.Os
Packit Service 1d0348
.Sh NAME
Packit Service 1d0348
.Nm archive_clear_error ,
Packit Service 1d0348
.Nm archive_compression ,
Packit Service 1d0348
.Nm archive_compression_name ,
Packit Service 1d0348
.Nm archive_copy_error ,
Packit Service 1d0348
.Nm archive_errno ,
Packit Service 1d0348
.Nm archive_error_string ,
Packit Service 1d0348
.Nm archive_file_count ,
Packit Service 1d0348
.Nm archive_filter_code ,
Packit Service 1d0348
.Nm archive_filter_count ,
Packit Service 1d0348
.Nm archive_filter_name ,
Packit Service 1d0348
.Nm archive_format ,
Packit Service 1d0348
.Nm archive_format_name ,
Packit Service 1d0348
.Nm archive_position ,
Packit Service 1d0348
.Nm archive_set_error
Packit Service 1d0348
.Nd libarchive utility functions
Packit Service 1d0348
.Sh LIBRARY
Packit Service 1d0348
Streaming Archive Library (libarchive, -larchive)
Packit Service 1d0348
.Sh SYNOPSIS
Packit Service 1d0348
.In archive.h
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_clear_error "struct archive *"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_compression "struct archive *"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_compression_name "struct archive *"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_copy_error "struct archive *" "struct archive *"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_errno "struct archive *"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_error_string "struct archive *"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_file_count "struct archive *"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_filter_code "struct archive *" "int"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_filter_count "struct archive *" "int"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_filter_name "struct archive *" "int"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_format "struct archive *"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_format_name "struct archive *"
Packit Service 1d0348
.Ft int64_t
Packit Service 1d0348
.Fn archive_position "struct archive *" "int"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fo archive_set_error
Packit Service 1d0348
.Fa "struct archive *"
Packit Service 1d0348
.Fa "int error_code"
Packit Service 1d0348
.Fa "const char *fmt"
Packit Service 1d0348
.Fa "..."
Packit Service 1d0348
.Fc
Packit Service 1d0348
.Sh DESCRIPTION
Packit Service 1d0348
These functions provide access to various information about the
Packit Service 1d0348
.Tn struct archive
Packit Service 1d0348
object used in the
Packit Service 1d0348
.Xr libarchive 3
Packit Service 1d0348
library.
Packit Service 1d0348
.Bl -tag -compact -width indent
Packit Service 1d0348
.It Fn archive_clear_error
Packit Service 1d0348
Clears any error information left over from a previous call.
Packit Service 1d0348
Not generally used in client code.
Packit Service 1d0348
.It Fn archive_compression
Packit Service 1d0348
Synonym for
Packit Service 1d0348
.Fn archive_filter_code(a, 0) .
Packit Service 1d0348
.It Fn archive_compression_name
Packit Service 1d0348
Synonym for
Packit Service 1d0348
.Fn archive_filter_name(a, 0) .
Packit Service 1d0348
.It Fn archive_copy_error
Packit Service 1d0348
Copies error information from one archive to another.
Packit Service 1d0348
.It Fn archive_errno
Packit Service 1d0348
Returns a numeric error code (see
Packit Service 1d0348
.Xr errno 2 )
Packit Service 1d0348
indicating the reason for the most recent error return.
Packit Service 1d0348
Note that this can not be reliably used to detect whether an
Packit Service 1d0348
error has occurred.
Packit Service 1d0348
It should be used only after another libarchive function
Packit Service 1d0348
has returned an error status.
Packit Service 1d0348
.It Fn archive_error_string
Packit Service 1d0348
Returns a textual error message suitable for display.
Packit Service 1d0348
The error message here is usually more specific than that
Packit Service 1d0348
obtained from passing the result of
Packit Service 1d0348
.Fn archive_errno
Packit Service 1d0348
to
Packit Service 1d0348
.Xr strerror 3 .
Packit Service 1d0348
.It Fn archive_file_count
Packit Service 1d0348
Returns a count of the number of files processed by this archive object.
Packit Service 1d0348
The count is incremented by calls to
Packit Service 1d0348
.Xr archive_write_header 3
Packit Service 1d0348
or
Packit Service 1d0348
.Xr archive_read_next_header 3 .
Packit Service 1d0348
.It Fn archive_filter_code
Packit Service 1d0348
Returns a numeric code identifying the indicated filter.
Packit Service 1d0348
See
Packit Service 1d0348
.Fn archive_filter_count
Packit Service 1d0348
for details of the numbering.
Packit Service 1d0348
.It Fn archive_filter_count
Packit Service 1d0348
Returns the number of filters in the current pipeline.
Packit Service 1d0348
For read archive handles, these filters are added automatically
Packit Service 1d0348
by the automatic format detection.
Packit Service 1d0348
For write archive handles, these filters are added by calls to the various
Packit Service 1d0348
.Fn archive_write_add_filter_XXX
Packit Service 1d0348
functions.
Packit Service 1d0348
Filters in the resulting pipeline are numbered so that filter 0
Packit Service 1d0348
is the filter closest to the format handler.
Packit Service 1d0348
As a convenience, functions that expect a filter number will
Packit Service 1d0348
accept -1 as a synonym for the highest-numbered filter.
Packit Service 1d0348
.Pp
Packit Service 1d0348
For example, when reading a uuencoded gzipped tar archive, there
Packit Service 1d0348
are three filters:
Packit Service 1d0348
filter 0 is the gunzip filter,
Packit Service 1d0348
filter 1 is the uudecode filter,
Packit Service 1d0348
and filter 2 is the pseudo-filter that wraps the archive read functions.
Packit Service 1d0348
In this case, requesting
Packit Service 1d0348
.Fn archive_position(a, -1)
Packit Service 1d0348
would be a synonym for
Packit Service 1d0348
.Fn archive_position(a, 2)
Packit Service 1d0348
which would return the number of bytes currently read from the archive, while
Packit Service 1d0348
.Fn archive_position(a, 1)
Packit Service 1d0348
would return the number of bytes after uudecoding, and
Packit Service 1d0348
.Fn archive_position(a, 0)
Packit Service 1d0348
would return the number of bytes after decompression.
Packit Service 1d0348
.It Fn archive_filter_name
Packit Service 1d0348
Returns a textual name identifying the indicated filter.
Packit Service 1d0348
See
Packit Service 1d0348
.Fn archive_filter_count
Packit Service 1d0348
for details of the numbering.
Packit Service 1d0348
.It Fn archive_format
Packit Service 1d0348
Returns a numeric code indicating the format of the current
Packit Service 1d0348
archive entry.
Packit Service 1d0348
This value is set by a successful call to
Packit Service 1d0348
.Fn archive_read_next_header .
Packit Service 1d0348
Note that it is common for this value to change from
Packit Service 1d0348
entry to entry.
Packit Service 1d0348
For example, a tar archive might have several entries that
Packit Service 1d0348
utilize GNU tar extensions and several entries that do not.
Packit Service 1d0348
These entries will have different format codes.
Packit Service 1d0348
.It Fn archive_format_name
Packit Service 1d0348
A textual description of the format of the current entry.
Packit Service 1d0348
.It Fn archive_position
Packit Service 1d0348
Returns the number of bytes read from or written to the indicated filter.
Packit Service 1d0348
In particular,
Packit Service 1d0348
.Fn archive_position(a, 0)
Packit Service 1d0348
returns the number of bytes read or written by the format handler, while
Packit Service 1d0348
.Fn archive_position(a, -1)
Packit Service 1d0348
returns the number of bytes read or written to the archive.
Packit Service 1d0348
See
Packit Service 1d0348
.Fn archive_filter_count
Packit Service 1d0348
for details of the numbering here.
Packit Service 1d0348
.It Fn archive_set_error
Packit Service 1d0348
Sets the numeric error code and error description that will be returned
Packit Service 1d0348
by
Packit Service 1d0348
.Fn archive_errno
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_error_string .
Packit Service 1d0348
This function should be used within I/O callbacks to set system-specific
Packit Service 1d0348
error codes and error descriptions.
Packit Service 1d0348
This function accepts a printf-like format string and arguments.
Packit Service 1d0348
However, you should be careful to use only the following printf
Packit Service 1d0348
format specifiers:
Packit Service 1d0348
.Dq %c ,
Packit Service 1d0348
.Dq %d ,
Packit Service 1d0348
.Dq %jd ,
Packit Service 1d0348
.Dq %jo ,
Packit Service 1d0348
.Dq %ju ,
Packit Service 1d0348
.Dq %jx ,
Packit Service 1d0348
.Dq %ld ,
Packit Service 1d0348
.Dq %lo ,
Packit Service 1d0348
.Dq %lu ,
Packit Service 1d0348
.Dq %lx ,
Packit Service 1d0348
.Dq %o ,
Packit Service 1d0348
.Dq %u ,
Packit Service 1d0348
.Dq %s ,
Packit Service 1d0348
.Dq %x ,
Packit Service 1d0348
.Dq %% .
Packit Service 1d0348
Field-width specifiers and other printf features are
Packit Service 1d0348
not uniformly supported and should not be used.
Packit Service 1d0348
.El
Packit Service 1d0348
.Sh SEE ALSO
Packit Service 1d0348
.Xr archive_read 3 ,
Packit Service 1d0348
.Xr archive_write 3 ,
Packit Service 1d0348
.Xr libarchive 3 ,
Packit Service 1d0348
.Xr printf 3
Packit Service 1d0348
.Sh HISTORY
Packit Service 1d0348
The
Packit Service 1d0348
.Nm libarchive
Packit Service 1d0348
library first appeared in
Packit Service 1d0348
.Fx 5.3 .
Packit Service 1d0348
.Sh AUTHORS
Packit Service 1d0348
.An -nosplit
Packit Service 1d0348
The
Packit Service 1d0348
.Nm libarchive
Packit Service 1d0348
library was written by
Packit Service 1d0348
.An Tim Kientzle Aq kientzle@acm.org .