luasandbox
1.4.0
Generic Lua sandbox for dynamic data analysis
|
Lua sandbox serialization. More...
#include <stdio.h>
#include "luasandbox/util/output_buffer.h"
#include "luasandbox_output.h"
#include "luasandbox/lua.h"
Go to the source code of this file.
Functions | |
LSB_EXPORT void | lsb_add_serialize_function (lua_State *lua, lua_CFunction fp) |
Add a serialization function to the environment table. More... | |
LSB_EXPORT lsb_err_value | lsb_serialize_binary (lsb_output_buffer *output, const void *src, size_t len) |
Serializes a binary data to a Lua string. More... | |
LSB_EXPORT lsb_err_value | lsb_serialize_double (lsb_output_buffer *output, double d) |
More efficient serialization of a double to a string. More... | |
Lua sandbox serialization.
Definition in file luasandbox_serialize.h.
LSB_EXPORT void lsb_add_serialize_function | ( | lua_State * | lua, |
lua_CFunction | fp | ||
) |
Add a serialization function to the environment table.
The environment table must be on the top of the stack. This function will receive the userdata, fully qualified variable name, and lsb_output_buffer struct as pointers on the Lua stack.
lsb_output_buffer* output = (output_data*)lua_touserdata(lua, -1); const char key = (const char)lua_touserdata(lua, -2); ud_object* ud = (ud_object*)lua_touserdata(lua, -3);
lua | Pointer the Lua state. |
fp | Function pointer to the serializer. |
LSB_EXPORT lsb_err_value lsb_serialize_binary | ( | lsb_output_buffer * | output, |
const void * | src, | ||
size_t | len | ||
) |
Serializes a binary data to a Lua string.
output | Pointer the output buffer. |
src | Pointer to the binary data. |
len | Length in bytes of the data to output. |
LSB_EXPORT lsb_err_value lsb_serialize_double | ( | lsb_output_buffer * | output, |
double | d | ||
) |
More efficient serialization of a double to a string.
output | Pointer the output buffer. |
d | Double value to convert to a string. |