12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /*
- * Copyright (C) 2019 Weber Yann
- *
- * This file is part of PyFCGI.
- *
- * PyFCGI is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * PyFCGI 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with PyFCGI. If not, see <http://www.gnu.org/licenses/>.
- */
- #ifndef _PYUTILS__H__
- #define _PYUTILS__H__
-
- #include "config.h"
-
- #include <fcgiapp.h>
- #include <fcgi_stdio.h> /* fcgi library; put it first*/
-
- #define PY_SSIZE_T_CLEAN
- #include <Python.h>
-
- #include "logger.h"
- #include "python_pyfcgi.h"
-
- /* Imports from libpyfcgi python module header */
- extern PyObject* response_status;
- extern PyObject* response_headers;
- extern PyObject* libpyfcgi_self;
-
- /**@brief Call Py_Initialize & update_python_path
- */
- void pyinit();
-
- /**@brief Add . to the embed pythonpath
- * @deprecated Py_SetPath breaks Py_GetPrefix()... now
- */
- void update_python_path();
-
- /**@brief Fetch stdout & stderr python flush() function
- * @param PyObject* pystdout_flush
- * @param PyObject* pystderr_flush
- */
- void fetch_pyflush(PyObject**, PyObject**);
-
- /**@brief Create two pipes for stdout & stderr
- * @ingroup worker_process
- * @params int[2] pystdout
- * @params int[2] pystderr
- */
- void update_python_fd(int[2], int[2]);
-
- /**@brief Clear then update python sys.environ using current FCI environ
- * @ingroup worker_process
- * @note The environ has to be set without a call to os.putenv, the problem
- * is that the os.environ is a special mapping calling putenv on setitem...
- * For these reason the os.environ will be replaced by a new dict instance for
- * each request...
- * @param PyObject* os module
- * @return Python env dict
- */
- PyObject* update_pyenv(PyObject*, char**);
-
- /**@brief Import & return the python entrypoint callable
- * from PyFCGI_conf.py_entrymod & PyFCGI_conf.py_entryfun */
- PyObject* import_entrypoint();
-
- /**@brief Return the start_response() python function for pep333 worker */
- PyObject* get_start_response();
-
-
- /**@brief Logs an exception */
- void log_expt(int priority);
-
- /**@brief Set python version
- * @param char[16] version buffer */
- void pyfcgi_python_version(char[16]);
-
- /**@brief Import os module and exit on error
- * @return Imported module */
- PyObject* python_osmod();
-
- #endif
|