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

Data stream output buffer. More...

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

Go to the source code of this file.

Classes

struct  lsb_output_buffer
 

Macros

#define LSB_OUTPUT_SIZE   1024
 

Typedefs

typedef struct lsb_output_buffer lsb_output_buffer
 

Functions

LSB_UTIL_EXPORT lsb_err_value lsb_init_output_buffer (lsb_output_buffer *b, size_t max_message_size)
 Initialize the provided input buffer. More...
 
LSB_UTIL_EXPORT void lsb_free_output_buffer (lsb_output_buffer *b)
 Frees the memory internally allocated by the buffer and resets the state. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_expand_output_buffer (lsb_output_buffer *b, size_t needed)
 Resize the output buffer when more space is needed. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_outputc (lsb_output_buffer *b, char ch)
 Append a character to the output buffer. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_outputf (lsb_output_buffer *b, const char *fmt,...)
 Append a formatted string to the output buffer. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_outputs (lsb_output_buffer *b, const char *str, size_t len)
 Append a fixed string to the output buffer. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_outputd (lsb_output_buffer *b, double d)
 More efficient output of a double to a string. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_outputfd (lsb_output_buffer *b, double d)
 More efficient output of a double to a string; no NaN or Inf outputs. More...
 

Detailed Description

Data stream output buffer.

Definition in file output_buffer.h.

Macro Definition Documentation

#define LSB_OUTPUT_SIZE   1024

Definition at line 16 of file output_buffer.h.

Typedef Documentation

Function Documentation

LSB_UTIL_EXPORT lsb_err_value lsb_expand_output_buffer ( lsb_output_buffer b,
size_t  needed 
)

Resize the output buffer when more space is needed.

Parameters
bOutput buffer to resize.
neededNumber of additional bytes needed.
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT void lsb_free_output_buffer ( lsb_output_buffer b)

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

Parameters
bOutput buffer
LSB_UTIL_EXPORT lsb_err_value lsb_init_output_buffer ( lsb_output_buffer b,
size_t  max_message_size 
)

Initialize the provided input buffer.

Parameters
bOutput buffer
max_message_sizeThe maximum message size the buffer will handle before erroring
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT lsb_err_value lsb_outputc ( lsb_output_buffer b,
char  ch 
)

Append a character to the output buffer.

Parameters
bPointer the b buffer.
chCharacter to append to the b.
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT lsb_err_value lsb_outputd ( lsb_output_buffer b,
double  d 
)

More efficient output of a double to a string.

NaN/Inf check and then calls lsb_outputfd.

Parameters
bPointer the output buffer.
dDouble value to convert to a string.
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT lsb_err_value lsb_outputf ( lsb_output_buffer b,
const char *  fmt,
  ... 
)

Append a formatted string to the output buffer.

Parameters
bPointer the b buffer.
fmtPrintf format specifier.
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT lsb_err_value lsb_outputfd ( lsb_output_buffer b,
double  d 
)

More efficient output of a double to a string; no NaN or Inf outputs.

Parameters
bPointer the output buffer.
dDouble value to convert to a string.
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT lsb_err_value lsb_outputs ( lsb_output_buffer b,
const char *  str,
size_t  len 
)

Append a fixed string to the output buffer.

Parameters
bPointer the b buffer.
strString to append to the b.
lenLength of the string to append
Returns
lsb_err_value NULL on success error message on failure