QDBM(3)

NAME
Cabin - the utility API of QDBM

SYNOPSIS

#include <cabin.h>
#include <stdlib.h>

extern void (*cbfatalfunc)(const char *message);
void *cbmalloc(size_t size);
void *cbrealloc(void *ptr, size_t size);
char *cbmemdup(const char *ptr, int size);
void cbisort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
void cbssort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
void cbhsort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
void cbqsort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
CBDATUM *cbdatumopen(const char *ptr, int size);
CBDATUM *cbdatumdup(const CBDATUM *datum);
void cbdatumclose(CBDATUM *datum);
void cbdatumcat(CBDATUM *datum, const char *ptr, int size);
const char *cbdatumptr(const CBDATUM *datum);
int cbdatumsize(const CBDATUM *datum);
void cbdatumsetsize(CBDATUM *datum, int size);
CBLIST *cblistopen(void);
CBLIST *cblistdup(const CBLIST *list);
void cblistclose(CBLIST *list);
int cblistnum(const CBLIST *list);
const char *cblistval(const CBLIST *list, int index, int *sp);
void cblistpush(CBLIST *list, const char *ptr, int size);
char *cblistpop(CBLIST *list, int *sp);
void cblistunshift(CBLIST *list, const char *ptr, int size);
char *cblistshift(CBLIST *list, int *sp);
void cblistinsert(CBLIST *list, int index, const char *ptr, int size);
char *cblistremove(CBLIST *list, int index, int *sp);
void cblistsort(CBLIST *list);
int cblistlsearch(const CBLIST *list, const char *ptr, int size);
int cblistbsearch(const CBLIST *list, const char *ptr, int size);
char *cblistdump(const CBLIST *list, int *sp);
CBLIST *cblistload(const char *ptr, int size);
CBMAP *cbmapopen(void);
CBMAP *cbmapdup(CBMAP *map);
void cbmapclose(CBMAP *map);
int cbmapput(CBMAP *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int over);
int cbmapout(CBMAP *map, const char *kbuf, int ksiz);
const char *cbmapget(const CBMAP *map, const char *kbuf, int ksiz, int *sp);
int cbmapmove(CBMAP *map, const char *kbuf, int ksiz, int head);
void cbmapiterinit(CBMAP *map);
const char *cbmapiternext(CBMAP *map, int *sp);
int cbmaprnum(const CBMAP *map);
char *cbmapdump(const CBMAP *map, int *sp);
CBMAP *cbmapload(const char *ptr, int size);
char *cbsprintf(const char *format, ...);
char *cbreplace(const char *str, CBMAP *pairs);
CBLIST *cbsplit(const char *ptr, int size, const char *delim);
char *cbreadfile(const char *name, int *sp);
CBLIST *cbreadlines(const char *name);
CBLIST *cbdirlist(const char *name);
int cbfilestat(const char *name, int *isdirp, int *sizep, int *mtimep);
char *cburlencode(const char *ptr, int size);
char *cburldecode(const char *str, int *sp);
char *cbbaseencode(const char *ptr, int size);
char *cbbasedecode(const char *str, int *sp);
char *cbquoteencode(const char *ptr, int size);
char *cbquotedecode(const char *str, int *sp);
char *cbdeflate(const char *ptr, int size, int *sp);
char *cbinflate(const char *ptr, int size, int *sp);

DESCRIPTION

Cabin is the utility API which provides memory allocating functions, sorting functions, extensible datum, array list, hash map, and so on for handling records easily on memory.

In order to use Cabin, you should include `cabin.h' and `stdlib.h' in the source files. Usually, the following description will be near the beginning of a source file.

    #include <cabin.h>
    #include <stdlib.h>

A pointer to `CBDATUM' is used as a handle of an extensible datum. A datum handle is opened with the function `cbdatumopen' and closed with `cbdatumclose'. A pointer to `CBLIST' is used as a handle of an array list. A list handle is opened with the function `cblistopen' and closed with `cblistclose'. A pointer to `CBMAP' is used as a handle of a hash map. A map handle is opened with the function `cbmapopen' and closed with `cbmapclose'. You should not refer directly to any member of each handles.

The external variable `cbfatalfunc' is the pointer to call back function for handling a fatal error.

extern void (*cbfatalfunc)(const char *message);
    The argument specifies the error message. The initial value of this variable is `NULL'. If the value is `NULL', the default function is called when a fatal error occurs. A fatal error occures when memory allocation is failed.

The function `cbmalloc' is used in order to allocate a region on memory.

void *cbmalloc(size_t size);
    `size' specifies the size of the region. The return value is the pointer to the allocated region. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbrealloc' is used in order to re-allocate a region on memory.

void *cbrealloc(void *ptr, size_t size);
    `ptr' specifies the pointer to a region. `size' specifies the size of the region. The return value is the pointer to the re-allocated region. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `memdup' is used in order to duplicate a region on memory.

