HTP  0.5
Data Structures | Macros | Typedefs | Functions
bstr_builder.h File Reference
#include "htp_list.h"

Go to the source code of this file.

Data Structures

struct  bstr_builder_t
 

Macros

#define BSTR_BUILDER_DEFAULT_SIZE   16
 

Typedefs

typedef struct bstr_builder_t bstr_builder_t
 

Functions

htp_status_t bstr_builder_appendn (bstr_builder_t *bb, bstr *b)
 
htp_status_t bstr_builder_append_c (bstr_builder_t *bb, const char *cstr)
 
htp_status_t bstr_builder_append_mem (bstr_builder_t *bb, const void *data, size_t len)
 
void bstr_builder_clear (bstr_builder_t *bb)
 
bstr_builder_tbstr_builder_create (void)
 
void bstr_builder_destroy (bstr_builder_t *bb)
 
size_t bstr_builder_size (const bstr_builder_t *bb)
 
bstrbstr_builder_to_str (const bstr_builder_t *bb)
 

Detailed Description

Author
Ivan Ristic ivanr.nosp@m.@web.nosp@m.kreat.nosp@m.or.c.nosp@m.om

Macro Definition Documentation

#define BSTR_BUILDER_DEFAULT_SIZE   16

Typedef Documentation

Function Documentation

htp_status_t bstr_builder_append_c ( bstr_builder_t bb,
const char *  cstr 
)

Adds one new piece, in the form of a NUL-terminated string, to the builder. This function will make a copy of the provided string.

Parameters
[in]bb
[in]cstr
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_status_t bstr_builder_append_mem ( bstr_builder_t bb,
const void *  data,
size_t  len 
)

Adds one new piece, defined with the supplied pointer and length, to the builder. This function will make a copy of the provided data region.

Parameters
[in]bb
[in]data
[in]len
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_status_t bstr_builder_appendn ( bstr_builder_t bb,
bstr b 
)

Adds one new string to the builder. This function will adopt the string and destroy it when the builder itself is destroyed.

Parameters
[in]bb
[in]b
Returns
HTP_OK on success, HTP_ERROR on failure.
void bstr_builder_clear ( bstr_builder_t bb)

Clears this string builder, destroying all existing pieces. You may want to clear a builder once you've either read all the pieces and done something with them, or after you've converted the builder into a single string.

Parameters
[in]bb
bstr_builder_t* bstr_builder_create ( void  )

Creates a new string builder.

Returns
New string builder, or NULL on error.
void bstr_builder_destroy ( bstr_builder_t bb)

Destroys an existing string builder, also destroying all the pieces stored within.

Parameters
[in]bb
size_t bstr_builder_size ( const bstr_builder_t bb)

Returns the size (the number of pieces) currently in a string builder.

Parameters
[in]bb
Returns
size
bstr* bstr_builder_to_str ( const bstr_builder_t bb)

Creates a single string out of all the pieces held in a string builder. This method will not destroy any of the pieces.

Parameters
[in]bb
Returns
New string, or NULL on error.