Blame libarchive/archive_util.3

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