]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/tdb2.h
tdb2: remove tdb_hashfn_t prototype
[ccan] / ccan / tdb2 / tdb2.h
index 3cbdfbefda30f4d39374ddd10849a56e4e06583f..5e354dfe9b5d562603d474dacef0e771de53cefe 100644 (file)
@@ -1,17 +1,17 @@
 #ifndef CCAN_TDB2_H
 #define CCAN_TDB2_H
 
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    trivial database library
 
    Copyright (C) Andrew Tridgell 1999-2004
-   
+
      ** NOTE! The following LGPL license applies to the tdb
      ** library. This does NOT imply that all of Samba is released
      ** under the LGPL
-   
+
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
@@ -57,19 +57,17 @@ extern "C" {
 #define TDB_NOSYNC   64 /* don't use synchronous transactions */
 #define TDB_SEQNUM   128 /* maintain a sequence number */
 #define TDB_VOLATILE   256 /* Activate the per-hashchain freelist, default 5 */
-#define TDB_ALLOW_NESTING 512 /* Allow transactions to nest */
 
 /* error codes */
-enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, 
+enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
                TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOEXIST,
-               TDB_ERR_EINVAL, TDB_ERR_RDONLY, TDB_ERR_NESTING };
+               TDB_ERR_EINVAL, TDB_ERR_RDONLY };
 
 /* flags for tdb_summary. Logical or to combine. */
 enum tdb_summary_flags { TDB_SUMMARY_HISTOGRAMS = 1 };
 
 /* logging uses one of the following levels */
-enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, 
-                     TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
+enum tdb_log_level {TDB_LOG_ERROR = 0, TDB_LOG_USE_ERROR, TDB_LOG_WARNING};
 
 typedef struct tdb_data {
        unsigned char *dptr;
@@ -80,9 +78,6 @@ struct tdb_context;
 
 /* FIXME: Make typesafe */
 typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
-typedef void (*tdb_logfn_t)(struct tdb_context *, enum tdb_debug_level, void *, const char *);
-typedef uint64_t (*tdb_hashfn_t)(const void *key, size_t len, uint64_t seed,
-                                void *priv);
 
 enum tdb_attribute_type {
        TDB_ATTRIBUTE_LOG = 0,
@@ -98,13 +93,17 @@ struct tdb_attribute_base {
 
 struct tdb_attribute_log {
        struct tdb_attribute_base base; /* .attr = TDB_ATTRIBUTE_LOG */
-       tdb_logfn_t log_fn;
+       void (*log_fn)(struct tdb_context *tdb,
+                      enum tdb_log_level level,
+                      void *log_private,
+                      const char *message);
        void *log_private;
 };
 
 struct tdb_attribute_hash {
        struct tdb_attribute_base base; /* .attr = TDB_ATTRIBUTE_HASH */
-       tdb_hashfn_t hash_fn;
+       uint64_t (*hash_fn)(const void *key, size_t len, uint64_t seed,
+                           void *priv);
        void *hash_private;
 };
 
@@ -118,6 +117,7 @@ struct tdb_attribute_stats {
        size_t size; /* = sizeof(struct tdb_attribute_stats) */
        uint64_t allocs;
        uint64_t   alloc_subhash;
+       uint64_t   alloc_chain;
        uint64_t   alloc_bucket_exact;
        uint64_t   alloc_bucket_max;
        uint64_t   alloc_leftover;