ekg2  GIT master
python-user.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_USER_H_
21 
22 #define __PYTHON_USER_H_
23 
24 #include <Python.h>
25 
26 typedef struct {
27  PyObject_HEAD
28  char * name;
29  char * session;
30 } ekg_userObj;
31 
32 PyObject * python_build_user(char * session, const char * name);
33 PyObject * ekg_user_repr(ekg_userObj * self);
34 PyObject * ekg_user_str(ekg_userObj * self);
36 int ekg_user_init(ekg_userObj *self, PyObject *args, PyObject *kwds);
37 PyObject *ekg_user_groups(ekg_userObj * self);
38 PyObject *ekg_user_get_attr(ekg_userObj * self, char * attr);
39 
40 staticforward PyMethodDef ekg_user_methods[] = {
41  {"groups", (PyCFunction)ekg_user_groups, METH_NOARGS, "Returns groups user belongs to"},
42  {NULL, NULL, 0, NULL}
43 };
44 
45 static PyTypeObject ekg_user_type = {
46  PyObject_HEAD_INIT(NULL)
47  0,
48  "user",
49  sizeof(ekg_userObj),
50  0,
51  (destructor)ekg_user_dealloc,
52  0,
53  (getattrfunc)ekg_user_get_attr,
54  0,
55  0,
56  (reprfunc)ekg_user_repr,
57  0,
58  0,
59  0,
60  0, /*tp_hash */
61  0, /*tp_call*/
62  (reprfunc)ekg_user_str, /*tp_str*/
63  0, /*tp_getattro*/
64  0, /*tp_setattro*/
65  0, /*tp_as_buffer*/
66  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
67  "User object", /* tp_doc */
68  0, /* tp_traverse */
69  0, /* tp_clear */
70  0, /* tp_richcompare */
71  0, /* tp_weaklistoffset */
72  0, /* tp_iter */
73  0, /* tp_iternext */
74  ekg_user_methods, /* tp_methods */
75  0, /* tp_members */
76  0, /* tp_getset */
77  0, /* tp_base */
78  0, /* tp_dict */
79  0, /* tp_descr_get */
80  0, /* tp_descr_set */
81  0, /* tp_dictoffset */
82  (initproc)ekg_user_init, /* tp_init */
83  0, /* tp_alloc */
84  0, /* tp_new */
85 };
86 
87 #endif
88 
89 /*
90  * Local Variables:
91  * mode: c
92  * c-file-style: "k&r"
93  * c-basic-offset: 8
94  * indent-tabs-mode: t
95  * End:
96  * vim: sts=8 sw=8
97  */
int ekg_user_init(ekg_userObj *self, PyObject *args, PyObject *kwds)
Definition: python-user.c:89
PyObject * ekg_user_groups(ekg_userObj *self)
Definition: python-user.c:269
void ekg_user_dealloc(ekg_userObj *o)
Definition: python-user.c:225
PyObject * ekg_user_get_attr(ekg_userObj *self, char *attr)
Definition: python-user.c:112
#define NULL
Definition: oralog.c:49
char * session
Definition: python-user.h:29
static PyTypeObject ekg_user_type
Definition: python-user.h:45
Definition: python-user.h:26
const char * name
Definition: remote.c:88
PyObject * ekg_user_repr(ekg_userObj *self)
Definition: python-user.c:242
PyObject * ekg_user_str(ekg_userObj *self)
Definition: python-user.c:256
PyObject_HEAD char * name
Definition: python-user.h:28
staticforward PyMethodDef ekg_user_methods[]
Definition: python-user.h:40
PyObject * python_build_user(char *session, const char *name)
Definition: python-user.c:49