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 2 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, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * Component: ldb skel module
30 * Description: example module
36 #include "ldb/include/ldb.h"
37 #include "ldb/include/ldb_private.h"
41 char *some_private_data;
45 static int skel_search(struct ldb_module *module, const struct ldb_dn *base,
46 enum ldb_scope scope, struct ldb_parse_tree *tree,
47 const char * const *attrs, struct ldb_message ***res)
49 return ldb_next_search(module, base, scope, tree, attrs, res);
53 static int skel_add_record(struct ldb_module *module, const struct ldb_message *msg)
55 return ldb_next_add_record(module, msg);
59 static int skel_modify_record(struct ldb_module *module, const struct ldb_message *msg)
61 return ldb_next_modify_record(module, msg);
65 static int skel_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
67 return ldb_next_delete_record(module, dn);
71 static int skel_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
73 return ldb_next_rename_record(module, olddn, newdn);
76 /* start a transaction */
77 static int skel_start_trans(struct ldb_module *module)
79 return ldb_next_start_trans(module);
82 /* end a transaction */
83 static int skel_end_trans(struct ldb_module *module)
85 return ldb_next_end_trans(module);
88 /* delete a transaction */
89 static int skel_del_trans(struct ldb_module *module)
91 return ldb_next_del_trans(module);
94 static int skel_destructor(void *module_ctx)
96 struct ldb_module *ctx = talloc_get_type(module_ctx, struct ldb_module);
97 struct private_data *data = talloc_get_type(ctx->private_data, struct private_data);
98 /* put your clean-up functions here */
99 if (data->some_private_data) talloc_free(data->some_private_data);
103 static const struct ldb_module_ops skel_ops = {
105 .search_bytree = skel_search_bytree,
106 .add_record = skel_add_record,
107 .modify_record = skel_modify_record,
108 .delete_record = skel_delete_record,
109 .rename_record = skel_rename_record,
110 .start_transaction = skel_start_trans,
111 .end_transaction = skel_end_trans,
112 .del_transaction = skel_del_trans,
115 #ifdef HAVE_DLOPEN_DISABLED
116 struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
118 struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options[])
121 struct ldb_module *ctx;
122 struct private_data *data;
124 ctx = talloc(ldb, struct ldb_module);
128 data = talloc(ctx, struct private_data);
134 data->some_private_data = NULL;
135 ctx->private_data = data;
138 ctx->prev = ctx->next = NULL;
139 ctx->ops = &skel_ops;
141 talloc_set_destructor (ctx, skel_destructor);