catdasp_setdb - set key cache handler function
#include <cat/dasp.h>
int catdasp_setdb(catdasp_protocol *proto, catdb_func *func, void *handle);
This function registers a database handler function that is currently used
to manage the ALLTAK key cache for a DASP session.
The semantics for the database handler are the same as for the database
handler used by catssl_setdb. The handle argument can contain arbitrary data and will be passed to the function.
The function should match the following prototype:
typedef int catdb_func(int op,
const catdb_data *data,
void *handle);
The data argument is a structure that looks as follows:
typedef struct catdb_data {
cat_data key;
cat_data value;
} catdb_data;
Where cat_data
is the following structure:
typedef struct cat_data {
int len;
void *data;
} cat_data;
The processing of the function depends on the op argument. If the function is successful, it should return 0. Any other
return values are considered fatal errors.
The op argument should be one of the following values:
- CATDB_PUT
-
Store the data indexed by key, overwriting any existing entry. Both the key and data must be copied, and
should be considered read-only.
- CATDB_GET
-
Find the data entry indexed by key, then allocate space for the value part, copy data into it, and set the
length field accordingly. The function returns 0 if successful, or any
other value on error.
- CATDB_DEL
-
Remove the entry indexed by key from the database.
- CATDB_CHECK
-
If the length of the supplied data is greater than zero, it is compared with the data stored under key in the database. If the data does not match, CAT_EBUSY is returned.
The function is responsible for handling the ageing of old entries. In a
threaded environment, the library will ensure that calls to these functions
are serialized.
Returns CAT_OK
.
cat, catdasp
catssl_setdb