ekg2
|
00001 /* $Id$ */ 00002 00003 /* 00004 * (C) Copyright 2004-2005 Leszek Krupiński <leafnode@pld-linux.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License Version 2 as 00008 * published by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __PYTHON_PLUGIN_H_ 00021 00022 #define __PYTHON_PLUGIN_H_ 00023 00024 #include <Python.h> 00025 00026 typedef struct 00027 { 00028 PyObject_HEAD; 00029 char *name; 00030 int prio; 00031 int loaded; 00032 } ekg_pluginObj; 00033 00034 void ekg_plugin_dealloc(ekg_pluginObj *o); 00035 int ekg_plugin_init(ekg_pluginObj *self, PyObject *args, PyObject *kwds); 00036 PyObject* ekg_plugin_unload(ekg_pluginObj *self, PyObject *args); 00037 PyObject* ekg_plugin_load(ekg_pluginObj *self, PyObject *args); 00038 PyObject* ekg_plugin_is_loaded(ekg_pluginObj *self, PyObject *args); 00039 PyObject* ekg_plugin_get_attr(ekg_pluginObj * self, char * attr); 00040 00041 staticforward PyMethodDef ekg_plugin_methods[] = { 00042 {"load", (PyCFunction)ekg_plugin_load, METH_VARARGS, "Load plugin"}, 00043 {"unload", (PyCFunction)ekg_plugin_unload, METH_NOARGS, "Unload plugin"}, 00044 {"isLoaded", (PyCFunction)ekg_plugin_is_loaded, METH_NOARGS, "Check if plugin is loaded"}, 00045 {NULL, NULL, 0, NULL} 00046 }; 00047 00048 static PyTypeObject ekg_plugin_type = { 00049 PyObject_HEAD_INIT(NULL) 00050 0, 00051 "plugin", 00052 sizeof(ekg_pluginObj), 00053 0, 00054 (destructor)ekg_plugin_dealloc, 00055 0, 00056 (getattrfunc)ekg_plugin_get_attr, 00057 0, 00058 0, 00059 0, 00060 0, 00061 0, 00062 0, 00063 0, /*tp_hash */ 00064 0, /*tp_call*/ 00065 0, /*tp_str*/ 00066 0, /*tp_getattro*/ 00067 0, /*tp_setattro*/ 00068 0, /*tp_as_buffer*/ 00069 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 00070 "Plugin object", /* tp_doc */ 00071 0, /* tp_traverse */ 00072 0, /* tp_clear */ 00073 0, /* tp_richcompare */ 00074 0, /* tp_weaklistoffset */ 00075 0, /* tp_iter */ 00076 0, /* tp_iternext */ 00077 ekg_plugin_methods, /* tp_methods */ 00078 0, /* tp_members */ 00079 0, /* tp_getset */ 00080 0, /* tp_base */ 00081 0, /* tp_dict */ 00082 0, /* tp_descr_get */ 00083 0, /* tp_descr_set */ 00084 0, /* tp_dictoffset */ 00085 (initproc)ekg_plugin_init, /* tp_init */ 00086 0, /* tp_alloc */ 00087 0, /* tp_new */ 00088 }; 00089 00090 00091 #endif 00092 00093 /* 00094 * Local Variables: 00095 * mode: c 00096 * c-file-style: "k&r" 00097 * c-basic-offset: 8 00098 * indent-tabs-mode: t 00099 * End: 00100 * vim: sts=8 sw=8 00101 */