]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/private.h
tdb2: remove tdb_traverse_read
[ccan] / ccan / tdb2 / private.h
index 75e49c8313fcee17d40f8fe01ecd7953c7305fb3..3366aea2d16c09c91d11ec4b115dab1b3eaca0a3 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef TDB_PRIVATE_H
 #define TDB_PRIVATE_H
- /* 
+ /*
    Trivial Database 2: private types and prototypes
    Copyright (C) Rusty Russell 2010
 
@@ -325,17 +325,20 @@ struct tdb_context {
        int mmap_flags;
 
        /* Error code for last tdb error. */
-       enum TDB_ERROR ecode; 
+       enum TDB_ERROR ecode;
 
        /* the flags passed to tdb_open, for tdb_reopen. */
        uint32_t flags;
 
        /* Logging function */
-       tdb_logfn_t logfn;
+       void (*logfn)(struct tdb_context *tdb,
+                     enum tdb_log_level level,
+                     void *log_private,
+                     const char *message);
        void *log_private;
 
        /* Hash function. */
-       tdb_hashfn_t khash;
+       uint64_t (*khash)(const void *key, size_t len, uint64_t seed, void *);
        void *hash_priv;
        uint64_t hash_seed;
 
@@ -361,13 +364,13 @@ struct tdb_context {
 
        /* Single list of all TDBs, to avoid multiple opens. */
        struct tdb_context *next;
-       dev_t device;   
+       dev_t device;
        ino_t inode;
 };
 
 struct tdb_methods {
-       int (*read)(struct tdb_context *, tdb_off_t, void *, tdb_len_t);
-       int (*write)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
+       int (*tread)(struct tdb_context *, tdb_off_t, void *, tdb_len_t);
+       int (*twrite)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
        int (*oob)(struct tdb_context *, tdb_off_t, bool);
        int (*expand_file)(struct tdb_context *, tdb_len_t);
        void *(*direct)(struct tdb_context *, tdb_off_t, size_t, bool);
@@ -379,6 +382,14 @@ struct tdb_methods {
 /* hash.c: */
 void tdb_hash_init(struct tdb_context *tdb);
 
+int first_in_hash(struct tdb_context *tdb,
+                 struct traverse_info *tinfo,
+                 TDB_DATA *kbuf, size_t *dlen);
+
+int next_in_hash(struct tdb_context *tdb,
+                struct traverse_info *tinfo,
+                TDB_DATA *kbuf, size_t *dlen);
+
 /* Hash random memory. */
 uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len);
 
@@ -535,14 +546,6 @@ bool tdb_has_expansion_lock(struct tdb_context *tdb);
 /* If it needs recovery, grab all the locks and do it. */
 int tdb_lock_and_recover(struct tdb_context *tdb);
 
-/* traverse.c: */
-int first_in_hash(struct tdb_context *tdb, int ltype,
-                 struct traverse_info *tinfo,
-                 TDB_DATA *kbuf, size_t *dlen);
-int next_in_hash(struct tdb_context *tdb, int ltype,
-                struct traverse_info *tinfo,
-                TDB_DATA *kbuf, size_t *dlen);
-
 /* transaction.c: */
 int tdb_transaction_recover(struct tdb_context *tdb);
 bool tdb_needs_recovery(struct tdb_context *tdb);
@@ -550,7 +553,7 @@ bool tdb_needs_recovery(struct tdb_context *tdb);
 /* tdb.c: */
 void COLD tdb_logerr(struct tdb_context *tdb,
                     enum TDB_ERROR ecode,
-                    enum tdb_debug_level level,
+                    enum tdb_log_level level,
                     const char *fmt, ...);
 
 #ifdef TDB_TRACE