*/
#include <ccan/tdb2/tdb2.h>
-#include <ccan/hash/hash.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
}
static void tdb_log(struct tdb_context *tdb, enum tdb_log_level level,
- void *priv, const char *message)
+ const char *message, void *priv)
{
fputs(message, stderr);
}
" store key data : store a record (replace)\n"
" show key : show a record by key\n"
" delete key : delete a record by key\n"
+#if 0
" list : print the database hash table and freelist\n"
" free : print the database freelist\n"
+#endif
" check : check the integrity of an opened database\n"
" speed : perform speed tests on the database\n"
" ! command : execute system command\n"
union tdb_attribute log_attr;
log_attr.base.attr = TDB_ATTRIBUTE_LOG;
log_attr.base.next = NULL;
- log_attr.log.log_fn = tdb_log;
+ log_attr.log.fn = tdb_log;
if (tdb) tdb_close(tdb);
tdb = tdb_open(tdbname, (disable_mmap?TDB_NOMMAP:0),
}
}
-static uint64_t jenkins_hash(const void *key, size_t len, uint64_t seed,
- void *priv)
-{
- return hash_any(key, len, seed);
-}
-
static void open_tdb(const char *tdbname)
{
union tdb_attribute log_attr;
log_attr.base.attr = TDB_ATTRIBUTE_LOG;
log_attr.base.next = NULL;
- log_attr.log.log_fn = tdb_log;
+ log_attr.log.fn = tdb_log;
if (tdb) tdb_close(tdb);
tdb = tdb_open(tdbname, disable_mmap?TDB_NOMMAP:0, O_RDWR, 0600,
do {
long int r = random();
TDB_DATA key, dbuf;
- key.dptr = (unsigned char *)"store test";
- key.dsize = strlen((char *)key.dptr);
+ key = tdb_mkdata("store test", strlen("store test"));
dbuf.dptr = (unsigned char *)&r;
dbuf.dsize = sizeof(r);
tdb_store(tdb, key, dbuf, TDB_REPLACE);
do {
long int r = random();
TDB_DATA key, dbuf;
- key.dptr = (unsigned char *)"store test";
- key.dsize = strlen((char *)key.dptr);
+ key = tdb_mkdata("store test", strlen("store test"));
dbuf.dptr = (unsigned char *)&r;
dbuf.dsize = sizeof(r);
tdb_fetch(tdb, key, &dbuf);
do {
long int r = random();
TDB_DATA key, dbuf;
- key.dptr = (unsigned char *)"transaction test";
- key.dsize = strlen((char *)key.dptr);
+ key = tdb_mkdata("transaction test", strlen("transaction test"));
dbuf.dptr = (unsigned char *)&r;
dbuf.dsize = sizeof(r);
tdb_transaction_start(tdb);