r3783: - don't use make proto for ldb anymore
[nivanova/samba-autobuild/.git] / source4 / lib / ldb / modules / skel.c
1 /* 
2    ldb database library
3
4    Copyright (C) Simo Sorce  2004
5
6      ** NOTE! The following LGPL license applies to the ldb
7      ** library. This does NOT imply that all of Samba is released
8      ** under the LGPL
9    
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.
14
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.
19
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
23 */
24
25 /*
26  *  Name: ldb
27  *
28  *  Component: ldb skel module
29  *
30  *  Description: example module
31  *
32  *  Author: Simo Sorce
33  */
34
35 #include "includes.h"
36 #include "ldb/include/ldb.h"
37 #include "ldb/include/ldb_private.h"
38
39 /* close */
40 static int skel_close(struct ldb_module *module)
41 {
42         return ldb_next_close(module);
43 }
44
45 /* search */
46 static int skel_search(struct ldb_module *module, const char *base,
47                        enum ldb_scope scope, const char *expression,
48                        const char * const *attrs, struct ldb_message ***res)
49 {
50         return ldb_next_search(module, base, scope, expression, attrs, res); 
51 }
52
53 /* search_free */
54 static int skel_search_free(struct ldb_module *module, struct ldb_message **res)
55 {
56         return ldb_next_search_free(module, res);
57 }
58
59 /* add_record */
60 static int skel_add_record(struct ldb_module *module, const struct ldb_message *msg)
61 {
62         return ldb_next_add_record(module, msg);
63 }
64
65 /* modify_record */
66 static int skel_modify_record(struct ldb_module *module, const struct ldb_message *msg)
67 {
68         return ldb_next_modify_record(module, msg);
69 }
70
71 /* delete_record */
72 static int skel_delete_record(struct ldb_module *module, const char *dn)
73 {
74         return ldb_next_delete_record(module, dn);
75 }
76
77 /* rename_record */
78 static int skel_rename_record(struct ldb_module *module, const char *olddn, const char *newdn)
79 {
80         return ldb_next_rename_record(module, olddn, newdn);
81 }
82
83 /* return extended error information */
84 static const char *skel_errstring(struct ldb_module *module)
85 {
86         return ldb_next_errstring(module);
87 }
88
89 static void skel_cache_free(struct ldb_module *module)
90 {
91         ldb_next_cache_free(module);
92 }
93
94 static const struct ldb_module_ops skel_ops = {
95         "skel",
96         skel_close, 
97         skel_search,
98         skel_search_free,
99         skel_add_record,
100         skel_modify_record,
101         skel_delete_record,
102         skel_rename_record,
103         skel_errstring,
104         skel_cache_free
105 };
106
107 #ifdef HAVE_DLOPEN
108  struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
109 #else
110 struct ldb_module *skel_plugin_init(struct ldb_context *ldb, const char *options[])
111 #endif
112 {
113         struct ldb_module *ctx;
114
115         ctx = (struct ldb_module *)malloc(sizeof(struct ldb_module));
116         if (!ctx)
117                 return NULL;
118
119         ctx->ldb = ldb;
120         ctx->prev = ctx->next = NULL;
121         ctx->private_data = NULL;
122         ctx->ops = &skel_ops;
123
124         return ctx;
125 }