summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2006-04-15 10:13:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:04:08 -0500
commitaa8ced45126c1aa44200bcaf05b51ddd194ea70f (patch)
tree3ec2381301656b61046573e0d7a6e7f8a87968bf /source4/lib/ldb
parentbd41ecdcd0b566c63b9c184a8f5ffdf8db8bd869 (diff)
downloadsamba-aa8ced45126c1aa44200bcaf05b51ddd194ea70f.tar.gz
samba-aa8ced45126c1aa44200bcaf05b51ddd194ea70f.tar.bz2
samba-aa8ced45126c1aa44200bcaf05b51ddd194ea70f.zip
r15092: Remove some swig stuff that didn't work out and the %rename call.
Add wrappers for some of the ldb_msg_* functions. (This used to be commit ca7c94675ed19cdc6df27d492895c3148500536f)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/swig/ldb.i73
1 files changed, 13 insertions, 60 deletions
diff --git a/source4/lib/ldb/swig/ldb.i b/source4/lib/ldb/swig/ldb.i
index 31c1ffe3e4..67c644b4f8 100644
--- a/source4/lib/ldb/swig/ldb.i
+++ b/source4/lib/ldb/swig/ldb.i
@@ -72,20 +72,22 @@ int talloc_free(TALLOC_CTX *ptr);
* 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 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1,
}
%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_message {
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 @@ struct ldb_result {
* 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);