ekg2  GIT master
python-plugin.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2004-2005 Leszek Krupiński <leafnode@pld-linux.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License Version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef __PYTHON_PLUGIN_H_
21 
22 #define __PYTHON_PLUGIN_H_
23 
24 #include <Python.h>
25 
26 typedef struct
27 {
29  char *name;
30  int prio;
31  int loaded;
33 
35 int ekg_plugin_init(ekg_pluginObj *self, PyObject *args, PyObject *kwds);
36 PyObject* ekg_plugin_unload(ekg_pluginObj *self, PyObject *args);
37 PyObject* ekg_plugin_load(ekg_pluginObj *self, PyObject *args);
38 PyObject* ekg_plugin_is_loaded(ekg_pluginObj *self, PyObject *args);
39 PyObject* ekg_plugin_get_attr(ekg_pluginObj * self, char * attr);
40 
41 staticforward PyMethodDef ekg_plugin_methods[] = {
42  {"load", (PyCFunction)ekg_plugin_load, METH_VARARGS, "Load plugin"},
43  {"unload", (PyCFunction)ekg_plugin_unload, METH_NOARGS, "Unload plugin"},
44  {"isLoaded", (PyCFunction)ekg_plugin_is_loaded, METH_NOARGS, "Check if plugin is loaded"},
45  {NULL, NULL, 0, NULL}
46 };
47 
48 static PyTypeObject ekg_plugin_type = {
49  PyObject_HEAD_INIT(NULL)
50  0,
51  "plugin",
52  sizeof(ekg_pluginObj),
53  0,
54  (destructor)ekg_plugin_dealloc,
55  0,
56  (getattrfunc)ekg_plugin_get_attr,
57  0,
58  0,
59  0,
60  0,
61  0,
62  0,
63  0, /*tp_hash */
64  0, /*tp_call*/
65  0, /*tp_str*/
66  0, /*tp_getattro*/
67  0, /*tp_setattro*/
68  0, /*tp_as_buffer*/
69  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
70  "Plugin object", /* tp_doc */
71  0, /* tp_traverse */
72  0, /* tp_clear */
73  0, /* tp_richcompare */
74  0, /* tp_weaklistoffset */
75  0, /* tp_iter */
76  0, /* tp_iternext */
77  ekg_plugin_methods, /* tp_methods */
78  0, /* tp_members */
79  0, /* tp_getset */
80  0, /* tp_base */
81  0, /* tp_dict */
82  0, /* tp_descr_get */
83  0, /* tp_descr_set */
84  0, /* tp_dictoffset */
85  (initproc)ekg_plugin_init, /* tp_init */
86  0, /* tp_alloc */
87  0, /* tp_new */
88 };
89 
90 
91 #endif
92 
93 /*
94  * Local Variables:
95  * mode: c
96  * c-file-style: "k&r"
97  * c-basic-offset: 8
98  * indent-tabs-mode: t
99  * End:
100  * vim: sts=8 sw=8
101  */
char * name
Definition: python-plugin.h:29
int ekg_plugin_init(ekg_pluginObj *self, PyObject *args, PyObject *kwds)
Definition: python-plugin.c:48
int prio
Definition: python-plugin.h:30
void ekg_plugin_dealloc(ekg_pluginObj *o)
Definition: python-plugin.c:84
int loaded
Definition: python-plugin.h:31
#define NULL
Definition: oralog.c:49
PyObject_HEAD
Definition: python-plugin.h:28
PyObject * ekg_plugin_load(ekg_pluginObj *self, PyObject *args)
Definition: python-plugin.c:97
staticforward PyMethodDef ekg_plugin_methods[]
Definition: python-plugin.h:41
static PyTypeObject ekg_plugin_type
Definition: python-plugin.h:48
Definition: python-plugin.h:26
PyObject * ekg_plugin_is_loaded(ekg_pluginObj *self, PyObject *args)
Definition: python-plugin.c:128
PyObject * ekg_plugin_get_attr(ekg_pluginObj *self, char *attr)
Definition: python-plugin.c:72
PyObject * ekg_plugin_unload(ekg_pluginObj *self, PyObject *args)
Definition: python-plugin.c:147