r15092: Remove some swig stuff that didn't work out and the %rename call.
authorTim Potter <tpot@samba.org>
Sat, 15 Apr 2006 10:13:09 +0000 (10:13 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:04:08 +0000 (14:04 -0500)
Add wrappers for some of the ldb_msg_* functions.
(This used to be commit ca7c94675ed19cdc6df27d492895c3148500536f)

source4/lib/ldb/swig/ldb.i

index 31c1ffe3e4dd0d976ac392e9343c0e539e96f679..67c644b4f8fa48177e2d557a902236804cff891d 100644 (file)
@@ -72,20 +72,22 @@ int talloc_free(TALLOC_CTX *ptr);
  * Wrap struct ldb_val
  */
 
  * 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;
        }
        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 = Py_None;
        } else {
-               $result = PyString_FromStringAndSize($1.data, $1.length);
+               $result = PyString_FromStringAndSize($1->data, $1->length);
        }
 }
 
        }
 }
 
@@ -103,33 +105,11 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1,
 }
 
 %typemap(argout) struct ldb_result ** {
 }
 
 %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 *);
 
        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
  */
 /*
  * Wrap struct ldb_message_element
  */
@@ -153,33 +133,9 @@ struct ldb_message {
        struct ldb_dn *dn;
        unsigned int num_elements;
        struct ldb_message_element *elements;
        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
  */
 /*
  * Wrap struct ldb_result
  */
@@ -197,23 +153,20 @@ struct ldb_result {
  * Wrap ldb functions 
  */
 
  * Wrap ldb functions 
  */
 
-%rename ldb_init init;
 struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx);
 
 struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx);
 
-%rename ldb_errstring errstring;
 const char *ldb_errstring(struct ldb_context *ldb);
 
 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[]);
 
 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);
 
 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);
 
 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);
 
 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);
 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);