2010-11-18 14:20:56 +03:00
/*
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
2010-11-18 14:20:56 +03:00
2004-11-15 14:42:17 +03:00
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
2007-07-10 06:46:15 +04:00
version 3 of the License , or ( at your option ) any later version .
2004-11-15 14:42:17 +03:00
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
2007-07-10 07:42:26 +04:00
License along with this library ; if not , see < http : //www.gnu.org/licenses/>.
2004-11-15 14:42:17 +03:00
*/
/*
* Name : ldb
*
* Component : ldb skel module
*
* Description : example module
*
* Author : Simo Sorce
*/
2010-11-01 15:36:42 +03:00
# include "replace.h"
# include "system/filesys.h"
# include "system/time.h"
2009-01-30 02:39:30 +03:00
# include "ldb_module.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-09-18 22:49:06 +04:00
char * some_private_data ;
2005-05-22 14:27:51 +04:00
} ;
2004-11-15 14:42:17 +03:00
/* search */
2006-01-05 07:56:19 +03:00
static int skel_search ( struct ldb_module * module , struct ldb_request * req )
2004-11-15 14:42:17 +03:00
{
2006-01-05 07:56:19 +03:00
return ldb_next_request ( module , req ) ;
2004-11-15 14:42:17 +03:00
}
2006-01-05 07:56:19 +03:00
/* add */
static int skel_add ( struct ldb_module * module , struct ldb_request * req ) {
return ldb_next_request ( module , req ) ;
2004-11-15 14:42:17 +03:00
}
2006-01-05 07:56:19 +03:00
/* modify */
static int skel_modify ( struct ldb_module * module , struct ldb_request * req )
2004-11-15 14:42:17 +03:00
{
2006-01-05 07:56:19 +03:00
return ldb_next_request ( module , req ) ;
2004-11-15 14:42:17 +03:00
}
2006-01-05 07:56:19 +03:00
/* delete */
static int skel_delete ( struct ldb_module * module , struct ldb_request * req )
2004-11-15 14:42:17 +03:00
{
2006-01-05 07:56:19 +03:00
return ldb_next_request ( module , req ) ;
2004-11-15 14:42:17 +03:00
}
2006-01-05 07:56:19 +03:00
/* rename */
static int skel_rename ( struct ldb_module * module , struct ldb_request * req )
2004-11-15 14:42:17 +03:00
{
2006-01-05 07:56:19 +03:00
return ldb_next_request ( module , req ) ;
2004-11-15 14:42:17 +03:00
}
2005-09-17 23:25:50 +04:00
/* start a transaction */
static int skel_start_trans ( struct ldb_module * module )
2004-11-21 18:51:54 +03:00
{
2005-09-17 23:25:50 +04:00
return ldb_next_start_trans ( module ) ;
2004-11-21 18:51:54 +03:00
}
2005-09-17 23:25:50 +04:00
/* end a transaction */
2005-09-24 19:42:15 +04:00
static int skel_end_trans ( struct ldb_module * module )
2004-11-21 18:51:54 +03:00
{
2005-09-24 19:42:15 +04:00
return ldb_next_end_trans ( module ) ;
}
/* delete a transaction */
static int skel_del_trans ( struct ldb_module * module )
{
return ldb_next_del_trans ( module ) ;
2004-11-21 18:51:54 +03:00
}
2006-05-24 11:34:11 +04:00
static int skel_destructor ( struct ldb_module * ctx )
2005-02-27 14:35:47 +03:00
{
2009-01-30 02:39:30 +03:00
struct private_data * data ;
data = talloc_get_type ( ldb_module_get_private ( ctx ) , struct private_data ) ;
2005-02-27 14:35:47 +03:00
/* put your clean-up functions here */
2005-09-18 22:49:06 +04:00
if ( data - > some_private_data ) talloc_free ( data - > some_private_data ) ;
2009-01-30 02:39:30 +03:00
2005-02-27 14:35:47 +03:00
return 0 ;
}
2005-11-08 03:11:45 +03:00
static int skel_request ( struct ldb_module * module , struct ldb_request * req )
{
2006-05-29 05:30:02 +04:00
return ldb_next_request ( module , req ) ;
2005-11-08 03:11:45 +03:00
}
2007-02-13 06:52:57 +03:00
static int skel_init ( struct ldb_module * module )
2006-01-06 19:12:45 +03:00
{
2009-01-30 02:39:30 +03:00
struct ldb_context * ldb ;
2005-05-22 14:27:51 +04:00
struct private_data * data ;
2004-11-15 14:42:17 +03:00
2009-01-30 02:39:30 +03:00
ldb = ldb_module_get_ctx ( module ) ;
2007-02-13 06:52:57 +03:00
data = talloc ( module , struct private_data ) ;
2005-05-22 14:27:51 +04:00
if ( data = = NULL ) {
2009-01-30 02:39:30 +03:00
ldb_oom ( ldb ) ;
2007-02-13 06:52:57 +03:00
return LDB_ERR_OPERATIONS_ERROR ;
2005-05-22 14:27:51 +04:00
}
2005-09-18 22:49:06 +04:00
data - > some_private_data = NULL ;
2009-01-30 02:39:30 +03:00
ldb_module_set_private ( module , data ) ;
2005-05-22 14:27:51 +04:00
2007-02-13 06:52:57 +03:00
talloc_set_destructor ( module , skel_destructor ) ;
2005-02-27 14:35:47 +03:00
2007-02-13 06:52:57 +03:00
return ldb_next_init ( module ) ;
2006-03-02 19:32:53 +03:00
}
2010-11-01 06:59:28 +03:00
static const struct ldb_module_ops ldb_skel_module_ops = {
2006-03-02 19:32:53 +03:00
. name = " skel " ,
. init_context = skel_init ,
2006-05-29 05:30:02 +04:00
. search = skel_search ,
. add = skel_add ,
. modify = skel_modify ,
. del = skel_delete ,
. rename = skel_rename ,
2006-03-02 19:32:53 +03:00
. request = skel_request ,
. start_transaction = skel_start_trans ,
. end_transaction = skel_end_trans ,
. del_transaction = skel_del_trans ,
} ;
2010-11-01 06:59:28 +03:00
int ldb_skel_init ( const char * version )
{
2010-11-01 14:30:23 +03:00
LDB_MODULE_CHECK_VERSION ( version ) ;
2010-11-01 06:59:28 +03:00
return ldb_register_module ( & ldb_skel_module_ops ) ;
}