## zziplib Library Functions

Version 0.13.58

`#include <zzip/lib.h>`

``zzip_error`(ZZIP_DIR * dir) : int`
``zzip_seterror`(ZZIP_DIR * dir, int errcode) : void`
``zzip_open`(zzip_char_t * filename, int o_flags) : ZZIP_FILE *`
``zzip_open_ext_io`(zzip_char_t * filename, int o_flags, int o_modes, zzip_strings_t * ext, zzip_plugin_io_t io) : ZZIP_FILE *`
``zzip_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) : ZZIP_FILE *`
``zzip_opendir`(zzip_char_t * filename) : ZZIP_DIR *`
``zzip_opendir_ext_io`(zzip_char_t * filename, int o_modes, zzip_strings_t * ext, zzip_plugin_io_t io) : ZZIP_DIR *`
``zzip_file_real`(ZZIP_FILE * fp) : int`
``zzip_dir_real`(ZZIP_DIR * dir) : int`
``zzip_realdir`(ZZIP_DIR * dir) : void *`
``zzip_realfd`(ZZIP_FILE * fp) : int`
``zzip_dir_stat`(ZZIP_DIR * dir, zzip_char_t * name, ZZIP_STAT * zs, int flags) : int`
``zzip_file_stat`(ZZIP_FILE * file, ZZIP_STAT * zs) : int`
``zzip_fstat`(ZZIP_FILE * file, ZZIP_STAT * zs) : int`
``zzip_strerror`(int errcode) : zzip_char_t *`
``zzip_strerror_of`(ZZIP_DIR * dir) : zzip_char_t *`
``zzip_dir_open`(zzip_char_t * filename, zzip_error_t * e) : ZZIP_DIR *`
``zzip_dir_open_ext_io`(zzip_char_t * filename, zzip_error_t * e, zzip_strings_t * ext, zzip_plugin_io_t io) : ZZIP_DIR *`
``zzip_dir_read`(ZZIP_DIR * dir, ZZIP_DIRENT * d) : int`
``zzip_init_io`(zzip_plugin_io_handlers_t io, int flags) : int`
``zzip_get_default_io`() : zzip_plugin_io_t`
``zzip_rewinddir`(ZZIP_DIR * dir) : void`
``zzip_telldir`(ZZIP_DIR * dir) : zzip_off_t`
``zzip_seekdir`(ZZIP_DIR * dir, zzip_off_t offset) : void`
``zzip_fopen`(zzip_char_t * filename, zzip_char_t * mode) : ZZIP_FILE *`
``zzip_freopen`(zzip_char_t * filename, zzip_char_t * mode, ZZIP_FILE * stream) : ZZIP_FILE *`
``zzip_dirhandle`(ZZIP_FILE * fp) : ZZIP_DIR *`
``zzip_dirfd`(ZZIP_DIR * dir) : int`
``zzip_read`(ZZIP_FILE * fp, void *buf, zzip_size_t len) : zzip_ssize_t`
``zzip_fread`(void *ptr, zzip_size_t size, zzip_size_t nmemb, ZZIP_FILE * file) : zzip_size_t`
``zzip_dir_free`(ZZIP_DIR * dir) : int`
``zzip_dir_close`(ZZIP_DIR * dir) : int`
``zzip_fclose`(ZZIP_FILE * fp) : int`
``zzip_close`(ZZIP_FILE * fp) : int`
``zzip_dir_fdopen`(int fd, zzip_error_t * errcode_p) : ZZIP_DIR *`
``zzip_dir_fdopen_ext_io`(int fd, zzip_error_t * errcode_p, zzip_strings_t * ext, const zzip_plugin_io_t io) : ZZIP_DIR *`
``zzip_dir_alloc_ext_io`(zzip_strings_t * ext, const zzip_plugin_io_t io) : ZZIP_DIR *`
``zzip_dir_alloc`(zzip_strings_t * fileext) : ZZIP_DIR *`
``zzip_readdir`(ZZIP_DIR * dir) : ZZIP_DIRENT *`
``zzip_closedir`(ZZIP_DIR * dir) : int`
``zzip_errno`(int errcode) : int`
``zzip_file_close`(ZZIP_FILE * fp) : int`
``zzip_file_open`(ZZIP_DIR * dir, zzip_char_t * name, int o_mode) : ZZIP_FILE *`
``zzip_inflate_init`(ZZIP_FILE * fp, struct zzip_dir_hdr *hdr) : static int`
``zzip_file_read`(ZZIP_FILE * fp, void *buf, zzip_size_t len) : zzip_ssize_t`
``zzip_rewind`(ZZIP_FILE * fp) : int`
``zzip_seek`(ZZIP_FILE * fp, zzip_off_t offset, int whence) : zzip_off_t`
``zzip_tell`(ZZIP_FILE * fp) : zzip_off_t`
``zzip_compr_str`(int compr) : zzip_char_t *`
``__zzip_fetch_disk_trailer`(int fd, zzip_off_t filesize, struct _disk_trailer *_zzip_restrict trailer, zzip_plugin_io_t io) : int`
``__zzip_parse_root_directory`(int fd, struct _disk_trailer *trailer, struct zzip_dir_hdr **hdr_return, zzip_plugin_io_t io) : int`
``__zzip_try_open`(zzip_char_t * filename, int filemode, zzip_strings_t * ext, zzip_plugin_io_t io) : int`

### Documentation

`zzip_error(ZZIP_DIR * dir) : int`
`zzip_seterror(ZZIP_DIR * dir, int errcode) : void`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/info.c
  The `zzip_seterror` function just does dir->errcode = errcode

`zzip_open(zzip_char_t * filename, int o_flags) : ZZIP_FILE *`
`zzip_open_ext_io(zzip_char_t * filename, int o_flags, int o_modes, zzip_strings_t * ext, zzip_plugin_io_t io) : ZZIP_FILE *`
`zzip_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) : ZZIP_FILE *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c
  The `zzip_open_ext_io` function uses explicit ext and io instead of the internal defaults, setting them to zero is equivalent to `zzip_open` note that the two flag types have been split into an o_flags (for fcntl-like openflags) and o_modes where the latter shall carry the zzip_flags and possibly accessmodes for unix filesystems. Since this version of zziplib can not write zipfiles, it is not yet used for anything else than zzip-specific modeflags. The `zzip_open_ext_io` function returns a new zzip-handle (use `zzip_close` to return it). On error the `zzip_open_ext_io` function will return null setting `errno(3)`.
  The `zzip_open_shared_io` function takes an extra stream argument - if a handle has been then ext/io can be left null and the new stream handle will pick up the ext/io. This should be used only in specific environment however since `zzip_file_real` does not store any ext-sequence. The benefit for the `zzip_open_shared_io` function comes in when the old file handle was openened from a file within a zip archive. When the new file is in the same zip archive then the internal zzip_dir structures will be shared. It is even quicker, as no check needs to be done anymore trying to guess the zip archive place in the filesystem, here we just check whether the zip archive's filepath is a prefix part of the filename to be opened. Note that the `zzip_open_shared_io` function is also used by `zzip_freopen` that will unshare the old handle, thereby possibly closing the handle. The `zzip_open_shared_io` function returns a new zzip-handle (use `zzip_close` to return it). On error the `zzip_open_shared_io` function will return null setting `errno(3)`.

