]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/tools/tdbtool.c
tdb2: rearrange log function to put data arg at the end.
[ccan] / ccan / tdb2 / tools / tdbtool.c
index 3ae7866d2c63c6137bd7cb1f59ac64bc35cbd761..262253cda45a33c99e9b0e9b20b1d9856e269bce 100644 (file)
@@ -21,7 +21,6 @@
 */
 
 #include <ccan/tdb2/tdb2.h>
-#include <ccan/hash/hash.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
@@ -128,7 +127,7 @@ static double _end_timer(void)
 }
 
 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);
 }
@@ -207,8 +206,10 @@ static void help(void)
 "  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"
@@ -232,7 +233,7 @@ static void create_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),
@@ -242,18 +243,12 @@ static void create_tdb(const char *tdbname)
        }
 }
 
-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,
@@ -459,8 +454,7 @@ static void speed_tdb(const char *tlimit)
        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);
@@ -475,8 +469,7 @@ static void speed_tdb(const char *tlimit)
        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);
@@ -491,8 +484,7 @@ static void speed_tdb(const char *tlimit)
        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);