5 Unix SMB/CIFS implementation.
7 trivial database library (version 1 compat functions)
9 Copyright (C) Andrew Tridgell 1999-2004
10 Copyright (C) Rusty Russell 2011
12 ** NOTE! The following LGPL license applies to the tdb
13 ** library. This does NOT imply that all of Samba is released
16 This library is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Lesser General Public
18 License as published by the Free Software Foundation; either
19 version 3 of the License, or (at your option) any later version.
21 This library is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 Lesser General Public License for more details.
26 You should have received a copy of the GNU Lesser General Public
27 License along with this library; if not, see <http://www.gnu.org/licenses/>.
33 #include <sys/types.h>
39 typedef int (*tdb1_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
40 typedef void (*tdb1_log_func)(struct tdb_context *, enum tdb_log_level, enum TDB_ERROR,
41 const char *, void *);
42 typedef uint64_t (*tdb1_hash_func)(const void *key, size_t len, uint64_t seed,
45 struct tdb1_logging_context {
50 struct tdb_context *tdb1_open(const char *name, int hash_size, int tdb1_flags,
51 int open_flags, mode_t mode);
53 struct tdb_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags,
54 int open_flags, mode_t mode,
55 const struct tdb1_logging_context *log_ctx,
56 tdb1_hash_func hash_fn);
58 void tdb1_set_max_dead(struct tdb_context *tdb, int max_dead);
60 TDB_DATA tdb1_fetch(struct tdb_context *tdb, TDB_DATA key);
62 int tdb1_parse_record(struct tdb_context *tdb, TDB_DATA key,
63 int (*parser)(TDB_DATA key, TDB_DATA data,
67 int tdb1_delete(struct tdb_context *tdb, TDB_DATA key);
69 int tdb1_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
71 int tdb1_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
73 int tdb1_close(struct tdb_context *tdb);
75 TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
77 TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
79 int tdb1_traverse(struct tdb_context *tdb, tdb1_traverse_func fn, void *private_data);
81 int tdb1_traverse_read(struct tdb_context *tdb, tdb1_traverse_func fn, void *private_data);
83 int tdb1_exists(struct tdb_context *tdb, TDB_DATA key);
85 int tdb1_lockall(struct tdb_context *tdb);
87 int tdb1_unlockall(struct tdb_context *tdb);
89 int tdb1_lockall_read(struct tdb_context *tdb);
91 int tdb1_unlockall_read(struct tdb_context *tdb);
93 int tdb1_transaction_start(struct tdb_context *tdb);
95 int tdb1_transaction_prepare_commit(struct tdb_context *tdb);
97 int tdb1_transaction_commit(struct tdb_context *tdb);
99 int tdb1_transaction_cancel(struct tdb_context *tdb);
101 int tdb1_get_seqnum(struct tdb_context *tdb);
103 int tdb1_hash_size(struct tdb_context *tdb);
105 void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
107 uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed, void *);
109 int tdb1_check(struct tdb_context *tdb,
110 int (*check) (TDB_DATA key, TDB_DATA data, void *private_data),
113 /* @} ******************************************************************/
115 /* Low level locking functions: use with care */
116 int tdb1_chainlock(struct tdb_context *tdb, TDB_DATA key);
117 int tdb1_chainunlock(struct tdb_context *tdb, TDB_DATA key);
118 int tdb1_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
119 int tdb1_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
122 /* wipe and repack */
123 int tdb1_wipe_all(struct tdb_context *tdb);
124 int tdb1_repack(struct tdb_context *tdb);
126 /* Debug functions. Not used in production. */
127 char *tdb1_summary(struct tdb_context *tdb);
129 extern TDB_DATA tdb1_null;