Author: tpot
Date: 2006-04-15 10:13:09 +0000 (Sat, 15 Apr 2006)
New Revision: 15092

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15092

Log:
Remove some swig stuff that didn't work out and the %rename call.

Add wrappers for some of the ldb_msg_* functions.

Modified:
   branches/SAMBA_4_0/source/lib/ldb/swig/ldb.i


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/swig/ldb.i
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/swig/ldb.i        2006-04-15 10:10:23 UTC 
(rev 15091)
+++ branches/SAMBA_4_0/source/lib/ldb/swig/ldb.i        2006-04-15 10:13:09 UTC 
(rev 15092)
@@ -72,20 +72,22 @@
  * Wrap struct ldb_val
  */
 
-%typemap(in) struct ldb_val {
+%typemap(in) struct ldb_val * (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);
+       $1->length = PyString_Size($input);
+       $1->data = PyString_AsString($input);
 }
 
-%typemap(out) struct ldb_val {
-       if ($1.data == NULL && $1.length == 0) {
+%typemap(out) struct ldb_val * {
+       if ($1->data == NULL && $1->length == 0) {
+               Py_INCREF(Py_None);
                $result = Py_None;
        } else {
-               $result = PyString_FromStringAndSize($1.data, $1.length);
+               $result = PyString_FromStringAndSize($1->data, $1->length);
        }
 }
 
@@ -103,34 +105,12 @@
 }
 
 %typemap(argout) struct ldb_result ** {
-
-       /* XXX: Check result for error and throw exception if necessary */
-
        resultobj = SWIG_NewPointerObj(*$1, SWIGTYPE_p_ldb_result, 0);
 }      
 
 %types(struct ldb_result *);
 
 /*
- * Wrap struct ldb_dn
- */
-
-%typemap(in) struct ldb_dn * {
-       if ($input == Py_None) {
-               $1 = NULL;
-       } else if (!PyString_Check($input)) {
-               PyErr_SetString(PyExc_TypeError, "string arg expected");
-               return NULL;
-       } else {
-               $1 = ldb_dn_explode(NULL, PyString_AsString($input));
-       }
-}
-
-%typemap(out) struct ldb_dn * {
-       $result = PyString_FromString(ldb_dn_linearize($1, $1));
-}
-
-/*
  * Wrap struct ldb_message_element
  */
 
@@ -153,33 +133,9 @@
        struct ldb_dn *dn;
        unsigned int num_elements;
        struct ldb_message_element *elements;
-       void *private_data; /* private to the backend */
+       void *private_data;
 };
 
-%typemap(in) struct ldb_message * {
-       PyObject *obj, *key, *value;
-       int pos;
-
-       $1 = ldb_msg_new(NULL);
-
-       obj = PyObject_GetAttrString($input, "dn");
-       $1->dn = ldb_dn_explode(NULL, PyString_AsString(obj));
-
-       obj = PyObject_GetAttrString($input, "private_data");
-       $1->private_data = PyString_AsString(obj);
-
-       obj = PyObject_GetAttrString($input, "elements");
-
-       pos = 0;
-       while (PyDict_Next(obj, &pos, &key, &value)) {
-               struct ldb_val v;
-
-               v.data = PyString_AsString(value);
-               v.length = PyString_Size(value);
-               ldb_msg_add_value($1, PyString_AsString(key), &v);
-       }
-}
-
 /*
  * Wrap struct ldb_result
  */
@@ -197,23 +153,20 @@
  * Wrap ldb functions 
  */
 
-%rename ldb_init init;
 struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx);
 
-%rename ldb_errstring errstring;
 const char *ldb_errstring(struct ldb_context *ldb);
 
-%rename ldb_connect connect;
 int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, 
const char *options[]);
 
-%rename ldb_search search;
 int ldb_search(struct ldb_context *ldb, const struct ldb_dn *base, enum 
ldb_scope scope, const char *expression, const char * const *attrs, struct 
ldb_result **OUT);
 
-%rename ldb_delete delete;
 int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn);
 
-%rename ldb_rename rename;
 int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const 
struct ldb_dn *newdn);
 
-%rename ldb_add add;
 int ldb_add(struct ldb_context *ldb, const struct ldb_message *message);
+
+struct ldb_message *ldb_msg_new(void *mem_ctx);
+struct ldb_message_element *ldb_msg_find_element(const struct ldb_message 
*msg, const char *attr_name);
+int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const 
struct ldb_val *val);

Reply via email to