From a57b1aa0f1df4fb5ec5a5b38f0505302ae20f001 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 19 Dec 2008 01:22:07 +0000 Subject: Initial work using manual Python bindings for LDB, rather than SWIG-generated ones. --- source4/lib/ldb/pyldb.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 source4/lib/ldb/pyldb.h (limited to 'source4/lib/ldb/pyldb.h') diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h new file mode 100644 index 0000000000..31d13b8237 --- /dev/null +++ b/source4/lib/ldb/pyldb.h @@ -0,0 +1,59 @@ +/* + Unix SMB/CIFS implementation. + + Swig interface to ldb. + + Copyright (C) 2005,2006 Tim Potter + Copyright (C) 2006 Simo Sorce + Copyright (C) 2007-2008 Jelmer Vernooij + + ** 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 . +*/ + +#ifndef _PYLDB_H_ +#define _PYLDB_H_ + +#include +#include +#include +#include + +typedef py_talloc_Object PyLdbObject; +PyAPI_DATA(PyTypeObject) PyLdb; + +typedef py_talloc_Object PyLdbDnObject; +PyAPI_DATA(PyTypeObject) PyLdbDn; +struct ldb_dn *PyLdbDn_AsDn(PyObject *); +PyObject *PyLdbDn_FromDn(struct ldb_dn *); +int PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn); +#define PyLdbDn_Check(ob) PyObject_TypeCheck(ob, &PyLdbDn) + +typedef py_talloc_Object PyLdbMessageObject; +PyAPI_DATA(PyTypeObject) PyLdbMessage; +PyObject *PyLdbMessage_FromMessage(struct ldb_message *message); +struct ldb_message *PyLdbMessage_AsMessage(PyObject *obj); +#define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage) + +typedef py_talloc_Object PyLdbModuleObject; +PyAPI_DATA(PyTypeObject) PyLdbModule; +PyObject *PyLdbModule_FromModule(struct ldb_module *mod); + +typedef py_talloc_Object PyLdbMessageElementObject; +struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, PyObject *obj, int flags, const char *name); + +#endif /* _PYLDB_H_ */ -- cgit From 04bef7fe2ab689a9ab569d5581034e0c02237771 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 19 Dec 2008 16:08:35 +0000 Subject: Fix more tests. --- source4/lib/ldb/pyldb.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/pyldb.h') diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h index 31d13b8237..14989cc5ee 100644 --- a/source4/lib/ldb/pyldb.h +++ b/source4/lib/ldb/pyldb.h @@ -35,12 +35,15 @@ typedef py_talloc_Object PyLdbObject; PyAPI_DATA(PyTypeObject) PyLdb; +PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx); +#define PyLdb_AsLdbContext(pyobj) py_talloc_get_type(pyobj, struct ldb_context) typedef py_talloc_Object PyLdbDnObject; PyAPI_DATA(PyTypeObject) PyLdbDn; struct ldb_dn *PyLdbDn_AsDn(PyObject *); PyObject *PyLdbDn_FromDn(struct ldb_dn *); -int PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn); +bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn); +#define PyLdbDn_AsDn(pyobj) py_talloc_get_type(pyobj, struct ldb_dn) #define PyLdbDn_Check(ob) PyObject_TypeCheck(ob, &PyLdbDn) typedef py_talloc_Object PyLdbMessageObject; @@ -48,12 +51,30 @@ PyAPI_DATA(PyTypeObject) PyLdbMessage; PyObject *PyLdbMessage_FromMessage(struct ldb_message *message); struct ldb_message *PyLdbMessage_AsMessage(PyObject *obj); #define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage) +#define PyLdbMessage_AsMessage(pyobj) py_talloc_get_type(pyobj, struct ldb_message) typedef py_talloc_Object PyLdbModuleObject; PyAPI_DATA(PyTypeObject) PyLdbModule; PyObject *PyLdbModule_FromModule(struct ldb_module *mod); +#define PyLdbModule_AsModule(pyobj) py_talloc_get_type(pyobj, struct ldb_module) typedef py_talloc_Object PyLdbMessageElementObject; +PyAPI_DATA(PyTypeObject) PyLdbMessageElement; struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, PyObject *obj, int flags, const char *name); +PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *); +#define PyLdbMessageElement_AsMessageElement(pyobj) py_talloc_get_type(pyobj, struct ldb_message_element) +#define PyLdbMessageElement_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessageElement) + +typedef py_talloc_Object PyLdbTreeObject; +PyAPI_DATA(PyTypeObject) PyLdbTree; +PyObject *PyLdbTree_FromTree(struct ldb_parse_tree *); +#define PyLdbTree_AsTree(pyobj) py_talloc_get_type(pyobj, struct ldb_parse_tree) + +#define PyErr_LDB_ERROR_IS_ERR_RAISE(ret,ldb) \ + if (ret != LDB_SUCCESS) { \ + PyErr_SetLdbError(ret, ldb); \ + return NULL; \ + } + #endif /* _PYLDB_H_ */ -- cgit