summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/ldb.i19
-rw-r--r--source4/lib/ldb/ldb_wrap.c59
2 files changed, 30 insertions, 48 deletions
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 5569d08ebb..57cb6b5f47 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -106,7 +106,7 @@ typedef int ldb_error;
}
#ifdef SWIGPYTHON
-%typemap(argout) struct ldb_result ** (int i) {
+%typemap(argout,noblock=1) struct ldb_result ** (int i) {
$result = PyList_New((*$1)->count);
for (i = 0; i < (*$1)->count; i++) {
PyList_SetItem($result, i,
@@ -129,7 +129,7 @@ typedef int ldb_error;
}
}
-%typemap(freearg) const char * const *attrs {
+%typemap(freearg,noblock=1) const char * const *attrs {
talloc_free($1);
}
#endif
@@ -331,7 +331,6 @@ typedef struct ldb_message {
return ret;
}
~ldb_msg() { talloc_free($self); }
-
ldb_msg_element *find_element(const char *name);
#ifdef SWIGPYTHON
@@ -393,8 +392,7 @@ static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *
}
%}
-%typemap(in,numinputs=1) (void (*debug)(void *context, enum ldb_debug_level level, const char *fmt, va_list ap),
- void *context) {
+%typemap(in,numinputs=1,noblock=1) (void (*debug)(void *context, enum ldb_debug_level level, const char *fmt, va_list ap), void *context) {
$1 = py_ldb_debug;
/* FIXME: Should be decreased somewhere as well. Perhaps register a
destructor and tie it to the ldb context ? */
@@ -485,6 +483,7 @@ typedef struct ldb_context {
PyObject *key, *value;
ldb_msg_element *msgel;
ldb_msg *msg = NULL;
+
if (PyDict_Check(py_msg)) {
msg = ldb_msg_new(NULL);
msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
@@ -516,7 +515,7 @@ typedef struct ldb_context {
return LDB_ERR_OTHER;
}
- ret = ldb_add($self,msg);
+ ret = ldb_add($self, msg);
talloc_free(msg);
return ret;
@@ -542,9 +541,9 @@ typedef struct ldb_context {
ldb_error transaction_cancel();
#ifdef SWIGPYTHON
- %typemap(in,numinputs=0) struct ldb_result **result_as_bool (struct ldb_result *tmp) { $1 = &tmp; }
- %typemap(argout) struct ldb_result **result_as_bool { $result = ((*$1)->count > 0)?Py_True:Py_False; }
- %typemap(freearg) struct ldb_result **result_as_bool { talloc_free(*$1); }
+ %typemap(in,numinputs=0,noblock=1) struct ldb_result **result_as_bool (struct ldb_result *tmp) { $1 = &tmp; }
+ %typemap(argout,noblock=1) struct ldb_result **result_as_bool { $result = ((*$1)->count > 0)?Py_True:Py_False; }
+ %typemap(freearg,noblock=1) struct ldb_result **result_as_bool { talloc_free(*$1); }
ldb_error __contains__(ldb_dn *dn, struct ldb_result **result_as_bool)
{
return ldb_search($self, dn, LDB_SCOPE_BASE, NULL, NULL,
@@ -597,7 +596,7 @@ 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 * {
+%typemap(in,noblock=1) const struct ldb_module_ops * {
$1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops);
$1->name = (char *)PyObject_GetAttrString($input, (char *)"name");
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 5f2f73e749..7368d7f058 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -3040,6 +3040,7 @@ SWIGINTERN ldb_error ldb_add__SWIG_1(ldb *self,PyObject *py_msg){
PyObject *key, *value;
ldb_msg_element *msgel;
ldb_msg *msg = NULL;
+
if (PyDict_Check(py_msg)) {
msg = ldb_msg_new(NULL);
msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
@@ -3071,7 +3072,7 @@ SWIGINTERN ldb_error ldb_add__SWIG_1(ldb *self,PyObject *py_msg){
return 80;
}
- ret = ldb_add(self,msg);
+ ret = ldb_add(self, msg);
talloc_free(msg);
return ret;
@@ -4358,26 +4359,20 @@ SWIGINTERN PyObject *_wrap_Ldb_search(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_fail;
}
resultobj = Py_None;
- {
- resultobj = PyList_New((*arg6)->count);
- for (i6 = 0; i6 < (*arg6)->count; i6++) {
- PyList_SetItem(resultobj, i6,
- SWIG_NewPointerObj((*arg6)->msgs[i6], SWIGTYPE_p_ldb_message, 0)
- );
- }
+ resultobj = PyList_New((*arg6)->count);
+ for (i6 = 0; i6 < (*arg6)->count; i6++) {
+ PyList_SetItem(resultobj, i6,
+ SWIG_NewPointerObj((*arg6)->msgs[i6], SWIGTYPE_p_ldb_message, 0)
+ );
}
talloc_free(arg2);
if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
- {
- talloc_free(arg5);
- }
+ talloc_free(arg5);
return resultobj;
fail:
talloc_free(arg2);
if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
- {
- talloc_free(arg5);
- }
+ talloc_free(arg5);
return NULL;
}
@@ -4833,13 +4828,11 @@ SWIGINTERN PyObject *_wrap_Ldb_set_debug(PyObject *SWIGUNUSEDPARM(self), PyObjec
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_set_debug" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- arg2 = py_ldb_debug;
- /* FIXME: Should be decreased somewhere as well. Perhaps register a
- destructor and tie it to the ldb context ? */
- Py_INCREF(obj1);
- arg3 = obj1;
- }
+ arg2 = py_ldb_debug;
+ /* FIXME: Should be decreased somewhere as well. Perhaps register a
+ destructor and tie it to the ldb context ? */
+ Py_INCREF(obj1);
+ arg3 = obj1;
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"ldb context must be non-NULL");
@@ -5051,9 +5044,7 @@ SWIGINTERN PyObject *_wrap_Ldb___contains__(PyObject *SWIGUNUSEDPARM(self), PyOb
(char *) "self",(char *) "dn", NULL
};
- {
- arg3 = &tmp3;
- }
+ arg3 = &tmp3;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb___contains__",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
@@ -5072,19 +5063,13 @@ SWIGINTERN PyObject *_wrap_Ldb___contains__(PyObject *SWIGUNUSEDPARM(self), PyOb
SWIG_fail;
}
resultobj = Py_None;
- {
- resultobj = ((*arg3)->count > 0)?Py_True:Py_False;
- }
+ resultobj = ((*arg3)->count > 0)?Py_True:Py_False;
talloc_free(arg2);
- {
- talloc_free(*arg3);
- }
+ talloc_free(*arg3);
return resultobj;
fail:
talloc_free(arg2);
- {
- talloc_free(*arg3);
- }
+ talloc_free(*arg3);
return NULL;
}
@@ -5231,11 +5216,9 @@ SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObj
};
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:register_module",kwnames,&obj0)) SWIG_fail;
- {
- arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops);
-
- arg1->name = (char *)PyObject_GetAttrString(obj0, (char *)"name");
- }
+ arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops);
+
+ arg1->name = (char *)PyObject_GetAttrString(obj0, (char *)"name");
result = ldb_register_module((struct ldb_module_ops const *)arg1);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_strerror(result)));