#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdbool.h>
Go to the source code of this file.
Compounds | |
struct | vsdb_info |
information structure filled in by vsdb_get_info More... | |
Functions | |
vsdb_t * | vsdb_open (char *name, int mode) |
open a database. | |
void | vsdb_close (vsdb_t *v) |
Close database. | |
void | vsdb_get_info (vsdb_t *vsdb, struct vsdb_info *info) |
get information about database. | |
vsdb_transaction_t * | vsdb_transaction_begin (vsdb_t *vsdb, int mode) |
begin a transaction. | |
void | vsdb_transaction_rollback (vsdb_transaction_t *vt) |
rollback a transaction. | |
int | vsdb_transaction_commit (vsdb_transaction_t *vt) |
commits a transaction. | |
void | vsdb_clear (vsdb_transaction_t *vt, void *key, size_t keysz) |
delete a key/data pair from the database. | |
void | vsdb_set (vsdb_transaction_t *vt, void *key, size_t keysz, void *data, size_t datasz) |
add or replace a key/datapair in the database. | |
int | vsdb_lookup (vsdb_transaction_t *vt, void *key, size_t keysz, uintmax_t *which) |
lookup an entry in the database. | |
void | vsdb_aread_entry (vsdb_transaction_t *vt, uintmax_t entry, void **key, size_t *keysz, void **data, size_t *datasz) |
read entry into freshly allocated arrays. | |
char * | vsdb_lookup_ss (vsdb_transaction_t *vt, char *key) |
utility to lookup a string value with a string key. | |
int | vsdb_repair_database (char *s) |
Attempt to repair a database. | |
void | vsdb_set_verbose_mode (bool val) |
Turn verbose mode on or off. | |
void | vsdb_set_die_on_error (void) |
This will casue vsdb to die with an error message on stderr instead of returning (-1) on errors and setting errno. | |
void | vsdb_set_errfn (void(*fn)(char *)) |
set error handling function, if this function returns then (-1) is returned and errno is set appropriatly. |
Definition in file vsdb.h.
|
read entry into freshly allocated arrays. for each non-NULL parameter, set the referenced value to a freshly allocated copy of the data in the database. the values should be freed with the standard free of malloc/free. any of key,keysz,data, or datasz may be passed NULL if you do not wish to retrieve their values. |
|
Close database. release all resources and rollback all open transactions assosiated with a database. |
|
lookup an entry in the database. returns 0 and sets *which if entry is found. returns 1 if entry not found. |
|
utility to lookup a string value with a string key. the value returned and the key parameter are NULL terminated, although it is assumed the entries in the database will not have the trailing NULL. |
|
open a database.
|
|
Attempt to repair a database. This normally need not be called by user programs. |
|
set error handling function, if this function returns then (-1) is returned and errno is set appropriatly. All clean-up is done before calling this error function so longjmp() may be called to leave it without leaking resources. |
|
Turn verbose mode on or off. setting verbose mode will also set an error handler which prints errors to stderr before returning the error code. |
|
begin a transaction. This ALWAYS must be paired with a vsdb_transaction_commit() or vsdb_transaction_rollback(). |
|
commits a transaction. This attempts to cause all changes to the database during this transaction to become permament and visible to other readers of this database. This function returns 0 on success, a positive number if there was a conflict and the commit should be retried and -1 on error. it is important to check the return code and retry the transaction if a positive number is returned. |
|
rollback a transaction. All changes made to the database in this transaction are discarded. |