2 * Sherlock Library -- Fast Database Management Routines
4 * (c) 1999 Martin Mares <mj@ucw.cz>
12 struct sdbm_options { /* Set to 0 for default */
13 char *name; /* File name */
14 uns flags; /* See SDBM_xxx below */
15 uns page_order; /* Binary logarithm of file page size */
16 uns cache_size; /* Number of cached pages */
17 int key_size; /* Key size, -1=variable */
18 int val_size; /* Value size, -1=variable */
21 struct sdbm *sdbm_open(struct sdbm_options *);
22 void sdbm_close(struct sdbm *);
23 int sdbm_store(struct sdbm *, byte *key, uns keylen, byte *val, uns vallen);
24 int sdbm_replace(struct sdbm *, byte *key, uns keylen, byte *val, uns vallen); /* val == NULL -> delete */
25 int sdbm_delete(struct sdbm *, byte *key, uns keylen);
26 int sdbm_fetch(struct sdbm *, byte *key, uns keylen, byte *val, uns *vallen); /* val can be NULL */
27 void sdbm_rewind(struct sdbm *);
28 int sdbm_get_next(struct sdbm *, byte *key, uns *keylen, byte *val, uns *vallen); /* val can be NULL */
29 void sdbm_sync(struct sdbm *);
31 #define SDBM_CREAT 1 /* Create the database if it doesn't exist */
32 #define SDBM_WRITE 2 /* Open the database in read/write mode */
33 #define SDBM_SYNC 4 /* Sync after each operation */
34 #define SDBM_FAST 8 /* Don't sync on directory splits -- results in slightly faster
35 * operation, but reconstruction of database after program crash
38 #define SDBM_FSYNC 16 /* When syncing, call fsync() */
40 #define SDBM_ERROR_BAD_KEY_SIZE -1 /* Fixed key size doesn't match */
41 #define SDBM_ERROR_BAD_VAL_SIZE -2 /* Fixed value size doesn't match */
42 #define SDBM_ERROR_TOO_LARGE -3 /* Key/value doesn't fit in buffer supplied */
43 #define SDBM_ERROR_READ_ONLY -4 /* Database has been opened read only */
44 #define SDBM_ERROR_GIANT -5 /* Key/value too large to fit in a page */