char *cbmemdup(const char *ptr, int size);
    `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the allocated region of the duplicate. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbisort' is used in order to sort an array using insert sort.

void cbisort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
    `base' spacifies the pointer to an array. `nmemb' specifies the number of elements of the array. `size' specifies the size of each element. `compar' specifies the pointer to comparing function. The two arguments specify the pointers of elements. The comparing function should returns positive if the former is big, negative if the latter is big, 0 if both are equal. Insert sort is useful only if most elements have been sorted already.

The function `cbssort' is used in order to sort an array using shell sort.

void cbssort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
    `base' spacifies the pointer to an array. `nmemb' specifies the number of elements of the array. `size' specifies the size of each element. `compar' specifies the pointer to comparing function. The two arguments specify the pointers of elements. The comparing function should returns positive if the former is big, negative if the latter is big, 0 if both are equal. If most elements have been sorted, shell sort may be faster than heap sort or quick sort.

The function `cbhsort' is used in order to sort an array using heap sort.

void cbhsort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
    `base' spacifies the pointer to an array. `nmemb' specifies the number of elements of the array. `size' specifies the size of each element. `compar' specifies the pointer to comparing function. The two arguments specify the pointers of elements. The comparing function should returns positive if the former is big, negative if the latter is big, 0 if both are equal. Although heap sort is robust against bias of input, quick sort is faster in most cases.

The function `cbqsort' is used in order to sort an array using quick sort.

void cbqsort(void *base, int nmemb, int size, int(*compar)(const void *, const void *));
    `base' spacifies the pointer to an array. `nmemb' specifies the number of elements of the array. `size' specifies the size of each element. `compar' specifies the pointer to comparing function. The two arguments specify the pointers of elements. The comparing function should returns positive if the former is big, negative if the latter is big, 0 if both are equal. Being sensitive to bias of input, quick sort is the fastest sorting algorithm.

The function `cbdatumopen' is used in order to get a datum handle.

CBDATUM *cbdatumopen(const char *ptr, int size);
    `ptr' specifies the pointer to the region of the initial content. If it is `NULL', an empty datum is created. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is a datum handle.

The function `cbdatumdup' is used in order to copy a datum.

CBDATUM *cbdatumdup(const CBDATUM *datum);
    `datum' specifies a datum handle. The return value is a new datum handle.

The function `cbdatumclose' is used in order to free a datum handle.

void cbdatumclose(CBDATUM *datum);
    `datum' specifies a datum handle. Because the region of a closed handle is released, it becomes impossible to use the handle.

The function `cbdatumcat' is used in order to concatenate a datum and a region.

void cbdatumcat(CBDATUM *datum, const char *ptr, int size);
    `datum' specifies a datum handle. `ptr' specifies the pointer to the region to be appended. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'.

The function `cbdatumptr' is used in order to get the pointer of the region of a datum.

const char *cbdatumptr(const CBDATUM *datum);
    `datum' specifies a datum handle. The return value is the pointer of the region of a datum. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.

The function `cbdatumsize' is used in order to get the size of the region of a datum.

int cbdatumsize(const CBDATUM *datum);
    `datum' specifies a datum handle. The return value is the size of the region of a datum.

The function `cbdatumsetsize' is used in order to change the size of the region of a datum.

void cbdatumsetsize(CBDATUM *datum, int size);
    `datum' specifies a datum handle. `size' specifies the new size of the region. If the new size is bigger than the one of old, the surplus region is filled with zero codes.

The function `cblistopen' is used in order to get a list handle.

CBLIST *cblistopen(void);
    The return value is a list handle.

The function `cblistdup' is used in order to copy a list.

CBLIST *cblistdup(const CBLIST *list);
    `list' specifies a list handle. The return value is a new list handle.

The function `cblistclose' is used in order to close a list handle.

void cblistclose(CBLIST *list);
    `list' specifies a list handle. Because the region of a closed handle is released, it becomes impossible to use the handle.

The function `cblistnum' is used in order to get the number of elements of a list.

int cblistnum(const CBLIST *list);
    `list' specifies a list handle. The return value is the number of elements of the list.

The function `cblistval' is used in order to get the pointer to the region of an element.

const char *cblistval(const CBLIST *list, int index, int *sp);
    `list' specifies a list handle. `index' specifies the index of an element. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the element. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. If `index' is equal to or more than the number of elements, the return value is `NULL'.

The function `cblistpush' is used in order to add an element at the end of a list.

void cblistpush(CBLIST *list, const char *ptr, int size);
    `list' specifies a list handle. `ptr' specifies the pointer to the region of an element. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'.

The function `cblistpop' is used in order to remove an element of the end of a list.

char *cblistpop(CBLIST *list, int *sp);
    `list' specifies a list handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the value. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. If the list is empty, the return value is `NULL'.

