ARCHIVE_UTIL(3)
π ARCHIVE_UTIL(3) β the libarchive utility functions, bestie edition
okay so this is ARCHIVE_UTIL(3), section 3 of the Library Functions Manual, and it's literally the page where all of libarchive's little helper functions live. they don't do the big dramatic archive stuff, they just hand you the tea about what's going on inside your struct archive object. and honestly? iconic behavior. π«Ά
π LIBRARY
Streaming Archive Library (libarchive, -larchive)
β¨ SYNOPSIS β¨
#include <archive.h>
void
archive_clear_error(struct archive *);
int
archive_compression(struct archive *);
const char *
archive_compression_name(struct archive *);
void
archive_copy_error(struct archive *, struct archive *);
int
archive_errno(struct archive *);
const char *
archive_error_string(struct archive *);
int
archive_file_count(struct archive *);
int
archive_filter_code(struct archive *, int);
int
archive_filter_count(struct archive *, int);
const char *
archive_filter_name(struct archive *, int);
int
archive_format(struct archive *);
const char *
archive_format_name(struct archive *);
int64_t
archive_position(struct archive *, int);
void
archive_set_error(struct archive *, int error_code, const char *fmt,
...);
π¦ DESCRIPTION π¦
so these functions are all about getting information out of the struct archive object you're using with the libarchive(3) library. they're the little side-eye glances into what your archive handle is thinking. no cap. π
archive_clear_error()β wipes any leftover error info from a previous call. bestie, this is not generally used in client code, so don't come for me if you've never touched it. it just clears the slate. β¨archive_compression()β literally just a synonym forarchive_filter_code(a, 0). same energy, different name.archive_compression_name()β synonym forarchive_filter_name(a, 0). matching set πarchive_copy_error()β copies the error info from one archive to another. passing the drama along, respectfully.archive_errno()β gives you back a numeric error code (see errno(2)) that tells you why the most recent error return happened. β οΈ but be careful: this can not be reliably used to detect whether an error has occurred. it's only valid after another libarchive function has already returned an error status. so don't use it as your error detector, use it as your error explainer. iykyk.archive_error_string()β returns a textual error message that's suitable for display. and it's usually more specific than what you'd get by passing the result ofarchive_errno()to strerror(3). so like, it actually tells you what went down instead of being vague. πarchive_file_count()β returns a count of how many files this archive object has processed. the count goes up when you callarchive_write_header(3)orarchive_read_next_header(3). keeping score fr fr.archive_filter_code()β returns a numeric code identifying the filter you point at. seearchive_filter_count()for how the numbering works. π’archive_filter_count()β returns how many filters are in the current pipeline. for read archive handles, these filters get added automatically by the automatic format detection. for write archive handles, they get added by calls to the variousarchive_write_add_filter_XXX()functions. the filters in the resulting pipeline are numbered so that filter 0 is the filter closest to the format handler. and as a lil convenience, functions that expect a filter number will accept-1as a synonym for the highest-numbered filter. π
example time, because this is the part that makes it click: when you're reading a uuencoded gzipped tar archive, there are three filters β filter 0 is the gunzip filter, filter 1 is the uudecode filter, and filter 2 is the pseudo-filter that wraps the archive read functions. so in that case, requesting archive_position(a, -1) would be a synonym for archive_position(a, 2), which would return the number of bytes currently read from the archive. meanwhile archive_position(a, 1) would return the number of bytes after uudecoding, and archive_position(a, 0) would return the number of bytes after decompression. layers, bestie. onion energy. π§
β¨
archive_filter_name()β returns a textual name identifying the indicated filter. again, seearchive_filter_count()for the numbering deets. π·οΈarchive_format()β returns a numeric code indicating the format of the current archive entry. this value gets set by a successful call toarchive_read_next_header(). and heads up: it's super common for this value to change from entry to entry. like, a tar archive might have several entries that use GNU tar extensions and several entries that don't β those entries will have totally different format codes. main character entries with main character codes. πarchive_format_name()β a textual description of the format of the current entry. the vibe check of the format, basically. πΈarchive_position()β returns the number of bytes read from or written to the indicated filter. specifically,archive_position(a, 0)returns the number of bytes read or written by the format handler, whilearchive_position(a, -1)returns the number of bytes read or written to the archive. seearchive_filter_count()for the numbering details here too. πarchive_set_error()β sets the numeric error code and error description thatarchive_errno()andarchive_error_string()will later hand back. you should use this function within I/O callbacks to set system-specific error codes and error descriptions. it accepts a printf-like format string and arguments. π¨ but β and this is the important part β you should be careful to use only the following printf format specifiers:%c,%d,%jd,%jo,%ju,%jx,%ld,%lo,%lu,%lx,%o,%u,%s,%x,%%. field-width specifiers and other printf features are not uniformly supported and should not be used. periodt. don't get creative with your format strings, bestie, it will not slay. π
π SEE ALSO
archive_read(3), archive_write(3), libarchive(3), printf(3)
π HISTORY
The libarchive library first appeared in FreeBSD 5.3. a whole era. β
π«Ά AUTHORS
The libarchive library was written by Tim Kientzle <kientzle@acm.org>. ty for your service, king. π
and that's the whole page, bestie β this version is from Debian, dated February 2, 2012, filed under ARCHIVE_UTIL(3) in section 3 of the Library Functions Manual. go forth and archive responsibly πππ¦
π¦ where this page comes from
- centos-stream 10: libarchive-devel 3.7.7-11.el10 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- debian trixie: libarchive-dev 3.7.4-4+deb13u1 Β· BSD-2-Clause
- fedora 43: libarchive-devel 3.8.1-3.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 43: libarchive-devel 3.8.1-3.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 43: libarchive-devel 3.8.4-1.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 43: libarchive-devel 3.8.4-1.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.4-2.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.4-2.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.7-1.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.7-1.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- ubuntu questing: libarchive-dev 3.7.7-0ubuntu3
- ubuntu questing: libarchive-dev 3.7.7-0ubuntu3.2
- ubuntu resolute: libarchive-dev 3.8.5-1ubuntu2 Β· BSD-2-Clause
- ubuntu resolute: libarchive-dev 3.8.5-1ubuntu2.3 Β· BSD-2-Clause
- Copyright (c) 2003-2007 Tim Kientzle
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms