2 ashd - A Sane HTTP Daemon
3 Copyright (C) 2008 Fredrik Tolf <fredrik@dolda2000.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <ashd/utils.h>
23 #include <ashd/proc.h>
25 static PyObject *p_recvfd(PyObject *self, PyObject *args)
33 if(!PyArg_ParseTuple(args, "|i", &fd))
36 Py_BEGIN_ALLOW_THREADS;
37 ret = recvfd(fd, &data, &dlen);
41 return(Py_BuildValue("OO", Py_None, Py_None));
43 if(PyErr_CheckSignals())
47 PyErr_SetFromErrno(PyExc_OSError);
50 ro = Py_BuildValue("Ni", PyBytes_FromStringAndSize(data, dlen), ret);
56 static PyObject *p_sendfd(PyObject *self, PyObject *args)
61 if(!PyArg_ParseTuple(args, "iiy*", &sock, &fd, &data))
64 Py_BEGIN_ALLOW_THREADS;
65 ret = sendfd(sock, fd, data.buf, data.len);
67 PyBuffer_Release(&data);
70 if(PyErr_CheckSignals())
74 PyErr_SetFromErrno(PyExc_OSError);
81 static PyMethodDef methods[] = {
82 {"recvfd", p_recvfd, METH_VARARGS, "Receive a datagram and a file descriptor"},
83 {"sendfd", p_sendfd, METH_VARARGS, "Send a datagram and a file descriptor"},
87 static struct PyModuleDef module = {
88 PyModuleDef_HEAD_INIT,
94 PyMODINIT_FUNC PyInit_htlib(void)
96 return(PyModule_Create(&module));