The function `cblistunshift' is used in order to add an element at the top of a list.

void cblistunshift(CBLIST *list, const char *ptr, int size);
    `list' specifies a list handle. `ptr' specifies the pointer to the region of an element. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'.

The function `cblistshift' is used in order to remove an element of the top of a list.

char *cblistshift(CBLIST *list, int *sp);
    `list' specifies a list handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the value. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. If the list is empty, the return value is `NULL'.

The function `cblistinsert' is used in orderto add an element at the specified location of a list.

void cblistinsert(CBLIST *list, int index, const char *ptr, int size);
    `list' specifies a list handle. `index' specifies the index of an element. `ptr' specifies the pointer to the region of the element. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'.

The function `cblistremove' is used in order to remove an element at the specified location of a list.

char *cblistremove(CBLIST *list, int index, int *sp);
    `list' specifies a list handle. `index' specifies the index of an element. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the value. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. If `index' is equal to or more than the number of elements, no element is removed and the return value is `NULL'.

The function `cblistsort' is used in order to sort elements of a list in lexical order.

void cblistsort(CBLIST *list);
    `list' specifies a list handle. Quick sort is used for sorting.

The function `cblistlsearch' is used in order to search a list for an element using liner search.

int cblistlsearch(const CBLIST *list, const char *ptr, int size);
    `list' specifies a list handle. `ptr' specifies the pointer to the region of a key. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the index of a corresponding element or -1 if there is no corresponding element. If two or more elements corresponds, the former returns.

The function `cblistbsearch' is used in order to search a list for an element using binary search.

int cblistbsearch(const CBLIST *list, const char *ptr, int size);
    `list' specifies a list handle. It should be sorted in lexical order. `ptr' specifies the pointer to the region of a key. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the index of a corresponding element or -1 if there is no corresponding element. If two or more elements corresponds, which returnes is not defined.

The function `cblistdump' is used in order to serialize a list into a byte array.

char *cblistdump(const CBLIST *list, int *sp);
    `list' specifies a list handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. The return value is the pointer to the region of the result serial region. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cblistload' is used in order to redintegrate a serialized list.

CBLIST *cblistload(const char *ptr, int size);
    `ptr' specifies the pointer to a byte array. `size' specifies the size of the region. The return value is a new list handle.

The function `cbmapopen' is used in order to get a map handle.

CBMAP *cbmapopen(void);
    The return value is a map handle.

The function `cbmapdup' is used in order to copy a map.

CBMAP *cbmapdup(CBMAP *map);
    `map' specifies a map handle. The return value is a new map handle. The iterator of the source map is initialized.

The function `cbmapclose' is used in order to close a map handle.

void cbmapclose(CBMAP *map);
    `map' specifies a map handle. Because the region of a closed handle is released, it becomes impossible to use the handle.

The function `cbmapput' is used in order to store a record.

int cbmapput(CBMAP *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int over);
    `map' specifies a map handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. `vbuf' specifies the pointer to the region of a value. `vsiz' specifies the size of the region of the value. If it is negative, the size is assigned with `strlen(vbuf)'. `over' specifies whether the value of the duplicated record is overwritten or not. If `over' is false and the key is duplicated, the return value is false, else, it is true.

The function `cbmapout' is used in order to delete a record.

int cbmapout(CBMAP *map, const char *kbuf, int ksiz);
    `map' specifies a map handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. If successful, the return value is true. False is returned when no record corresponds to the specified key.

The function `cbmapget' is used in order to retrieve a record.

const char *cbmapget(const CBMAP *map, const char *kbuf, int ksiz, int *sp);
    `map' specifies a map handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. If successful, the return value is the pointer to the region of the value of the corresponding record. `NULL' is returned when no record corresponds. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.

The function `cbmapmove' is used in order to move a record to the edge.

int cbmapmove(CBMAP *map, const char *kbuf, int ksiz, int head);
    `map' specifies a map handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. `head' specifies the destination which is head if it is true or tail if else. If successful, the return value is true. False is returned when no record corresponds to the specified key.

The function `cbmapiterinit' is used in order to initialize the iterator of a map handle.

void cbmapiterinit(CBMAP *map);
    `map' specifies a map handle. The iterator is used in order to access the key of every record stored in a map.

The function `cbmapiternext' is used in order to get the next key of the iterator.

const char *cbmapiternext(CBMAP *map, int *sp);
    `map' specifies a map handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. If successful, the return value is the pointer to the region of the next key, else, it is `NULL'. `NULL' is returned when no record is to be get out of the iterator. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. The order of iteration is assured to be the same of the one of storing.

The function `cbmaprnum' is used in order to get the number of the records stored in a map.

int cbmaprnum(const CBMAP *map);
    `map' specifies a map handle. The return value is the number of the records stored in the map.

The function `cbmapdump' is used in order to serialize a map into a byte array.

