2 * Sherlock Library -- Fast Database Management Routines
4 * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.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 */
26 struct sdbm *sdbm_open(struct sdbm_options *);
27 void sdbm_close(struct sdbm *);
28 int sdbm_store(struct sdbm *, byte *key, uns keylen, byte *val, uns vallen);
29 int sdbm_replace(struct sdbm *, byte *key, uns keylen, byte *val, uns vallen); /* val == NULL -> delete */
30 int sdbm_delete(struct sdbm *, byte *key, uns keylen);
31 int sdbm_fetch(struct sdbm *, byte *key, uns keylen, byte *val, uns *vallen); /* val can be NULL */
32 void sdbm_rewind(struct sdbm *);
33 int sdbm_get_next(struct sdbm *, byte *key, uns *keylen, byte *val, uns *vallen); /* val can be NULL */
34 void sdbm_sync(struct sdbm *);
36 #define SDBM_CREAT 1 /* Create the database if it doesn't exist */
37 #define SDBM_WRITE 2 /* Open the database in read/write mode */
38 #define SDBM_SYNC 4 /* Sync after each operation */
39 #define SDBM_FAST 8 /* Don't sync on directory splits -- results in slightly faster
40 * operation, but reconstruction of database after program crash
43 #define SDBM_FSYNC 16 /* When syncing, call fsync() */
45 #define SDBM_ERROR_BAD_KEY_SIZE -1 /* Fixed key size doesn't match */
46 #define SDBM_ERROR_BAD_VAL_SIZE -2 /* Fixed value size doesn't match */
47 #define SDBM_ERROR_TOO_LARGE -3 /* Key/value doesn't fit in buffer supplied */
48 #define SDBM_ERROR_READ_ONLY -4 /* Database has been opened read only */