2 Unix SMB/CIFS implementation.
6 Copyright (C) 2005,2006 Tim Potter <tpot@samba.org>
7 Copyright (C) 2006 Simo Sorce <idra@samba.org>
8 Copyright (C) 2007-2008 Jelmer Vernooij <jelmer@samba.org>
10 ** NOTE! The following LGPL license applies to the ldb
11 ** library. This does NOT imply that all of Samba is released
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 3 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, see <http://www.gnu.org/licenses/>.
36 #include "ldb_errors.h"
37 #include "ldb_private.h"
39 typedef struct ldb_message ldb_msg;
40 typedef struct ldb_context ldb;
41 typedef struct ldb_dn ldb_dn;
42 typedef struct ldb_ldif ldb_ldif;
43 typedef struct ldb_message_element ldb_message_element;
44 typedef int ldb_error;
45 typedef int ldb_int_error;
51 %include "exception.i"
54 /* Don't expose talloc contexts in Python code. Python does reference
55 counting for us, so just create a new top-level talloc context.
57 %typemap(in, numinputs=0, noblock=1) TALLOC_CTX * {
63 %constant int SCOPE_DEFAULT = LDB_SCOPE_DEFAULT;
64 %constant int SCOPE_BASE = LDB_SCOPE_BASE;
65 %constant int SCOPE_ONELEVEL = LDB_SCOPE_ONELEVEL;
66 %constant int SCOPE_SUBTREE = LDB_SCOPE_SUBTREE;
68 %constant int CHANGETYPE_NONE = LDB_CHANGETYPE_NONE;
69 %constant int CHANGETYPE_ADD = LDB_CHANGETYPE_ADD;
70 %constant int CHANGETYPE_DELETE = LDB_CHANGETYPE_DELETE;
71 %constant int CHANGETYPE_MODIFY = LDB_CHANGETYPE_MODIFY;
74 * Wrap struct ldb_context
77 /* The ldb functions will crash if a NULL ldb context is passed so
78 catch this before it happens. */
80 %typemap(check,noblock=1) struct ldb_context* {
82 SWIG_exception(SWIG_ValueError,
83 "ldb context must be non-NULL");
86 %typemap(check,noblock=1) ldb_msg * {
88 SWIG_exception(SWIG_ValueError,
89 "Message can not be None");
96 %typemap(in,noblock=1) struct ldb_val *INPUT (struct ldb_val temp) {
98 if (!PyString_Check($input)) {
99 PyErr_SetString(PyExc_TypeError, "string arg expected");
102 $1->length = PyString_Size($input);
103 $1->data = PyString_AsString($input);
107 PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
108 struct ldb_message_element *el,
111 const struct ldb_schema_attribute *a;
112 struct ldb_val new_val;
113 TALLOC_CTX *mem_ctx = talloc_new(NULL);
118 if (ldb_ctx != NULL) {
119 a = ldb_schema_attribute_by_name(ldb_ctx, el->name);
122 if (a->syntax->ldif_write_fn(ldb_ctx, mem_ctx, val, &new_val) != 0) {
123 talloc_free(mem_ctx);
129 ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length);
131 talloc_free(mem_ctx);
138 %typemap(out,noblock=1) struct ldb_val * {
139 $result = PyString_FromStringAndSize((const char *)$1->data, $1->length)
142 %typemap(out,noblock=1) struct ldb_val {
143 $result = PyString_FromStringAndSize((const char *)$1.data, $1.length)
147 * Wrap struct ldb_result
150 %typemap(in,noblock=1,numinputs=0) struct ldb_result **OUT (struct ldb_result *temp_ldb_result) {
151 $1 = &temp_ldb_result;
155 %typemap(argout,noblock=1) struct ldb_result ** (int i) {
156 $result = PyList_New((*$1)->count);
157 for (i = 0; i < (*$1)->count; i++) {
158 PyList_SetItem($result, i,
159 SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0)
164 %typemap(in,noblock=1,numinputs=1) const char * const *NULL_STR_LIST {
165 if ($input == Py_None) {
167 } else if (PySequence_Check($input)) {
169 $1 = talloc_array(NULL, char *, PySequence_Size($input)+1);
170 for(i = 0; i < PySequence_Size($input); i++)
171 $1[i] = PyString_AsString(PySequence_GetItem($input, i));
174 SWIG_exception(SWIG_TypeError, "expected sequence");
178 %typemap(freearg,noblock=1) const char * const *NULL_STR_LIST {
182 %apply const char * const *NULL_STR_LIST { const char * const *attrs }
183 %apply const char * const *NULL_STR_LIST { const char * const *control_strings }
187 %types(struct ldb_result *);
193 %rename(__str__) ldb_dn::get_linearized;
194 %rename(__cmp__) ldb_dn::compare;
195 %rename(__len__) ldb_dn::get_comp_num;
197 typedef struct ldb_dn {
199 ldb_dn(ldb *ldb_ctx, const char *str)
201 ldb_dn *ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
202 /* ldb_dn_new() doesn't accept NULL as memory context, so
203 we do it this way... */
204 talloc_steal(NULL, ret);
207 SWIG_exception(SWIG_ValueError,
208 "unable to parse dn string");
212 ~ldb_dn() { talloc_free($self); }
213 %feature("docstring") validate "S.validate() -> bool\n" \
214 "Validate DN is correct.";
216 const char *get_casefold();
217 const char *get_linearized();
218 ldb_dn *parent() { return ldb_dn_get_parent(NULL, $self); }
219 int compare(ldb_dn *other);
221 %feature("docstring") is_special "S.is_special() -> bool\n" \
222 "Check whether this is a special LDB DN.";
224 %feature("docstring") is_null "S.is_null() -> bool\n" \
225 "Check whether this is a null DN.";
227 bool check_special(const char *name);
229 %feature("docstring") add_child "S.add_child(dn) -> None\n" \
230 "Add a child DN to this DN.";
231 bool add_child(ldb_dn *child);
232 %feature("docstring") add_base "S.add_base(dn) -> None\n" \
233 "Add a base DN to this DN.";
234 bool add_base(ldb_dn *base);
235 %feature("docstring") canonical_str "S.canonical_str() -> string\n" \
236 "Canonical version of this DN (like a posix path).";
237 const char *canonical_str() {
238 return ldb_dn_canonical_string($self, $self);
240 %feature("docstring") canonical_ex_str "S.canonical_ex_str() -> string\n" \
241 "Canonical version of this DN (like a posix path, with terminating newline).";
242 const char *canonical_ex_str() {
243 return ldb_dn_canonical_ex_string($self, $self);
248 char *dn = ldb_dn_get_linearized($self), *ret;
249 asprintf(&ret, "Dn('%s')", dn);
254 ldb_dn *__add__(ldb_dn *other)
256 ldb_dn *ret = ldb_dn_copy(NULL, $self);
257 ldb_dn_add_child(ret, other);
261 /* FIXME: implement __getslice__ */
264 def __eq__(self, other):
265 if isinstance(other, self.__class__):
266 return self.__cmp__(other) == 0
267 if isinstance(other, str):
268 return str(self) == other
276 struct ldb_context *ldb_context_from_py_object(PyObject *py_obj)
278 struct ldb_context *ldb_ctx;
279 if (SWIG_ConvertPtr(py_obj, (void *)&ldb_ctx, SWIGTYPE_p_ldb_context, 0 | 0 ) < 0)
284 int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
285 struct ldb_context *ldb_ctx, ldb_dn **dn)
289 if (ldb_ctx != NULL && PyString_Check(object)) {
290 odn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
297 ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn,
298 SWIG_POINTER_EXCEPTION);
299 *dn = ldb_dn_copy(mem_ctx, odn);
306 ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
307 PyObject *set_obj, int flags,
308 const char *attr_name)
310 struct ldb_message_element *me = talloc(mem_ctx, struct ldb_message_element);
311 me->name = attr_name;
313 if (PyString_Check(set_obj)) {
315 me->values = talloc_array(me, struct ldb_val, me->num_values);
316 me->values[0].length = PyString_Size(set_obj);
317 me->values[0].data = (uint8_t *)talloc_strdup(me->values,
318 PyString_AsString(set_obj));
319 } else if (PySequence_Check(set_obj)) {
321 me->num_values = PySequence_Size(set_obj);
322 me->values = talloc_array(me, struct ldb_val, me->num_values);
323 for (i = 0; i < me->num_values; i++) {
324 PyObject *obj = PySequence_GetItem(set_obj, i);
325 me->values[i].length = PyString_Size(obj);
326 me->values[i].data = (uint8_t *)PyString_AsString(obj);
336 PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
337 ldb_message_element *me)
342 /* Python << 2.5 doesn't have PySet_New and PySet_Add. */
343 result = PyList_New(me->num_values);
345 for (i = 0; i < me->num_values; i++) {
346 PyList_SetItem(result, i,
347 ldb_val_to_py_object(ldb_ctx, me, &me->values[i]));
356 int ldb_msg_element_compare(ldb_message_element *, ldb_message_element *);
357 /* ldb_message_element */
358 %rename(MessageElement) ldb_message_element;
359 %rename(ldb_message_element_compare) ldb_msg_element_compare;
360 typedef struct ldb_message_element {
363 PyObject *__iter__(void)
365 return PyObject_GetIter(ldb_msg_element_to_set(NULL, $self));
368 PyObject *__set__(void)
370 return ldb_msg_element_to_set(NULL, $self);
373 ldb_message_element(PyObject *set_obj, int flags=0, const char *name = NULL)
375 return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
380 return $self->num_values;
386 if (i < 0 || i >= $self->num_values)
389 return ldb_val_to_py_object(NULL, $self, &$self->values[i]);
392 ~ldb_message_element() { talloc_free($self); }
393 %rename(__cmp__) ldb_msg_element_compare;
396 def __getitem__(self, i):
399 raise KeyError("no such value")
403 return "MessageElement([%s])" % (",".join(repr(x) for x in self.__set__()))
405 def __eq__(self, other):
406 if (len(self) == 1 and self.get(0) == other):
408 if isinstance(other, self.__class__):
409 return self.__cmp__(other) == 0
411 for i in range(len(self)):
412 if self.get(i) != o.next():
416 } ldb_message_element;
420 %rename(Message) ldb_message;
422 %rename(__delitem__) ldb_message::remove_attr;
423 %typemap(out) ldb_message_element * {
425 PyErr_SetString(PyExc_KeyError, "no such element");
427 $result = SWIG_NewPointerObj($1, SWIGTYPE_p_ldb_message_element, 0);
431 PyObject *ldb_msg_list_elements(ldb_msg *msg)
434 PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
435 if (msg->dn != NULL) {
436 PyList_SetItem(obj, j, PyString_FromString("dn"));
439 for (i = 0; i < msg->num_elements; i++) {
440 PyList_SetItem(obj, j, PyString_FromString(msg->elements[i].name));
449 typedef struct ldb_message {
453 ldb_msg(ldb_dn *dn = NULL) {
454 ldb_msg *ret = ldb_msg_new(NULL);
455 ret->dn = talloc_reference(ret, dn);
458 ~ldb_msg() { talloc_free($self); }
459 ldb_message_element *find_element(const char *name);
462 void __setitem__(const char *attr_name, ldb_message_element *val)
464 struct ldb_message_element *el;
466 ldb_msg_remove_attr($self, attr_name);
468 el = talloc($self, struct ldb_message_element);
469 el->name = talloc_strdup(el, attr_name);
470 el->num_values = val->num_values;
471 el->values = talloc_reference(el, val->values);
473 ldb_msg_add($self, el, val->flags);
476 void __setitem__(const char *attr_name, PyObject *val)
478 struct ldb_message_element *el = ldb_msg_element_from_pyobject(NULL,
480 talloc_steal($self, el);
481 ldb_msg_remove_attr($self, attr_name);
482 ldb_msg_add($self, el, el->flags);
485 unsigned int __len__() { return $self->num_elements; }
489 return ldb_msg_list_elements($self);
492 PyObject *__iter__(void)
494 return PyObject_GetIter(ldb_msg_list_elements($self));
497 void remove_attr(const char *name);
499 def get(self, key, default=None):
502 return self.find_element(key)
504 def __getitem__(self, key):
505 ret = self.get(key, None)
507 raise KeyError("No such element")
511 for k in self.keys():
515 return list(self.iteritems())
518 return "Message(%s)" % repr(dict(self.iteritems()))
523 /* FIXME: Convert ldb_result to 3-tuple:
524 (msgs, refs, controls)
527 typedef struct ldb_ldif ldb_ldif;
531 static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0);
533 static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap)
536 PyObject *fn = context;
538 vasprintf(&text, fmt, ap);
539 PyObject_CallFunction(fn, (char *)"(i,s)", level, text);
544 %typemap(in,numinputs=1,noblock=1) (void (*debug)(void *context, enum ldb_debug_level level, const char *fmt, va_list ap), void *context) {
546 /* FIXME: Should be decreased somewhere as well. Perhaps register a
547 destructor and tie it to the ldb context ? */
554 static PyObject *ldb_ldif_to_pyobject(ldb_ldif *ldif)
559 return Py_BuildValue((char *)"(iO)", ldif->changetype,
560 SWIG_NewPointerObj(ldif->msg, SWIGTYPE_p_ldb_message, 0));
570 PyObject *PyExc_LdbError;
574 LdbError = _ldb.LdbError
578 PyExc_LdbError = PyErr_NewException((char *)"_ldb.LdbError", NULL, NULL);
579 PyDict_SetItemString(d, "LdbError", PyExc_LdbError);
582 %ignore _LDB_ERRORS_H_;
584 %include "include/ldb_errors.h"
591 %typemap(out,noblock=1) ldb_error {
592 if ($1 != LDB_SUCCESS) {
593 PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", $1, ldb_errstring(arg1)));
599 %typemap(out,noblock=1) ldb_int_error {
600 if ($1 != LDB_SUCCESS) {
601 PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", $1, ldb_strerror($1)));
607 %typemap(out,noblock=1) struct ldb_control ** {
609 PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(s)", ldb_errstring(arg1)));
612 $result = SWIG_NewPointerObj($1, $1_descriptor, 0);
615 %rename(Ldb) ldb_context;
617 %typemap(in,noblock=1) struct ldb_dn * {
618 if (ldb_dn_from_pyobject(NULL, $input, arg1, &$1) != 0) {
623 %typemap(freearg,noblock=1) struct ldb_dn * {
627 %typemap(in,numinputs=1) ldb_msg *add_msg {
628 Py_ssize_t dict_pos, msg_pos;
629 ldb_message_element *msgel;
630 PyObject *key, *value;
632 if (PyDict_Check($input)) {
633 PyObject *dn_value = PyDict_GetItemString($input, "dn");
634 $1 = ldb_msg_new(NULL);
635 $1->elements = talloc_zero_array($1, struct ldb_message_element, PyDict_Size($input));
636 msg_pos = dict_pos = 0;
638 /* using argp1 (magic SWIG value) here is a hack */
639 if (ldb_dn_from_pyobject($1, dn_value, argp1, &$1->dn) != 0) {
640 SWIG_exception(SWIG_TypeError, "unable to import dn object");
642 if ($1->dn == NULL) {
643 SWIG_exception(SWIG_TypeError, "dn set but not found");
647 while (PyDict_Next($input, &dict_pos, &key, &value)) {
648 char *key_str = PyString_AsString(key);
649 if (strcmp(key_str, "dn") != 0) {
650 msgel = ldb_msg_element_from_pyobject($1->elements, value, 0, key_str);
652 SWIG_exception(SWIG_TypeError, "unable to import element");
654 memcpy(&$1->elements[msg_pos], msgel, sizeof(*msgel));
659 if ($1->dn == NULL) {
660 SWIG_exception(SWIG_TypeError, "no dn set");
663 $1->num_elements = msg_pos;
665 if (SWIG_ConvertPtr($input, (void **)&$1, SWIGTYPE_p_ldb_message, 0) != 0) {
666 SWIG_exception(SWIG_TypeError, "unable to convert ldb message");
671 /* Top-level ldb operations */
672 typedef struct ldb_context {
674 ldb(void) { return ldb_init(NULL); }
676 %feature("docstring") connect "S.connect(url,flags=0,options=None) -> None\n" \
677 "Connect to a LDB URL.";
678 ldb_error connect(const char *url, unsigned int flags = 0,
679 const char *options[] = NULL);
681 ~ldb() { talloc_free($self); }
682 ldb_error search_ex(TALLOC_CTX *mem_ctx,
684 enum ldb_scope scope = LDB_SCOPE_DEFAULT,
685 const char *expression = NULL,
686 const char *const *attrs = NULL,
687 struct ldb_control **controls = NULL,
688 struct ldb_result **OUT) {
690 struct ldb_result *res;
691 struct ldb_request *req;
692 res = talloc_zero(mem_ctx, struct ldb_result);
694 return LDB_ERR_OPERATIONS_ERROR;
697 ret = ldb_build_search_req(&req, $self, mem_ctx,
698 base?base:ldb_get_default_basedn($self),
704 ldb_search_default_callback);
706 if (ret != LDB_SUCCESS) {
711 ldb_set_timeout($self, req, 0); /* use default timeout */
713 ret = ldb_request($self, req);
715 if (ret == LDB_SUCCESS) {
716 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
725 %feature("docstring") delete "S.delete(dn) -> None\n" \
727 ldb_error delete(ldb_dn *dn);
728 %feature("docstring") rename "S.rename(old_dn, new_dn) -> None\n" \
730 ldb_error rename(ldb_dn *olddn, ldb_dn *newdn);
731 struct ldb_control **parse_control_strings(TALLOC_CTX *mem_ctx,
732 const char * const*control_strings);
733 %feature("docstring") add "S.add(message) -> None\n" \
735 ldb_error add(ldb_msg *add_msg);
736 %feature("docstring") modify "S.modify(message) -> None\n" \
738 ldb_error modify(ldb_msg *message);
739 ldb_dn *get_config_basedn();
740 ldb_dn *get_root_basedn();
741 ldb_dn *get_schema_basedn();
742 ldb_dn *get_default_basedn();
743 PyObject *schema_format_value(const char *element_name, PyObject *val)
745 const struct ldb_schema_attribute *a;
746 struct ldb_val old_val;
747 struct ldb_val new_val;
748 TALLOC_CTX *mem_ctx = talloc_new(NULL);
751 old_val.data = PyString_AsString(val);
752 old_val.length = PyString_Size(val);
754 a = ldb_schema_attribute_by_name($self, element_name);
760 if (a->syntax->ldif_write_fn($self, mem_ctx, &old_val, &new_val) != 0) {
761 talloc_free(mem_ctx);
765 ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length);
767 talloc_free(mem_ctx);
772 const char *errstring();
773 %feature("docstring") set_create_perms "S.set_create_perms(mode) -> None\n" \
774 "Set mode to use when creating new LDB files.";
775 void set_create_perms(unsigned int perms);
776 %feature("docstring") set_modules_dir "S.set_modules_dir(path) -> None\n" \
777 "Set path LDB should search for modules";
778 void set_modules_dir(const char *path);
779 ldb_error set_debug(void (*debug)(void *context, enum ldb_debug_level level,
780 const char *fmt, va_list ap),
782 %feature("docstring") set_opaque "S.set_opaque(name, value) -> None\n" \
783 "Set an opaque value on this LDB connection. \n"
784 ":note: Passing incorrect values may cause crashes.";
785 ldb_error set_opaque(const char *name, void *value);
786 %feature("docstring") get_opaque "S.get_opaque(name) -> value\n" \
787 "Get an opaque value set on this LDB connection. \n"
788 ":note: The returned value may not be useful in Python.";
789 void *get_opaque(const char *name);
790 %feature("docstring") transaction_start "S.transaction_start() -> None\n" \
791 "Start a new transaction.";
792 ldb_error transaction_start();
793 %feature("docstring") transaction_commit "S.transaction_commit() -> None\n" \
794 "Commit currently active transaction.";
795 ldb_error transaction_commit();
796 %feature("docstring") transaction_commit "S.transaction_cancel() -> None\n" \
797 "Cancel currently active transaction.";
798 ldb_error transaction_cancel();
799 void schema_attribute_remove(const char *name);
800 ldb_error schema_attribute_add(const char *attribute, unsigned flags, const char *syntax);
801 ldb_error setup_wellknown_attributes(void);
804 %typemap(in,numinputs=0,noblock=1) struct ldb_result **result_as_bool (struct ldb_result *tmp) { $1 = &tmp; }
805 %typemap(argout,noblock=1) struct ldb_result **result_as_bool { $result = ((*$1)->count > 0)?Py_True:Py_False; }
806 %typemap(freearg,noblock=1) struct ldb_result **result_as_bool { talloc_free(*$1); }
807 ldb_error __contains__(ldb_dn *dn, struct ldb_result **result_as_bool)
809 return ldb_search($self, dn, LDB_SCOPE_BASE, NULL, NULL,
813 %feature("docstring") parse_ldif "S.parse_ldif(ldif) -> iter(messages)\n" \
814 "Parse a string formatted using LDIF.";
816 PyObject *parse_ldif(const char *s)
818 PyObject *list = PyList_New(0);
819 struct ldb_ldif *ldif;
820 while ((ldif = ldb_ldif_read_string($self, &s)) != NULL) {
821 PyList_Append(list, ldb_ldif_to_pyobject(ldif));
823 return PyObject_GetIter(list);
829 asprintf(&ret, "<ldb connection at 0x%x>", ret);
835 def __init__(self, url=None, flags=0, options=None):
836 """Create a new LDB object.
838 Will also connect to the specified URL if one was given.
840 _ldb.Ldb_swiginit(self,_ldb.new_Ldb())
842 self.connect(url, flags, options)
844 def search(self, base=None, scope=SCOPE_DEFAULT, expression=None,
845 attrs=None, controls=None):
846 """Search in a database.
848 :param base: Optional base DN to search
849 :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
850 :param expression: Optional search expression
851 :param attrs: Attributes to return (defaults to all)
852 :param controls: Optional list of controls
853 :return: Iterator over Message objects
855 if not (attrs is None or isinstance(attrs, list)):
856 raise TypeError("attributes not a list")
857 parsed_controls = None
858 if controls is not None:
859 parsed_controls = self.parse_control_strings(controls)
860 return self.search_ex(base, scope, expression, attrs,
866 %typemap(in,noblock=1) struct ldb_dn *;
867 %typemap(freearg,noblock=1) struct ldb_dn *;
869 %nodefault ldb_message;
870 %nodefault ldb_context;
873 %rename(valid_attr_name) ldb_valid_attr_name;
874 %feature("docstring") ldb_valid_attr_name "S.valid_attr_name(name) -> bool\n"
875 "Check whether the supplied name is a valid attribute name.";
876 int ldb_valid_attr_name(const char *s);
878 typedef unsigned long time_t;
881 static char *timestring(time_t t)
883 char *tresult = ldb_timestring(NULL, t);
884 char *result = strdup(tresult);
885 talloc_free(tresult);
890 %rename(string_to_time) ldb_string_to_time;
891 time_t ldb_string_to_time(const char *s);
893 %typemap(in,noblock=1) const struct ldb_module_ops * {
894 $1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops);
896 $1->name = (char *)PyObject_GetAttrString($input, (char *)"name");
899 %feature("docstring") ldb_register_module "S.register_module(module) -> None\n"
900 "Register a LDB module.";
901 %rename(register_module) ldb_register_module;
902 ldb_int_error ldb_register_module(const struct ldb_module_ops *);