4 Copyright (C) Simo Sorce 2004
6 ** NOTE! The following LGPL license applies to the ldb
7 ** library. This does NOT imply that all of Samba is released
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 3 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, see <http://www.gnu.org/licenses/>.
27 * Component: ldb skel module
29 * Description: example module
35 #include "system/filesys.h"
36 #include "system/time.h"
37 #include "ldb_module.h"
41 char *some_private_data
;
45 static int skel_search(struct ldb_module
*module
, struct ldb_request
*req
)
47 return ldb_next_request(module
, req
);
51 static int skel_add(struct ldb_module
*module
, struct ldb_request
*req
){
52 return ldb_next_request(module
, req
);
56 static int skel_modify(struct ldb_module
*module
, struct ldb_request
*req
)
58 return ldb_next_request(module
, req
);
62 static int skel_delete(struct ldb_module
*module
, struct ldb_request
*req
)
64 return ldb_next_request(module
, req
);
68 static int skel_rename(struct ldb_module
*module
, struct ldb_request
*req
)
70 return ldb_next_request(module
, req
);
73 /* start a transaction */
74 static int skel_start_trans(struct ldb_module
*module
)
76 return ldb_next_start_trans(module
);
79 /* end a transaction */
80 static int skel_end_trans(struct ldb_module
*module
)
82 return ldb_next_end_trans(module
);
85 /* delete a transaction */
86 static int skel_del_trans(struct ldb_module
*module
)
88 return ldb_next_del_trans(module
);
91 static int skel_destructor(struct ldb_module
*ctx
)
93 struct private_data
*data
;
95 data
= talloc_get_type(ldb_module_get_private(ctx
), struct private_data
);
97 /* put your clean-up functions here */
98 if (data
->some_private_data
) talloc_free(data
->some_private_data
);
103 static int skel_request(struct ldb_module
*module
, struct ldb_request
*req
)
105 return ldb_next_request(module
, req
);
108 static int skel_init(struct ldb_module
*module
)
110 struct ldb_context
*ldb
;
111 struct private_data
*data
;
113 ldb
= ldb_module_get_ctx(module
);
115 data
= talloc(module
, struct private_data
);
118 return LDB_ERR_OPERATIONS_ERROR
;
121 data
->some_private_data
= NULL
;
122 ldb_module_set_private(module
, data
);
124 talloc_set_destructor (module
, skel_destructor
);
126 return ldb_next_init(module
);
129 static const struct ldb_module_ops ldb_skel_module_ops
= {
131 .init_context
= skel_init
,
132 .search
= skel_search
,
134 .modify
= skel_modify
,
136 .rename
= skel_rename
,
137 .request
= skel_request
,
138 .start_transaction
= skel_start_trans
,
139 .end_transaction
= skel_end_trans
,
140 .del_transaction
= skel_del_trans
,
143 int ldb_skel_init(const char *version
)
145 LDB_MODULE_CHECK_VERSION(version
);
146 return ldb_register_module(&ldb_skel_module_ops
);