Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

zip_source_function(3) [debian man page]

ZIP_SOURCE_FUNCTION(3)					     Library Functions Manual					    ZIP_SOURCE_FUNCTION(3)

NAME
zip_source_function - create data source from function LIBRARY
libzip (-lzip) SYNOPSIS
#include <zip.h> struct zip_source * zip_source_function(struct zip *archive, zip_source_callback fn, void *userdata); DESCRIPTION
The function zip_source_function creates a zip source from the user-provided function fn, which must be of the following type: typedef zip_int64_t (*zip_source_callback)(void *state, void *data, zip_uint64_t len, enum zip_source_cmd cmd); When called by the library, the first argument is the userdata argument supplied to zip_source_function. The next two arguments are a buf- fer data of size len when data is expected to be returned, or else NULL and 0. The last argument, cmd, specifies which action the function should perform: ZIP_SOURCE_OPEN Prepare for reading. Return 0 on success, -1 on error. ZIP_SOURCE_READ Read data into the buffer data of size len. Return the number of bytes placed into data on success, -1 on error. ZIP_SOURCE_CLOSE Reading is done. Return 0. ZIP_SOURCE_STAT Get meta information for the input data. data points to an initialized which should be filled in. (See zip_stat_init(3). ) Information only available after the source has been read (e.g. size) can be omitted in an earlier call. Return sizeof(struct zip_stat) on success, -1 on error. ZIP_SOURCE_ERROR Get error information. data points to an array of two ints, which should be filled with the libzip error code and the corresponding system error code for the error that occurred. See zip_errors(3) for details on the error codes. Return return(2 * sizeof(int)). ZIP_SOURCE_FREE Clean up and free all resources. Return 0. The library will always issue ZIP_SOURCE_OPEN before issuing ZIP_SOURCE_READ. When it no longer wishes to read from this source, it will issue ZIP_SOURCE_CLOSE. If the library wishes to read the data again, it will issue ZIP_SOURCE_OPEN a second time. If the function is unable to provide the data again, it should return -1. ZIP_SOURCE_STAT can be issued at any time. ZIP_SOURCE_ERROR will only be issued in response to the function returning -1. ZIP_SOURCE_FREE will be the last command issued; if ZIP_SOURCE_OPEN was called and succeeded, ZIP_SOURCE_CLOSE will be called before ZIP_SOURCE_FREE. RETURN VALUES
Upon successful completion, the created source is returned. Otherwise, NULL is returned and the error code in archive is set to indicate the error. ERRORS
zip_source_function fails if: [ZIP_ER_MEMORY] Required memory could not be allocated. SEE ALSO
libzip(3), zip_add(3), zip_replace(3), zip_source_buffer(3), zip_source_file(3), zip_source_filep(3), zip_source_free(3), zip_source_zip(3), zip_stat_init(3) AUTHORS
Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at> NiH March 30, 2009 ZIP_SOURCE_FUNCTION(3)

Check Out this Related Man Page

ZIP_FOPEN(3)						     Library Functions Manual						      ZIP_FOPEN(3)

NAME
zip_fopen , - .Nm zip_fopen_index open file in zip archive for reading LIBRARY
libzip (-lzip) SYNOPSIS
#include <zip.h> struct zip_file * zip_fopen(struct zip *archive, const char *fname, int flags); struct zip_file * zip_fopen_index(struct zip *archive, zip_uint64_t index, int flags); DESCRIPTION
The zip_fopen function opens the file name fname in archive. The flags argument specifies how the name lookup should be done, according to the values are described in zip_name_locate(3). Also, the following values may be or'ed to it. ZIP_FL_COMPRESSED Read the compressed data. Otherwise the data is uncompressed by zip_fread. ZIP_FL_UNCHANGED Read the original data from the zip archive, ignoring any changes made to the file. The zip_fopen_index function opens the file at position index. If encrypted data is encountered, the functions call zip_fopen_encrypted(3) or zip_fopen_index_encrypted(3) respectively, using the default password set with zip_set_default_password(3). RETURN VALUES
Upon successful completion, a struct zip_file pointer is returned. Otherwise, NULL is returned and the error code in archive is set to indicate the error. ERRORS
[ZIP_ER_CHANGED] The file data has been changed. [ZIP_ER_COMPNOTSUPP] The compression method used is not supported. [ZIP_ER_ENCRNOTSUPP] The encryption method used is not supported. [ZIP_ER_MEMORY] Required memory could not be allocated. [ZIP_ER_READ] A file read error occurred. [ZIP_ER_SEEK] A file seek error occurred. [ZIP_ER_ZLIB] Initializing the zlib stream failed. The function zip_fopen may also fail and set for any of the errors specified for the routine zip_name_locate(3). The function zip_fopen_index may also fail with ZIP_ER_INVAL if index is invalid. SEE ALSO
libzip(3), zip_fclose(3), zip_fread(3), zip_get_num_entries(3), zip_name_locate(3), zip_set_default_password(3) AUTHORS
Dieter Baron <dillo@giga.or.at> and Thomas Klausner <tk@giga.or.at> NiH February 14, 2011 ZIP_FOPEN(3)
Man Page