]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/tdb1.h
e3204283853c516dfab63a8d9202faee2e90a3f1
[ccan] / ccan / tdb2 / tdb1.h
1 #ifndef TDB1_H
2 #define TDB1_H
3
4 /*
5    Unix SMB/CIFS implementation.
6
7    trivial database library (version 1 compat functions)
8
9    Copyright (C) Andrew Tridgell 1999-2004
10    Copyright (C) Rusty Russell 2011
11
12      ** NOTE! The following LGPL license applies to the tdb
13      ** library. This does NOT imply that all of Samba is released
14      ** under the LGPL
15
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.
20
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.
25
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/>.
28 */
29 #include "tdb2.h"
30
31 #ifndef _SAMBA_BUILD_
32 /* For mode_t */
33 #include <sys/types.h>
34 /* For O_* flags. */
35 #include <sys/stat.h>
36 #endif
37
38
39 typedef int (*tdb1_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
40
41 void tdb1_set_max_dead(struct tdb_context *tdb, int max_dead);
42
43 int tdb1_parse_record(struct tdb_context *tdb, TDB_DATA key,
44                               int (*parser)(TDB_DATA key, TDB_DATA data,
45                                             void *private_data),
46                               void *private_data);
47
48 int tdb1_delete(struct tdb_context *tdb, TDB_DATA key);
49
50 int tdb1_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
51
52 TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
53
54 TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
55
56 int tdb1_traverse(struct tdb_context *tdb, tdb1_traverse_func fn, void *private_data);
57
58 int tdb1_traverse_read(struct tdb_context *tdb, tdb1_traverse_func fn, void *private_data);
59
60 int tdb1_exists(struct tdb_context *tdb, TDB_DATA key);
61
62 int tdb1_lockall(struct tdb_context *tdb);
63
64 int tdb1_unlockall(struct tdb_context *tdb);
65
66 int tdb1_lockall_read(struct tdb_context *tdb);
67
68 int tdb1_unlockall_read(struct tdb_context *tdb);
69
70 int tdb1_transaction_start(struct tdb_context *tdb);
71
72 int tdb1_transaction_prepare_commit(struct tdb_context *tdb);
73
74 int tdb1_transaction_commit(struct tdb_context *tdb);
75
76 int tdb1_get_seqnum(struct tdb_context *tdb);
77
78 void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
79
80 uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed, void *);
81
82 int tdb1_check(struct tdb_context *tdb,
83               int (*check) (TDB_DATA key, TDB_DATA data, void *private_data),
84               void *private_data);
85
86 /* @} ******************************************************************/
87
88 /* Low level locking functions: use with care */
89 int tdb1_chainlock(struct tdb_context *tdb, TDB_DATA key);
90 int tdb1_chainunlock(struct tdb_context *tdb, TDB_DATA key);
91 int tdb1_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
92 int tdb1_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
93
94
95 /* wipe and repack */
96 int tdb1_wipe_all(struct tdb_context *tdb);
97 int tdb1_repack(struct tdb_context *tdb);
98
99 /* Debug functions. Not used in production. */
100 char *tdb1_summary(struct tdb_context *tdb);
101
102 extern TDB_DATA tdb1_null;
103
104 #endif /* tdb1.h */