luasandbox
1.4.0
Generic Lua sandbox for dynamic data analysis
Main Page
Classes
Files
File List
File Members
include
luasandbox
util
input_buffer.h
Go to the documentation of this file.
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/** Data stream input buffer @file */
8
9
#ifndef luasandbox_util_input_buffer_h_
10
#define luasandbox_util_input_buffer_h_
11
12
#include <stdbool.h>
13
#include <stddef.h>
14
15
#include "
util.h
"
16
17
typedef
struct
lsb_input_buffer
18
{
19
char
*
buf
;
20
size_t
size
;
21
size_t
maxsize
;
22
size_t
readpos
;
23
size_t
scanpos
;
24
size_t
msglen
;
25
}
lsb_input_buffer
;
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
31
/**
32
* Initialize the provided input buffer
33
*
34
* @param b Input buffer
35
* @param max_message_size The maximum message size the buffer will handle
36
* before erroring (the internal buffer will contain extra space
37
* for the header)
38
*
39
* @return lsb_err_value NULL on success error message on failure
40
*/
41
LSB_UTIL_EXPORT
lsb_err_value
42
lsb_init_input_buffer
(
lsb_input_buffer
*b,
size_t
max_message_size);
43
44
/**
45
* Frees the memory internally allocated by the buffer and resets the state
46
*
47
* @param b Input buffer
48
*/
49
LSB_UTIL_EXPORT
void
lsb_free_input_buffer
(
lsb_input_buffer
*b);
50
51
/**
52
* Expands the input buffer (if necessary) to accomadate the requested number of
53
* bytes. The expansion happens in power of two increments up to the maxsize.
54
* The buffer never shrinks in size.
55
*
56
* @param b Input buffer
57
* @param len The length of the data being added to the buffer
58
*
59
* @return lsb_err_value NULL on success error message on failure
60
*/
61
LSB_UTIL_EXPORT
lsb_err_value
62
lsb_expand_input_buffer
(
lsb_input_buffer
*b,
size_t
len);
63
64
#ifdef __cplusplus
65
}
66
#endif
67
68
#endif
lsb_err_value
const char * lsb_err_value
Definition:
error.h:15
lsb_input_buffer
Definition:
input_buffer.h:17
lsb_input_buffer::maxsize
size_t maxsize
Definition:
input_buffer.h:21
lsb_input_buffer::buf
char * buf
Definition:
input_buffer.h:19
lsb_input_buffer::msglen
size_t msglen
Definition:
input_buffer.h:24
lsb_input_buffer::scanpos
size_t scanpos
Definition:
input_buffer.h:23
lsb_input_buffer::readpos
size_t readpos
Definition:
input_buffer.h:22
util.h
Shared types and structures.
LSB_UTIL_EXPORT
#define LSB_UTIL_EXPORT
Definition:
util.h:28
lsb_expand_input_buffer
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.
lsb_input_buffer::size
size_t size
Definition:
input_buffer.h:20
lsb_input_buffer
struct lsb_input_buffer lsb_input_buffer
lsb_free_input_buffer
LSB_UTIL_EXPORT void lsb_free_input_buffer(lsb_input_buffer *b)
Frees the memory internally allocated by the buffer and resets the state.
lsb_init_input_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.
Generated by
1.8.11