`zzip_opendir(zzip_char_t * filename) : ZZIP_DIR *`
`zzip_opendir_ext_io(zzip_char_t * filename, int o_modes, zzip_strings_t * ext, zzip_plugin_io_t io) : ZZIP_DIR *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/dir.c
  The `zzip_opendir_ext_io` function uses explicit ext and io instead of the internal defaults, setting them to zero is equivalent to `zzip_opendir`

`zzip_file_real(ZZIP_FILE * fp) : int`
`zzip_dir_real(ZZIP_DIR * dir) : int`
`zzip_realdir(ZZIP_DIR * dir) : void *`
`zzip_realfd(ZZIP_FILE * fp) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/info.c
  The `zzip_dir_real` function checks if the ZZIP_DIR-handle is wrapping a real directory or a zip-archive. Returns 1 for a stat'able directory, and 0 for a handle to zip-archive.
  The `zzip_realdir` function returns the posix DIR* handle (if one exists). Check before with `zzip_dir_real` if the the ZZIP_DIR points to a real directory.
  The `zzip_realfd` function returns the posix file descriptor (if one exists). Check before with `zzip_file_real` if the the ZZIP_FILE points to a real file.

`zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t * name, ZZIP_STAT * zs, int flags) : int`
`zzip_file_stat(ZZIP_FILE * file, ZZIP_STAT * zs) : int`
`zzip_fstat(ZZIP_FILE * file, ZZIP_STAT * zs) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/stat.c
  The `zzip_file_stat` function will obtain information about a opened file _within_ a zip-archive. The file is supposed to be open (otherwise -1 is returned). The st_size stat-member contains the uncompressed size. The optional d_name is never set here.
  The `zzip_fstat` function will obtain information about a opened file which may be either real/zipped. The file is supposed to be open (otherwise -1 is returned). The st_size stat-member contains the uncompressed size. The optional d_name is never set here. For a real file, we do set the d_csize := st_size and d_compr := 0 for meaningful defaults.

`zzip_strerror(int errcode) : zzip_char_t *`
`zzip_strerror_of(ZZIP_DIR * dir) : zzip_char_t *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/err.c
  The `zzip_strerror_of` function fetches the errorcode from the `DIR-handle` and runs it through `zzip_strerror` to obtain the static string describing the error.

