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) |
| 14 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 15 | #define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0) |
| 16 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 17 | /* Lua HAProxy integration functions. */ |
Thierry FOURNIER | 380d093 | 2015-01-23 14:27:52 +0100 | [diff] [blame] | 18 | void hlua_ctx_destroy(struct hlua *lua); |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 19 | void hlua_init(); |
Thierry FOURNIER | a4a0f3d | 2015-01-23 12:08:30 +0100 | [diff] [blame] | 20 | int hlua_post_init(); |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 21 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 22 | #else /* USE_LUA */ |
| 23 | |
Thierry FOURNIER | a097fdf | 2015-03-03 15:17:35 +0100 | [diff] [blame] | 24 | #define HLUA_IS_RUNNING(__hlua) 0 |
| 25 | |
Thierry FOURNIER | a718b29 | 2015-03-04 16:48:34 +0100 | [diff] [blame] | 26 | #define HLUA_INIT(__hlua) |
| 27 | |
| 28 | /* Empty function for compilation without Lua. */ |
| 29 | static inline void hlua_init() { } |
| 30 | static inline int hlua_post_init() { return 1; } |
| 31 | static inline void hlua_ctx_destroy() { } |
| 32 | |
| 33 | #endif /* USE_LUA */ |
| 34 | |
Thierry FOURNIER | 6f1fd48 | 2015-01-23 14:06:13 +0100 | [diff] [blame] | 35 | #endif /* _PROTO_HLUA_H */ |