2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Amitay Isaacs <amitay@gmail.com> 2011
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "lib/replace/system/python.h"
22 #include "python/py3compat.h"
23 #include "param/param.h"
24 #include "param/loadparm.h"
25 #include "lib/talloc/pytalloc.h"
27 static PyTypeObject
*loadparm_Type
= NULL
;
31 static PyObject
*py_get_context(PyObject
*self
, PyObject
*Py_UNUSED(ignored
))
33 PyObject
*py_loadparm
;
34 const struct loadparm_s3_helpers
*s3_context
;
35 const struct loadparm_context
*s4_context
;
36 TALLOC_CTX
*frame
= talloc_stackframe();
38 s3_context
= loadparm_s3_helpers();
40 s4_context
= loadparm_init_s3(frame
, s3_context
);
41 if (s4_context
== NULL
) {
47 py_loadparm
= pytalloc_steal(loadparm_Type
, discard_const_p(struct loadparm_context
, s4_context
));
48 if (py_loadparm
== NULL
) {
59 static PyMethodDef pyparam_methods
[] = {
60 { "get_context", (PyCFunction
)py_get_context
, METH_NOARGS
,
61 "Returns LoadParm context." },
65 static struct PyModuleDef moduledef
= {
66 PyModuleDef_HEAD_INIT
,
68 .m_doc
= "Parsing and writing Samba3 configuration files.",
70 .m_methods
= pyparam_methods
,
73 MODULE_INIT_FUNC(param
)
75 PyObject
*m
= NULL
, *mod
= NULL
;
77 m
= PyModule_Create(&moduledef
);
81 mod
= PyImport_ImportModule("samba.param");
86 loadparm_Type
= (PyTypeObject
*)PyObject_GetAttrString(mod
, "LoadParm");
88 if (loadparm_Type
== NULL
) {