summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-14 01:26:12 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:50:13 +0100
commit55f90f1166d1050d010fffcca696dfb897e42e82 (patch)
tree2df42a4befd44302519b6e177e88d18601b75e3f /source4/scripting
parent93b570616ded0db5a676f1e5dc25495d0055089b (diff)
downloadsamba-55f90f1166d1050d010fffcca696dfb897e42e82.tar.gz
samba-55f90f1166d1050d010fffcca696dfb897e42e82.tar.bz2
samba-55f90f1166d1050d010fffcca696dfb897e42e82.zip
r26446: Convert param module to SWIG.
(This used to be commit 94e5f9c92f65070ec8f1c1170c4a0769a4857c6d)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/config.mk4
-rw-r--r--source4/scripting/python/parammodule.c181
2 files changed, 0 insertions, 185 deletions
diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk
index c958761c70..9d972f7ee0 100644
--- a/source4/scripting/python/config.mk
+++ b/source4/scripting/python/config.mk
@@ -1,7 +1,3 @@
-[PYTHON::python_param]
-PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG
-OBJ_FILES = parammodule.o
-
[PYTHON::python_uuid]
PRIVATE_DEPENDENCIES = LIBNDR
OBJ_FILES = uuidmodule.o
diff --git a/source4/scripting/python/parammodule.c b/source4/scripting/python/parammodule.c
deleted file mode 100644
index bb7adab240..0000000000
--- a/source4/scripting/python/parammodule.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Python wrapper for reading smb.conf files
-
- Copyright (C) Jelmer Vernooij 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "Python.h"
-#include "param/param.h"
-
-staticforward PyTypeObject param_ParamFileType;
-
-typedef struct {
- PyObject_HEAD
- struct param_context *param_ctx;
-} param_ParamFileObject;
-
-static param_ParamFileObject *py_param_init(void)
-{
- param_ParamFileObject *param;
-
- param = PyObject_New(param_ParamFileObject, &param_ParamFileType);
-
- param->param_ctx = param_init(NULL);
-
- return param;
-}
-
-static PyObject *py_param_load(PyObject *self, PyObject *args)
-{
- char *filename = NULL;
- param_ParamFileObject *param;
-
- if (!PyArg_ParseTuple(args, "|s:new", &filename))
- return NULL;
-
- param = py_param_init();
-
- if (filename != NULL) {
- int ret = param_read(param->param_ctx, filename);
-
- if (ret == -1) {
- PyErr_SetString(PyExc_TypeError, "reading file failed");
- return NULL;
- }
- }
-
- return (PyObject *)param;
-}
-
-static void
-param_dealloc(PyObject* self)
-{
- PyObject_Del(self);
-}
-
-static PyObject *py_param_get(PyObject *_self, PyObject *args)
-{
- struct param_opt *param;
- const char *section_name = NULL, *param_name = NULL;
- param_ParamFileObject *self = (param_ParamFileObject *)_self;
-
- if (!PyArg_ParseTuple(args, (char *)"s|s", &param_name, &section_name))
- return NULL;
-
- param = param_get(self->param_ctx, section_name, param_name);
- if (param == NULL)
- return Py_None;
-
- return PyString_FromString(param->value);
-}
-
-static PyObject *py_param_set(PyObject *_self, PyObject *args)
-{
- param_ParamFileObject *self = (param_ParamFileObject *)_self;
- const char *section_name = NULL, *param_name = NULL, *param_value = NULL;
-
- if (!PyArg_ParseTuple(args, "ss|s", &param_name, &param_value, &section_name))
- return NULL;
-
- if (section_name == NULL)
- section_name = GLOBAL_NAME;
-
- if (param_set_string(self->param_ctx, section_name, param_name, param_value) != 0) {
- PyErr_SetString(PyExc_TypeError, "setting variable failed");
- return NULL;
- }
-
- return Py_None;
-}
-
-static PyObject *py_param_save(PyObject *_self, PyObject *args)
-{
- param_ParamFileObject *self = (param_ParamFileObject *)_self;
- const char *filename = NULL;
-
- if (!PyArg_ParseTuple(args, "s", &filename))
- return NULL;
-
- if (param_write(self->param_ctx, filename) != 0) {
- PyErr_SetString(PyExc_TypeError, "unable to save");
- return NULL;
- }
-
- return Py_None;
-}
-
-static PyObject *py_param_use(PyObject *_self, PyObject *args)
-{
- param_ParamFileObject *self = (param_ParamFileObject *)_self;
-
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
-
- if (param_use(global_loadparm, self->param_ctx) != 0) {
- PyErr_SetString(PyExc_TypeError, "unable to use");
- return NULL;
- }
-
- return Py_None;
-}
-
-static PyMethodDef param_methods[] = {
- {"get", (PyCFunction)py_param_get, METH_VARARGS,
- "Get a parameter."},
- {"set", (PyCFunction)py_param_set, METH_VARARGS,
- "Set a parameter."},
- {"save", (PyCFunction)py_param_save, METH_VARARGS,
- "Save file" },
- {"use", (PyCFunction)py_param_use, METH_VARARGS,
- "Use param file" },
- {NULL, NULL, 0, NULL}
-};
-
-static PyObject *
-param_getattr(PyTypeObject *obj, char *name)
-{
- return Py_FindMethod(param_methods, (PyObject *)obj, name);
-}
-
-static PyTypeObject param_ParamFileType = {
- PyObject_HEAD_INIT(NULL) 0,
- .tp_name = "ParamFile",
- .tp_basicsize = sizeof(param_ParamFileObject),
- .tp_dealloc = param_dealloc,
- .tp_getattr = param_getattr,
-};
-
-
-static PyMethodDef methods[] = {
- { "ParamFile", (PyCFunction)py_param_load, METH_VARARGS, NULL},
- { NULL, NULL }
-};
-
-PyDoc_STRVAR(param_doc, "Simple wrappers around the smb.conf parsers");
-
-PyMODINIT_FUNC initparam(void)
-{
- PyObject *mod = Py_InitModule3("param", methods, param_doc);
- if (mod == NULL)
- return;
-
- PyModule_AddObject(mod, "configfile",
- PyString_FromString(lp_configfile(global_loadparm)));
-}