diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-04-23 01:21:47 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-06-02 18:05:41 +0200 |
commit | 6ace18904d638f1fb49c31041ba23353d97b40cb (patch) | |
tree | 5f9d99d9762fe435355dca79f430166b666a9060 /source4/lib/ldb | |
parent | fe2b04b4bba6585ee5377d44b8e2627d32d404c4 (diff) | |
download | samba-6ace18904d638f1fb49c31041ba23353d97b40cb.tar.gz samba-6ace18904d638f1fb49c31041ba23353d97b40cb.tar.bz2 samba-6ace18904d638f1fb49c31041ba23353d97b40cb.zip |
Fix more unresolved symbols.
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/ldb.mk | 7 | ||||
-rw-r--r-- | source4/lib/ldb/pyldb.c | 64 | ||||
-rw-r--r-- | source4/lib/ldb/pyldb.h | 17 | ||||
-rw-r--r-- | source4/lib/ldb/python.mk | 9 |
4 files changed, 49 insertions, 48 deletions
diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 0589baf5d4..a9a6dad46d 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -67,8 +67,11 @@ build-python:: ldb.$(SHLIBEXT) pyldb.o: $(ldbdir)/pyldb.c $(CC) $(PICFLAG) -c $(ldbdir)/pyldb.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` -ldb.$(SHLIBEXT): pyldb.o - $(SHLD) $(SHLD_FLAGS) -o ldb.$(SHLIBEXT) pyldb.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags` +pyldb_util.o: $(ldbdir)/pyldb_util.c + $(CC) $(PICFLAG) -c $(ldbdir)/pyldb_util.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` + +ldb.$(SHLIBEXT): pyldb.o pyldb_util.o + $(SHLD) $(SHLD_FLAGS) -o ldb.$(SHLIBEXT) pyldb.o pyldb_util.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags` install-python:: build-python mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index bceda05e4f..bfa152b346 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - Swig interface to ldb. + Python interface to ldb. Copyright (C) 2005,2006 Tim Potter <tpot@samba.org> Copyright (C) 2006 Simo Sorce <idra@samba.org> @@ -41,25 +41,19 @@ typedef intargfunc ssizeargfunc; #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif -/* 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 - static PyObject *PyExc_LdbError; -void PyErr_SetLdbError(int ret, struct ldb_context *ldb_ctx) -{ - if (ret == LDB_ERR_PYTHON_EXCEPTION) - return; /* Python exception should already be set, just keep that */ - PyErr_SetObject(PyExc_LdbError, Py_BuildValue(discard_const_p(char, "(i,s)"), - ret, ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); -} +PyAPI_DATA(PyTypeObject) PyLdbMessage; +PyAPI_DATA(PyTypeObject) PyLdbModule; +PyAPI_DATA(PyTypeObject) PyLdbDn; +PyAPI_DATA(PyTypeObject) PyLdb; +PyAPI_DATA(PyTypeObject) PyLdbMessageElement; +PyAPI_DATA(PyTypeObject) PyLdbTree; static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx, struct ldb_message_element *el, struct ldb_val *val) { - const struct ldb_schema_attribute *a; struct ldb_val new_val; TALLOC_CTX *mem_ctx = talloc_new(NULL); PyObject *ret; @@ -390,7 +384,7 @@ static PyObject *py_ldb_set_debug(PyLdbObject *self, PyObject *args) Py_INCREF(cb); /* FIXME: Where do we DECREF cb ? */ - PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_set_debug(self->ldb_ctx, py_ldb_debug, cb), PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ldb_set_debug(self->ldb_ctx, py_ldb_debug, cb), PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } @@ -419,25 +413,25 @@ static PyObject *py_ldb_set_modules_dir(PyTypeObject *self, PyObject *args) static PyObject *py_ldb_transaction_start(PyLdbObject *self) { - PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_transaction_start(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ldb_transaction_start(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } static PyObject *py_ldb_transaction_commit(PyLdbObject *self) { - PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_transaction_commit(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ldb_transaction_commit(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } static PyObject *py_ldb_transaction_cancel(PyLdbObject *self) { - PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_transaction_cancel(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ldb_transaction_cancel(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } static PyObject *py_ldb_setup_wellknown_attributes(PyLdbObject *self) { - PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_setup_wellknown_attributes(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ldb_setup_wellknown_attributes(PyLdb_AsLdbContext(self)), PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } @@ -529,7 +523,7 @@ static int py_ldb_init(PyLdbObject *self, PyObject *args, PyObject *kwargs) if (url != NULL) { ret = ldb_connect(ldb, url, flags, options); if (ret != LDB_SUCCESS) { - PyErr_SetLdbError(ret, ldb); + PyErr_SetLdbError(PyExc_LdbError, ret, ldb); return -1; } } @@ -582,7 +576,7 @@ static PyObject *py_ldb_connect(PyLdbObject *self, PyObject *args, PyObject *kwa ret = ldb_connect(PyLdb_AsLdbContext(self), url, flags, options); talloc_free(options); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } @@ -600,7 +594,7 @@ static PyObject *py_ldb_modify(PyLdbObject *self, PyObject *args) } ret = ldb_modify(PyLdb_AsLdbContext(self), PyLdbMessage_AsMessage(py_msg)); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } @@ -657,7 +651,7 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args) } ret = ldb_add(PyLdb_AsLdbContext(self), msg); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } @@ -677,7 +671,7 @@ static PyObject *py_ldb_delete(PyLdbObject *self, PyObject *args) return NULL; ret = ldb_delete(ldb, dn); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, ldb); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb); Py_RETURN_NONE; } @@ -699,7 +693,7 @@ static PyObject *py_ldb_rename(PyLdbObject *self, PyObject *args) return NULL; ret = ldb_rename(ldb, dn1, dn2); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, ldb); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb); Py_RETURN_NONE; } @@ -725,7 +719,7 @@ static PyObject *py_ldb_schema_attribute_add(PyLdbObject *self, PyObject *args) ret = ldb_schema_attribute_add(PyLdb_AsLdbContext(self), attribute, flags, syntax); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, PyLdb_AsLdbContext(self)); Py_RETURN_NONE; } @@ -860,7 +854,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar if (ret != LDB_SUCCESS) { talloc_free(res); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, ldb_ctx); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb_ctx); return NULL; } @@ -874,7 +868,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar if (ret != LDB_SUCCESS) { talloc_free(res); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, ldb_ctx); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb_ctx); return NULL; } @@ -1044,7 +1038,7 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj) ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) { - PyErr_SetLdbError(ret, ldb_ctx); + PyErr_SetLdbError(PyExc_LdbError, ret, ldb_ctx); return -1; } @@ -1140,12 +1134,12 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P ret = ldb_build_search_req(&req, mod->ldb, NULL, PyLdbDn_AsDn(py_base), scope, NULL /* expr */, py_attrs == Py_None?NULL:PyList_AsStringList(req, py_attrs, "attrs"), NULL /* controls */, NULL, NULL, NULL); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, mod->ldb); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb); ret = mod->ops->search(mod, req); talloc_free(req); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, mod->ldb); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb); return PyLdbResult_FromResult(req->op.search.res); } @@ -1168,7 +1162,7 @@ static PyObject *py_ldb_module_add(PyLdbModuleObject *self, PyObject *args) mod = PyLdbModule_AsModule(self); ret = mod->ops->add(mod, req); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, mod->ldb); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb); Py_RETURN_NONE; } @@ -1190,7 +1184,7 @@ static PyObject *py_ldb_module_modify(PyLdbModuleObject *self, PyObject *args) mod = PyLdbModule_AsModule(self); ret = mod->ops->modify(mod, req); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, mod->ldb); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb); Py_RETURN_NONE; } @@ -1210,7 +1204,7 @@ static PyObject *py_ldb_module_delete(PyLdbModuleObject *self, PyObject *args) ret = PyLdbModule_AsModule(self)->ops->del(PyLdbModule_AsModule(self), req); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, NULL); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, NULL); Py_RETURN_NONE; } @@ -1232,7 +1226,7 @@ static PyObject *py_ldb_module_rename(PyLdbModuleObject *self, PyObject *args) ret = PyLdbModule_AsModule(self)->ops->rename(PyLdbModule_AsModule(self), req); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, NULL); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, NULL); Py_RETURN_NONE; } @@ -2045,7 +2039,7 @@ static PyObject *py_register_module(PyObject *module, PyObject *args) ret = ldb_register_module(ops); - PyErr_LDB_ERROR_IS_ERR_RAISE(ret, NULL); + PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, NULL); Py_RETURN_NONE; } diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h index 731911a387..931dd7eeae 100644 --- a/source4/lib/ldb/pyldb.h +++ b/source4/lib/ldb/pyldb.h @@ -34,7 +34,6 @@ typedef struct { TALLOC_CTX *mem_ctx; } PyLdbObject; -PyAPI_DATA(PyTypeObject) PyLdb; PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx); #define PyLdb_AsLdbContext(pyobj) ((PyLdbObject *)pyobj)->ldb_ctx #define PyLdb_Check(ob) PyObject_TypeCheck(ob, &PyLdb) @@ -45,7 +44,6 @@ typedef struct { TALLOC_CTX *mem_ctx; } PyLdbDnObject; -PyAPI_DATA(PyTypeObject) PyLdbDn; PyObject *PyLdbDn_FromDn(struct ldb_dn *); bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn); #define PyLdbDn_AsDn(pyobj) ((PyLdbDnObject *)pyobj)->dn @@ -56,8 +54,6 @@ typedef struct { struct ldb_message *msg; TALLOC_CTX *mem_ctx; } PyLdbMessageObject; -PyAPI_DATA(PyTypeObject) PyLdbMessage; -PyObject *PyLdbMessage_FromMessage(struct ldb_message *message); #define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage) #define PyLdbMessage_AsMessage(pyobj) ((PyLdbMessageObject *)pyobj)->msg @@ -66,7 +62,7 @@ typedef struct { struct ldb_module *mod; TALLOC_CTX *mem_ctx; } PyLdbModuleObject; -PyAPI_DATA(PyTypeObject) PyLdbModule; +PyObject *PyLdbMessage_FromMessage(struct ldb_message *message); PyObject *PyLdbModule_FromModule(struct ldb_module *mod); #define PyLdbModule_AsModule(pyobj) ((PyLdbModuleObject *)pyobj)->mod @@ -75,7 +71,6 @@ typedef struct { struct ldb_message_element *el; TALLOC_CTX *mem_ctx; } 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 *, TALLOC_CTX *mem_ctx); #define PyLdbMessageElement_AsMessageElement(pyobj) ((PyLdbMessageElementObject *)pyobj)->el @@ -86,16 +81,18 @@ typedef struct { struct ldb_parse_tree *tree; TALLOC_CTX *mem_ctx; } PyLdbTreeObject; -PyAPI_DATA(PyTypeObject) PyLdbTree; PyObject *PyLdbTree_FromTree(struct ldb_parse_tree *); #define PyLdbTree_AsTree(pyobj) ((PyLdbTreeObject *)pyobj)->tree -void PyErr_SetLdbError(int ret, struct ldb_context *ldb_ctx); -#define PyErr_LDB_ERROR_IS_ERR_RAISE(ret,ldb) \ +void PyErr_SetLdbError(PyObject *exctype, int ret, struct ldb_context *ldb_ctx); +#define PyErr_LDB_ERROR_IS_ERR_RAISE(err,ret,ldb) \ if (ret != LDB_SUCCESS) { \ - PyErr_SetLdbError(ret, ldb); \ + PyErr_SetLdbError(err, ret, ldb); \ return NULL; \ } +/* 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 #endif /* _PYLDB_H_ */ diff --git a/source4/lib/ldb/python.mk b/source4/lib/ldb/python.mk index 6cc6d2e90e..90f62c9040 100644 --- a/source4/lib/ldb/python.mk +++ b/source4/lib/ldb/python.mk @@ -1,6 +1,13 @@ [PYTHON::pyldb] LIBRARY_REALNAME = ldb.$(SHLIBEXT) PUBLIC_DEPENDENCIES = LIBLDB PYTALLOC +PRIVATE_DEPENDENCIES = pyldb_util -pyldb_OBJ_FILES = $(ldbsrcdir)/pyldb.o +pyldb_OBJ_FILES = $(ldbsrcdir)/pyldb.o +$(pyldb_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir)/include + +[SUBSYSTEM::pyldb_util] +PUBLIC_DEPENDENCIES = LIBPYTHON + +pyldb_util_OBJ_FILES = $(ldbsrcdir)/pyldb_util.o $(pyldb_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir)/include |