Main Page   Compound List   File List   Compound Members   File Members  

vsdb.h File Reference

Interface to libvsdb. More...

#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.


Detailed Description

Interface to libvsdb.

Definition in file vsdb.h.


Function Documentation

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.

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.

Definition at line 933 of file vsdb.c.

void vsdb_close vsdb_t *    v
 

Close database.

release all resources and rollback all open transactions assosiated with a database.

Definition at line 826 of file vsdb.c.

int vsdb_lookup vsdb_transaction_t *    vt,
void *    key,
size_t    keysz,
uintmax_t *    which
 

lookup an entry in the database.

returns 0 and sets *which if entry is found. returns 1 if entry not found.

Definition at line 888 of file vsdb.c.

char* vsdb_lookup_ss vsdb_transaction_t *    vt,
char *    key
 

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.

Definition at line 984 of file vsdb.c.

vsdb_t* vsdb_open char *    name,
int    mode
 

open a database.

Parameters:
name  path to the database directory.
mode  one of O_RDONLY, O_RDWR, O_WRONLY perhaps ored with the flags O_CREAT or O_TRUNC this returns NULL on error.

Definition at line 775 of file vsdb.c.

int vsdb_repair_database char *    s
 

Attempt to repair a database.

This normally need not be called by user programs.

Definition at line 717 of file vsdb.c.

void vsdb_set_errfn void(*    fn)(char *)
 

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.

Definition at line 169 of file vsdb.c.

void vsdb_set_verbose_mode bool    val
 

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.

Definition at line 141 of file vsdb.c.

vsdb_transaction_t* vsdb_transaction_begin vsdb_t *    vsdb,
int    mode
 

begin a transaction.

This ALWAYS must be paired with a vsdb_transaction_commit() or vsdb_transaction_rollback().

Definition at line 363 of file vsdb.c.

int vsdb_transaction_commit vsdb_transaction_t *    vt
 

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.

Definition at line 417 of file vsdb.c.

void vsdb_transaction_rollback vsdb_transaction_t *    vt
 

rollback a transaction.

All changes made to the database in this transaction are discarded.

Definition at line 396 of file vsdb.c.


Generated on Wed Jun 18 17:30:39 2003 for libvsdb by doxygen1.2.18