Main Page   Compound List   File List   Compound Members   File Members  

vsdb.h

Go to the documentation of this file.
00001 
00005 #ifndef VSDB_H
00006 #define VSDB_H
00007 
00008 #include <inttypes.h>
00009 #include <sys/types.h>
00010 #include <sys/stat.h>
00011 #include <fcntl.h>
00012 #include <stdbool.h>
00013 
00014 typedef struct vsdb vsdb_t;
00015 typedef struct vsdb_transaction  vsdb_transaction_t;
00016 
00021 struct vsdb_info {
00022         time_t mtime;          
00023         uintmax_t num_entries; 
00024         uint32_t generation;   
00025         char *name;            
00026         uintmax_t key_size;    
00027         uintmax_t data_size;   
00028 };
00029 
00030 /* opening and closing database */
00031 vsdb_t *vsdb_open(char *name, int mode);
00032 void vsdb_close(vsdb_t *v);
00033 
00034 /* sometimes useful to reference count database handles */
00035 void vsdb_ref(vsdb_t *v);
00036 void vsdb_unref(vsdb_t *v);
00037 
00038 
00039 /* querying database info */
00040 void vsdb_get_info(vsdb_t *vsdb, struct vsdb_info *info);
00041 uintmax_t vsdb_transaction_num_entries(vsdb_transaction_t *vt);
00042 
00043 
00044 
00045 /* transaction management */
00046 
00047 /* every call to this MUST be matched by an abort or commit transaction request */
00048 vsdb_transaction_t *vsdb_transaction_begin(vsdb_t *vsdb, int mode); 
00049 
00050 /* aborts transaction */
00051 void vsdb_transaction_rollback(vsdb_transaction_t *vt); //TODO  finish
00052 
00053 /* returns 0 on success  < 0 on error, and > 0 when transaction should be retried */
00054 int vsdb_transaction_commit(vsdb_transaction_t *vt); 
00055 
00056 
00057 /* NULL or "" sets default table */
00058 void vsdb_set_current_table(vsdb_transaction_t *vt, char *name);
00059 
00060 /* manipulating the database */
00061 
00062 void vsdb_clear(vsdb_transaction_t *vt, void *key, size_t keysz);
00063 void vsdb_set(vsdb_transaction_t *vt, void *key, size_t keysz, void *data, size_t datasz);
00064 /* returns 0 on success , < 0 on error and > 0 when entry is not found */
00065 int vsdb_lookup(vsdb_transaction_t *vt, void *key, size_t keysz, uintmax_t *which);
00066 
00067 /* examining entries */
00068 void vsdb_aread_entry(vsdb_transaction_t *vt, uintmax_t entry, void **key, size_t *keysz, void **data, size_t *datasz);
00069 void vsdb_read_entry(vsdb_transaction_t *vt, uintmax_t entry, void *key, off_t keyoffset, size_t keysz, void *data, off_t dataoffset, size_t datasz);
00070 
00071 
00072 /* utility routines */
00073 char *vsdb_lookup_ss(vsdb_transaction_t *vt, char *key);
00074 int vsdb_repair_database(char *s);
00075 
00076 
00077 /* error handling */
00078 void vsdb_set_verbose_mode(bool val);
00079 void vsdb_set_die_on_error(void);
00080 void vsdb_set_errfn(void (*fn)(char *));
00081 
00082 #endif

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