util: ntdb_new() supports NTDB_CLEAR_IF_FIRST.
[ddiss/samba.git] / lib / util / util_ntdb.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    tdb utility functions
5
6    Copyright (C) Rusty Russell 2012
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef _____LIB_UTIL_UTIL_NTDB_H__
23 #define _____LIB_UTIL_UTIL_NTDB_H__
24 #include <ntdb.h>
25 #include <talloc.h>
26
27 struct loadparm_context;
28 union ntdb_attribute;
29
30
31 /* You only need this on databases with NTDB_CLEAR_IF_FIRST */
32 int ntdb_reopen(struct ntdb_context *ntdb);
33
34 /* You only need to do this if you have NTDB_CLEAR_IF_FIRST databases, and
35  * the parent will go away before this child. */
36 int ntdb_reopen_all(void);
37
38 /*
39  * This is like TDB_CLEAR_IF_FIRST, for use with ntdb_new.
40  *
41  * It's a bad idea for new code.
42  */
43 #define NTDB_CLEAR_IF_FIRST 1048576
44
45 /***************************************************************
46  Open an NTDB using talloc: it will be allocated off the context, and
47  all NTDB_DATA.dptr are allocated as children of the ntdb context.
48  Sets up a logging function for you, and uses lp_ctx to decide whether
49  to disable mmap.
50
51  Any extra ntdb attributes can be handed through attr; usually it's
52  NULL, ntdb_new provides logging and allocator attributes.
53
54  The destructor for the struct ntdb_context will do ntdb_close()
55  for you.
56 ****************************************************************/
57 struct ntdb_context *ntdb_new(TALLOC_CTX *ctx,
58                               const char *name, int ntdb_flags,
59                               int open_flags, mode_t mode,
60                               union ntdb_attribute *attr,
61                               struct loadparm_context *lp_ctx);
62 #endif /* _____LIB_UTIL_UTIL_NTDB_H__ */