cat_filedbfunc - operate on a cat_filedb.
#include <cat/cat.h>
#include <cat/catutil.h>
int cat_filedbfunc(int op, catdb_data *entry, void *handle);
This function performs operation op on entry in the cache file referenced by handle. The handle must have been opened by a call to
cat_newfiledb().
The function stores, retrieves, or deletes entries in the cache file, as
specified by the op flag. The following values can be given for
op:
- CATDB_PUT
-
Store the data indexed by key and overwrite any existing entry. The data will be copied and should be
considered read-only.
- CATDB_GET
-
Find the data entry indexed by key, allocate space for the value part, copy the data into the allocated
space, and set the length field of value accordingly. The retrieved data
must be freed by the caller with a call to
free().
- CATDB_DEL
-
Delete the entry indexed by key from the cache.
- CATDB_CHECK
-
Check if data entry indexed by key exists in the database. Return the length of the data if found.
If the length of the supplied data is greater than zero, it is compared with the data stored under key in the database. If it does not match, CAT_EBUSY is returned.
The size of the key is currently limited to 64 bytes.
The CATDB_CHECK operation returns a positive value if successul, other values return zero.
On error a negative code is returned.
If the key is too big, the function will return CAT_EOVERFLOW.
catutil, cat_filedbfunc, cat_freefiledb