2008-12-19 04:22:07 +03:00
/*
Unix SMB / CIFS implementation .
Swig interface to ldb .
Copyright ( C ) 2007 - 2008 Jelmer Vernooij < jelmer @ samba . org >
* * 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 3 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 , see < http : //www.gnu.org/licenses/>.
*/
# ifndef _PYLDB_H_
# define _PYLDB_H_
# include <Python.h>
2009-04-23 13:23:06 +04:00
# include <talloc.h>
2008-12-19 04:22:07 +03:00
2008-12-23 07:07:29 +03:00
typedef struct {
PyObject_HEAD
TALLOC_CTX * mem_ctx ;
2010-04-20 09:33:00 +04:00
struct ldb_context * ldb_ctx ;
2008-12-23 07:07:29 +03:00
} PyLdbObject ;
# define PyLdb_AsLdbContext(pyobj) ((PyLdbObject *)pyobj)->ldb_ctx
2008-12-21 02:24:54 +03:00
# define PyLdb_Check(ob) PyObject_TypeCheck(ob, &PyLdb)
2008-12-19 04:22:07 +03:00
2008-12-23 07:07:29 +03:00
typedef struct {
PyObject_HEAD
TALLOC_CTX * mem_ctx ;
2010-04-20 09:33:00 +04:00
struct ldb_dn * dn ;
2008-12-23 07:07:29 +03:00
} PyLdbDnObject ;
2008-12-19 04:22:07 +03:00
PyObject * PyLdbDn_FromDn ( struct ldb_dn * ) ;
2008-12-19 19:08:35 +03:00
bool PyObject_AsDn ( TALLOC_CTX * mem_ctx , PyObject * object , struct ldb_context * ldb_ctx , struct ldb_dn * * dn ) ;
2008-12-23 07:07:29 +03:00
# define PyLdbDn_AsDn(pyobj) ((PyLdbDnObject *)pyobj)->dn
2008-12-19 04:22:07 +03:00
# define PyLdbDn_Check(ob) PyObject_TypeCheck(ob, &PyLdbDn)
2008-12-23 07:07:29 +03:00
typedef struct {
PyObject_HEAD
TALLOC_CTX * mem_ctx ;
2010-04-20 09:33:00 +04:00
struct ldb_message * msg ;
2008-12-23 07:07:29 +03:00
} PyLdbMessageObject ;
2010-11-15 05:53:05 +03:00
PyObject * PyLdbMessage_FromMessage ( struct ldb_message * message ) ;
2008-12-19 04:22:07 +03:00
# define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage)
2008-12-23 07:07:29 +03:00
# define PyLdbMessage_AsMessage(pyobj) ((PyLdbMessageObject *)pyobj)->msg
2008-12-19 04:22:07 +03:00
2008-12-23 07:07:29 +03:00
typedef struct {
PyObject_HEAD
TALLOC_CTX * mem_ctx ;
2010-04-20 09:33:00 +04:00
struct ldb_module * mod ;
2008-12-23 07:07:29 +03:00
} PyLdbModuleObject ;
2008-12-19 04:22:07 +03:00
PyObject * PyLdbModule_FromModule ( struct ldb_module * mod ) ;
2008-12-23 07:07:29 +03:00
# define PyLdbModule_AsModule(pyobj) ((PyLdbModuleObject *)pyobj)->mod
2008-12-19 04:22:07 +03:00
2008-12-23 07:07:29 +03:00
typedef struct {
PyObject_HEAD
TALLOC_CTX * mem_ctx ;
2010-04-20 09:33:00 +04:00
struct ldb_message_element * el ;
2008-12-23 07:07:29 +03:00
} PyLdbMessageElementObject ;
2008-12-19 04:22:07 +03:00
struct ldb_message_element * PyObject_AsMessageElement ( TALLOC_CTX * mem_ctx , PyObject * obj , int flags , const char * name ) ;
2008-12-21 09:34:27 +03:00
PyObject * PyLdbMessageElement_FromMessageElement ( struct ldb_message_element * , TALLOC_CTX * mem_ctx ) ;
2008-12-23 07:07:29 +03:00
# define PyLdbMessageElement_AsMessageElement(pyobj) ((PyLdbMessageElementObject *)pyobj)->el
2008-12-19 19:08:35 +03:00
# define PyLdbMessageElement_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessageElement)
2008-12-23 07:07:29 +03:00
typedef struct {
PyObject_HEAD
TALLOC_CTX * mem_ctx ;
2010-04-20 09:33:00 +04:00
struct ldb_parse_tree * tree ;
2008-12-23 07:07:29 +03:00
} PyLdbTreeObject ;
2008-12-19 19:08:35 +03:00
PyObject * PyLdbTree_FromTree ( struct ldb_parse_tree * ) ;
2008-12-23 07:07:29 +03:00
# define PyLdbTree_AsTree(pyobj) ((PyLdbTreeObject *)pyobj)->tree
2008-12-19 19:08:35 +03:00
2009-04-23 03:21:47 +04:00
# define PyErr_LDB_ERROR_IS_ERR_RAISE(err,ret,ldb) \
2008-12-19 19:08:35 +03:00
if ( ret ! = LDB_SUCCESS ) { \
2009-04-23 03:21:47 +04:00
PyErr_SetLdbError ( err , ret , ldb ) ; \
2008-12-19 19:08:35 +03:00
return NULL ; \
}
2009-04-23 03:21:47 +04:00
/* Picked out of thin air. To do this properly, we should probably have some part of the
* errors in LDB be allocated to bindings ? */
# define LDB_ERR_PYTHON_EXCEPTION 142
2008-12-19 04:22:07 +03:00
# endif /* _PYLDB_H_ */