selftest: Fix uninitialized variables in selftest output.
[Samba/gebeck_regimport.git] / lib / util / util_tdb.h
blobda6378ee6a7476f4750e63404b08ba885d10cf02
1 #ifndef _____LIB_UTIL_UTIL_TDB_H__
2 #define _____LIB_UTIL_UTIL_TDB_H__
5 /***************************************************************
6 Make a TDB_DATA and keep the const warning in one place
7 ****************************************************************/
8 TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
9 TDB_DATA string_tdb_data(const char *string);
10 TDB_DATA string_term_tdb_data(const char *string);
12 /****************************************************************************
13 Lock a chain by string. Return -1 if lock failed.
14 ****************************************************************************/
15 int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval);
17 /****************************************************************************
18 Unlock a chain by string.
19 ****************************************************************************/
20 void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval);
22 /****************************************************************************
23 Read lock a chain by string. Return -1 if lock failed.
24 ****************************************************************************/
25 int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval);
27 /****************************************************************************
28 Read unlock a chain by string.
29 ****************************************************************************/
30 void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval);
32 /****************************************************************************
33 Fetch a int32_t value by a arbitrary blob key, return -1 if not found.
34 Output is int32_t in native byte order.
35 ****************************************************************************/
36 int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key);
38 /****************************************************************************
39 Fetch a int32_t value by string key, return -1 if not found.
40 Output is int32_t in native byte order.
41 ****************************************************************************/
42 int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr);
44 /****************************************************************************
45 Store a int32_t value by an arbitary blob key, return 0 on success, -1 on failure.
46 Input is int32_t in native byte order. Output in tdb is in little-endian.
47 ****************************************************************************/
48 int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v);
50 /****************************************************************************
51 Store a int32_t value by string key, return 0 on success, -1 on failure.
52 Input is int32_t in native byte order. Output in tdb is in little-endian.
53 ****************************************************************************/
54 int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v);
56 /****************************************************************************
57 Fetch a uint32_t value by a arbitrary blob key, return -1 if not found.
58 Output is uint32_t in native byte order.
59 ****************************************************************************/
60 bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value);
62 /****************************************************************************
63 Fetch a uint32_t value by string key, return -1 if not found.
64 Output is uint32_t in native byte order.
65 ****************************************************************************/
66 bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value);
68 /****************************************************************************
69 Store a uint32_t value by an arbitary blob key, return 0 on success, -1 on failure.
70 Input is uint32_t in native byte order. Output in tdb is in little-endian.
71 ****************************************************************************/
72 bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value);
74 /****************************************************************************
75 Store a uint32_t value by string key, return 0 on success, -1 on failure.
76 Input is uint32_t in native byte order. Output in tdb is in little-endian.
77 ****************************************************************************/
78 bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value);
80 /****************************************************************************
81 Store a buffer by a null terminated string key. Return 0 on success, -1
82 on failure.
83 ****************************************************************************/
84 int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags);
86 /****************************************************************************
87 Fetch a buffer using a null terminated string key. Don't forget to call
88 free() on the result dptr.
89 ****************************************************************************/
90 TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr);
92 /****************************************************************************
93 Delete an entry using a null terminated string key.
94 ****************************************************************************/
95 int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr);
97 /****************************************************************************
98 Atomic integer change. Returns old value. To create, set initial value in *oldval.
99 ****************************************************************************/
100 int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val);
102 /****************************************************************************
103 Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
104 ****************************************************************************/
105 bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint32_t *oldval, uint32_t change_val);
107 /****************************************************************************
108 Allow tdb_delete to be used as a tdb_traversal_fn.
109 ****************************************************************************/
110 int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf,
111 void *state);
113 #endif /* _____LIB_UTIL_UTIL_TDB_H__ */