Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

python_ioin.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2019 Weber Yann
  3. *
  4. * This file is part of PyFCGI.
  5. *
  6. * PyFCGI is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * PyFCGI is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PyFCGI. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**@defgroup lib_ioin Defines libpyfcgi.IoIn class
  20. * @brief The IoIn class implement base IO interface allowing python to read
  21. * HTTP request from FCGI
  22. * @ingroup libpyfcgo
  23. */
  24. /**@file python_ioin.h
  25. * @ingroup lib_ioin
  26. */
  27. #ifndef _PYTHON_IOIN__H__
  28. #define _PYTHON_IOIN__H__
  29. #include "config.h"
  30. #include <fcgiapp.h>
  31. #include <fcgi_stdio.h> /* fcgi library; put it first */
  32. #define PY_SSIZE_T_CLEAN
  33. #include <Python.h>
  34. #include "structmember.h"
  35. #include <limits.h>
  36. #include <stdlib.h>
  37. #define IoIn__FromString(self, str) \
  38. (((IoIn*)self)->bin?PyBytes_FromString:PyUnicode_FromString)(str)
  39. #define IoIn__FromBuff(self) IoIn__FromString(self, ((IoIn*)self)->buff)
  40. extern PyMethodDef IoIn_methods[];
  41. extern PyMemberDef IoIn_members[];
  42. extern PyTypeObject IoInType;
  43. typedef struct
  44. {
  45. PyObject_VAR_HEAD;
  46. PyObject *closed;
  47. FCGX_Stream **in_stream;
  48. char *buff;
  49. /**@brief buffer size */
  50. int buff_sz;
  51. /**@brief 1 if binary stream (sending PyBytes) 0 if sending PyUnicode */
  52. short bin;
  53. /**@brief 1 if EOF encountered, else 0 */
  54. short eof;
  55. } IoIn;
  56. int pyfcgi_ioin_init(PyObject *self, PyObject *args, PyObject *kwds);
  57. void pyfcgi_ioin_del(IoIn *self);
  58. PyObject* pyfcgi_ioin_close(PyObject *self, PyObject **argv, Py_ssize_t argc);
  59. PyObject* pyfcgi_ioin_fileno(PyObject *self, PyObject **argv, Py_ssize_t argc);
  60. PyObject* pyfcgi_ioin_flush(PyObject *self, PyObject **argv, Py_ssize_t argc);
  61. PyObject* pyfcgi_ioin_isatty(PyObject *self, PyObject **argv, Py_ssize_t argc);
  62. PyObject* pyfcgi_ioin_readable(PyObject *self, PyObject **argv, Py_ssize_t argc);
  63. PyObject* pyfcgi_ioin_readline(PyObject *self, PyObject **argv, Py_ssize_t argc);
  64. PyObject* pyfcgi_ioin_readlines(PyObject *self, PyObject **argv, Py_ssize_t argc);
  65. PyObject* pyfcgi_ioin_read(PyObject *self, PyObject **argv, Py_ssize_t argc);
  66. PyObject* pyfcgi_ioin_readall(PyObject *self, PyObject **argv, Py_ssize_t argc);
  67. PyObject* pyfcgi_ioin_readinto(PyObject *self, PyObject **argv, Py_ssize_t argc);
  68. PyObject* pyfcgi_ioin_WriteError(PyObject *self, PyObject **argv, Py_ssize_t argc);
  69. #define pyfcgi_ioin_writelines pyfcgi_ioin_WriteError
  70. #define pyfcgi_ioin_write pyfcgi_ioin_WriteError
  71. PyObject* pyfcgi_ioin_SeekError(PyObject *self, PyObject **argv, Py_ssize_t argc);
  72. #define pyfcgi_ioin_seek pyfcgi_ioin_SeekError
  73. #define pyfcgi_ioin_tell pyfcgi_ioin_SeekError
  74. PyObject* pyfcgi_ioin_truncate(PyObject *self, PyObject **argv, Py_ssize_t argc);
  75. PyObject* pyfcgi_ioin_seekable(PyObject *self, PyObject **argv, Py_ssize_t argc);
  76. PyObject* pyfcgi_ioin_writable(PyObject *self, PyObject **argv, Py_ssize_t argc);
  77. #endif