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_USER_H_ 00021 00022 #define __PYTHON_USER_H_ 00023 00024 #include <Python.h> 00025 00026 typedef struct { 00027 PyObject_HEAD 00028 char * name; 00029 char * session; 00030 } ekg_userObj; 00031 00032 PyObject * python_build_user(char * session, const char * name); 00033 PyObject * ekg_user_repr(ekg_userObj * self); 00034 PyObject * ekg_user_str(ekg_userObj * self); 00035 void ekg_user_dealloc(ekg_userObj * o); 00036 int ekg_user_init(ekg_userObj *self, PyObject *args, PyObject *kwds); 00037 PyObject *ekg_user_groups(ekg_userObj * self); 00038 PyObject *ekg_user_get_attr(ekg_userObj * self, char * attr); 00039 00040 staticforward PyMethodDef ekg_user_methods[] = { 00041 {"groups", (PyCFunction)ekg_user_groups, METH_NOARGS, "Returns groups user belongs to"}, 00042 {NULL, NULL, 0, NULL} 00043 }; 00044 00045 static PyTypeObject ekg_user_type = { 00046 PyObject_HEAD_INIT(NULL) 00047 0, 00048 "user", 00049 sizeof(ekg_userObj), 00050 0, 00051 (destructor)ekg_user_dealloc, 00052 0, 00053 (getattrfunc)ekg_user_get_attr, 00054 0, 00055 0, 00056 (reprfunc)ekg_user_repr, 00057 0, 00058 0, 00059 0, 00060 0, /*tp_hash */ 00061 0, /*tp_call*/ 00062 (reprfunc)ekg_user_str, /*tp_str*/ 00063 0, /*tp_getattro*/ 00064 0, /*tp_setattro*/ 00065 0, /*tp_as_buffer*/ 00066 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 00067 "User object", /* tp_doc */ 00068 0, /* tp_traverse */ 00069 0, /* tp_clear */ 00070 0, /* tp_richcompare */ 00071 0, /* tp_weaklistoffset */ 00072 0, /* tp_iter */ 00073 0, /* tp_iternext */ 00074 ekg_user_methods, /* tp_methods */ 00075 0, /* tp_members */ 00076 0, /* tp_getset */ 00077 0, /* tp_base */ 00078 0, /* tp_dict */ 00079 0, /* tp_descr_get */ 00080 0, /* tp_descr_set */ 00081 0, /* tp_dictoffset */ 00082 (initproc)ekg_user_init, /* tp_init */ 00083 0, /* tp_alloc */ 00084 0, /* tp_new */ 00085 }; 00086 00087 #endif 00088 00089 /* 00090 * Local Variables: 00091 * mode: c 00092 * c-file-style: "k&r" 00093 * c-basic-offset: 8 00094 * indent-tabs-mode: t 00095 * End: 00096 * vim: sts=8 sw=8 00097 */