[SCM] Samba Shared Repository - branch master updated - bd41b4579c26f40f55811b332874ddeca3478e24

Jelmer Vernooij jelmer at samba.org
Sat Dec 20 23:53:54 GMT 2008


The branch, master has been updated
       via  bd41b4579c26f40f55811b332874ddeca3478e24 (commit)
       via  c1a9b68623a663c36451df31aa44fe5f0e22af17 (commit)
       via  64419f47daa3d28587fd29f5c4217755acac7e4f (commit)
       via  40510348299e3b7b5bcebdb39072f2a44316c806 (commit)
       via  13fa639a29a3e79d825a9b75ac507285e39ff364 (commit)
       via  0d585a67ed469a0657ae8c40098f5b862e8e4084 (commit)
       via  94ed43390cce2e4a09af9e0f94797852c0075863 (commit)
       via  5688f9b13e2e58b7ed945301390188c2b40c4d60 (commit)
       via  759a3bcc88230c5232b748bb8f5a0c6e0cce128c (commit)
       via  04bef7fe2ab689a9ab569d5581034e0c02237771 (commit)
       via  7f4e4df58de8878b43ff104a70a89b44690534a3 (commit)
       via  263036a798b4c431f03dae20d33f90585d2b0cab (commit)
       via  e0672ae29bcd345bdf0fec96844f658ffd941039 (commit)
       via  a57b1aa0f1df4fb5ec5a5b38f0505302ae20f001 (commit)
      from  42b7762f9b69b543038ad1bb754e3d9a813704db (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bd41b4579c26f40f55811b332874ddeca3478e24
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Dec 21 00:53:06 2008 +0100

    Avoid linking in all Python modules to the samba binaries - we can just let Python dlopen() them.

commit c1a9b68623a663c36451df31aa44fe5f0e22af17
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Dec 21 00:37:31 2008 +0100

    Create and use convenience function for creating new talloc-wrapping Python Objects, support subtypes of DCE/RPC interfaces properly

commit 64419f47daa3d28587fd29f5c4217755acac7e4f
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Dec 21 00:24:54 2008 +0100

    Implement some of the stubs in misc python module.

commit 40510348299e3b7b5bcebdb39072f2a44316c806
Merge: 13fa639a29a3e79d825a9b75ac507285e39ff364 42b7762f9b69b543038ad1bb754e3d9a813704db
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Dec 21 00:11:50 2008 +0100

    Merge branch 'master' of ssh://git.samba.org/data/git/samba

commit 13fa639a29a3e79d825a9b75ac507285e39ff364
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Dec 20 23:38:30 2008 +0100

    Use plain C implementation for misc Python module rather than SWIG.

commit 0d585a67ed469a0657ae8c40098f5b862e8e4084
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Dec 20 23:00:23 2008 +0100

    Support subtypes of ldb.Ldb.

commit 94ed43390cce2e4a09af9e0f94797852c0075863
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Dec 20 22:21:39 2008 +0100

    Fix all pyldb tests except for modules.

commit 5688f9b13e2e58b7ed945301390188c2b40c4d60
Merge: 759a3bcc88230c5232b748bb8f5a0c6e0cce128c ec80992ef5b54c443e41ebb91e793384907e68ba
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Dec 20 21:21:19 2008 +0100

    Merge branch 'master' of ssh://git.samba.org/data/git/samba

commit 759a3bcc88230c5232b748bb8f5a0c6e0cce128c
Merge: 9617a3945b804bf2d1409285df2a7add12690063 04bef7fe2ab689a9ab569d5581034e0c02237771
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 19 23:55:45 2008 +0100

    Merge branch 'pyregistry' of git://git.samba.org/jelmer/samba
    
    Conflicts:
    	source4/lib/ldb/ldb_wrap.c

commit 04bef7fe2ab689a9ab569d5581034e0c02237771
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 19 16:08:35 2008 +0000

    Fix more tests.

commit 7f4e4df58de8878b43ff104a70a89b44690534a3
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 19 13:41:44 2008 +0000

    Port over more functionality to new SWIGless Python module.

commit 263036a798b4c431f03dae20d33f90585d2b0cab
Merge: e0672ae29bcd345bdf0fec96844f658ffd941039 f87da49830960aebe4ffa551e7e1f16330d28cca
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 19 12:03:17 2008 +0000

    Merge branch 'master' of ssh://git.samba.org/data/git/samba into pyregistry

commit e0672ae29bcd345bdf0fec96844f658ffd941039
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 19 01:24:00 2008 +0000

    Remove swig support from standalone ldb build.

commit a57b1aa0f1df4fb5ec5a5b38f0505302ae20f001
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 19 01:22:07 2008 +0000

    Initial work using manual Python bindings for LDB, rather than SWIG-generated ones.

-----------------------------------------------------------------------

Summary of changes:
 lib/talloc/pytalloc.h                       |    6 +-
 pidl/lib/Parse/Pidl/Samba4/Python.pm        |    7 +-
 source4/build/smb_build/input.pm            |    2 +-
 source4/lib/ldb/Makefile.in                 |    1 -
 source4/lib/ldb/autogen.sh                  |    2 -
 source4/lib/ldb/ldb.i                       | 1289 -----
 source4/lib/ldb/ldb.mk                      |   17 +-
 source4/lib/ldb/ldb.py                      |  508 --
 source4/lib/ldb/ldb_wrap.c                  | 7531 ---------------------------
 source4/lib/ldb/pyldb.c                     | 2040 ++++++++
 source4/lib/ldb/pyldb.h                     |   81 +
 source4/lib/ldb/python.mk                   |   10 +-
 source4/lib/ldb/rules.mk                    |    5 -
 source4/lib/ldb/tests/python/api.py         |   23 +-
 source4/librpc/config.mk                    |    2 +-
 source4/param/config.mk                     |    2 +-
 source4/param/param.i                       |    3 +
 source4/param/param.py                      |    1 +
 source4/param/param_wrap.c                  |   45 +
 source4/param/provision.c                   |    4 +-
 source4/scripting/python/config.mk          |   10 +-
 source4/scripting/python/misc.i             |  121 -
 source4/scripting/python/misc.py            |  123 -
 source4/scripting/python/misc_wrap.c        | 3986 --------------
 source4/scripting/python/pymisc.c           |  273 +
 source4/scripting/python/samba/provision.py |    2 +-
 26 files changed, 2485 insertions(+), 13609 deletions(-)
 delete mode 100644 source4/lib/ldb/ldb.i
 delete mode 100644 source4/lib/ldb/ldb.py
 delete mode 100644 source4/lib/ldb/ldb_wrap.c
 create mode 100644 source4/lib/ldb/pyldb.c
 create mode 100644 source4/lib/ldb/pyldb.h
 delete mode 100644 source4/scripting/python/misc.i
 delete mode 100644 source4/scripting/python/misc.py
 delete mode 100644 source4/scripting/python/misc_wrap.c
 create mode 100644 source4/scripting/python/pymisc.c


Changeset truncated at 500 lines:

diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index aad5840..e6745f9 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -21,6 +21,7 @@
 #define _PY_TALLOC_H_
 
 #include <Python.h>
+#include <talloc.h>
 
 typedef struct {
 	PyObject_HEAD
@@ -36,8 +37,7 @@ void py_talloc_dealloc(PyObject* self);
 
 /* FIXME: Call PyErr_SetString(PyExc_TypeError, "expected " __STR(type) ") 
  * when talloc_get_type() returns NULL. */
-#define py_talloc_get_type(py_obj, type) \
-	talloc_get_type(py_talloc_get_ptr(py_obj), type)
+#define py_talloc_get_type(py_obj, type) (talloc_get_type(py_talloc_get_ptr(py_obj), type))
 
 #define py_talloc_get_ptr(py_obj) ((py_talloc_Object *)py_obj)->ptr
 #define py_talloc_get_mem_ctx(py_obj)  ((py_talloc_Object *)py_obj)->talloc_ctx
@@ -48,4 +48,6 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *
 /* Sane default implementation of reprfunc. */
 PyObject *py_talloc_default_repr(PyObject *py_obj);
 
+#define py_talloc_new(type, typeobj) py_talloc_import(typeobj, talloc_zero(NULL, type))
+
 #endif /* _PY_TALLOC_H_ */
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 15dbd67..120a35a 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -224,8 +224,7 @@ sub PythonStruct($$$$$$)
 	$self->pidl("static PyObject *py_$name\_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
 	$self->pidl("{");
 	$self->indent;
-	$self->pidl("$cname *ret = talloc_zero(NULL, $cname);");
-	$self->pidl("return py_talloc_import(type, ret);");
+	$self->pidl("return py_talloc_new($cname, type);");
 	$self->deindent;
 	$self->pidl("}");
 	$self->pidl("");
@@ -677,7 +676,7 @@ sub Interface($$$)
 		$self->pidl("};");
 		$self->pidl("");
 
-		$self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
+		$self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
 		$self->pidl("{");
 		$self->indent;
 		$self->pidl("dcerpc_InterfaceObject *ret;");
@@ -728,7 +727,7 @@ sub Interface($$$)
 		$self->deindent;
 		$self->pidl("}");
 
-		$self->pidl("ret = PyObject_New(dcerpc_InterfaceObject, &$interface->{NAME}_InterfaceType);");
+		$self->pidl("ret = PyObject_New(dcerpc_InterfaceObject, type);");
 		$self->pidl("");
 		$self->pidl("event_ctx = event_context_init(mem_ctx);");
 		$self->pidl("");
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 1696a36..df9a525 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -108,7 +108,7 @@ sub check_module($$$)
 		push (@{$mod->{PUBLIC_DEPENDENCIES}}, $mod->{SUBSYSTEM});
 		add_libreplace($mod);
 	} 
-	if (grep(/MERGED_OBJ/, @{$mod->{OUTPUT_TYPE}})) {
+	if (grep(/MERGED_OBJ/, @{$mod->{OUTPUT_TYPE}}) and $mod->{TYPE} ne "PYTHON") {
 		push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
 		push (@{$INPUT->{$mod->{SUBSYSTEM}}{PRIVATE_DEPENDENCIES}}, $mod->{NAME});
 	}
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in
index 8d95dae..d97ca8b 100644
--- a/source4/lib/ldb/Makefile.in
+++ b/source4/lib/ldb/Makefile.in
@@ -17,7 +17,6 @@ builddir = @builddir@
 sharedbuilddir = @sharedbuilddir@
 INSTALLCMD = @INSTALL@
 SLAPD = @SLAPD@
-SWIG = swig
 EXTRA_OBJ=@EXTRA_OBJ@
 TESTS=test-tdb.sh @TESTS@
 PACKAGE_VERSION = @PACKAGE_VERSION@
diff --git a/source4/lib/ldb/autogen.sh b/source4/lib/ldb/autogen.sh
index 52fc8b6..e4d367d 100755
--- a/source4/lib/ldb/autogen.sh
+++ b/source4/lib/ldb/autogen.sh
@@ -11,8 +11,6 @@ autoconf $IPATHS || exit 1
 
 rm -rf autom4te.cache
 
-swig -O -Wall -python -keyword ldb.i # Ignore errors, for now
-
 echo "Now run ./configure and then make."
 exit 0
 
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
deleted file mode 100644
index 7831d6d..0000000
--- a/source4/lib/ldb/ldb.i
+++ /dev/null
@@ -1,1289 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-
-   Swig interface to ldb.
-
-   Copyright (C) 2005,2006 Tim Potter <tpot at samba.org>
-   Copyright (C) 2006 Simo Sorce <idra at samba.org>
-   Copyright (C) 2007-2008 Jelmer Vernooij <jelmer at 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/>.
-*/
-
-%define DOCSTRING
-"An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server."
-%enddef
-
-%module(docstring=DOCSTRING) ldb
-
-%{
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "talloc.h"
-#include "events.h"
-#include "ldb.h"
-#include "ldb_errors.h"
-#include "ldb_private.h"
-
-typedef struct ldb_message ldb_msg;
-typedef struct ldb_context ldb;
-typedef struct ldb_dn ldb_dn;
-typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_message_element;
-typedef struct ldb_module ldb_module;
-typedef int ldb_error;
-typedef int ldb_int_error;
-
-%}
-
-%import "carrays.i"
-%import "typemaps.i"
-%include "exception.i"
-%import "stdint.i"
-
-/* Don't expose talloc contexts in Python code. Python does reference 
-   counting for us, so just create a new top-level talloc context.
- */
-%typemap(in, numinputs=0, noblock=1) TALLOC_CTX * {
-    $1 = NULL;
-}
-
-
-
-%constant int SCOPE_DEFAULT = LDB_SCOPE_DEFAULT;
-%constant int SCOPE_BASE = LDB_SCOPE_BASE;
-%constant int SCOPE_ONELEVEL = LDB_SCOPE_ONELEVEL;
-%constant int SCOPE_SUBTREE = LDB_SCOPE_SUBTREE;
-
-%constant int CHANGETYPE_NONE = LDB_CHANGETYPE_NONE;
-%constant int CHANGETYPE_ADD = LDB_CHANGETYPE_ADD;
-%constant int CHANGETYPE_DELETE = LDB_CHANGETYPE_DELETE;
-%constant int CHANGETYPE_MODIFY = LDB_CHANGETYPE_MODIFY;
-
-/* 
- * Wrap struct ldb_context
- */
-
-/* The ldb functions will crash if a NULL ldb context is passed so
-   catch this before it happens. */
-
-%typemap(check,noblock=1) struct ldb_context* {
-	if ($1 == NULL)
-		SWIG_exception(SWIG_ValueError, 
-			"ldb context must be non-NULL");
-}
-
-%typemap(check,noblock=1) ldb_msg * {
-	if ($1 == NULL)
-		SWIG_exception(SWIG_ValueError, 
-			"Message can not be None");
-}
-
-/*
- * Wrap struct ldb_val
- */
-
-%typemap(in,noblock=1) struct ldb_val *INPUT (struct ldb_val temp) {
-	$1 = &temp;
-	if (!PyString_Check($input)) {
-		PyErr_SetString(PyExc_TypeError, "string arg expected");
-		return NULL;
-	}
-	$1->length = PyString_Size($input);
-	$1->data = PyString_AsString($input);
-}
-
-%inline %{
-PyObject *ldb_val_to_py_object(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;
-        
-        new_val = *val;
-        
-        if (ldb_ctx != NULL) {        
-        	a = ldb_schema_attribute_by_name(ldb_ctx, el->name);
-        
-        	if (a != NULL) {
-        		if (a->syntax->ldif_write_fn(ldb_ctx, mem_ctx, val, &new_val) != 0) {
-        			talloc_free(mem_ctx);
-        			return NULL;
-        		}
-        	}
-        } 
-        
-	ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length);
-	
-	talloc_free(mem_ctx);
-	
-	return ret;
-}
-
-%}
-
-%typemap(out,noblock=1) struct ldb_val * {
-	$result = PyString_FromStringAndSize((const char *)$1->data, $1->length)
-}
-
-%typemap(out,noblock=1) struct ldb_val {
-	$result = PyString_FromStringAndSize((const char *)$1.data, $1.length)
-}
-
-/*
- * Wrap struct ldb_result
- */
-
-%typemap(in,noblock=1,numinputs=0) struct ldb_result ** (struct ldb_result *temp_ldb_result) {
-	$1 = &temp_ldb_result;
-}
-
-#ifdef SWIGPYTHON
-%typemap(argout,noblock=1) struct ldb_result ** (int i) {
-    if ($1 == NULL) {
-        $result = Py_None;
-    } else {
-        $result = PyList_New((*$1)->count);
-        for (i = 0; i < (*$1)->count; i++) {
-            PyList_SetItem($result, i, 
-                SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0)
-            );
-        }
-    }
-}
-
-%typemap(in,noblock=1,numinputs=1) const char * const *NULL_STR_LIST {
-    if ($input == Py_None) {
-        $1 = NULL;
-    } else if (PySequence_Check($input)) {
-        int i;
-        $1 = talloc_array(NULL, char *, PySequence_Size($input)+1);
-        for(i = 0; i < PySequence_Size($input); i++)
-            $1[i] = PyString_AsString(PySequence_GetItem($input, i));
-        $1[i] = NULL;
-    } else {
-        SWIG_exception(SWIG_TypeError, "expected sequence");
-    }
-}
-
-%typemap(freearg,noblock=1) const char * const *NULL_STR_LIST {
-    talloc_free($1);
-}
-
-%apply const char * const *NULL_STR_LIST { const char * const *attrs }
-%apply const char * const *NULL_STR_LIST { const char * const *options }
-%apply const char * const *NULL_STR_LIST { const char * const *control_strings }
-
-#endif
-
-%types(struct ldb_result *, struct ldb_parse_tree *);
-
-/*
- * Wrap struct ldb_dn
- */
-
-%rename(__str__) ldb_dn::get_linearized;
-%rename(__cmp__) ldb_dn::compare;
-%rename(__len__) ldb_dn::get_comp_num;
-%rename(Dn) ldb_dn;
-%feature("docstring") ldb_dn "A LDB distinguished name.";
-typedef struct ldb_dn {
-    %extend {
-        %feature("docstring") ldb_dn "S.__init__(ldb, string)\n" \
-                 "Create a new DN.";
-        ldb_dn(ldb *ldb_ctx, const char *str)
-        {
-            ldb_dn *ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
-            /* ldb_dn_new() doesn't accept NULL as memory context, so 
-               we do it this way... */
-            talloc_steal(NULL, ret);
-
-            if (ret == NULL || !ldb_dn_validate(ret))
-                SWIG_exception(SWIG_ValueError, 
-                                "unable to parse dn string");
-fail:
-            return ret;
-        }
-        ~ldb_dn() { talloc_free($self); }
-        %feature("docstring") validate "S.validate() -> bool\n" \
-                                       "Validate DN is correct.";
-        bool validate();
-        const char *get_casefold();
-        const char *get_linearized();
-        %feature("docstring") parent "S.parent() -> dn\n" \
-                                     "Get the parent for this DN.";
-        ldb_dn *parent() { return ldb_dn_get_parent(NULL, $self); }
-        int compare(ldb_dn *other);
-        bool is_valid();
-        %feature("docstring") is_special "S.is_special() -> bool\n" \
-                                         "Check whether this is a special LDB DN.";
-        bool is_special();
-        %feature("docstring") is_null "S.is_null() -> bool\n" \
-                                         "Check whether this is a null DN.";
-        bool is_null();
-        bool check_special(const char *name);
-        int get_comp_num();
-        %feature("docstring") add_child "S.add_child(dn) -> None\n" \
-                                         "Add a child DN to this DN.";
-        bool add_child(ldb_dn *child);
-        %feature("docstring") add_base "S.add_base(dn) -> None\n" \
-                                         "Add a base DN to this DN.";
-        bool add_base(ldb_dn *base);
-        %feature("docstring") canonical_str "S.canonical_str() -> string\n" \
-                                         "Canonical version of this DN (like a posix path).";
-        const char *canonical_str() {
-            return ldb_dn_canonical_string($self, $self);
-        }
-        %feature("docstring") canonical_ex_str "S.canonical_ex_str() -> string\n" \
-                                               "Canonical version of this DN (like a posix path, with terminating newline).";
-        const char *canonical_ex_str() {
-            return ldb_dn_canonical_ex_string($self, $self);
-        }
-#ifdef SWIGPYTHON
-        char *__repr__(void)
-        {
-            char *dn = ldb_dn_get_linearized($self), *ret;
-            asprintf(&ret, "Dn('%s')", dn);
-            return ret;
-        }
-
-        ldb_dn *__add__(ldb_dn *other)
-        {
-            ldb_dn *ret = ldb_dn_copy(NULL, $self);
-            ldb_dn_add_child(ret, other);
-            return ret;
-        }
-
-        /* FIXME: implement __getslice__ */
-#endif
-    %pythoncode {
-        def __eq__(self, other):
-            if isinstance(other, self.__class__):
-                return self.__cmp__(other) == 0
-            if isinstance(other, str):
-                return str(self) == other
-            return False
-    }
-    }
-} ldb_dn;
-
-#ifdef SWIGPYTHON
-%{
-struct ldb_context *ldb_context_from_py_object(PyObject *py_obj)
-{
-        struct ldb_context *ldb_ctx;
-    if (SWIG_ConvertPtr(py_obj, (void *)&ldb_ctx, SWIGTYPE_p_ldb_context, 0 |  0 ) < 0)
-        return NULL;
-    return ldb_ctx;
-}
-
-int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object, 
-                         struct ldb_context *ldb_ctx, ldb_dn **dn)
-{
-    int ret;
-    struct ldb_dn *odn;
-    if (ldb_ctx != NULL && PyString_Check(object)) {
-        odn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
-	if (!odn) {
-		return SWIG_ERROR;
-	}
-	*dn = odn;
-        return 0;
-    }
-    ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn, 
-                           SWIG_POINTER_EXCEPTION);
-    *dn = ldb_dn_copy(mem_ctx, odn);
-    if (odn && !*dn) {
- 	return SWIG_ERROR;
-    }
-    return ret;
-}
-
-ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
-                                               PyObject *set_obj, int flags,
-                                               const char *attr_name)
-{
-    struct ldb_message_element *me = talloc(mem_ctx, struct ldb_message_element);
-    me->name = attr_name;
-    me->flags = flags;
-    if (PyString_Check(set_obj)) {
-        me->num_values = 1;
-        me->values = talloc_array(me, struct ldb_val, me->num_values);
-        me->values[0].length = PyString_Size(set_obj);
-        me->values[0].data = (uint8_t *)talloc_strdup(me->values, 
-                                           PyString_AsString(set_obj));
-    } else if (PySequence_Check(set_obj)) {
-        int i;
-        me->num_values = PySequence_Size(set_obj);
-        me->values = talloc_array(me, struct ldb_val, me->num_values);
-        for (i = 0; i < me->num_values; i++) {
-            PyObject *obj = PySequence_GetItem(set_obj, i);
-            me->values[i].length = PyString_Size(obj);
-            me->values[i].data = (uint8_t *)PyString_AsString(obj);
-        }
-    } else {
-        talloc_free(me);
-        me = NULL;
-    }
-
-    return me;
-}
-
-PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, 
-                                 ldb_message_element *me)
-{
-    int i;
-    PyObject *result;
-
-    /* Python << 2.5 doesn't have PySet_New and PySet_Add. */
-    result = PyList_New(me->num_values);
-
-    for (i = 0; i < me->num_values; i++) {
-        PyList_SetItem(result, i,
-            ldb_val_to_py_object(ldb_ctx, me, &me->values[i]));
-    }
-
-    return result;
-}
-
-%}
-#endif
-
-/* ldb_message_element */
-%rename(MessageElement) ldb_message_element;
-%feature("docstring") ldb_message_element "Message element.";
-typedef struct ldb_message_element {
-    %extend {
-#ifdef SWIGPYTHON
-        int __cmp__(ldb_message_element *other)
-        {
-            return ldb_msg_element_compare($self, other);
-        }
-
-        PyObject *__iter__(void)
-        {
-            return PyObject_GetIter(ldb_msg_element_to_set(NULL, $self));
-        }
-
-        PyObject *__set__(void)
-        {
-            return ldb_msg_element_to_set(NULL, $self);
-        }
-
-        ldb_message_element(PyObject *set_obj, int flags=0, const char *name = NULL)
-        {
-            return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
-        }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list