luasandbox  1.4.0
Generic Lua sandbox for dynamic data analysis
Classes | Typedefs | Functions
input_buffer.h File Reference

Data stream input buffer. More...

#include <stdbool.h>
#include <stddef.h>
#include "util.h"
Include dependency graph for input_buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lsb_input_buffer
 

Typedefs

typedef struct lsb_input_buffer lsb_input_buffer
 

Functions

LSB_UTIL_EXPORT lsb_err_value lsb_init_input_buffer (lsb_input_buffer *b, size_t max_message_size)
 Initialize the provided input buffer. More...
 
LSB_UTIL_EXPORT void lsb_free_input_buffer (lsb_input_buffer *b)
 Frees the memory internally allocated by the buffer and resets the state. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_expand_input_buffer (lsb_input_buffer *b, size_t len)
 Expands the input buffer (if necessary) to accomadate the requested number of bytes. More...
 

Detailed Description

Data stream input buffer.

Definition in file input_buffer.h.

Typedef Documentation

Function Documentation

LSB_UTIL_EXPORT lsb_err_value lsb_expand_input_buffer ( lsb_input_buffer b,
size_t  len 
)

Expands the input buffer (if necessary) to accomadate the requested number of bytes.

The expansion happens in power of two increments up to the maxsize. The buffer never shrinks in size.

Parameters
bInput buffer
lenThe length of the data being added to the buffer
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT void lsb_free_input_buffer ( lsb_input_buffer b)

Frees the memory internally allocated by the buffer and resets the state.

Parameters
bInput buffer
LSB_UTIL_EXPORT lsb_err_value lsb_init_input_buffer ( lsb_input_buffer b,
size_t  max_message_size 
)

Initialize the provided input buffer.

Parameters
bInput buffer
max_message_sizeThe maximum message size the buffer will handle before erroring (the internal buffer will contain extra space for the header)
Returns
lsb_err_value NULL on success error message on failure