15 #ifdef luasandbox_EXPORTS    16 #define LSB_EXPORT __declspec(dllexport)    18 #define LSB_EXPORT __declspec(dllimport)    22 #define LSB_EXPORT __attribute__ ((visibility ("default")))    28 #define LSB_ERROR_SIZE 256    30 #define LSB_SHUTTING_DOWN     "shutting down"    31 #define LSB_CONFIG_TABLE      "lsb_config"    32 #define LSB_THIS_PTR          "lsb_this_ptr"    33 #define LSB_MEMORY_LIMIT      "memory_limit"    34 #define LSB_INSTRUCTION_LIMIT "instruction_limit"    35 #define LSB_INPUT_LIMIT       "input_limit"    36 #define LSB_OUTPUT_LIMIT      "output_limit"    37 #define LSB_LOG_LEVEL         "log_level"    38 #define LSB_LUA_PATH          "path"    39 #define LSB_LUA_CPATH         "cpath"    40 #define LSB_NIL_ERROR         "<nil error message>"   105 lsb_create(
void *parent, 
const char *lua_file, 
const char *cfg,
   249                                  const char *func_name);
 LSB_EXPORT lua_State * lsb_get_lua(lsb_lua_sandbox *lsb)
Access the Lua pointer. 
 
struct lsb_lua_sandbox lsb_lua_sandbox
 
const char * lsb_err_value
 
LSB_EXPORT lsb_err_id LSB_ERR_TERMINATED
 
LSB_EXPORT lsb_state lsb_get_state(lsb_lua_sandbox *lsb)
Retrieve the current sandbox status. 
 
LSB_EXPORT size_t lsb_usage(lsb_lua_sandbox *lsb, lsb_usage_type utype, lsb_usage_stat ustat)
Retrieve the sandbox usage statistics. 
 
LSB_EXPORT lsb_err_id LSB_ERR_INIT
 
LSB_EXPORT void lsb_set_error(lsb_lua_sandbox *lsb, const char *err)
Sets the last error string. 
 
Error handling and logging. 
 
LSB_EXPORT const char * lsb_get_error(lsb_lua_sandbox *lsb)
Return the last error in human readable form. 
 
int(* lua_CFunction)(lua_State *L)
 
struct lua_State lua_State
 
LSB_EXPORT void lsb_stop_sandbox(lsb_lua_sandbox *lsb)
Aborts the running sandbox from a different thread of execution. 
 
LSB_EXPORT const lsb_logger * lsb_get_logger(lsb_lua_sandbox *lsb)
Access the logger struct stored in the sandbox. 
 
LSB_EXPORT lsb_err_value lsb_init(lsb_lua_sandbox *lsb, const char *state_file)
Initializes the Lua sandbox and loads/runs the Lua script that was specified in lua_create_sandbox. 
 
LSB_EXPORT lsb_err_value lsb_pcall_setup(lsb_lua_sandbox *lsb, const char *func_name)
Helper function to load the Lua function and set the instruction limits. 
 
LSB_EXPORT lsb_err_id LSB_ERR_LUA
 
LSB_EXPORT lsb_lua_sandbox * lsb_create(void *parent, const char *lua_file, const char *cfg, lsb_logger *logger)
Allocates and initializes the structure around the Lua sandbox allowing full specification of the san...
 
LSB_EXPORT void lsb_stop_sandbox_clean(lsb_lua_sandbox *lsb)
Changes the sandbox state to LSB_STOP to allow for a clean exit. 
 
LSB_EXPORT const char * lsb_get_lua_file(lsb_lua_sandbox *lsb)
Returns the filename of the Lua source. 
 
LSB_EXPORT void lsb_pcall_teardown(lsb_lua_sandbox *lsb)
Helper function to update the statistics after the call. 
 
LSB_EXPORT void * lsb_get_parent(lsb_lua_sandbox *lsb)
Access the parent pointer stored in the sandbox. 
 
LSB_EXPORT void lsb_terminate(lsb_lua_sandbox *lsb, const char *err)
Change the sandbox state to LSB_TERMINATED due to a fatal error. 
 
LSB_EXPORT char * lsb_destroy(lsb_lua_sandbox *lsb)
Frees the memory associated with the sandbox. 
 
LSB_EXPORT void lsb_add_function(lsb_lua_sandbox *lsb, lua_CFunction func, const char *func_name)
Create a CFunction for use by the Sandbox.