Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 1 | #ifndef _PROTO_HLUA_H |
| 2 | #define _PROTO_HLUA_H |
| 3 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 4 | #ifdef USE_LUA |
| 5 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 6 | #include <lua.h> |
| 7 | |
| 8 | #include <types/hlua.h> |
| 9 | |
Thierry FOURNIER | a097fdf | 2015-03-03 15:17:35 +0100 | [diff] [blame] | 10 | /* The following macros are used to set flags. */ |
| 11 | #define HLUA_SET_RUN(__hlua) do {(__hlua)->flags |= HLUA_RUN;} while(0) |
| 12 | #define HLUA_CLR_RUN(__hlua) do {(__hlua)->flags &= ~HLUA_RUN;} while(0) |
| 13 | #define HLUA_IS_RUNNING(__hlua) ((__hlua)->flags & HLUA_RUN) |
Thierry FOURNIER | 4abd3ae | 2015-03-03 17:29:06 +0100 | [diff] [blame] | 14 | #define HLUA_SET_CTRLYIELD(__hlua) do {(__hlua)->flags |= HLUA_CTRLYIELD;} while(0) |
| 15 | #define HLUA_CLR_CTRLYIELD(__hlua) do {(__hlua)->flags &= ~HLUA_CTRLYIELD;} while(0) |
| 16 | #define HLUA_IS_CTRLYIELDING(__hlua) ((__hlua)->flags & HLUA_CTRLYIELD) |
Thierry FOURNIER | ef6a211 | 2015-03-05 17:45:34 +0100 | [diff] [blame] | 17 | #define HLUA_SET_WAKERESWR(__hlua) do {(__hlua)->flags |= HLUA_WAKERESWR;} while(0) |
| 18 | #define HLUA_CLR_WAKERESWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKERESWR;} while(0) |
| 19 | #define HLUA_IS_WAKERESWR(__hlua) ((__hlua)->flags & HLUA_WAKERESWR) |
Thierry FOURNIER | 53e08ec | 2015-03-06 00:35:53 +0100 | [diff] [blame] | 20 | #define HLUA_SET_WAKEREQWR(__hlua) do {(__hlua)->flags |= HLUA_WAKEREQWR;} while(0) |
| 21 | #define HLUA_CLR_WAKEREQWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKEREQWR;} while(0) |
| 22 | #define HLUA_IS_WAKEREQWR(__hlua) ((__hlua)->flags & HLUA_WAKEREQWR) |
Thierry FOURNIER | a097fdf | 2015-03-03 15:17:35 +0100 | [diff] [blame] | 23 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 24 | #define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0) |
| 25 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 26 | /* Lua HAProxy integration functions. */ |
Christopher Faulet | 979865e | 2021-03-24 14:48:45 +0100 | [diff] [blame] | 27 | const char *hlua_traceback(lua_State *L, const char* sep); |
Thierry FOURNIER | 380d093 | 2015-01-23 14:27:52 +0100 | [diff] [blame] | 28 | void hlua_ctx_destroy(struct hlua *lua); |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 29 | void hlua_init(); |
Thierry FOURNIER | a4a0f3d | 2015-01-23 12:08:30 +0100 | [diff] [blame] | 30 | int hlua_post_init(); |
Willy Tarreau | 83a5ff4 | 2019-08-21 14:14:50 +0200 | [diff] [blame] | 31 | void hlua_applet_tcp_fct(struct appctx *ctx); |
| 32 | void hlua_applet_http_fct(struct appctx *ctx); |
| 33 | struct task *hlua_process_task(struct task *task, void *context, unsigned short state); |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 34 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 35 | #else /* USE_LUA */ |
| 36 | |
Thierry FOURNIER | a097fdf | 2015-03-03 15:17:35 +0100 | [diff] [blame] | 37 | #define HLUA_IS_RUNNING(__hlua) 0 |
| 38 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 39 | #define HLUA_INIT(__hlua) |
| 40 | |
| 41 | /* Empty function for compilation without Lua. */ |
| 42 | static inline void hlua_init() { } |
| 43 | static inline int hlua_post_init() { return 1; } |
Willy Tarreau | ce7b4de | 2015-06-17 20:18:54 +0200 | [diff] [blame] | 44 | static inline void hlua_ctx_destroy(struct hlua *lua) { } |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 45 | |
| 46 | #endif /* USE_LUA */ |
| 47 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 48 | #endif /* _PROTO_HLUA_H */ |