`zzip_dir_open(zzip_char_t * filename, zzip_error_t * e) : ZZIP_DIR *`
`zzip_dir_open_ext_io(zzip_char_t * filename, zzip_error_t * e, zzip_strings_t * ext, zzip_plugin_io_t io) : ZZIP_DIR *`
`zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * d) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c
  the `zzip_dir_open_ext_io` function uses explicit ext and io instead of the internal defaults. Setting these to zero is equivalent to `zzip_dir_open`
  fills the dirent-argument with the values and increments the read-pointer of the dir-argument. returns 0 if there no entry (anymore).

`zzip_init_io(zzip_plugin_io_handlers_t io, int flags) : int`
`zzip_get_default_io() : zzip_plugin_io_t`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/plugin.c
  The `zzip_get_default_io` function returns a zzip_plugin_io_t handle to static defaults wrapping the posix io file functions for actual file access.

`zzip_rewinddir(ZZIP_DIR * dir) : void`
`zzip_telldir(ZZIP_DIR * dir) : zzip_off_t`
`zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset) : void`

  | /vol/8/src/cvs/workspace/zzip-0/zzip/dir.c The `zzip_rewinddir` function is the equivalent of a `rewinddir(2)` for a realdir or the zipfile in place of a directory. The ZZIP_DIR handle returned from `zzip_opendir` has a flag saying realdir or zipfile. As for a zipfile, the filenames will include the filesubpath, so take care.
  The `zzip_telldir` function is the equivalent of `telldir(2)` for a realdir or zipfile.
  The `zzip_seekdir` function is the equivalent of `seekdir(2)` for a realdir or zipfile.

`zzip_fopen(zzip_char_t * filename, zzip_char_t * mode) : ZZIP_FILE *`
`zzip_freopen(zzip_char_t * filename, zzip_char_t * mode, ZZIP_FILE * stream) : ZZIP_FILE *`

  | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c The `zzip_fopen` function will `fopen(3)` a real/zipped file. It has some magic functionality builtin - it will first try to open the given filename as a normal file. If it does not exist, the given path to the filename (if any) is split into its directory-part and the file-part. A ".zip" extension is then added to the directory-part to create the name of a zip-archive. That zip-archive (if it exists) is being searched for the file-part, and if found a zzip-handle is returned. Note that if the file is found in the normal fs-directory the returned structure is mostly empty and the `zzip_read` call will use the libc `read(2)` to obtain data. Otherwise a `zzip_file_open` is performed and any error mapped to `errno(3)`. unlike the posix-wrapper `zzip_open` the mode-argument is a string which allows for more freedom to support the extra zzip modes called ZZIP_CASEINSENSITIVE and ZZIP_IGNOREPATH. Currently, this `zzip_fopen` call will convert the following characters in the mode-string into their corrsponding mode-bits: `"r" : O_RDONLY :` read-only `"b" : O_BINARY :` binary (win32 specific) `"f" : O_NOCTTY :` no char device (unix) `"i" : ZZIP_CASELESS :` inside zip file `"*" : ZZIP_NOPATHS :` inside zip file only all other modes will be ignored for zip-contained entries but they are transferred for compatibility and portability, including these extra sugar bits: `"x" : O_EXCL :` fail if file did exist `"s" : O_SYNC :` synchronized access `"n" : O_NONBLOCK :` nonblocking access `"z#" : compression level :` for zlib `"g#" : group access :` unix access bits `"u#" : owner access :` unix access bits `"o#" : world access :` unix access bits ... the access bits are in traditional unix bit format with 7 = read/write/execute, 6 = read/write, 4 = read-only. The default access mode is 0664, and the compression level is ignored since the lib can not yet write zip files, otherwise it would be the initialisation value for the zlib deflateInit where 0 = no-compression, 1 = best-speed, 9 = best-compression. The `zzip_fopen` function returns a new zzip-handle (use `zzip_close` to return it). On error the `zzip_fopen` function will return null setting `errno(3)`.
  The `zzip_freopen` function receives an additional argument pointing to a ZZIP_FILE* being already in use. If this extra argument is null then the `zzip_freopen` function is identical with calling `zzip_fopen` Per default, the old file stream is closed and only the internal structures associated with it are kept. These internal structures may be reused for the return value, and this is a lot quicker when the filename matches a zipped file that is incidently in the very same zip arch as the old filename wrapped in the stream struct. That's simply because the zip arch's central directory does not need to be read again. As an extension for the `zzip_freopen` function, if the mode-string contains a "q" then the old stream is not closed but left untouched, instead it is only given as a hint that a new file handle may share/copy the zip arch structures of the old file handle if that is possible, i.e when they are in the same zip arch. The `zzip_freopen` function returns a new zzip-handle (use `zzip_close` to return it). On error the `zzip_freopen` function will return null setting `errno(3)`.

`zzip_dirhandle(ZZIP_FILE * fp) : ZZIP_DIR *`
`zzip_dirfd(ZZIP_DIR * dir) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/info.c
  The `zzip_dirfd` function will just return dir->fd If a ZZIP_DIR does point to a zipfile then the file-descriptor of that zipfile is returned, otherwise a NULL is returned and the ZZIP_DIR wraps a real directory DIR (if you have dirent on your system).

