lib:util: Add generate_random_u64_range()
[Samba.git] / lib / dbwrap / dbwrap_private.h
blob3ac5ebf97a10bbeef201010c48b3c9eb838604eb
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 tevent_context;
27 struct tevent_req;
29 struct db_record {
30 struct db_context *db;
31 TDB_DATA key, value;
32 bool value_valid;
33 NTSTATUS (*storev)(struct db_record *rec, const TDB_DATA *dbufs,
34 int num_dbufs, int flag);
35 NTSTATUS (*delete_rec)(struct db_record *rec);
36 void *private_data;
39 struct db_context {
40 struct db_record *(*fetch_locked)(struct db_context *db,
41 TALLOC_CTX *mem_ctx,
42 TDB_DATA key);
43 int (*traverse)(struct db_context *db,
44 int (*f)(struct db_record *rec,
45 void *private_data),
46 void *private_data);
47 int (*traverse_read)(struct db_context *db,
48 int (*f)(struct db_record *rec,
49 void *private_data),
50 void *private_data);
51 int (*get_seqnum)(struct db_context *db);
52 int (*transaction_start)(struct db_context *db);
53 NTSTATUS (*transaction_start_nonblock)(struct db_context *db);
54 int (*transaction_commit)(struct db_context *db);
55 int (*transaction_cancel)(struct db_context *db);
56 NTSTATUS (*parse_record)(struct db_context *db, TDB_DATA key,
57 void (*parser)(TDB_DATA key, TDB_DATA data,
58 void *private_data),
59 void *private_data);
60 struct tevent_req *(*parse_record_send)(
61 TALLOC_CTX *mem_ctx,
62 struct tevent_context *ev,
63 struct db_context *db,
64 TDB_DATA key,
65 void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data),
66 void *private_data,
67 enum dbwrap_req_state *req_state);
68 NTSTATUS (*parse_record_recv)(struct tevent_req *req);
69 NTSTATUS (*do_locked)(struct db_context *db, TDB_DATA key,
70 void (*fn)(struct db_record *rec,
71 TDB_DATA value,
72 void *private_data),
73 void *private_data);
74 int (*exists)(struct db_context *db,TDB_DATA key);
75 int (*wipe)(struct db_context *db);
76 int (*check)(struct db_context *db);
77 size_t (*id)(struct db_context *db, uint8_t *id, size_t idlen);
79 const char *name;
80 void *private_data;
81 enum dbwrap_lock_order lock_order;
82 bool persistent;
85 #define DBWRAP_LOCK_ORDER_MIN DBWRAP_LOCK_ORDER_1
86 #define DBWRAP_LOCK_ORDER_MAX DBWRAP_LOCK_ORDER_4
88 #define DBWRAP_LOCK_ORDER_VALID(order) \
89 (((order) >= DBWRAP_LOCK_ORDER_MIN) && \
90 ((order) <= DBWRAP_LOCK_ORDER_MAX))
92 #endif /* __DBWRAP_PRIVATE_H__ */