From fb021305e4bc1175ae0d1960fbafc7eba29ef2f0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Dec 2007 14:28:45 -0600 Subject: r26567: Allow registering new ldb modules from python. (This used to be commit 485db76d8476fce399a9b6cb977cf55ea35ec189) --- source4/lib/ldb/ldb.i | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/ldb.i') diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index 15a49ec9c5..1ed1b45eaf 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -34,6 +34,7 @@ #include "talloc.h" #include "ldb.h" #include "ldb_errors.h" +#include "ldb_private.h" typedef struct ldb_message ldb_msg; typedef struct ldb_context ldb; @@ -425,16 +426,18 @@ PyObject *PyExc_LdbError; * Wrap ldb functions */ + +%typemap(out) ldb_error { + if ($1 != LDB_SUCCESS) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", $1, ldb_strerror($1))); + SWIG_fail; + } + $result = Py_None; +}; + %rename(Ldb) ldb_context; /* Top-level ldb operations */ typedef struct ldb_context { - %typemap(out) ldb_error { - if ($1 != LDB_SUCCESS) { - PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", $1, ldb_strerror($1))); - SWIG_fail; - } - $result = Py_None; - }; %extend { ldb(const char *url=NULL, unsigned int flags = 0, const char *options[] = NULL) @@ -572,3 +575,12 @@ static char *timestring(time_t t) %rename(string_to_time) ldb_string_to_time; time_t ldb_string_to_time(const char *s); + +%typemap(in) const struct ldb_module_ops * { + $1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); + + $1->name = PyObject_GetAttrString($input, "name"); +} + +%rename(register_module) ldb_register_module; +ldb_error ldb_register_module(const struct ldb_module_ops *); -- cgit