2004-11-15 14:42:17 +03:00
/*
ldb database library
Copyright ( C ) Simo Sorce 2004
* * NOTE ! The following LGPL license applies to the ldb
* * library . This does NOT imply that all of Samba is released
* * under the LGPL
This library is free software ; you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation ; either
version 2 of the License , or ( at your option ) any later version .
This library is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public
License along with this library ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
/*
* Name : ldb
*
* Component : ldb skel module
*
* Description : example module
*
* Author : Simo Sorce
*/
# include "includes.h"
2004-11-16 12:00:52 +03:00
# include "ldb/include/ldb.h"
# include "ldb/include/ldb_private.h"
2004-11-15 14:42:17 +03:00
2005-05-23 10:49:17 +04:00
struct private_data {
2005-05-22 14:40:54 +04:00
2005-05-23 10:49:17 +04:00
char * errstring ;
2005-05-22 14:27:51 +04:00
} ;
2004-11-15 14:42:17 +03:00
/* search */
2005-08-18 19:02:01 +04:00
static int skel_search ( struct ldb_module * module , const struct ldb_dn * base ,
2004-11-15 14:42:17 +03:00
enum ldb_scope scope , const char * expression ,
const char * const * attrs , struct ldb_message * * * res )
{
return ldb_next_search ( module , base , scope , expression , attrs , res ) ;
}
/* add_record */
static int skel_add_record ( struct ldb_module * module , const struct ldb_message * msg )
{
return ldb_next_add_record ( module , msg ) ;
}
/* modify_record */
static int skel_modify_record ( struct ldb_module * module , const struct ldb_message * msg )
{
return ldb_next_modify_record ( module , msg ) ;
}
/* delete_record */
2005-08-18 19:02:01 +04:00
static int skel_delete_record ( struct ldb_module * module , const struct ldb_dn * dn )
2004-11-15 14:42:17 +03:00
{
return ldb_next_delete_record ( module , dn ) ;
}
/* rename_record */
2005-08-18 19:02:01 +04:00
static int skel_rename_record ( struct ldb_module * module , const struct ldb_dn * olddn , const struct ldb_dn * newdn )
2004-11-15 14:42:17 +03:00
{
return ldb_next_rename_record ( module , olddn , newdn ) ;
}
2004-11-21 18:51:54 +03:00
/* named_lock */
2005-05-22 14:27:51 +04:00
static int skel_named_lock ( struct ldb_module * module , const char * lockname )
2004-11-21 18:51:54 +03:00
{
return ldb_next_named_lock ( module , lockname ) ;
}
/* named_unlock */
2005-05-22 14:27:51 +04:00
static int skel_named_unlock ( struct ldb_module * module , const char * lockname )
2004-11-21 18:51:54 +03:00
{
return ldb_next_named_unlock ( module , lockname ) ;
}
2004-11-15 14:42:17 +03:00
/* return extended error information */
static const char * skel_errstring ( struct ldb_module * module )
{
return ldb_next_errstring ( module ) ;
}
2005-02-27 14:35:47 +03:00
static int skel_destructor ( void * module_ctx )
{
2005-05-23 10:49:17 +04:00
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 ) ;
2005-02-27 14:35:47 +03:00
/* put your clean-up functions here */
2005-05-23 10:49:17 +04:00
if ( data - > errstring ) talloc_free ( data - > errstring ) ;
2005-02-27 14:35:47 +03:00
return 0 ;
}
2004-11-15 14:42:17 +03:00
static const struct ldb_module_ops skel_ops = {
2005-05-23 10:49:17 +04:00
. name = " skel " ,
. search = skel_search ,
2005-06-13 13:10:17 +04:00
. search_bytree = skel_search_bytree ,
2005-05-23 10:49:17 +04:00
. 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
2004-11-15 14:42:17 +03:00
} ;
2005-05-22 14:27:51 +04:00
# ifdef HAVE_DLOPEN_DISABLED
struct ldb_module * init_module ( struct ldb_context * ldb , const char * options [ ] )
2004-11-15 14:42:17 +03:00
# else
2005-05-22 14:27:51 +04:00
struct ldb_module * skel_module_init ( struct ldb_context * ldb , const char * options [ ] )
2004-11-15 14:42:17 +03:00
# endif
{
struct ldb_module * ctx ;
2005-05-22 14:27:51 +04:00
struct private_data * data ;
2004-11-15 14:42:17 +03:00
2005-05-22 14:27:51 +04:00
ctx = talloc ( ldb , struct ldb_module ) ;
2004-11-15 14:42:17 +03:00
if ( ! ctx )
return NULL ;
2005-05-22 14:27:51 +04:00
data = talloc ( ctx , struct private_data ) ;
if ( data = = NULL ) {
talloc_free ( ctx ) ;
return NULL ;
}
2005-05-23 10:49:17 +04:00
data - > errstring = NULL ;
2005-05-22 14:27:51 +04:00
ctx - > private_data = data ;
2004-11-15 14:42:17 +03:00
ctx - > ldb = ldb ;
ctx - > prev = ctx - > next = NULL ;
ctx - > ops = & skel_ops ;
2005-02-27 14:35:47 +03:00
talloc_set_destructor ( ctx , skel_destructor ) ;
2004-11-15 14:42:17 +03:00
return ctx ;
}