123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /*
- * 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 pystdout_flush will point on &sys.stdout.flush() python function
- * @param pystderr_flush will point on &sys.stderr.flush() python function
- */
- void fetch_pyflush(PyObject** pystdout_flush, PyObject** pystderr_flush);
-
- /**@brief Create two pipes for stdout & stderr
- * @ingroup worker_process
- * @param pipe_out pipe for stdout
- * @param pipe_err pipe for stderr
- * @warning Deprecated behavior. We will us ioin like classes for std & err
- * output
- */
- void update_python_fd(int pipe_out[2], int pipe_err[2]);
-
- /**@brief Clear then update python sys.environ using current FCGI 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 py_osmod Python os module
- * @param environ The environ string provided by libfcgi
- * @return Python env dict
- */
- PyObject* update_pyenv(PyObject* py_osmod, char** environ);
-
- /**@brief Import & return the python entrypoint callable
- * from PyFCGI_conf.py_entrymod & PyFCGI_conf.py_entryfun */
- PyObject* import_entrypoint();
-
- /**@brief Init and return libpyfcgi */
- PyObject* pyinit_libpyfcgi();
- /**@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 version version buffer */
- void pyfcgi_python_version(char version[16]);
-
- /**@brief Import os module and exit on error
- * @return Imported module */
- PyObject* python_osmod();
-
- #endif
|