cat_memdbfunc - perform operations on a cat_memdb.
#include <cat/cat.h>
#include <cat/catutil.h>
int cat_memdbfunc(int op, catdb_data *entry, void *handle);
This function performs operation op on entry in the database referenced by
handle. This function is usually used as a callback function for catssl_setdb or catdasp_setdb.
The catdb_data structure looks as follows:
typedef struct catdb_data {
cat_data key;
cat_data value;
}
The following operations can be specified 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 space
allocated, and set the length field of value
accordingly. The retrieved data must be freed by the caller with a call to
free().
- CATDB_DEL
-
Remove the entry indexed by key from the database.
- 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 behaviour of this function can be controlled using the
cat_memdbflags() function.
The CATDB_CHECK operation returns a positive value if successful, other values return zero.
On error a negative code is returned.
cat, catutil
cat_newmemdb, cat_freememdb, cat_memdbforeach,
cat_memdbflags