ekg2
plugins/python/python-session.h
Idź do dokumentacji tego pliku.
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_SESSION_H_
00021 
00022 #define __PYTHON_SESSION_H_
00023 
00024 #include <Python.h>
00025 
00026 typedef struct {
00027         PyObject_HEAD
00028         char * name;
00029 } ekg_sessionObj;
00030 
00031 void ekg_session_dealloc(ekg_sessionObj * o);
00032 PyObject * ekg_session_repr(ekg_sessionObj * self);
00033 PyObject * ekg_session_str(ekg_sessionObj * self);
00034 int ekg_session_init(ekg_sessionObj *self, PyObject *args, PyObject *kwds);
00035 int ekg_session_len(ekg_sessionObj * self);
00036 PyObject *ekg_session_set(ekg_sessionObj * self, PyObject * key, PyObject * value);
00037 PyObject *ekg_session_connected(ekg_sessionObj * self);
00038 PyObject *ekg_session_get_attr(ekg_sessionObj * self, char * attr);
00039 PyObject *ekg_session_user_get(ekg_sessionObj * self, PyObject * pyargs);
00040 PyObject *ekg_session_users(ekg_sessionObj * self);
00041 PyObject *ekg_session_get(ekg_sessionObj * self, PyObject * key);
00042 PyObject *ekg_session_status_set(ekg_sessionObj * self, PyObject * pyargs);
00043 PyObject *ekg_session_status(ekg_sessionObj * self);
00044 PyObject *ekg_session_connect(ekg_sessionObj * self);
00045 PyObject *ekg_session_disconnect(ekg_sessionObj * self);
00046 
00047 staticforward PyMethodDef ekg_session_methods[] = {
00048         {"connected", (PyCFunction)ekg_session_connected, METH_NOARGS, "Check if session is connected"},
00049         {"user_get", (PyCFunction)ekg_session_user_get, METH_VARARGS, "Return user object"},
00050         {"users", (PyCFunction)ekg_session_users, METH_NOARGS, "Return userlist"},
00051         {"status_set", (PyCFunction)ekg_session_status_set, METH_VARARGS, "Set status for session"},
00052         {"status", (PyCFunction)ekg_session_status, METH_NOARGS, "Get status tuple for session"},
00053         {"connect", (PyCFunction)ekg_session_connect, METH_NOARGS, "Connect session"},
00054         {"disconnect", (PyCFunction)ekg_session_disconnect, METH_NOARGS, "Disconnect session"},
00055         {NULL, NULL, 0, NULL}
00056 };
00057 
00058 static PyMappingMethods ekg_session_mapping = {
00059     (inquiry) ekg_session_len,
00060     (binaryfunc) ekg_session_get,
00061     (objobjargproc) ekg_session_set
00062 };
00063 
00064 static PyTypeObject ekg_session_type = {
00065     PyObject_HEAD_INIT(NULL)
00066     0,
00067     "session",
00068     sizeof(ekg_sessionObj),
00069     0,
00070     (destructor)ekg_session_dealloc,
00071     0,
00072     (getattrfunc)ekg_session_get_attr,
00073     0,
00074     0,
00075     (reprfunc)ekg_session_repr,
00076     0,
00077     0,
00078     &ekg_session_mapping,
00079     0,                                                  /*tp_hash */
00080     0,                                                  /*tp_call*/
00081     (reprfunc)ekg_session_str,                          /*tp_str*/
00082     0,                                                  /*tp_getattro*/
00083     0,                                                  /*tp_setattro*/
00084     0,                                                  /*tp_as_buffer*/
00085     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,           /*tp_flags*/
00086     "Session object",                                   /* tp_doc */
00087     0,                                                  /* tp_traverse */
00088     0,                                                  /* tp_clear */
00089     0,                                                  /* tp_richcompare */
00090     0,                                                  /* tp_weaklistoffset */
00091     0,                                                  /* tp_iter */
00092     0,                                                  /* tp_iternext */
00093     ekg_session_methods,                                /* tp_methods */
00094     0,                                                  /* tp_members */
00095     0,                                                  /* tp_getset */
00096     0,                                                  /* tp_base */
00097     0,                                                  /* tp_dict */
00098     0,                                                  /* tp_descr_get */
00099     0,                                                  /* tp_descr_set */
00100     0,                                                  /* tp_dictoffset */
00101     (initproc)ekg_session_init,                         /* tp_init */
00102     0,                                                  /* tp_alloc */
00103     0,                                                  /* tp_new */
00104 };
00105 
00106 #endif
00107 
00108 /*
00109  * Local Variables:
00110  * mode: c
00111  * c-file-style: "k&r"
00112  * c-basic-offset: 8
00113  * indent-tabs-mode: t
00114  * End:
00115  * vim: sts=8 sw=8
00116  */
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje