r12658: Couple of fixes related to shared module builds.
[abartlet/samba.git/.git] / source4 / lib / ldb / modules / skel.c
index 1221ac70f140ef9a8c8ab51cb04f6b9a8d5bcffe..fcec0f3fd81c2e667a0cc5b014aeff0a85884db1 100644 (file)
 
 struct private_data {
 
-       char *errstring;
+       char *some_private_data;
 };
 
 /* search */
-static int skel_search(struct ldb_module *module, const char *base,
-                      enum ldb_scope scope, const char *expression,
-                      const char * const *attrs, struct ldb_message ***res)
+static int skel_search(struct ldb_module *module, const struct ldb_dn *base,
+                      enum ldb_scope scope, struct ldb_parse_tree *tree,
+                      const char * const *attrs, struct ldb_result **res)
 {
-       return ldb_next_search(module, base, scope, expression, attrs, res); 
+       return ldb_next_search(module, base, scope, tree, attrs, res); 
 }
 
 /* add_record */
@@ -62,33 +62,33 @@ static int skel_modify_record(struct ldb_module *module, const struct ldb_messag
 }
 
 /* delete_record */
-static int skel_delete_record(struct ldb_module *module, const char *dn)
+static int skel_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
 {
        return ldb_next_delete_record(module, dn);
 }
 
 /* rename_record */
-static int skel_rename_record(struct ldb_module *module, const char *olddn, const char *newdn)
+static int skel_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
 {
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-/* named_lock */
-static int skel_named_lock(struct ldb_module *module, const char *lockname)
+/* start a transaction */
+static int skel_start_trans(struct ldb_module *module)
 {
-       return ldb_next_named_lock(module, lockname);
+       return ldb_next_start_trans(module);
 }
 
-/* named_unlock */
-static int skel_named_unlock(struct ldb_module *module, const char *lockname)
+/* end a transaction */
+static int skel_end_trans(struct ldb_module *module)
 {
-       return ldb_next_named_unlock(module, lockname);
+       return ldb_next_end_trans(module);
 }
 
-/* return extended error information */
-static const char *skel_errstring(struct ldb_module *module)
+/* delete a transaction */
+static int skel_del_trans(struct ldb_module *module)
 {
-       return ldb_next_errstring(module);
+       return ldb_next_del_trans(module);
 }
 
 static int skel_destructor(void *module_ctx)
@@ -96,28 +96,51 @@ static int skel_destructor(void *module_ctx)
        struct ldb_module *ctx = talloc_get_type(module_ctx, struct ldb_module);
        struct private_data *data = talloc_get_type(ctx->private_data, struct private_data);
        /* put your clean-up functions here */
-       if (data->errstring) talloc_free(data->errstring);
+       if (data->some_private_data) talloc_free(data->some_private_data);
        return 0;
 }
 
+static int skel_request(struct ldb_module *module, struct ldb_request *req)
+{
+       switch (req->operation) {
+
+       case LDB_REQ_SEARCH:
+               return skel_search_bytree(module,
+                                         req->op.search->base,
+                                         req->op.search->scope, 
+                                         req->op.search->tree, 
+                                         req->op.search->attrs, 
+                                         req->op.search->res);
+
+       case LDB_REQ_ADD:
+               return skel_add(module, req->op.add->message);
+
+       case LDB_REQ_MODIFY:
+               return skel_modify(module, req->op.mod->message);
+
+       case LDB_REQ_DELETE:
+               return skel_delete(module, req->op.del->dn);
+
+       case LDB_REQ_RENAME:
+               return skel_rename(module,
+                                       req->op.rename->olddn,
+                                       req->op.rename->newdn);
+
+       default:
+               return ldb_next_request(module, req);
+
+       }
+}
+
 static const struct ldb_module_ops skel_ops = {
-       .name           = "skel",
-       .search         = skel_search,
-       .search_bytree  = skel_search_bytree,
-       .add_record     = skel_add_record,
-       .modify_record  = skel_modify_record,
-       .delete_record  = skel_delete_record,
-       .rename_record  = skel_rename_record,
-       .named_lock     = skel_named_lock,
-       .named_unlock   = skel_named_unlock,
-       .errstring      = skel_errstring
+       .name              = "skel",
+       .request           = skel_request,
+       .start_transaction = skel_start_trans,
+       .end_transaction   = skel_end_trans,
+       .del_transaction   = skel_del_trans,
 };
 
-#ifdef HAVE_DLOPEN_DISABLED
-struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
-#else
 struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options[])
-#endif
 {
        struct ldb_module *ctx;
        struct private_data *data;
@@ -132,7 +155,7 @@ struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options
                return NULL;
        }
 
-       data->errstring = NULL;
+       data->some_private_data = NULL;
        ctx->private_data = data;
 
        ctx->ldb = ldb;