summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-04-20 18:14:17 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-06-02 18:05:40 +0200
commit42fa7ec8236fcacdc02a7f3f275cbe01791df43d (patch)
tree28c0dfd071db1d6d59d08269cd613d53bc18beba /source4/lib/ldb
parent4602cc0ac15b6e41158ed3f01da3061693628b60 (diff)
downloadsamba-42fa7ec8236fcacdc02a7f3f275cbe01791df43d.tar.gz
samba-42fa7ec8236fcacdc02a7f3f275cbe01791df43d.tar.bz2
samba-42fa7ec8236fcacdc02a7f3f275cbe01791df43d.zip
Split up Python code a little bit so we don't hav eto link python modules
to each other.
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/pyldb_util.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source4/lib/ldb/pyldb_util.c b/source4/lib/ldb/pyldb_util.c
new file mode 100644
index 0000000000..9f9a0deb8c
--- /dev/null
+++ b/source4/lib/ldb/pyldb_util.c
@@ -0,0 +1,39 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ interface to ldb.
+
+ Copyright (C) 2009 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/>.
+*/
+
+#include "replace.h"
+#include "ldb_private.h"
+#include <Python.h>
+#include "pyldb.h"
+
+void PyErr_SetLdbError(PyObject *error, 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(error,
+ Py_BuildValue(discard_const_p(char, "(i,s)"), ret,
+ ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
+}