X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb2.h;h=343264d588f0a04db188556f6f1f1f542cd4cd2b;hb=7f63d84eb712c54c57c3d4e9a92ffefe2f1b2ade;hp=98831b4a764c980244fb984b3680f7d84e0df5a0;hpb=b846677c1ec77e986c7d6b7c913aa2a4b0c82d4e;p=ccan diff --git a/ccan/tdb2/tdb2.h b/ccan/tdb2/tdb2.h index 98831b4a..343264d5 100644 --- a/ccan/tdb2/tdb2.h +++ b/ccan/tdb2/tdb2.h @@ -40,6 +40,7 @@ extern "C" { /* For uint64_t */ #include #endif +#include /* flags to tdb_store() */ #define TDB_REPLACE 1 /* Unused */ @@ -63,6 +64,9 @@ 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 }; +/* flags for tdb_summary. Logical or to combine. */ +enum tdb_summary_flags { TDB_SUMMARY_HISTOGRAMS = 1 }; + /* debugging uses one of the following levels */ enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, TDB_DEBUG_WARNING, TDB_DEBUG_TRACE}; @@ -72,18 +76,6 @@ typedef struct tdb_data { size_t dsize; } TDB_DATA; -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - struct tdb_context; /* FIXME: Make typesafe */ @@ -133,6 +125,8 @@ int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key); int64_t tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *p); int64_t tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *p); +TDB_DATA tdb_firstkey(struct tdb_context *tdb); +TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key); int tdb_close(struct tdb_context *tdb); int tdb_check(struct tdb_context *tdb, int (*check)(TDB_DATA key, TDB_DATA data, void *private_data), @@ -141,6 +135,8 @@ int tdb_check(struct tdb_context *tdb, enum TDB_ERROR tdb_error(struct tdb_context *tdb); const char *tdb_errorstr(struct tdb_context *tdb); +char *tdb_summary(struct tdb_context *tdb, enum tdb_summary_flags flags); + extern struct tdb_data tdb_null; #ifdef __cplusplus