luasandbox  1.4.0
Generic Lua sandbox for dynamic data analysis
Functions
luasandbox_serialize.h File Reference

Lua sandbox serialization. More...

#include <stdio.h>
#include "luasandbox/util/output_buffer.h"
#include "luasandbox_output.h"
#include "luasandbox/lua.h"
Include dependency graph for luasandbox_serialize.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...
 

Detailed Description

Lua sandbox serialization.

Definition in file luasandbox_serialize.h.

Function Documentation

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);

Parameters
luaPointer the Lua state.
fpFunction pointer to the serializer.
Returns
lsb_err_value NULL on success error message on failure
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.

Parameters
outputPointer the output buffer.
srcPointer to the binary data.
lenLength in bytes of the data to output.
Returns
lsb_err_value NULL on success error message on failure
LSB_EXPORT lsb_err_value lsb_serialize_double ( lsb_output_buffer output,
double  d 
)

More efficient serialization of a double to a string.

Parameters
outputPointer the output buffer.
dDouble value to convert to a string.
Returns
lsb_err_value NULL on success error message on failure