ZIP_SOURCE_LAYERED(3)
ZIP_SOURCE_LAYERED π β¨
okay bestie, pull up a chair, we're doing a 3 manpage today β Library Functions Manual energy, section ZIP_SOURCE_LAYERED(3), and it's genuinely one of the cutest little builder functions in the whole libzip lineup. let's get into it π«Ά
β¨ NAME β¨
zip_source_layered, zip_source_layered_create β create layered data source from function
π LIBRARY π
libzip (-lzip)
πΈ SYNOPSIS πΈ
#include <zip.h>
zip_source_t *
zip_source_layered(zip_t *archive, zip_source_t *source,
zip_source_layered_callback fn, void *userdata);
zip_source_t *
zip_source_layered_create(zip_source_t *source,
zip_source_layered_callback fn, void *userdata, zip_error_t *error);
π DESCRIPTION π
so zip_source_layered() and zip_source_layered_create() are the two besties that create a layered zip source β meaning you hand them a function fn that you wrote, and they wrap it around whatever source is underneath. no cap, that's the whole vibe.
and that function fn has to be exactly this type, no substitutions:
typedef zip_int64_t (*p_source_layered_callback)(zip_source_t *source,
void *userdata, void *data, zip_uint64_t length, zip_source_cmd_t cmd)
archive or error are the spots where errors get reported, and yes, they can be NULL. lowkey convenient.
when the library calls your function, here's the tea on the arguments:
- the first argument is the source of the lower layer π
- the second argument is the
userdataargument you supplied to the function π - the next two arguments are a buffer
dataof sizelengthβ and this is when data is being passed in or expected to be returned. otherwise it'sNULLand0π - the last argument,
cmd, tells the function which action it should perform π
want the full rundown of the commands? go read zip_source_function(3). iykyk.
so what's a layered source for? it transforms the data or metadata of the source below it in some way. iconic. but heads up bestie:
layered sources can't support writing and are not sufficient to cleanly add support for additional compression or encryption methods. this may be revised in a later release of libzip. periodt.
on success, the layered source takes ownership of source. the caller should not free it. do not. i'm serious. π
and the way it interacts with the lower layer depends entirely on the command:
π¦ ZIP_SOURCE_ACCEPT_EMPTY
if the layered source supports this command, the lower layer is not called automatically. otherwise, the return value of the lower source is used.
π¦ ZIP_SOURCE_CLOSE
the lower layer is closed after the callback returns.
π¦ ZIP_SOURCE_ERROR
the lower layer is not called automatically. if you need to retrieve error information from the lower layer, use zip_error_set_from_source(3) or zip_source_pass_to_lower_layer(3).
π¦ ZIP_SOURCE_FREE
the lower layer is freed after the callback returns.
π¦ ZIP_SOURCE_GET_FILE_ATTRIBUTES
the attributes of the lower layer are merged with the attributes returned by the callback β information set by the callback wins over the lower layer, with these two exceptions:
- the higher
version_neededis used general_purpose_bit_flagsare only overwritten if the corresponding bit is set ingeneral_purpose_bit_mask
π¦ ZIP_SOURCE_OPEN
the lower layer is opened before the callback is called.
π¦ ZIP_SOURCE_READ
the lower layer is not called automatically.
π¦ ZIP_SOURCE_SEEK
the lower layer is not called automatically.
π¦ ZIP_SOURCE_STAT
data contains the stat information from the lower layer when the callback is called.
π¦ ZIP_SOURCE_SUPPORTS
data contains the bitmap of commands supported by the lower layer when the callback is called. since layered sources can't support writing, all commands related to writing are stripped from the returned support bitmap.
π¦ ZIP_SOURCE_TELL
the lower layer is not called automatically.
π RETURN VALUES π
upon successful completion, the created source is returned. otherwise, NULL is returned and the error code in archive or error is set to indicate the error (unless it is NULL). π
π ERRORS π
zip_source_layered() fails if:
[ZIP_ER_MEMORY]β required memory could not be allocated.
π SEE ALSO π
libzip(3), zip_file_add(3), zip_file_attributes_init(3), zip_file_replace(3), zip_source(5), zip_source_function(3), zip_source_pass_to_lower_layer(3)
β HISTORY β
zip_source_layered() and zip_source_layered_create() were added in libzip 1.10.
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at>
and that's the whole page, bestie π«Ά this Debian build dropped on January 20, 2023, filed under ZIP_SOURCE_LAYERED(3) β slay, go layer some sources, and remember: don't free what you handed over. π
β¨
π¦ where this page comes from
- arch rolling: libzip 1.11.4-1 Β· BSD
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- nixpkgs unstable: libzip 1.11.4
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms