zzip_open(3)

NAME
zzip_open, zzip_open_ext_io, zzip_open_shared_io - start usage.

SYNOPSIS

#include <zzip/lib.h>

b'ZZIP_FILE *\fInzzip_open(zzip_char_t * filename, int o_flags)
b'ZZIP_FILE *\fInzzip_open_ext_io(zzip_char_t * filename, int o_flags, int o_modes,                zzip_strings_t * ext, zzip_plugin_io_t io)
b'ZZIP_FILE *\fInzzip_open_shared_io(ZZIP_FILE * stream,                   zzip_char_t * filename, int o_flags, int o_modes,                   zzip_strings_t * ext, zzip_plugin_io_t io)n'

DESCRIPTION
b' The zzip_open function will open(2) a real/zipped file

b'It has some magic functionality builtin - it will first try to openthe given <emphasis>filename</emphasis> as a normal file. If it does notexist, the given path to the filename (if any) is split intoits directory-part and the file-part. A ".zip" extension isthen added to the directory-part to create the name of azip-archive. That zip-archive (if it exists) is being searchedfor the file-part, and if found a zzip-handle is returned.

b'Note that if the file is found in the normal fs-directory thereturned structure is mostly empty and the zzip_read call willuse the libc read(2) to obtain data. Otherwise a zzip_file_openis performed and any error mapped to errno(3).

b'There was a possibility to transfer zziplib-specific openmodesthrough o_flags but you should please not use them anymore andlook into zzip_open_ext_io to submit them down. The zzip_open functionis shallow in that it just extracts the zzipflags and calls

b' zzip_open_ext_io(filename, o_flags, zzipflags|0664, 0, 0)

b' you must stop using this extra functionality (not well known anyway)since zzip_open might be later usable to open files for writingin which case the _EXTRAFLAGS will get in conflict.

b'compare with open(2) and zzip_fopenn'

b'The zzip_open_ext_io function uses explicit ext and io instead of the internaldefaults, setting them to zero is equivalent to zzip_open

b'note that the two flag types have been split into an o_flags(for fcntl-like openflags) and o_modes where the latter shallcarry the zzip_flags and possibly accessmodes for unix filesystems.Since this version of zziplib can not write zipfiles, it is notyet used for anything else than zzip-specific modeflags.

b'The zzip_open_ext_io function returns a new zzip-handle (use zzip_close to returnit). On error the zzip_open_ext_io function will return null setting errno(3).

b'If any ext_io handlers were used then the referenced structureshould be static as the allocated ZZIP_FILE does not copy them.n'

b'The zzip_open_shared_io function takes an extra stream argument - if a handle has beenthen ext/io can be left null and the new stream handle will pick upthe ext/io. This should be used only in specific environment howeversince zzip_file_real does not store any ext-sequence.

b"The benefit for the zzip_open_shared_io function comes in when the old file handlewas openened from a file within a zip archive. When the new fileis in the same zip archive then the internal zzip_dir structureswill be shared. It is even quicker, as no check needs to be doneanymore trying to guess the zip archive place in the filesystem,here we just check whether the zip archive's filepath is a prefixpart of the filename to be opened.

b'Note that the zzip_open_shared_io function is also used by zzip_freopen thatwill unshare the old handle, thereby possibly closing the handle.

b'The zzip_open_shared_io function returns a new zzip-handle (use zzip_close to returnit). On error the zzip_open_shared_io function will return null setting errno(3).n

AUTHOR
b'Guido Draheim <guidod@gmx.de>Tomi Ollila <Tomi.Ollila@iki.fi>

COPYRIGHT
b'Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)n'