kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

python_api.h (2079B)



      1 /*
      2  * Copyright (c) 2016 Stanislav Yudin <stan@endlessinsomnia.com>
      3  * Copyright (c) 2017-2022 Joris Vink <joris@coders.se>
      4  *
      5  * Permission to use, copy, modify, and distribute this software for any
      6  * purpose with or without fee is hereby granted, provided that the above
      7  * copyright notice and this permission notice appear in all copies.
      8  *
      9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     16  */
     17 
     18 #ifndef __H_PYTHON_H
     19 #define __H_PYTHON_H
     20 
     21 #undef _POSIX_C_SOURCE
     22 #undef _XOPEN_SOURCE
     23 
     24 #define PY_SSIZE_T_CLEAN	1
     25 
     26 #include <Python.h>
     27 #include <frameobject.h>
     28 
     29 void		kore_python_init(void);
     30 void		kore_python_preinit(void);
     31 void		kore_python_cleanup(void);
     32 void		kore_python_coro_run(void);
     33 void		kore_python_proc_reap(void);
     34 int		kore_python_coro_pending(void);
     35 void		kore_python_path(const char *);
     36 void		kore_python_coro_delete(void *);
     37 void		kore_python_routes_resolve(void);
     38 void		kore_python_log_error(const char *);
     39 
     40 PyObject	*kore_python_callable(PyObject *, const char *);
     41 
     42 #if defined(__linux__)
     43 void	kore_python_seccomp_cleanup(void);
     44 void	kore_python_seccomp_hook(const char *);
     45 #endif
     46 
     47 #if !defined(KORE_SINGLE_BINARY)
     48 extern const char			*kore_pymodule;
     49 #endif
     50 
     51 extern struct kore_module_functions	kore_python_module;
     52 extern struct kore_runtime		kore_python_runtime;
     53 
     54 #define KORE_PYTHON_SIGNAL_HOOK		"koreapp.signal"
     55 #define KORE_PYTHON_TEARDOWN_HOOK	"koreapp.cleanup"
     56 #define KORE_PYTHON_CONFIG_HOOK		"koreapp.configure"
     57 #define KORE_PYTHON_DAEMONIZED_HOOK	"koreapp.daemonized"
     58 #define KORE_PYTHON_WORKER_STOP_HOOK	"koreapp.workerstop"
     59 #define KORE_PYTHON_WORKER_START_HOOK	"koreapp.workerstart"
     60 
     61 #endif