summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb.i
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-11-25 14:26:16 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:46:08 +0100
commit3023afce68684b5c256c1951adb62f255e00c7bc (patch)
tree28bb6aa12110252c6d7d1b1dba955472735cf6d1 /source4/lib/ldb/ldb.i
parent2be2505c542278face921b595ff3659eb982dfd2 (diff)
downloadsamba-3023afce68684b5c256c1951adb62f255e00c7bc.tar.gz
samba-3023afce68684b5c256c1951adb62f255e00c7bc.tar.bz2
samba-3023afce68684b5c256c1951adb62f255e00c7bc.zip
r26112: Do proper error checking in __contains__.
(This used to be commit b67cc409fa5aa931b0847b7d3bdd2edf72daf88d)
Diffstat (limited to 'source4/lib/ldb/ldb.i')
-rw-r--r--source4/lib/ldb/ldb.i26
1 files changed, 8 insertions, 18 deletions
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index b37082af38..3b7a949fb7 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -29,8 +29,6 @@
%{
-/* Include headers */
-
#include <stdint.h>
#include <stdbool.h>
#include "talloc.h"
@@ -80,10 +78,6 @@ typedef int ldb_error;
"Message can not be None");
}
-/*
- * Wrap a small bit of talloc
- */
-
/*
* Wrap struct ldb_val
*/
@@ -133,7 +127,6 @@ typedef int ldb_error;
//talloc_free($1);
}
-
/*
* Wrap struct ldb_result
*/
@@ -413,8 +406,8 @@ 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) {
$1 = py_ldb_debug;
- /* FIXME: Should be decreased somewhere as well. Perhaps register a destructor and
- tie it to the ldb context ? */
+ /* FIXME: Should be decreased somewhere as well. Perhaps register a
+ destructor and tie it to the ldb context ? */
Py_INCREF($input);
$2 = $input;
}
@@ -518,16 +511,13 @@ fail:
ldb_error transaction_cancel();
#ifdef SWIGPYTHON
- bool __contains__(ldb_dn *dn)
+ %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); }
+ ldb_error __contains__(ldb_dn *dn, struct ldb_result **result_as_bool)
{
- struct ldb_result *result;
-
- int ret = ldb_search($self, dn, LDB_SCOPE_BASE, NULL, NULL,
- &result);
-
- /* FIXME: Check ret and set exception if necessary */
-
- return result->count > 0;
+ return ldb_search($self, dn, LDB_SCOPE_BASE, NULL, NULL,
+ result_as_bool);
}
PyObject *parse_ldif(const char *s)