char *cbmapdump(const CBMAP *map, int *sp);
    `map' specifies a map handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. The return value is the pointer to the region of the result serial region. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbmapload' is used in order to redintegrate a serialized map.

CBMAP *cbmapload(const char *ptr, int size);
    `ptr' specifies the pointer to a byte array. `size' specifies the size of the region. The return value is a new map handle.

The function `cbsprintf' is used in order to allocate a formatted string on memory.

char *cbsprintf(const char *format, ...);
    `format' specifies a printf-like format string. The conversion character `%' can be used with such flag characters as `d', `o', `u', `x', `X', `e', `E', `f', `g', `G', `c', `s', and `%'. Specifiers of the field length and the precision can be put between the conversion characters and the flag characters. The specifiers consist of decimal characters, `.', `+', `-', and the space character. The other arguments are used according to the format string. The return value is the pointer to the allocated region of the result string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbreplace' is used in order to replace some patterns in a string.

char *cbreplace(const char *str, CBMAP *pairs);
    `str' specifies the pointer to a source string. `pairs' specifies the handle of a map composed of pairs of replacement. The key of each pair specifies a pattern before replacement and its value specifies the pattern after replacement. The return value is the pointer to the allocated region of the result string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbsplit' is used in order to make a list by splitting a serial datum.

CBLIST *cbsplit(const char *ptr, int size, const char *delim);
    `ptr' specifies the pointer to the region of the source content. If it is `NULL', an empty datum is created. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. `dalim' specifies a string containing delimiting characters. If it is `NULL', zero code is used as a delimiter. The return value is a list handle. Because the handle of the return value is opened with the function `cblistopen', it should be closed with the function `cblistclose'.

The function `cbreadfile' is used in order to read whole data of a file.

char *cbreadfile(const char *name, int *sp);
    `name' specifies the name of a file. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the allocated region of the read data. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbreadlines' is used in order to read every line of a file.

CBLIST *cbreadlines(const char *name);
    `name' specifies the name of a file. The return value is a list handle of the lines if successful, else it is NULL. Line separators are cut out.

The function `cbdirlist' is used in order to read names of files in a directory.

CBLIST *cbdirlist(const char *name);
    `name' specifies the name of a directory. The return value is a list handle of names if successful, else it is NULL.

The function `cbfileinfo' is used in order to get the status of a file or a directory.

int cbfilestat(const char *name, int *isdirp, int *sizep, int *mtimep);
    `name' specifies the name of a file or a directory. `dirp' specifies the pointer to a variable to which whether the file is a directory is assigned. If it is `NULL', it is not used. `sizep' specifies the pointer to a variable to which the size of the file is assigned. If it is `NULL', it is not used. `mtimep' specifies the pointer to a variable to which the last modified time of the file is assigned. If it is `NULL', it is not used. If successful, the return value is true, else, false. False is returned when the file does not exist or the permission is denied.

The function `cburlencode' is used in order to encode a serial object with URL encoding.

char *cburlencode(const char *ptr, int size);
    `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the result string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cburldecode' is used in order to decode a string encoded with URL encoding.

char *cburldecode(const char *str, int *sp);
    `str' specifies the pointer to a source string. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the result. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbbaseencode' is used in order to encode a serial object with Base64 encoding.

char *cbbaseencode(const char *ptr, int size);
    `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the result string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbbasedecode' is used in order to decode a string encoded with Base64 encoding.

char *cbbasedecode(const char *str, int *sp);
    `str' specifies the pointer to a source string. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the result. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbquoteencode' is used in order to encode a serial object with quoted-printable encoding.

char *cbquoteencode(const char *ptr, int size);
    `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the result string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbquotedecode' is used in order to decode a string encoded with quoted-printable encoding.

char *cbquotedecode(const char *str, int *sp);
    `str' specifies the pointer to a source string. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. The return value is the pointer to the region of the result. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use.

The function `cbdeflate' is used in order to compress a serial object with ZLIB.

char *cbdeflate(const char *ptr, int size, int *sp);
    `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If successful, the return value is the pointer to the result object, else, it is `NULL'. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. This function is available only if QDBM is built with enabling ZLIB.

The function `cbinflate' is used in order to decompress a serial object compressed with ZLIB.

char *cbinflate(const char *ptr, int size, int *sp);
    Decompress a serial object compressed with ZLIB. `ptr' specifies the pointer to a region. `size' specifies the size of the region. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. If successful, the return value is the pointer to the result object, else, it is `NULL'. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. This function is available only if QDBM is built with enabling ZLIB.

Each functions of Cabin is not reentrant, and not thread-safe.

SEE ALSO

qdbm(3), depot(3), curia(3), relic(3), hovel(3), villa(3), odeum(3), ndbm(3), gdbm(3)