s3: Enforce a lock order in dbwrap
[metze/samba/wip.git] / source3 / lib / dbwrap / dbwrap_private.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Database interface wrapper around tdb - private header
4
5    Copyright (C) Volker Lendecke 2005-2007
6    Copyright (C) Gregor Beck 2011
7    Copyright (C) Michael Adam 2011
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef __DBWRAP_PRIVATE_H__
24 #define __DBWRAP_PRIVATE_H__
25
26 #include "dbwrap/dbwrap_open.h"
27
28 struct db_record {
29         TDB_DATA key, value;
30         NTSTATUS (*store)(struct db_record *rec, TDB_DATA data, int flag);
31         NTSTATUS (*delete_rec)(struct db_record *rec);
32         void *private_data;
33 };
34
35 struct db_context {
36         struct db_record *(*fetch_locked)(struct db_context *db,
37                                           TALLOC_CTX *mem_ctx,
38                                           TDB_DATA key);
39         int (*traverse)(struct db_context *db,
40                         int (*f)(struct db_record *rec,
41                                  void *private_data),
42                         void *private_data);
43         int (*traverse_read)(struct db_context *db,
44                              int (*f)(struct db_record *rec,
45                                       void *private_data),
46                              void *private_data);
47         int (*get_seqnum)(struct db_context *db);
48         int (*get_flags)(struct db_context *db);
49         int (*transaction_start)(struct db_context *db);
50         int (*transaction_commit)(struct db_context *db);
51         int (*transaction_cancel)(struct db_context *db);
52         NTSTATUS (*parse_record)(struct db_context *db, TDB_DATA key,
53                                  void (*parser)(TDB_DATA key, TDB_DATA data,
54                                                 void *private_data),
55                                  void *private_data);
56         int (*exists)(struct db_context *db,TDB_DATA key);
57         int (*wipe)(struct db_context *db);
58         void *private_data;
59         enum dbwrap_lock_order lock_order;
60         bool persistent;
61 };
62
63 #endif /* __DBWRAP_PRIVATE_H__ */
64