44#define LUASCRIPT_MAX_EXECUTION_TIME_SEC 5.0
45#define LUASCRIPT_CHECKINTERVAL 10000
48#define LUASCRIPT_GLOBAL_VAR_NAME "__fcl"
65#define LUASCRIPT_SECURE_LUA_VERSION1 503
66#define LUASCRIPT_SECURE_LUA_VERSION2 504
82#if LUA_VERSION_NUM != LUASCRIPT_SECURE_LUA_VERSION1 && LUA_VERSION_NUM != LUASCRIPT_SECURE_LUA_VERSION2
83#warning "The script runtime's unsafe symbols information is not up to date."
84#warning "This can be a big security hole!"
91#if LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504
118#error "Unsupported lua version"
145 msg =
"(error with no message)";
155 const char *begin, *end;
161 for (begin =
code; *begin !=
'\0';) {
164 end =
strchr(begin,
'\n');
172 const char *indicator;
174 indicator = (
lineno ==
i) ?
"-->" :
" ";
177 indicator,
i,
len,
len, begin);
237 luaL_error(
L,
"Execution time limit exceeded in script");
246#if LUASCRIPT_CHECKINTERVAL
259#if LUASCRIPT_CHECKINTERVAL
411 const char *format, ...)
424 const char *format,
va_list args)
433 if (
fcl->output_fct) {
454 for (
i = 0;
i < nreturns;
i++) {
467 log_error(
"Return value from lua function %s is a %s, want int",
510 for (
i = 0;
i < nargs;
i++) {
524 int arg =
va_arg(args,
int);
530 const char *arg =
va_arg(args,
const char*);
541 arg =
va_arg(args,
void*);
void astr_free(struct astring *astr)
void astr_add_line(struct astring *astr, const char *format,...)
void astr_add(struct astring *astr, const char *format,...)
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
static void base(QVariant data1, QVariant data2)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_base(level, message,...)
#define log_error(message,...)
static int luascript_report(struct fc_lua *fcl, int status, const char *code)
void luascript_pop_returns(struct fc_lua *fcl, const char *func_name, int nreturns, enum api_types *preturn_types, va_list args)
void luascript_push_args(struct fc_lua *fcl, int nargs, enum api_types *parg_types, va_list args)
static void luascript_traceback_func_push(lua_State *L)
static const char * luascript_unsafe_symbols_secure[]
bool luascript_check_function(struct fc_lua *fcl, const char *funcname)
int luascript_error_vargs(lua_State *L, const char *format, va_list vargs)
#define LUASCRIPT_CHECKINTERVAL
static void luascript_openlibs(lua_State *L, const luaL_Reg *llib)
int luascript_arg_error(lua_State *L, int narg, const char *msg)
#define LUASCRIPT_MAX_EXECUTION_TIME_SEC
bool luascript_callback_invoke(struct fc_lua *fcl, const char *callback_name, int nargs, enum api_types *parg_types, va_list args)
void luascript_remove_exported_object(struct fc_lua *fcl, void *object)
int luascript_do_string(struct fc_lua *fcl, const char *str, const char *name)
int luascript_error(lua_State *L, const char *format,...)
int luascript_do_file(struct fc_lua *fcl, const char *filename)
static void luascript_hook_end(lua_State *L)
static void luascript_exec_check(lua_State *L, lua_Debug *ar)
void luascript_vars_load(struct fc_lua *fcl, struct section_file *file, const char *section)
const Direction * luascript_dir(enum direction8 dir)
static void luascript_hook_start(lua_State *L)
static const char * luascript_unsafe_symbols_permissive[]
void luascript_log(struct fc_lua *fcl, enum log_level level, const char *format,...)
void luascript_log_vargs(struct fc_lua *fcl, enum log_level level, const char *format, va_list args)
void luascript_vars_save(struct fc_lua *fcl, struct section_file *file, const char *section)
struct fc_lua * luascript_get_fcl(lua_State *L)
struct fc_lua * luascript_new(luascript_log_func_t output_fct, bool secured_environment)
static void luascript_blacklist(lua_State *L, const char *lsymbols[])
int luascript_call(struct fc_lua *fcl, int narg, int nret, const char *code)
#define LUASCRIPT_GLOBAL_VAR_NAME
static void luascript_traceback_func_save(lua_State *L)
void luascript_destroy(struct fc_lua *fcl)
void(* luascript_log_func_t)(struct fc_lua *fcl, enum log_level level, const char *format,...) fc__attribute((__format__(__printf__
void luascript_func_free(struct fc_lua *fcl)
void luascript_signal_free(struct fc_lua *fcl)
enum direction8 Direction
bool is_valid_dir(enum direction8 dir)
#define fc_calloc(n, esz)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
#define secfile_insert_str_noescape(secfile, string, path,...)
struct setting_list * level[OLEVELS_NUM]
luascript_log_func_t output_fct
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)