r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[Samba/bb.git] / source / include / util_tdb.h
blobcb128422d5ef202a7199fb61ec8cfabd8b37757c
1 /*
2 Unix SMB/CIFS implementation.
3 tdb utility functions
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/>.
20 #ifndef __TDBUTIL_H__
21 #define __TDBUTIL_H__
23 #include "tdb.h"
25 #ifndef _BOOL
26 typedef int BOOL;
27 #define _BOOL
28 #endif
30 /* single node of a list returned by tdb_search_keys */
31 typedef struct keys_node
33 struct keys_node *prev, *next;
34 TDB_DATA node_key;
35 } TDB_LIST_NODE;
37 struct tdb_wrap {
38 struct tdb_context *tdb;
39 const char *name;
40 struct tdb_wrap *next, *prev;
43 struct tdb_validation_status {
44 BOOL tdb_error;
45 BOOL bad_freelist;
46 BOOL bad_entry;
47 BOOL unknown_key;
48 BOOL success;
51 typedef int (*tdb_validate_data_func)(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state);
53 TDB_LIST_NODE *tdb_search_keys(struct tdb_context*, const char*);
54 void tdb_search_list_free(TDB_LIST_NODE*);
55 int32 tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32 *oldval, int32 change_val);
56 int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval);
57 int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
58 int timeout);
59 void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval);
60 int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
61 unsigned int timeout);
62 void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval);
63 int32 tdb_fetch_int32(struct tdb_context *tdb, const char *keystr);
64 int tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32 value);
65 int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32 v);
66 int tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32 *value);
67 int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf,
68 void *state);
69 int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags);
70 TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr);
71 int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr);
72 struct tdb_context *tdb_open_log(const char *name, int hash_size,
73 int tdb_flags, int open_flags, mode_t mode);
74 int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...);
75 size_t tdb_pack(uint8 *buf, int bufsize, const char *fmt, ...);
76 TDB_DATA make_tdb_data(const uint8 *dptr, size_t dsize);
77 TDB_DATA string_tdb_data(const char *string);
78 TDB_DATA string_term_tdb_data(const char *string);
79 int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
80 int flag);
81 BOOL tdb_change_uint32_atomic(TDB_CONTEXT *tdb, const char *keystr,
82 uint32 *oldval, uint32 change_val);
83 int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key,
84 unsigned int timeout);
86 #endif /* __TDBUTIL_H__ */