summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8d6c9e2)
raw | patch | inline | side by side (parent: 8d6c9e2)
author | Sven Trenkel <collectd@semidefinite.de> | |
Sun, 11 Oct 2009 01:47:39 +0000 (03:47 +0200) | ||
committer | Sven Trenkel <collectd@semidefinite.de> | |
Sun, 11 Oct 2009 01:47:39 +0000 (03:47 +0200) |
src/python.c | patch | blob | history |
diff --git a/src/python.c b/src/python.c
index 6428a9476b8544bef56768550055b489c150329c..a6f79a4b786011ae3190fe02e476600bc7ad7598 100644 (file)
--- a/src/python.c
+++ b/src/python.c
typedef struct cpy_callback_s {
char *name;
PyObject *callback;
+ PyObject *data;
struct cpy_callback_s *next;
} cpy_callback_t;
Config_new /* tp_new */
};
-static PyObject *cpy_register_config(PyObject *self, PyObject *args) {
+static PyObject *cpy_register_config(PyObject *self, PyObject *args, PyObject *kwds) {
cpy_callback_t *c;
const char *name = NULL;
- PyObject *callback = NULL;
+ PyObject *callback = NULL, *data = NULL;
+ static char *kwlist[] = {"callback", "data", "name", NULL};
- if (PyArg_ParseTuple(args, "O|z", &callback, &name) == 0) return NULL;
+ if (PyArg_ParseTupleAndKeywords(args, kwds, "O|Oz", kwlist, &callback, &data, &name) == 0) return NULL;
if (PyCallable_Check(callback) == 0) {
PyErr_SetString(PyExc_TypeError, "callback needs a be a callable object.");
return 0;
c = malloc(sizeof(*c));
c->name = strdup(name);
c->callback = callback;
+ c->data = data;
c->next = cpy_config_callbacks;
cpy_config_callbacks = c;
return Py_None;
}
static PyMethodDef cpy_methods[] = {
- {"register_config", cpy_register_config, METH_VARARGS, "foo"},
+ {"register_config", (PyCFunction) cpy_register_config, METH_VARARGS | METH_KEYWORDS, "This is an unhelpful text."},
{0, 0, 0, 0}
};
void module_register(void) {
plugin_register_complex_config("python", cpy_config);
plugin_register_init("python", cpy_init);
-// plugin_register_read("netapp", cna_read);
- plugin_register_shutdown("netapp", cpy_shutdown);
+// plugin_register_read("python", cna_read);
+ plugin_register_shutdown("python", cpy_shutdown);
}