From 74c66c9a3f6aedbbcdbce66a1d72a3c3b74137f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 20 Jun 2010 13:29:35 +0200 Subject: s4-python: Implement LoadParm.dump(). --- source4/param/pyparam.c | 23 +++++++++++++++++++++++ source4/scripting/bin/testparm | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 40d25f7dcd..3335dd9a64 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -246,6 +246,27 @@ static PyObject *py_lp_ctx_services(py_talloc_Object *self) return ret; } +static PyObject *py_lp_dump(PyObject *self, PyObject *args) +{ + PyObject *py_stream; + bool show_defaults = false; + FILE *f; + struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self); + + if (!PyArg_ParseTuple(args, "O|b", &py_stream, &show_defaults)) + return NULL; + + f = PyFile_AsFile(py_stream); + if (f == NULL) { + PyErr_SetString(PyExc_TypeError, "Not a file stream"); + return NULL; + } + + lp_dump(lp_ctx, f, show_defaults, lp_numservices(lp_ctx)); + + Py_RETURN_NONE; +} + static PyMethodDef py_lp_ctx_methods[] = { { "load", (PyCFunction)py_lp_ctx_load, METH_VARARGS, "S.load(filename) -> None\n" @@ -269,6 +290,8 @@ static PyMethodDef py_lp_ctx_methods[] = { "S.private_path(name) -> path\n" }, { "services", (PyCFunction)py_lp_ctx_services, METH_NOARGS, "S.services() -> list" }, + { "dump", (PyCFunction)py_lp_dump, METH_VARARGS, + "S.dump(stream, show_defaults=False)" }, { NULL } }; diff --git a/source4/scripting/bin/testparm b/source4/scripting/bin/testparm index 0ea36d941b..43d8ee0673 100755 --- a/source4/scripting/bin/testparm +++ b/source4/scripting/bin/testparm @@ -192,6 +192,6 @@ if __name__ == '__main__': check_client_access(lp, cname, caddr) else: dump(lp, opts.section_name, opts.parameter_name, - not opts.suppress_prompt, opts.verbose) + not opts.suppress_prompt, opts.verbose or False) sys.exit(0) -- cgit