2020-06-04 03:20:54 -04:00
|
|
|
/*
|
|
|
|
|
* include/haproxy/hlua.h
|
|
|
|
|
* Lua core management functions
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2015-2016 Thierry Fournier <tfournier@arpalert.org>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
|
* exclusively.
|
|
|
|
|
*
|
|
|
|
|
* This library 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
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
2015-01-23 08:06:13 -05:00
|
|
|
|
2020-06-04 03:20:54 -04:00
|
|
|
#ifndef _HAPROXY_HLUA_H
|
|
|
|
|
#define _HAPROXY_HLUA_H
|
2015-03-04 10:48:34 -05:00
|
|
|
|
2020-06-04 03:20:54 -04:00
|
|
|
#include <haproxy/hlua-t.h>
|
2015-01-23 08:06:13 -05:00
|
|
|
|
2020-06-04 03:20:54 -04:00
|
|
|
#ifdef USE_LUA
|
2015-01-23 08:06:13 -05:00
|
|
|
|
2015-03-03 09:17:35 -05:00
|
|
|
/* The following macros are used to set flags. */
|
|
|
|
|
#define HLUA_SET_RUN(__hlua) do {(__hlua)->flags |= HLUA_RUN;} while(0)
|
|
|
|
|
#define HLUA_CLR_RUN(__hlua) do {(__hlua)->flags &= ~HLUA_RUN;} while(0)
|
|
|
|
|
#define HLUA_IS_RUNNING(__hlua) ((__hlua)->flags & HLUA_RUN)
|
2015-03-03 11:29:06 -05:00
|
|
|
#define HLUA_SET_CTRLYIELD(__hlua) do {(__hlua)->flags |= HLUA_CTRLYIELD;} while(0)
|
|
|
|
|
#define HLUA_CLR_CTRLYIELD(__hlua) do {(__hlua)->flags &= ~HLUA_CTRLYIELD;} while(0)
|
|
|
|
|
#define HLUA_IS_CTRLYIELDING(__hlua) ((__hlua)->flags & HLUA_CTRLYIELD)
|
2015-03-05 11:45:34 -05:00
|
|
|
#define HLUA_SET_WAKERESWR(__hlua) do {(__hlua)->flags |= HLUA_WAKERESWR;} while(0)
|
|
|
|
|
#define HLUA_CLR_WAKERESWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKERESWR;} while(0)
|
|
|
|
|
#define HLUA_IS_WAKERESWR(__hlua) ((__hlua)->flags & HLUA_WAKERESWR)
|
2015-03-05 18:35:53 -05:00
|
|
|
#define HLUA_SET_WAKEREQWR(__hlua) do {(__hlua)->flags |= HLUA_WAKEREQWR;} while(0)
|
|
|
|
|
#define HLUA_CLR_WAKEREQWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKEREQWR;} while(0)
|
|
|
|
|
#define HLUA_IS_WAKEREQWR(__hlua) ((__hlua)->flags & HLUA_WAKEREQWR)
|
2021-08-04 11:58:21 -04:00
|
|
|
#define HLUA_CLR_NOYIELD(__hlua) do {(__hlua)->flags &= ~HLUA_NOYIELD;} while(0)
|
|
|
|
|
#define HLUA_SET_NOYIELD(__hlua) do {(__hlua)->flags |= HLUA_NOYIELD;} while(0)
|
|
|
|
|
#define HLUA_CANT_YIELD(__hlua) ((__hlua)->flags & HLUA_NOYIELD)
|
|
|
|
|
|
2015-03-03 09:17:35 -05:00
|
|
|
|
2015-03-04 10:48:34 -05:00
|
|
|
#define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0)
|
|
|
|
|
|
2015-01-23 08:06:13 -05:00
|
|
|
/* Lua HAProxy integration functions. */
|
2021-03-24 09:48:45 -04:00
|
|
|
const char *hlua_traceback(lua_State *L, const char* sep);
|
2015-01-23 08:27:52 -05:00
|
|
|
void hlua_ctx_destroy(struct hlua *lua);
|
2015-01-23 08:06:13 -05:00
|
|
|
void hlua_init();
|
2015-01-23 06:08:30 -05:00
|
|
|
int hlua_post_init();
|
2019-08-21 08:14:50 -04:00
|
|
|
void hlua_applet_tcp_fct(struct appctx *ctx);
|
|
|
|
|
void hlua_applet_http_fct(struct appctx *ctx);
|
2021-03-02 10:09:26 -05:00
|
|
|
struct task *hlua_process_task(struct task *task, void *context, unsigned int state);
|
2022-06-19 11:39:33 -04:00
|
|
|
const char *hlua_show_current_location(const char *pfx);
|
2015-01-23 08:06:13 -05:00
|
|
|
|
2015-03-04 10:48:34 -05:00
|
|
|
#else /* USE_LUA */
|
|
|
|
|
|
2020-06-04 03:20:54 -04:00
|
|
|
/************************ For use when Lua is disabled ********************/
|
|
|
|
|
|
2015-03-03 09:17:35 -05:00
|
|
|
#define HLUA_IS_RUNNING(__hlua) 0
|
|
|
|
|
|
2015-03-04 10:48:34 -05:00
|
|
|
#define HLUA_INIT(__hlua)
|
|
|
|
|
|
|
|
|
|
/* Empty function for compilation without Lua. */
|
|
|
|
|
static inline void hlua_init() { }
|
|
|
|
|
static inline int hlua_post_init() { return 1; }
|
2015-06-17 14:18:54 -04:00
|
|
|
static inline void hlua_ctx_destroy(struct hlua *lua) { }
|
2022-06-19 11:39:33 -04:00
|
|
|
static inline const char *hlua_show_current_location(const char *pfx) { return NULL; }
|
2015-03-04 10:48:34 -05:00
|
|
|
|
|
|
|
|
#endif /* USE_LUA */
|
|
|
|
|
|
2020-06-04 03:20:54 -04:00
|
|
|
#endif /* _HAPROXY_HLUA_H */
|