2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 1999
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "talloc.h" /* for tdb_wrap_open() */
26 #include "../libcli/util/ntstatus.h" /* for map_nt_error_from_tdb() */
29 struct tdb_context *tdb;
31 struct tdb_wrap *next, *prev;
34 TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
35 TDB_DATA string_tdb_data(const char *string);
36 TDB_DATA string_term_tdb_data(const char *string);
38 int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key,
39 unsigned int timeout);
40 int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval);
41 int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval,
43 void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval);
44 int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
45 unsigned int timeout);
46 void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval);
48 int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key);
49 int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr);
50 bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value);
51 bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value);
52 int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v);
53 int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v);
54 bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value);
55 bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value);
56 int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val);
57 bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr,
58 uint32_t *oldval, uint32_t change_val);
60 int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags);
61 int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr,
62 TDB_DATA data, int flags);
63 TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr);
64 int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr);
65 int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
67 int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key);
69 int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...);
70 size_t tdb_pack(uint8 *buf, int bufsize, const char *fmt, ...);
71 bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8 **buf, size_t *len,
72 const char *fmt, ...);
74 struct tdb_context *tdb_open_log(const char *name, int hash_size,
75 int tdb_flags, int open_flags, mode_t mode);
77 struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
78 const char *name, int hash_size, int tdb_flags,
79 int open_flags, mode_t mode);
81 NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err);
83 #endif /* __TDBUTIL_H__ */