2 Unix SMB/Netbios implementation.
4 Samba database functions
5 Copyright (C) Andrew Tridgell 1999
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 typedef unsigned tdb_len;
23 typedef unsigned tdb_off;
25 /* this is stored at the front of every database */
27 unsigned version; /* version of the code */
28 unsigned hash_size; /* number of hash entries */
36 /* this is the context structure that is returned from a db open */
38 char *name; /* the name of the database */
39 void *map_ptr; /* where it is currently mapped */
40 int fd; /* open file descriptor for the database */
41 tdb_len map_size; /* how much space has been mapped */
42 int write_locked; /* set if we have the db locked */
43 struct tdb_header header; /* a cached copy of the header */
50 int tdb_writelock(TDB_CONTEXT *tdb);
51 int tdb_writeunlock(TDB_CONTEXT *tdb);
52 TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
53 int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key);
54 int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
55 TDB_CONTEXT *tdb_open(char *name, int hash_size, int flags, mode_t mode);
56 int tdb_close(TDB_CONTEXT *tdb);
57 TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb);
58 TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key);
59 int tdb_traverse(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf));
60 int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key);