summaryrefslogtreecommitdiff
path: root/source4/lib/com/pycom.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-19 02:27:40 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-19 02:27:40 +0200
commit495758a73e125e59921092c893c6e32ba7091fe1 (patch)
treebfaf7696d3452722d1c464cd733157ebc04bdd1a /source4/lib/com/pycom.c
parentba5fe7122586d8b382bf78f1e1cb5dbe4293c27b (diff)
downloadsamba-495758a73e125e59921092c893c6e32ba7091fe1.tar.gz
samba-495758a73e125e59921092c893c6e32ba7091fe1.tar.bz2
samba-495758a73e125e59921092c893c6e32ba7091fe1.zip
Fix COM compilation, add framework for COM python module.
Diffstat (limited to 'source4/lib/com/pycom.c')
-rw-r--r--source4/lib/com/pycom.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/source4/lib/com/pycom.c b/source4/lib/com/pycom.c
new file mode 100644
index 0000000000..b6d6b772a8
--- /dev/null
+++ b/source4/lib/com/pycom.c
@@ -0,0 +1,70 @@
+/*
+ Unix SMB/CIFS implementation.
+ Python bindings for COM library.
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include <Python.h>
+#include "lib/com/com.h"
+
+static PyObject *py_get_class_object(PyObject *self, PyObject *args)
+{
+ char *s_clsid, *s_iid;
+ struct GUID clsid, iid;
+ struct IUnknown *object;
+
+ if (!PyArg_ParseTuple(args, "ss", &s_clsid, &s_iid))
+ return NULL;
+
+ status = GUID_from_string(s_clsid, &clsid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_FromNTSTATUS(status);
+ return NULL;
+ }
+
+ status = GUID_from_string(s_iid, &iid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_FromNTSTATUS(status);
+ return NULL;
+ }
+
+ error = com_get_class_object(ctx, &clsid, &iid, &object);
+ if (!W_ERROR_IS_OK(error)) {
+ PyErr_FromWERROR(error);
+ return NULL;
+ }
+
+ /* FIXME: Magic, integrate with stubs generated by pidl. */
+
+ return Py_None;
+}
+
+static struct PyMethodDef com_methods[] = {
+ { "get_class_object", (PyCFunction)py_get_class_object, METH_VARARGS, "S.get_class_object(clsid, iid) -> instance" },
+ { NULL },
+};
+
+void initcom(void)
+{
+ PyObject *m;
+
+ /* FIXME: Initialize COM context and attach it to m. */
+
+ m = Py_InitModule3("com", com_methods, "Simple COM implementation");
+ if (m == NULL)
+ return;
+}