source: branches/samba-3.5.x/source4/lib/ldb/pyldb.h

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 3.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 Swig interface to ldb.
5
6 Copyright (C) 2007-2008 Jelmer Vernooij <jelmer@samba.org>
7
8 ** NOTE! The following LGPL license applies to the ldb
9 ** library. This does NOT imply that all of Samba is released
10 ** under the LGPL
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 3 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, see <http://www.gnu.org/licenses/>.
24*/
25
26#ifndef _PYLDB_H_
27#define _PYLDB_H_
28
29#include <Python.h>
30#include <talloc.h>
31
32typedef struct {
33 PyObject_HEAD
34 struct ldb_context *ldb_ctx;
35 TALLOC_CTX *mem_ctx;
36} PyLdbObject;
37
38PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx);
39#define PyLdb_AsLdbContext(pyobj) ((PyLdbObject *)pyobj)->ldb_ctx
40#define PyLdb_Check(ob) PyObject_TypeCheck(ob, &PyLdb)
41
42typedef struct {
43 PyObject_HEAD
44 struct ldb_dn *dn;
45 TALLOC_CTX *mem_ctx;
46} PyLdbDnObject;
47
48PyObject *PyLdbDn_FromDn(struct ldb_dn *);
49bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn);
50#define PyLdbDn_AsDn(pyobj) ((PyLdbDnObject *)pyobj)->dn
51#define PyLdbDn_Check(ob) PyObject_TypeCheck(ob, &PyLdbDn)
52
53typedef struct {
54 PyObject_HEAD
55 struct ldb_message *msg;
56 TALLOC_CTX *mem_ctx;
57} PyLdbMessageObject;
58#define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage)
59#define PyLdbMessage_AsMessage(pyobj) ((PyLdbMessageObject *)pyobj)->msg
60
61typedef struct {
62 PyObject_HEAD
63 struct ldb_module *mod;
64 TALLOC_CTX *mem_ctx;
65} PyLdbModuleObject;
66PyObject *PyLdbMessage_FromMessage(struct ldb_message *message);
67PyObject *PyLdbModule_FromModule(struct ldb_module *mod);
68#define PyLdbModule_AsModule(pyobj) ((PyLdbModuleObject *)pyobj)->mod
69
70typedef struct {
71 PyObject_HEAD
72 struct ldb_message_element *el;
73 TALLOC_CTX *mem_ctx;
74} PyLdbMessageElementObject;
75struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, PyObject *obj, int flags, const char *name);
76PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *, TALLOC_CTX *mem_ctx);
77#define PyLdbMessageElement_AsMessageElement(pyobj) ((PyLdbMessageElementObject *)pyobj)->el
78#define PyLdbMessageElement_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessageElement)
79
80typedef struct {
81 PyObject_HEAD
82 struct ldb_parse_tree *tree;
83 TALLOC_CTX *mem_ctx;
84} PyLdbTreeObject;
85PyObject *PyLdbTree_FromTree(struct ldb_parse_tree *);
86#define PyLdbTree_AsTree(pyobj) ((PyLdbTreeObject *)pyobj)->tree
87
88#define PyErr_LDB_ERROR_IS_ERR_RAISE(err,ret,ldb) \
89 if (ret != LDB_SUCCESS) { \
90 PyErr_SetLdbError(err, ret, ldb); \
91 return NULL; \
92 }
93
94/* Picked out of thin air. To do this properly, we should probably have some part of the
95 * errors in LDB be allocated to bindings ? */
96#define LDB_ERR_PYTHON_EXCEPTION 142
97
98#endif /* _PYLDB_H_ */
Note: See TracBrowser for help on using the repository browser.