1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | tdb utility functions
|
---|
4 | Copyright (C) Andrew Tridgell 1999
|
---|
5 |
|
---|
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.
|
---|
10 |
|
---|
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.
|
---|
15 |
|
---|
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/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef __TDBUTIL_H__
|
---|
21 | #define __TDBUTIL_H__
|
---|
22 |
|
---|
23 | #include "tdb.h"
|
---|
24 |
|
---|
25 | #include "talloc.h" /* for tdb_wrap_open() */
|
---|
26 | #include "../libcli/util/ntstatus.h" /* for map_nt_error_from_tdb() */
|
---|
27 | #include "../../lib/util/util_tdb.h"
|
---|
28 |
|
---|
29 | struct tdb_wrap {
|
---|
30 | struct tdb_context *tdb;
|
---|
31 | const char *name;
|
---|
32 | struct tdb_wrap *next, *prev;
|
---|
33 | };
|
---|
34 |
|
---|
35 | int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key,
|
---|
36 | unsigned int timeout);
|
---|
37 | int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval,
|
---|
38 | int timeout);
|
---|
39 | int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
|
---|
40 | unsigned int timeout);
|
---|
41 |
|
---|
42 | int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr,
|
---|
43 | TDB_DATA data, int flags);
|
---|
44 | int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
|
---|
45 | int flag);
|
---|
46 | int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key);
|
---|
47 |
|
---|
48 | int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...);
|
---|
49 | size_t tdb_pack(uint8 *buf, int bufsize, const char *fmt, ...);
|
---|
50 | bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8 **buf, size_t *len,
|
---|
51 | const char *fmt, ...);
|
---|
52 |
|
---|
53 | struct tdb_context *tdb_open_log(const char *name, int hash_size,
|
---|
54 | int tdb_flags, int open_flags, mode_t mode);
|
---|
55 |
|
---|
56 | struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
|
---|
57 | const char *name, int hash_size, int tdb_flags,
|
---|
58 | int open_flags, mode_t mode);
|
---|
59 |
|
---|
60 | NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err);
|
---|
61 |
|
---|
62 | int tdb_data_cmp(TDB_DATA t1, TDB_DATA t2);
|
---|
63 |
|
---|
64 | #endif /* __TDBUTIL_H__ */
|
---|