luasandbox
1.4.0
Generic Lua sandbox for dynamic data analysis
|
Lua sandbox output generation/retrieval functions. More...
Go to the source code of this file.
Functions | |
LSB_EXPORT void | lsb_add_output_function (lua_State *lua, lua_CFunction fp) |
Add a output function to the environment table. More... | |
LSB_EXPORT lua_CFunction | lsb_get_output_function (lua_State *lua, int index) |
Utility function to retrieve a user data output function. More... | |
LSB_EXPORT void | lsb_add_zero_copy_function (lua_State *lua, lua_CFunction fp) |
Add a zero copy function to the environment table. More... | |
LSB_EXPORT lua_CFunction | lsb_get_zero_copy_function (lua_State *lua, int index) |
Utility function to retrieve a user data zero copy function. More... | |
LSB_EXPORT void | lsb_output (lsb_lua_sandbox *lsb, int start, int end, int append) |
Write an array of variables on the Lua stack to the output buffer. More... | |
LSB_EXPORT void | lsb_output_coroutine (lsb_lua_sandbox *lsb, lua_State *lua, int start, int end, int append) |
Write an array of variables on the Lua stack to the output buffer. More... | |
LSB_EXPORT const char * | lsb_get_output (lsb_lua_sandbox *lsb, size_t *len) |
Retrieve the data in the output buffer and reset the buffer. More... | |
Lua sandbox output generation/retrieval functions.
Definition in file luasandbox_output.h.
LSB_EXPORT void lsb_add_output_function | ( | lua_State * | lua, |
lua_CFunction | fp | ||
) |
Add a output function to the environment table.
The environment table must be on the top of the stack. This function will receive the userdata and lsb_output_buffer struct as pointers on the Lua stack.
lsb_output_buffer* output = (output_data*)lua_touserdata(lua, -1); ud_object* ud = (ud_object*)lua_touserdata(lua, -2);
lua | Pointer the Lua state. |
fp | Function pointer to the outputter. |
LSB_EXPORT void lsb_add_zero_copy_function | ( | lua_State * | lua, |
lua_CFunction | fp | ||
) |
Add a zero copy function to the environment table.
The environment table must be on the top of the stack. This function will receive the userdata as a pointer on the Lua stack.
ud_object* ud = (ud_object*)lua_touserdata(lua, -1);
lua | Pointer the Lua state. |
fp | Function pointer to the zero copy function. |
LSB_EXPORT const char* lsb_get_output | ( | lsb_lua_sandbox * | lsb, |
size_t * | len | ||
) |
Retrieve the data in the output buffer and reset the buffer.
The returned output string will remain valid until additional sandbox output is performed. The output should be copied if the application needs to hold onto it.
lsb | Pointer to the sandbox. |
len | If len is not NULL, it will be set to the length of the string. |
LSB_EXPORT lua_CFunction lsb_get_output_function | ( | lua_State * | lua, |
int | index | ||
) |
Utility function to retrieve a user data output function.
lua | |
index |
LSB_EXPORT lua_CFunction lsb_get_zero_copy_function | ( | lua_State * | lua, |
int | index | ||
) |
Utility function to retrieve a user data zero copy function.
lua | |
index |
LSB_EXPORT void lsb_output | ( | lsb_lua_sandbox * | lsb, |
int | start, | ||
int | end, | ||
int | append | ||
) |
Write an array of variables on the Lua stack to the output buffer.
lsb | Pointer to the sandbox. |
start | Lua stack index of first variable. |
end | Lua stack index of the last variable. |
append | 0 to overwrite the output buffer, 1 to append the output to it |
LSB_EXPORT void lsb_output_coroutine | ( | lsb_lua_sandbox * | lsb, |
lua_State * | lua, | ||
int | start, | ||
int | end, | ||
int | append | ||
) |
Write an array of variables on the Lua stack to the output buffer.
After adding support for coroutines we need an extra variable to specify the correct Lua state.
lsb | Pointer to the sandbox. |
lua | Pointer the Lua state |
start | Lua stack index of first variable. |
end | Lua stack index of the last variable. |
append | 0 to overwrite the output buffer, 1 to append the output to it |