backupkey: Improve IDL
[Samba.git] / lib / dbwrap / dbwrap_private.h
bloba6bad04971b7729d7b3b523174a906642a8d68ee
1 /*
2 Unix SMB/CIFS implementation.
3 Database interface wrapper around tdb - private header
5 Copyright (C) Volker Lendecke 2005-2007
6 Copyright (C) Gregor Beck 2011
7 Copyright (C) Michael Adam 2011
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.
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.
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/>.
23 #ifndef __DBWRAP_PRIVATE_H__
24 #define __DBWRAP_PRIVATE_H__
26 struct db_record {
27 struct db_context *db;
28 TDB_DATA key, value;
29 NTSTATUS (*store)(struct db_record *rec, TDB_DATA data, int flag);
30 NTSTATUS (*delete_rec)(struct db_record *rec);
31 void *private_data;
34 struct db_context {
35 struct db_record *(*fetch_locked)(struct db_context *db,
36 TALLOC_CTX *mem_ctx,
37 TDB_DATA key);
38 struct db_record *(*try_fetch_locked)(struct db_context *db,
39 TALLOC_CTX *mem_ctx,
40 TDB_DATA key);
41 int (*traverse)(struct db_context *db,
42 int (*f)(struct db_record *rec,
43 void *private_data),
44 void *private_data);
45 int (*traverse_read)(struct db_context *db,
46 int (*f)(struct db_record *rec,
47 void *private_data),
48 void *private_data);
49 int (*get_seqnum)(struct db_context *db);
50 int (*transaction_start)(struct db_context *db);
51 NTSTATUS (*transaction_start_nonblock)(struct db_context *db);
52 int (*transaction_commit)(struct db_context *db);
53 int (*transaction_cancel)(struct db_context *db);
54 NTSTATUS (*parse_record)(struct db_context *db, TDB_DATA key,
55 void (*parser)(TDB_DATA key, TDB_DATA data,
56 void *private_data),
57 void *private_data);
58 int (*exists)(struct db_context *db,TDB_DATA key);
59 int (*wipe)(struct db_context *db);
60 int (*check)(struct db_context *db);
61 void (*id)(struct db_context *db, const uint8_t **id, size_t *idlen);
62 const char *name;
63 int hash_size;
64 void *private_data;
65 enum dbwrap_lock_order lock_order;
66 bool persistent;
67 void (*stored_callback)(struct db_context *db, struct db_record *rec,
68 void *private_data);
69 void *stored_callback_private_data;
72 #define DBWRAP_LOCK_ORDER_MIN DBWRAP_LOCK_ORDER_1
73 #define DBWRAP_LOCK_ORDER_MAX DBWRAP_LOCK_ORDER_3
75 #define DBWRAP_LOCK_ORDER_VALID(order) \
76 (((order) >= DBWRAP_LOCK_ORDER_MIN) && \
77 ((order) <= DBWRAP_LOCK_ORDER_MAX))
79 #endif /* __DBWRAP_PRIVATE_H__ */