s3: reply_readbraw_error needs an sconn as argument also in the non-LFS code path
[Samba.git] / lib / util / util_tdb.h
blobd2f6648462af04456beed061b279ef08992fb3f1
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 bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2);
10 TDB_DATA string_tdb_data(const char *string);
11 TDB_DATA string_term_tdb_data(const char *string);
13 /****************************************************************************
14 Lock a chain by string. Return -1 if lock failed.
15 ****************************************************************************/
16 int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval);
18 /****************************************************************************
19 Unlock a chain by string.
20 ****************************************************************************/
21 void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval);
23 /****************************************************************************
24 Read lock a chain by string. Return -1 if lock failed.
25 ****************************************************************************/
26 int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval);
28 /****************************************************************************
29 Read unlock a chain by string.
30 ****************************************************************************/
31 void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval);
33 /****************************************************************************
34 Fetch a int32_t value by a arbitrary blob key, return -1 if not found.
35 Output is int32_t in native byte order.
36 ****************************************************************************/
37 int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key);
39 /****************************************************************************
40 Fetch a int32_t value by string key, return -1 if not found.
41 Output is int32_t in native byte order.
42 ****************************************************************************/
43 int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr);
45 /****************************************************************************
46 Store a int32_t value by an arbitrary blob key, return 0 on success, -1 on failure.
47 Input is int32_t in native byte order. Output in tdb is in little-endian.
48 ****************************************************************************/
49 int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v);
51 /****************************************************************************
52 Store a int32_t value by string key, return 0 on success, -1 on failure.
53 Input is int32_t in native byte order. Output in tdb is in little-endian.
54 ****************************************************************************/
55 int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v);
57 /****************************************************************************
58 Fetch a uint32_t value by a arbitrary blob key, return -1 if not found.
59 Output is uint32_t in native byte order.
60 ****************************************************************************/
61 bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value);
63 /****************************************************************************
64 Fetch a uint32_t value by string key, return -1 if not found.
65 Output is uint32_t in native byte order.
66 ****************************************************************************/
67 bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value);
69 /****************************************************************************
70 Store a uint32_t value by an arbitrary blob key, return 0 on success, -1 on failure.
71 Input is uint32_t in native byte order. Output in tdb is in little-endian.
72 ****************************************************************************/
73 bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value);
75 /****************************************************************************
76 Store a uint32_t value by string key, return 0 on success, -1 on failure.
77 Input is uint32_t in native byte order. Output in tdb is in little-endian.
78 ****************************************************************************/
79 bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value);
81 /****************************************************************************
82 Store a buffer by a null terminated string key. Return 0 on success, -1
83 on failure.
84 ****************************************************************************/
85 int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags);
87 /****************************************************************************
88 Fetch a buffer using a null terminated string key. Don't forget to call
89 free() on the result dptr.
90 ****************************************************************************/
91 TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr);
93 /****************************************************************************
94 Delete an entry using a null terminated string key.
95 ****************************************************************************/
96 int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr);
98 /****************************************************************************
99 Atomic integer change. Returns old value. To create, set initial value in *oldval.
100 ****************************************************************************/
101 int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val);
103 /****************************************************************************
104 Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval.
105 ****************************************************************************/
106 bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint32_t *oldval, uint32_t change_val);
108 /****************************************************************************
109 Allow tdb_delete to be used as a tdb_traversal_fn.
110 ****************************************************************************/
111 int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf,
112 void *state);
114 #endif /* _____LIB_UTIL_UTIL_TDB_H__ */