svn commit: samba r25347 - in branches/4.0-python: . source/scripting/python

jelmer at samba.org jelmer at samba.org
Wed Sep 26 02:06:36 GMT 2007


Author: jelmer
Date: 2007-09-26 02:06:36 +0000 (Wed, 26 Sep 2007)
New Revision: 25347

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25347

Log:
Fix param module.
Added:
   branches/4.0-python/source/scripting/python/talloc.c
Modified:
   branches/4.0-python/
   branches/4.0-python/source/scripting/python/config.mk
   branches/4.0-python/source/scripting/python/parammodule.c


Changeset:

Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-python/source/scripting/python/config.mk
===================================================================
--- branches/4.0-python/source/scripting/python/config.mk	2007-09-26 02:06:32 UTC (rev 25346)
+++ branches/4.0-python/source/scripting/python/config.mk	2007-09-26 02:06:36 UTC (rev 25347)
@@ -1,4 +1,9 @@
+[SUBSYSTEM::talloc_python]
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBPYTHON
+OBJ_FILES = talloc.o
+PUBLIC_PROTO_HEADER = talloc.h
+
 [PYTHON::python_param]
-PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG
+PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG talloc_python
 OBJ_FILES = \
 			parammodule.o

Modified: branches/4.0-python/source/scripting/python/parammodule.c
===================================================================
--- branches/4.0-python/source/scripting/python/parammodule.c	2007-09-26 02:06:32 UTC (rev 25346)
+++ branches/4.0-python/source/scripting/python/parammodule.c	2007-09-26 02:06:36 UTC (rev 25347)
@@ -21,43 +21,56 @@
 */
 
 #include "includes.h"
-#include "scripting/ejs/smbcalls.h"
+#include "scripting/python/talloc.h"
 #include "Python.h"
 #include "param/param.h"
 
-PyTypeObject noddy_NoddyType;
+staticforward PyTypeObject param_ParamFileType;
 
 typedef struct {
-	    PyObject_HEAD
-} noddy_NoddyObject;
+	PyObject_HEAD
+} param_ParamFileObject;
 
-static PyObject *loadparm_object(void)
-{
-	PyObject *self = PyObject_New();	
-
-	/* FIXME */
-
-	return self;
-}
-
 static PyObject *param_load(PyObject *self, PyObject *args)
 {
+	int ret;
 	char *filename;
-	PyObject *param;
+	param_ParamFileObject *param;
 
 	if (!PyArg_ParseTuple(args, "s:new", &filename))
 	        return NULL;
 
-	param = PyObject_New();
+	param = PyObject_New(param_ParamFileObject, &param_ParamFileType);
 
+	ret = param_read(PyMemCtx(), filename);
+
+	if (ret == -1) {
+		PyErr_SetString(PyExc_TypeError, "reading file failed");
+		return NULL;
+	}
+
 	/* FIXME: Add members:
 	 *   globals
 	 *   shares
 	 */
 
-	return param;
+	return (PyObject *)param;
 }
 
+static void
+param_dealloc(PyObject* self)
+{
+	PyObject_Del(self);
+}
+
+static PyTypeObject param_ParamFileType = {
+	PyObject_HEAD_INIT(NULL) 0,
+	.tp_name = "ParamFile",
+	.tp_basicsize = sizeof(param_ParamFileObject),
+	.tp_dealloc = param_dealloc,
+};
+
+
 static PyMethodDef methods[] = {
 	{ "ParamFile", (PyCFunction)param_load, METH_VARARGS, NULL},
 	{ NULL, NULL }
@@ -65,6 +78,12 @@
 
 PyDoc_STRVAR(param_doc, "Simple wrappers around the smb.conf parsers");
 
+PyObject *loadparm_object(void)
+{
+
+	return NULL; /* FIXME */
+}
+
 PyMODINIT_FUNC initparam(void)
 {
 	PyObject *mod = Py_InitModule3("param", methods, param_doc);
@@ -72,5 +91,5 @@
 		return;
 
 	/* FIXME: Check error code */
-	PyModule_AddObject(mod, "default_config", loadparm_object());
+	/*PyModule_AddObject(mod, "default_config", loadparm_object());*/
 }

Added: branches/4.0-python/source/scripting/python/talloc.c
===================================================================
--- branches/4.0-python/source/scripting/python/talloc.c	2007-09-26 02:06:32 UTC (rev 25346)
+++ branches/4.0-python/source/scripting/python/talloc.c	2007-09-26 02:06:36 UTC (rev 25347)
@@ -0,0 +1,30 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Helper functions for using talloc and Python together
+
+   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 "scripting/ejs/smbcalls.h"
+#include "Python.h"
+#include "param/param.h"
+
+TALLOC_CTX *PyMemCtx() {
+	return talloc_autofree_context();
+}



More information about the samba-cvs mailing list