z3flib(3)

NAME
z3lib - compression/decompression library

SYNOPSIS
#include <time.h>
#include <z3lib.h>
#include <z3blib.h>
#include <z3dlib.h>
#include <z3flib.h>

int z3f_encode_init(int filedescr, struct z3fe_handle *zh, int level, time_t mtime, int os, int xlen, __u8 *fextra, char *fname, char *fcomment);

int z3f_encode_header(struct z3fe_handle *zh, int xlen, __u8 *fextra, char *fname, char *fcomment);

int z3f_encode_write(struct z3fe_handle *zh, __u8 *data, __u32 count);

int z3f_decode_init(int filedescr, struct z3fd_handle *zh);

int z3f_decode_read(struct z3fd_handle *zh, __u8 *data, __u32 count);

DESCRIPTION
This is the third layer of z3lib, it provides means to read and write from and to compressed files, according to RFC1952.

ENCODE
To encode data while writing it to a compressed file, open the file for writing first. Then, call z3f_encode_init once to initialise the compression structure zh. Next, call z3f_encode_header repeatedly, until it returns 0. This function may return -EAGAIN, which is no error. Here the parameters must not vary from one call to the next, and must be given the same values as with z3f_encode_init:

level
    The desired compression level, in range 1..9, or 0 for default

mtime
    The time stamp, in seconds since 1970/01/01 00:00:00

os  The operating system indicator byte, -1 when unknown

fextra
    An array of xlen bytes to be included in header, or NULL

fname
    A zero terminated name string, or NULL

fcomment
    A zero terminated comment string, or NULL

Now call z3f_encode_write repeatedly, until it returns 0. This function may return -EAGAIN, which is no error. When returning a positive value, it indicates the number of bytes actually transferred from the buffer data (of size count) into the compressed file. Note, that count must not be zero, unless no more data is available. In the latter case, count must be zero and the function must be called again, until it returns 0, too. Finally close the file.

DECODE
To decode data while reading it from a compressed file, open the file for reading first. Then, call z3f_decode_init once to initialise the decompression structure zh. Next, call z3f_decode_read repeatedly, until it returns 0. This function may return -EAGAIN, which is no error. When returning a positive value, it indicates the number of bytes actually transferred into the buffer data (of size count). Finally close the file.

SEE ALSO
z3lib(3), z3dlib(3), http://rfc.net/rfc1952.html, open(2), fileno(3), read(2), write(2), close(2), /usr/include/asm/errno.h.

AUTHOR
Oskar Schirmer (oskar@scara.com).