`zzip_read(ZZIP_FILE * fp, void *buf, zzip_size_t len) : zzip_ssize_t`
`zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, ZZIP_FILE * file) : zzip_size_t`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_dir_free(ZZIP_DIR * dir) : int`
`zzip_dir_close(ZZIP_DIR * dir) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c
  It will also `free(2)` the `ZZIP_DIR-handle` given. the counterpart for `zzip_dir_open` see also `zzip_dir_free`

`zzip_fclose(ZZIP_FILE * fp) : int`
`zzip_close(ZZIP_FILE * fp) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_dir_fdopen(int fd, zzip_error_t * errcode_p) : ZZIP_DIR *`
`zzip_dir_fdopen_ext_io(int fd, zzip_error_t * errcode_p, zzip_strings_t * ext, const zzip_plugin_io_t io) : ZZIP_DIR *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c
  the `zzip_dir_fdopen_ext_io` function uses explicit ext and io instead of the internal defaults, setting these to zero is equivalent to `zzip_dir_fdopen`

`zzip_dir_alloc_ext_io(zzip_strings_t * ext, const zzip_plugin_io_t io) : ZZIP_DIR *`
`zzip_dir_alloc(zzip_strings_t * fileext) : ZZIP_DIR *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c
  the `zzip_dir_alloc` function is obsolete - it was generally used for implementation and exported to let other code build on it. It is now advised to use `zzip_dir_alloc_ext_io` now on explicitly, just set that second argument to zero to achieve the same functionality as the old style.

`zzip_readdir(ZZIP_DIR * dir) : ZZIP_DIRENT *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/dir.c

`zzip_closedir(ZZIP_DIR * dir) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/dir.c

`zzip_errno(int errcode) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/err.c

`zzip_file_close(ZZIP_FILE * fp) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_file_open(ZZIP_DIR * dir, zzip_char_t * name, int o_mode) : ZZIP_FILE *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_inflate_init(ZZIP_FILE * fp, struct zzip_dir_hdr *hdr) : static int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_file_read(ZZIP_FILE * fp, void *buf, zzip_size_t len) : zzip_ssize_t`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_rewind(ZZIP_FILE * fp) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence) : zzip_off_t`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_tell(ZZIP_FILE * fp) : zzip_off_t`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/file.c

`zzip_compr_str(int compr) : zzip_char_t *`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/info.c

`__zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, struct _disk_trailer *_zzip_restrict trailer, zzip_plugin_io_t io) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c

`__zzip_parse_root_directory(int fd, struct _disk_trailer *trailer, struct zzip_dir_hdr **hdr_return, zzip_plugin_io_t io) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c

`__zzip_try_open(zzip_char_t * filename, int filemode, zzip_strings_t * ext, zzip_plugin_io_t io) : int`

  ... | /vol/8/src/cvs/workspace/zzip-0/zzip/zip.c