44#define LUASCRIPT_CHECKINTERVAL 10000
47#define LUASCRIPT_GLOBAL_VAR_NAME "__fcl"
64#define LUASCRIPT_SECURE_LUA_VERSION1 503
65#define LUASCRIPT_SECURE_LUA_VERSION2 504
81#if LUA_VERSION_NUM != LUASCRIPT_SECURE_LUA_VERSION1 && LUA_VERSION_NUM != LUASCRIPT_SECURE_LUA_VERSION2
82#warning "The script runtime's unsafe symbols information is not up to date."
83#warning "This can be a big security hole!"
90#if LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504
117#error "Unsupported lua version"
144 msg =
"(error with no message)";
154 const char *begin, *end;
160 for (begin =
code; *begin !=
'\0';) {
163 end =
strchr(begin,
'\n');
171 const char *indicator;
173 indicator = (
lineno ==
i) ?
"-->" :
" ";
176 indicator,
i,
len,
len, begin);
236 luaL_error(
L,
_(
"Execution time limit exceeded in script"));
245#if LUASCRIPT_CHECKINTERVAL
258#if LUASCRIPT_CHECKINTERVAL
410 const char *format, ...)
423 const char *format,
va_list args)
432 if (
fcl->output_fct) {
453 for (
i = 0;
i < nreturns;
i++) {
466 log_error(
"Return value from lua function %s is a %s, want int",
509 for (
i = 0;
i < nargs;
i++) {
523 int arg =
va_arg(args,
int);
529 const char *arg =
va_arg(args,
const char*);
540 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)
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)