File: python-session.h

package info (click to toggle)
ekg2 1%3A0.4~pre%2B20120506.1-16
  • links: PTS
  • area: main
  • in suites: buster
  • size: 6,860 kB
  • sloc: ansic: 78,587; xml: 3,439; perl: 1,908; pascal: 841; makefile: 658; python: 532; sh: 239; ruby: 76; php: 72; sql: 44; sed: 9
file content (116 lines) | stat: -rw-r--r-- 3,905 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* $Id$ */

/*
 *  (C) Copyright 2004-2005 Leszek KrupiƄski <leafnode@pld-linux.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License Version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __PYTHON_SESSION_H_

#define __PYTHON_SESSION_H_

#include <Python.h>

typedef struct {
	PyObject_HEAD
	char * name;
} ekg_sessionObj;

void ekg_session_dealloc(ekg_sessionObj * o);
PyObject * ekg_session_repr(ekg_sessionObj * self);
PyObject * ekg_session_str(ekg_sessionObj * self);
int ekg_session_init(ekg_sessionObj *self, PyObject *args, PyObject *kwds);
int ekg_session_len(ekg_sessionObj * self);
PyObject *ekg_session_set(ekg_sessionObj * self, PyObject * key, PyObject * value);
PyObject *ekg_session_connected(ekg_sessionObj * self);
PyObject *ekg_session_get_attr(ekg_sessionObj * self, char * attr);
PyObject *ekg_session_user_get(ekg_sessionObj * self, PyObject * pyargs);
PyObject *ekg_session_users(ekg_sessionObj * self);
PyObject *ekg_session_get(ekg_sessionObj * self, PyObject * key);
PyObject *ekg_session_status_set(ekg_sessionObj * self, PyObject * pyargs);
PyObject *ekg_session_status(ekg_sessionObj * self);
PyObject *ekg_session_connect(ekg_sessionObj * self);
PyObject *ekg_session_disconnect(ekg_sessionObj * self);

staticforward PyMethodDef ekg_session_methods[] = {
	{"connected", (PyCFunction)ekg_session_connected, METH_NOARGS, "Check if session is connected"},
	{"user_get", (PyCFunction)ekg_session_user_get, METH_VARARGS, "Return user object"},
	{"users", (PyCFunction)ekg_session_users, METH_NOARGS, "Return userlist"},
	{"status_set", (PyCFunction)ekg_session_status_set, METH_VARARGS, "Set status for session"},
	{"status", (PyCFunction)ekg_session_status, METH_NOARGS, "Get status tuple for session"},
	{"connect", (PyCFunction)ekg_session_connect, METH_NOARGS, "Connect session"},
	{"disconnect", (PyCFunction)ekg_session_disconnect, METH_NOARGS, "Disconnect session"},
	{NULL, NULL, 0, NULL}
};

static PyMappingMethods ekg_session_mapping = {
    (inquiry) ekg_session_len,
    (binaryfunc) ekg_session_get,
    (objobjargproc) ekg_session_set
};

static PyTypeObject ekg_session_type = {
    PyObject_HEAD_INIT(NULL)
    0,
    "session",
    sizeof(ekg_sessionObj),
    0,
    (destructor)ekg_session_dealloc,
    0,
    (getattrfunc)ekg_session_get_attr,
    0,
    0,
    (reprfunc)ekg_session_repr,
    0,
    0,
    &ekg_session_mapping,
    0,							/*tp_hash */
    0,							/*tp_call*/
    (reprfunc)ekg_session_str,				/*tp_str*/
    0,							/*tp_getattro*/
    0,							/*tp_setattro*/
    0,							/*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,		/*tp_flags*/
    "Session object",					/* tp_doc */
    0,							/* tp_traverse */
    0,							/* tp_clear */
    0,							/* tp_richcompare */
    0,							/* tp_weaklistoffset */
    0,							/* tp_iter */
    0,							/* tp_iternext */
    ekg_session_methods,				/* tp_methods */
    0,							/* tp_members */
    0,							/* tp_getset */
    0,							/* tp_base */
    0,							/* tp_dict */
    0,							/* tp_descr_get */
    0,							/* tp_descr_set */
    0,							/* tp_dictoffset */
    (initproc)ekg_session_init,				/* tp_init */
    0,							/* tp_alloc */
    0,							/* tp_new */
};

#endif

/*
 * Local Variables:
 * mode: c
 * c-file-style: "k&r"
 * c-basic-offset: 8
 * indent-tabs-mode: t
 * End:
 * vim: sts=8 sw=8
 */