The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Macros | Functions | Variables
sbuff.c File Reference

A generic string buffer structure for string printing and parsing. More...

#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
+ Include dependency graph for sbuff.c:

Go to the source code of this file.

Macros

#define _CHECK_SBUFF_INIT(_sbuff, _ret)   do { if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return _ret; } while (0)
 
#define CHECK_SBUFF_INIT(_sbuff)   _CHECK_SBUFF_INIT(_sbuff, 0)
 
#define CHECK_SBUFF_INIT_ERR(_sbuff)   _CHECK_SBUFF_INIT(_sbuff, FR_SBUFF_ERR_UNINITIALISED)
 
#define CHECK_SBUFF_WRITEABLE(_sbuff)   do { CHECK_SBUFF_INIT(_sbuff); if (unlikely((_sbuff)->is_const)) return 0; } while (0)
 
#define CONSTRAINED_END(_sbuff, _max, _used)    (((_max) - (_used)) > fr_sbuff_remaining(_sbuff) ? (_sbuff)->end : (_sbuff)->p + ((_max) - (_used)))
 Constrain end pointer to prevent advancing more than the amount the caller specified.
 
#define FILL_OR_GOTO_DONE(_out, _in, _len)
 Fill as much of the output buffer we can and break on partial copy.
 
#define SBUFF_PARSE_FLOAT_DEF(_name, _type, _func, _max_char)
 Used to define a number parsing functions for floats.
 
#define SBUFF_PARSE_INT_DEF(_name, _type, _min, _max, _max_char, _base)
 Used to define a number parsing functions for signed integers.
 
#define SBUFF_PARSE_UINT_DEF(_name, _type, _max, _max_char, _base)
 Used to define a number parsing functions for signed integers.
 

Functions

size_t _fr_sbuff_move_marker_to_marker (fr_sbuff_marker_t *out, fr_sbuff_marker_t *in, size_t len)
 Move data from one marker to another.
 
size_t _fr_sbuff_move_marker_to_sbuff (fr_sbuff_t *out, fr_sbuff_marker_t *in, size_t len)
 Move data from a marker to an sbuff.
 
size_t _fr_sbuff_move_sbuff_to_marker (fr_sbuff_marker_t *out, fr_sbuff_t *in, size_t len)
 Move data from an sbuff to a marker.
 
size_t _fr_sbuff_move_sbuff_to_sbuff (fr_sbuff_t *out, fr_sbuff_t *in, size_t len)
 Move data from one sbuff to another.
 
static int _sbuff_scratch_free (void *arg)
 Free the scratch buffer used for printf.
 
size_t fr_sbuff_adv_past_allowed (fr_sbuff_t *sbuff, size_t len, bool const allowed[static SBUFF_CHAR_CLASS], fr_sbuff_term_t const *tt)
 Wind position past characters in the allowed set.
 
size_t fr_sbuff_adv_past_str (fr_sbuff_t *sbuff, char const *needle, size_t needle_len)
 Return true and advance past the end of the needle if needle occurs next in the sbuff.
 
size_t fr_sbuff_adv_past_strcase (fr_sbuff_t *sbuff, char const *needle, size_t needle_len)
 Return true and advance past the end of the needle if needle occurs next in the sbuff.
 
char * fr_sbuff_adv_to_chr (fr_sbuff_t *sbuff, size_t len, char c)
 Wind position to first instance of specified char.
 
char * fr_sbuff_adv_to_chr_utf8 (fr_sbuff_t *sbuff, size_t len, char const *chr)
 Wind position to first instance of specified multibyte utf8 char.
 
char * fr_sbuff_adv_to_str (fr_sbuff_t *sbuff, size_t len, char const *needle, size_t needle_len)
 Wind position to the first instance of the specified needle.
 
char * fr_sbuff_adv_to_strcase (fr_sbuff_t *sbuff, size_t len, char const *needle, size_t needle_len)
 Wind position to the first instance of the specified needle.
 
size_t fr_sbuff_adv_until (fr_sbuff_t *sbuff, size_t len, fr_sbuff_term_t const *tt, char escape_chr)
 Wind position until we hit a character in the terminal set.
 
fr_slen_t fr_sbuff_array_concat (fr_sbuff_t *out, char const *const *array, char const *sep)
 Concat an array of strings (not NULL terminated), with a string separator.
 
bool fr_sbuff_eof_file (fr_sbuff_t *sbuff)
 Accessor function for the EOF state of the file extendor.
 
size_t fr_sbuff_extend_file (fr_sbuff_extend_status_t *status, fr_sbuff_t *sbuff, size_t extension)
 Refresh the buffer with more data from the file.
 
size_t fr_sbuff_extend_talloc (fr_sbuff_extend_status_t *status, fr_sbuff_t *sbuff, size_t extension)
 Reallocate the current buffer.
 
fr_slen_t fr_sbuff_in_array (fr_sbuff_t *out, char const *const *array, char const *sep)
 Concat an array of strings (NULL terminated), with a string separator.
 
ssize_t fr_sbuff_in_bstrcpy_buffer (fr_sbuff_t *sbuff, char const *str)
 Copy bytes into the sbuff up to the first \0.
 
ssize_t fr_sbuff_in_bstrncpy (fr_sbuff_t *sbuff, char const *str, size_t len)
 Copy bytes into the sbuff up to the first \0.
 
ssize_t fr_sbuff_in_escape (fr_sbuff_t *sbuff, char const *in, size_t inlen, fr_sbuff_escape_rules_t const *e_rules)
 Print an escaped string to an sbuff.
 
ssize_t fr_sbuff_in_escape_buffer (fr_sbuff_t *sbuff, char const *in, fr_sbuff_escape_rules_t const *e_rules)
 Print an escaped string to an sbuff taking a talloced buffer as input.
 
bool fr_sbuff_in_needs_escaping (char const *in, size_t inlen, fr_sbuff_escape_rules_t const *e_rules)
 Walk an input string and report whether fr_sbuff_in_escape() would escape any characters in it.
 
ssize_t fr_sbuff_in_sprintf (fr_sbuff_t *sbuff, char const *fmt,...)
 Print using a fmt string to an sbuff.
 
ssize_t fr_sbuff_in_strcpy (fr_sbuff_t *sbuff, char const *str)
 Copy bytes into the sbuff up to the first \0.
 
ssize_t fr_sbuff_in_vsprintf (fr_sbuff_t *sbuff, char const *fmt, va_list ap)
 Print using a fmt string to an sbuff.
 
bool fr_sbuff_is_terminal (fr_sbuff_t *in, fr_sbuff_term_t const *tt)
 Efficient terminal string search.
 
bool fr_sbuff_next_if_char (fr_sbuff_t *sbuff, char c)
 Return true if the current char matches, and if it does, advance.
 
bool fr_sbuff_next_unless_char (fr_sbuff_t *sbuff, char c)
 Return true and advance if the next char does not match.
 
fr_sbuff_err_t fr_sbuff_out_bool (bool *out, fr_sbuff_t *in)
 See if the string contains a truth value.
 
fr_sbuff_err_t fr_sbuff_out_bstrncpy (size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max)
 Copy as many bytes as possible from a sbuff to a sbuff.
 
fr_sbuff_err_t fr_sbuff_out_bstrncpy_allowed (size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, bool const allowed[static SBUFF_CHAR_CLASS])
 Copy as many allowed characters as possible from a sbuff to a sbuff.
 
fr_sbuff_err_t fr_sbuff_out_bstrncpy_exact (fr_sbuff_t *out, fr_sbuff_t *in, size_t len)
 Copy exactly len bytes from a sbuff to a sbuff or fail.
 
fr_sbuff_err_t fr_sbuff_out_bstrncpy_until (size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, fr_sbuff_term_t const *tt, fr_sbuff_unescape_rules_t const *u_rules)
 Copy from a sbuff to a sbuff until a terminal sequence is found.
 
fr_sbuff_err_t fr_sbuff_out_unescape_until (size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, fr_sbuff_term_t const *tt, fr_sbuff_unescape_rules_t const *u_rules)
 Copy from a sbuff to a sbuff until a terminal sequence is found, unescaping as we go.
 
void fr_sbuff_parse_rules_debug (FILE *fp, fr_sbuff_parse_rules_t const *p_rules)
 
int fr_sbuff_reset_talloc (fr_sbuff_t *sbuff)
 Reset a talloced buffer to its initial length, clearing any data stored.
 
size_t fr_sbuff_shift (fr_sbuff_t *sbuff, size_t shift, bool move_end)
 Shift the contents of the sbuff, returning the number of bytes we managed to shift.
 
void fr_sbuff_terminal_debug (FILE *fp, fr_sbuff_term_t const *tt)
 
static void fr_sbuff_terminal_idx_init (size_t *needle_len, uint8_t idx[static SBUFF_CHAR_CLASS], fr_sbuff_term_t const *term)
 Populate a terminal index.
 
static bool fr_sbuff_terminal_search (fr_sbuff_t *in, char const *p, uint8_t idx[static SBUFF_CHAR_CLASS], fr_sbuff_term_t const *term, UNUSED size_t needle_len)
 Efficient terminal string search.
 
fr_sbuff_term_t * fr_sbuff_terminals_amerge (TALLOC_CTX *ctx, fr_sbuff_term_t const *a, fr_sbuff_term_t const *b)
 Merge two sets of terminal strings.
 
size_t fr_sbuff_trim (fr_sbuff_t *sbuff, bool const to_trim[static SBUFF_CHAR_CLASS])
 Trim trailing characters from a string we're composing.
 
int fr_sbuff_trim_talloc (fr_sbuff_t *sbuff, size_t len)
 Trim a talloced sbuff to the minimum length required to represent the contained string.
 
void fr_sbuff_unescape_debug (FILE *fp, fr_sbuff_unescape_rules_t const *escapes)
 
void fr_sbuff_update (fr_sbuff_t *sbuff, char *new_buff, size_t new_len)
 Update all markers and pointers in the set of sbuffs to point to new_buff.
 
static size_t min (size_t x, size_t y)
 
static ssize_t safecpy (char *o_start, char *o_end, char const *i_start, char const *i_end)
 Copy function that allows overlapping memory ranges to be copied.
 
static char const * sbuff_print_char (char c)
 Print a char in a friendly format.
 
static void sbuff_scratch_init (TALLOC_CTX **out)
 Initialise a thread local scratch context.
 
static int8_t terminal_cmp (fr_sbuff_term_elem_t const *a, fr_sbuff_term_elem_t const *b)
 Compare two terminal elements for ordering purposes.
 

Variables

bool const sbuff_char_alpha_num [SBUFF_CHAR_CLASS] = { SBUFF_CHAR_CLASS_ALPHA_NUM }
 
bool const sbuff_char_blank [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_class_float [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_class_hex [SBUFF_CHAR_CLASS] = { SBUFF_CHAR_CLASS_HEX }
 
bool const sbuff_char_class_hostname [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_class_int [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_class_uint [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_class_zero [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_line_endings [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_whitespace [SBUFF_CHAR_CLASS]
 
bool const sbuff_char_word [SBUFF_CHAR_CLASS]
 
fr_table_num_ordered_t const sbuff_err_table []
 
size_t sbuff_err_table_len = NUM_ELEMENTS(sbuff_err_table)
 
static _Thread_local char * sbuff_scratch
 
static _Thread_local bool sbuff_scratch_freed
 When true, prevent use of the scratch space.
 

Detailed Description

A generic string buffer structure for string printing and parsing.

Definition in file sbuff.c.

Macro Definition Documentation

◆ _CHECK_SBUFF_INIT

#define _CHECK_SBUFF_INIT (   _sbuff,
  _ret 
)    do { if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return _ret; } while (0)

Definition at line 59 of file sbuff.c.

◆ CHECK_SBUFF_INIT

#define CHECK_SBUFF_INIT (   _sbuff)    _CHECK_SBUFF_INIT(_sbuff, 0)

Definition at line 60 of file sbuff.c.

◆ CHECK_SBUFF_INIT_ERR

#define CHECK_SBUFF_INIT_ERR (   _sbuff)    _CHECK_SBUFF_INIT(_sbuff, FR_SBUFF_ERR_UNINITIALISED)

Definition at line 66 of file sbuff.c.

◆ CHECK_SBUFF_WRITEABLE

#define CHECK_SBUFF_WRITEABLE (   _sbuff)    do { CHECK_SBUFF_INIT(_sbuff); if (unlikely((_sbuff)->is_const)) return 0; } while (0)

Definition at line 67 of file sbuff.c.

◆ CONSTRAINED_END

#define CONSTRAINED_END (   _sbuff,
  _max,
  _used 
)     (((_max) - (_used)) > fr_sbuff_remaining(_sbuff) ? (_sbuff)->end : (_sbuff)->p + ((_max) - (_used)))

Constrain end pointer to prevent advancing more than the amount the caller specified.

Parameters
[in]_sbuffto constrain.
[in]_maxmaximum amount to advance.
[in]_usedhow much we've advanced so far.
Returns
a temporary end pointer.

Definition at line 526 of file sbuff.c.

◆ FILL_OR_GOTO_DONE

#define FILL_OR_GOTO_DONE (   _out,
  _in,
  _len 
)
Value:
do { \
size_t _to_move = (_len); /* Evaluated once, _len is usually relative to _in's position */ \
if (fr_sbuff_move(_out, _in, _to_move) < _to_move) { \
goto done; \
} \
} while (0)
static fr_slen_t err
Definition dict.h:904
@ FR_SBUFF_ERR_NO_SPACE
static bool done
Definition radclient.c:80
#define fr_sbuff_move(_out, _in, _len)

Fill as much of the output buffer we can and break on partial copy.

Parameters
[in]_outsbuff to write to.
[in]_insbuff to copy from.
[in]_lenmaximum amount to copy.

Definition at line 510 of file sbuff.c.

◆ SBUFF_PARSE_FLOAT_DEF

#define SBUFF_PARSE_FLOAT_DEF (   _name,
  _type,
  _func,
  _max_char 
)
Value:
fr_sbuff_err_t fr_sbuff_out_##_name(_type *out, fr_sbuff_t *in, bool no_trailing) \
{ \
char buff[_max_char + 1] = ""; \
char *end; \
fr_sbuff_t our_in = FR_SBUFF(in); \
size_t len; \
_type res; \
switch (err) { \
case FR_SBUFF_OK: \
break; \
return FR_SBUFF_ERR_NOT_FOUND; /* Too many characters to be a float */ \
default: \
return err; \
} \
errno = 0; /* this is needed as parsing functions don't reset errno */ \
res = _func(buff, &end); \
if (errno == ERANGE) return (res > 0) ? FR_SBUFF_ERR_OVERFLOW : FR_SBUFF_ERR_UNDERFLOW; \
if (no_trailing && (*end != '\0')) return FR_SBUFF_ERR_TRAILING; \
*out = res; \
return FR_SBUFF_OK; \
}
static fr_slen_t in
Definition dict.h:904
fr_sbuff_err_t
@ FR_SBUFF_ERR_INPUT_EMPTY
@ FR_SBUFF_ERR_TRAILING
@ FR_SBUFF_ERR_UNDERFLOW
@ FR_SBUFF_ERR_OVERFLOW
@ FR_SBUFF_ERR_NOT_FOUND
@ FR_SBUFF_OK
bool const sbuff_char_class_float[SBUFF_CHAR_CLASS]
Definition sbuff.c:85
fr_sbuff_err_t fr_sbuff_out_bstrncpy_allowed(size_t *len, fr_sbuff_t *out, fr_sbuff_t *in, size_t max, bool const allowed[static SBUFF_CHAR_CLASS])
Copy as many allowed characters as possible from a sbuff to a sbuff.
Definition sbuff.c:869
#define FR_SBUFF(_sbuff_or_marker)
#define fr_sbuff_advance(_sbuff_or_marker, _len)
#define fr_sbuff_remaining(_sbuff_or_marker)
#define FR_SBUFF_OUT(_start, _len_or_end)
static char buff[sizeof("18446744073709551615")+3]
Definition size_tests.c:37
static fr_sbuff_err_t char ** out
Definition value.h:1062
static fr_sbuff_err_t char size_t * len
Definition value.h:1062

Used to define a number parsing functions for floats.

Parameters
[in]_nameFunction suffix.
[in]_typeOutput type.
[in]_funcParsing function to use.
[in]_max_charMaximum digits that can be used to represent an integer. Can't use stringify because of width modifiers like 'u' used in <stdint.h>.

Definition at line 1405 of file sbuff.c.

◆ SBUFF_PARSE_INT_DEF

#define SBUFF_PARSE_INT_DEF (   _name,
  _type,
  _min,
  _max,
  _max_char,
  _base 
)

Used to define a number parsing functions for signed integers.

Parameters
[in]_nameFunction suffix.
[in]_typeOutput type.
[in]_minvalue.
[in]_maxvalue.
[in]_max_charMaximum digits that can be used to represent an integer. Can't use stringify because of width modifiers like 'u' used in <stdint.h>.
[in]_baseto use.

Definition at line 1275 of file sbuff.c.

◆ SBUFF_PARSE_UINT_DEF

#define SBUFF_PARSE_UINT_DEF (   _name,
  _type,
  _max,
  _max_char,
  _base 
)

Used to define a number parsing functions for signed integers.

Parameters
[in]_nameFunction suffix.
[in]_typeOutput type.
[in]_maxvalue.
[in]_max_charMaximum digits that can be used to represent an integer. Can't use stringify because of width modifiers like 'u' used in <stdint.h>.
[in]_baseof the number being parsed, 8, 10, 16 etc...

Definition at line 1333 of file sbuff.c.

Function Documentation

◆ _fr_sbuff_move_marker_to_marker()

size_t _fr_sbuff_move_marker_to_marker ( fr_sbuff_marker_t *  out,
fr_sbuff_marker_t *  in,
size_t  len 
)

Move data from one marker to another.

Note
Do not call this function directly use fr_sbuff_move
Parameters
[in]outmarker to copy data to.
[in]inmarker to copy data from.
[in]lenMaximum length of string to copy.
Returns
The amount of data copied.

Definition at line 1490 of file sbuff.c.

+ Here is the call graph for this function:

◆ _fr_sbuff_move_marker_to_sbuff()

size_t _fr_sbuff_move_marker_to_sbuff ( fr_sbuff_t *  out,
fr_sbuff_marker_t *  in,
size_t  len 
)

Move data from a marker to an sbuff.

Note
Do not call this function directly use fr_sbuff_move
Parameters
[in]outsbuff to copy data to.
[in]inmarker to copy data from.
[in]lenMaximum length of string to copy.
Returns
The amount of data copied.

Definition at line 1470 of file sbuff.c.

+ Here is the call graph for this function:

◆ _fr_sbuff_move_sbuff_to_marker()

size_t _fr_sbuff_move_sbuff_to_marker ( fr_sbuff_marker_t *  out,
fr_sbuff_t *  in,
size_t  len 
)

Move data from an sbuff to a marker.

Note
Do not call this function directly use fr_sbuff_move
Parameters
[in]outmarker to copy data to.
[in]insbuff to copy data from.
[in]lenMaximum length of string to copy.
Returns
The amount of data copied.

Definition at line 1510 of file sbuff.c.

+ Here is the call graph for this function:

◆ _fr_sbuff_move_sbuff_to_sbuff()

size_t _fr_sbuff_move_sbuff_to_sbuff ( fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  len 
)

Move data from one sbuff to another.

Note
Do not call this function directly use fr_sbuff_move

Both in and out will be advanced by len, with len set to the shortest value between the user specified value, the number of bytes remaining in the input buffer (after extension), and the number of bytes remaining in the output buffer (after extension).

Parameters
[in]outsbuff to copy data to.
[in]insbuff to copy data from.
[in]lenMaximum length of string to copy.
Returns
The amount of data copied.

Definition at line 1450 of file sbuff.c.

+ Here is the call graph for this function:

◆ _sbuff_scratch_free()

static int _sbuff_scratch_free ( void *  arg)
static

Free the scratch buffer used for printf.

Definition at line 1592 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_adv_past_allowed()

size_t fr_sbuff_adv_past_allowed ( fr_sbuff_t *  sbuff,
size_t  len,
bool const  allowed[static SBUFF_CHAR_CLASS],
fr_sbuff_term_t const *  tt 
)

Wind position past characters in the allowed set.

Parameters
[in]sbuffsbuff to search in.
[in]lenMaximum amount to advance by. Unconstrained if SIZE_MAX.
[in]allowedcharacter set.
[in]ttIf not NULL, stop if we find a terminal sequence.
Returns
how many bytes we advanced.

Definition at line 1936 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_adv_past_str()

size_t fr_sbuff_adv_past_str ( fr_sbuff_t *  sbuff,
char const *  needle,
size_t  needle_len 
)

Return true and advance past the end of the needle if needle occurs next in the sbuff.

Parameters
[in]sbuffto search in.
[in]needleto search for.
[in]needle_lenof needle. If SIZE_MAX strlen is used to determine length of the needle.
Returns
how many bytes we advanced

Definition at line 1871 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_adv_past_strcase()

size_t fr_sbuff_adv_past_strcase ( fr_sbuff_t *  sbuff,
char const *  needle,
size_t  needle_len 
)

Return true and advance past the end of the needle if needle occurs next in the sbuff.

This function is similar to fr_sbuff_adv_past_str but is case insensitive.

Parameters
[in]sbuffto search in.
[in]needleto search for.
[in]needle_lenof needle. If SIZE_MAX strlen is used to determine length of the needle.
Returns
how many bytes we advanced

Definition at line 1902 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_adv_to_chr()

char * fr_sbuff_adv_to_chr ( fr_sbuff_t *  sbuff,
size_t  len,
char  c 
)

Wind position to first instance of specified char.

Parameters
[in,out]sbuffto search in.
[in]lenMaximum amount to advance by. Unconstrained if SIZE_MAX.
[in]cto search for.
Returns
  • NULL, no instances found.
  • The position of the first character.

Definition at line 2115 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_adv_to_chr_utf8()

char * fr_sbuff_adv_to_chr_utf8 ( fr_sbuff_t *  sbuff,
size_t  len,
char const *  chr 
)

Wind position to first instance of specified multibyte utf8 char.

Only use this function if the search char could be multibyte, as there's a large performance penalty.

Parameters
[in,out]sbuffto search in.
[in]lenthe maximum number of characters to search in sbuff.
[in]chrto search for.
Returns
  • NULL, no instances found.
  • The position of the first character.

Definition at line 2070 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_adv_to_str()

char * fr_sbuff_adv_to_str ( fr_sbuff_t *  sbuff,
size_t  len,
char const *  needle,
size_t  needle_len 
)

Wind position to the first instance of the specified needle.

Parameters
[in,out]sbuffsbuff to search in.
[in]lenMaximum amount to advance by. Unconstrained if SIZE_MAX.
[in]needleto search for.
[in]needle_lenLength of the needle. SIZE_MAX to used strlen.
Returns
  • NULL, no instances found.
  • The position of the first character.

Definition at line 2151 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_adv_to_strcase()

char * fr_sbuff_adv_to_strcase ( fr_sbuff_t *  sbuff,
size_t  len,
char const *  needle,
size_t  needle_len 
)

Wind position to the first instance of the specified needle.

Parameters
[in,out]sbuffsbuff to search in.
[in]lenMaximum amount to advance by. Unconstrained if SIZE_MAX.
[in]needleto search for.
[in]needle_lenLength of the needle. SIZE_MAX to used strlen.
Returns
  • NULL, no instances found.
  • The position of the first character.

Definition at line 2204 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_adv_until()

size_t fr_sbuff_adv_until ( fr_sbuff_t *  sbuff,
size_t  len,
fr_sbuff_term_t const *  tt,
char  escape_chr 
)

Wind position until we hit a character in the terminal set.

Parameters
[in]sbuffsbuff to search in.
[in]lenMaximum amount to advance by. Unconstrained if SIZE_MAX.
[in]ttToken terminals in the encompassing grammar.
[in]escape_chrIf not '\0', ignore characters in the tt set when prefixed with this escape character.
Returns
how many bytes we advanced.

Definition at line 2011 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_array_concat()

fr_slen_t fr_sbuff_array_concat ( fr_sbuff_t *  out,
char const *const *  array,
char const *  sep 
)

Concat an array of strings (not NULL terminated), with a string separator.

Parameters
[out]outWhere to write the resulting string.
[in]arrayof strings to concat.
[in]septo insert between elements. May be NULL.
Returns
  • >= 0 on success - length of the string created.
  • -1 on failure.

Definition at line 2448 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_eof_file()

bool fr_sbuff_eof_file ( fr_sbuff_t *  sbuff)

Accessor function for the EOF state of the file extendor.

Definition at line 364 of file sbuff.c.

◆ fr_sbuff_extend_file()

size_t fr_sbuff_extend_file ( fr_sbuff_extend_status_t *  status,
fr_sbuff_t *  sbuff,
size_t  extension 
)

Refresh the buffer with more data from the file.

Check for errors

Definition at line 282 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_extend_talloc()

size_t fr_sbuff_extend_talloc ( fr_sbuff_extend_status_t *  status,
fr_sbuff_t *  sbuff,
size_t  extension 
)

Reallocate the current buffer.

Parameters
[in]statusExtend status.
[in]sbuffto be extended.
[in]extensionHow many additional bytes should be allocated in the buffer.
Returns
  • 0 the extension operation failed.
  • >0 the number of bytes the buffer was extended by.

Definition at line 380 of file sbuff.c.

+ Here is the call graph for this function:

◆ fr_sbuff_in_array()

fr_slen_t fr_sbuff_in_array ( fr_sbuff_t *  out,
char const *const *  array,
char const *  sep 
)

Concat an array of strings (NULL terminated), with a string separator.

Parameters
[out]outWhere to write the resulting string.
[in]arrayof strings to concat.
[in]septo insert between elements. May be NULL.
Returns
  • >= 0 on success - length of the string created.
  • -1 on failure.

Definition at line 1839 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_bstrcpy_buffer()

ssize_t fr_sbuff_in_bstrcpy_buffer ( fr_sbuff_t *  sbuff,
char const *  str 
)

Copy bytes into the sbuff up to the first \0.

Parameters
[in]sbuffto copy into.
[in]strtalloced buffer to copy into sbuff.
Returns
  • >= 0 the number of bytes copied into the sbuff.
  • -1 the copy would not fit in the output buffer.

Definition at line 1573 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_bstrncpy()

ssize_t fr_sbuff_in_bstrncpy ( fr_sbuff_t *  sbuff,
char const *  str,
size_t  len 
)

Copy bytes into the sbuff up to the first \0.

Parameters
[in]sbuffto copy into.
[in]strto copy into buffer.
[in]lennumber of bytes to copy.
Returns
  • >= 0 the number of bytes copied into the sbuff.
  • -1 the copy would not fit in the output buffer.

Definition at line 1553 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_escape()

ssize_t fr_sbuff_in_escape ( fr_sbuff_t *  sbuff,
char const *  in,
size_t  inlen,
fr_sbuff_escape_rules_t const *  e_rules 
)

Print an escaped string to an sbuff.

Parameters
[in]sbuffto print into.
[in]into escape.
[in]inlenof string to escape.
[in]e_rulesEscaping rules. Used to escape special characters as data is written to the sbuff. May be NULL.
Returns
  • >= 0 the number of bytes printed into the sbuff.
  • -1 the printed output would not fit in the output buffer.

Definition at line 1705 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_escape_buffer()

ssize_t fr_sbuff_in_escape_buffer ( fr_sbuff_t *  sbuff,
char const *  in,
fr_sbuff_escape_rules_t const *  e_rules 
)

Print an escaped string to an sbuff taking a talloced buffer as input.

Parameters
[in]sbuffto print into.
[in]into escape.
[in]e_rulesEscaping rules. Used to escape special characters as data is written to the sbuff. May be NULL.
Returns
  • >= 0 the number of bytes printed into the sbuff.
  • -1 the printed output would not fit in the output buffer.

Definition at line 1821 of file sbuff.c.

+ Here is the call graph for this function:

◆ fr_sbuff_in_needs_escaping()

bool fr_sbuff_in_needs_escaping ( char const *  in,
size_t  inlen,
fr_sbuff_escape_rules_t const *  e_rules 
)

Walk an input string and report whether fr_sbuff_in_escape() would escape any characters in it.

Mirrors the per-byte decisions of fr_sbuff_in_escape: a byte inside a multi-byte UTF-8 sequence (when do_utf8 is set) is passed through, a byte with a substitution mapping is escaped, and a byte in the esc[] table is escaped. If any byte would be escaped, the function returns false at that byte. A NULL or chr=='\0' ruleset is treated as "no escaping": the function always returns true.

Parameters
[in]into inspect.
[in]inlenbytes of in to inspect.
[in]e_rulesescaping rules. May be NULL.
Returns
  • false at least one byte would be escaped.
  • true no byte would be escaped (the string is already safe).

Definition at line 1785 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_sprintf()

ssize_t fr_sbuff_in_sprintf ( fr_sbuff_t *  sbuff,
char const *  fmt,
  ... 
)

Print using a fmt string to an sbuff.

Parameters
[in]sbuffto print into.
[in]fmtstring.
[in]...arguments for format string.
Returns
  • >= 0 the number of bytes printed into the sbuff.
  • -1 the printed output would not fit in the output buffer.

Definition at line 1680 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_strcpy()

ssize_t fr_sbuff_in_strcpy ( fr_sbuff_t *  sbuff,
char const *  str 
)

Copy bytes into the sbuff up to the first \0.

Parameters
[in]sbuffto copy into.
[in]strto copy into buffer.
Returns
  • >= 0 the number of bytes copied into the sbuff.
  • -1 the copy would not fit in the output buffer.

Definition at line 1529 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_in_vsprintf()

ssize_t fr_sbuff_in_vsprintf ( fr_sbuff_t *  sbuff,
char const *  fmt,
va_list  ap 
)

Print using a fmt string to an sbuff.

Parameters
[in]sbuffto print into.
[in]fmtstring.
[in]aparguments for format string.
Returns
  • >= 0 the number of bytes printed into the sbuff. 0 if the formatted string could not be allocated. Nothing was printed and the error stack says why.
  • -1 the printed output would not fit in the output buffer.

Definition at line 1646 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_is_terminal()

bool fr_sbuff_is_terminal ( fr_sbuff_t *  in,
fr_sbuff_term_t const *  tt 
)

Efficient terminal string search.

Caller should ensure that a buffer extension of needle_len bytes has been requested before calling this function.

Parameters
[in]inSbuff to search in.
[in]ttToken terminals in the encompassing grammar.
Returns
  • true if found.
  • false if not.

Definition at line 2311 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_next_if_char()

bool fr_sbuff_next_if_char ( fr_sbuff_t *  sbuff,
char  c 
)

Return true if the current char matches, and if it does, advance.

Parameters
[in]sbuffto search for char in.
[in]cchar to search for.
Returns
  • true and advance if the next character matches.
  • false and don't advance if the next character doesn't match.

Definition at line 2247 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_next_unless_char()

bool fr_sbuff_next_unless_char ( fr_sbuff_t *  sbuff,
char  c 
)

Return true and advance if the next char does not match.

Parameters
[in]sbuffto search for char in.
[in]cchar to search for.
Returns
  • true and advance unless the character matches.
  • false and don't advance if the next character matches.

Definition at line 2268 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_out_bool()

fr_sbuff_err_t fr_sbuff_out_bool ( bool *  out,
fr_sbuff_t *  in 
)

See if the string contains a truth value.

Parameters
[out]outWhere to write boolean value.
[in]inWhere to search for a truth value. Advanced past the value on success.
Returns
  • FR_SBUFF_OK a truth value was found.
  • FR_SBUFF_ERR_INPUT_EMPTY no input.
  • FR_SBUFF_ERR_NOT_FOUND input does not start with a truth value.

Definition at line 1209 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_out_bstrncpy()

fr_sbuff_err_t fr_sbuff_out_bstrncpy ( size_t *  len,
fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  max 
)

Copy as many bytes as possible from a sbuff to a sbuff.

The copy stops after max bytes, at the end of the input, or when out is full.

Parameters
[out]lenNumber of bytes copied. May be NULL.
[out]outWhere to copy to.
[in]inWhere to copy from. Advanced by the number of bytes copied.
[in]maxMaximum number of bytes to copy. SIZE_MAX copies all remaining input.
Returns
  • FR_SBUFF_OK the copy stopped at max or at the end of the input.
  • FR_SBUFF_ERR_NO_SPACE out filled first. The partial copy is left in place.
  • FR_SBUFF_ERR_EXTEND in's extend callback failed. The partial copy is left in place.

Definition at line 755 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_out_bstrncpy_allowed()

fr_sbuff_err_t fr_sbuff_out_bstrncpy_allowed ( size_t *  len,
fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  max,
bool const  allowed[static SBUFF_CHAR_CLASS] 
)

Copy as many allowed characters as possible from a sbuff to a sbuff.

The copy stops at the first disallowed character, after max bytes, at the end of the input, or when out is full. The input sbuff is left pointing at the first character not copied.

Parameters
[out]lenNumber of bytes copied. May be NULL.
[out]outWhere to copy to.
[in]inWhere to copy from. Advanced by the number of bytes copied.
[in]maxMaximum number of bytes to copy. SIZE_MAX copies all remaining input.
[in]allowedCharacters to include the copy.
Returns
  • FR_SBUFF_OK the copy stopped at a disallowed character, at max, or at the end of the input.
  • FR_SBUFF_ERR_NO_SPACE out filled first. The partial copy is left in place.
  • FR_SBUFF_ERR_EXTEND in's extend callback failed. The partial copy is left in place.

Definition at line 869 of file sbuff.c.

◆ fr_sbuff_out_bstrncpy_exact()

fr_sbuff_err_t fr_sbuff_out_bstrncpy_exact ( fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  len 
)

Copy exactly len bytes from a sbuff to a sbuff or fail.

On failure nothing is left in out and in is not advanced.

Parameters
[out]outWhere to copy to.
[in]inWhere to copy from. Will copy len bytes from current position in buffer.
[in]lenHow many bytes to copy. If SIZE_MAX the entire buffer will be copied.
Returns
  • FR_SBUFF_OK len bytes were copied, and in was advanced by len.
  • FR_SBUFF_ERR_INPUT_SHORT in held fewer than len bytes.
  • FR_SBUFF_ERR_EXTEND in could not be extended because its extend callback failed.
  • FR_SBUFF_ERR_NO_SPACE out could not hold len bytes.

Definition at line 800 of file sbuff.c.

+ Here is the call graph for this function:

◆ fr_sbuff_out_bstrncpy_until()

fr_sbuff_err_t fr_sbuff_out_bstrncpy_until ( size_t *  len,
fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  max,
fr_sbuff_term_t const *  tt,
fr_sbuff_unescape_rules_t const *  u_rules 
)

Copy from a sbuff to a sbuff until a terminal sequence is found.

The copy stops before the first terminal, after max bytes, at the end of the input, or when out is full. The input sbuff is left pointing at the first character not copied.

Parameters
[out]lenNumber of bytes copied. May be NULL.
[out]outWhere to copy to.
[in]inWhere to copy from. Advanced by the number of bytes copied.
[in]maxMaximum number of bytes to copy. SIZE_MAX copies all remaining input.
[in]ttToken terminals in the encompassing grammar.
[in]u_rulesIf not NULL, ignore characters in the until set when prefixed with u_rules->chr. FIXME - Should actually evaluate u_rules fully.
Returns
  • FR_SBUFF_OK the copy stopped at a terminal, at max, or at the end of the input.
  • FR_SBUFF_ERR_NO_SPACE out filled first. The partial copy is left in place.
  • FR_SBUFF_ERR_EXTEND in's extend callback failed. The partial copy is left in place.

Definition at line 923 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_out_unescape_until()

fr_sbuff_err_t fr_sbuff_out_unescape_until ( size_t *  len,
fr_sbuff_t *  out,
fr_sbuff_t *  in,
size_t  max,
fr_sbuff_term_t const *  tt,
fr_sbuff_unescape_rules_t const *  u_rules 
)

Copy from a sbuff to a sbuff until a terminal sequence is found, unescaping as we go.

The copy stops before the first terminal, after max input bytes, at the end of the input, or when out is full. The input sbuff is left pointing at the first character not copied.

Parameters
[out]lenNumber of bytes written to out. May be NULL.
[out]outWhere to copy to.
[in]inWhere to copy from. Advanced by the number of bytes consumed.
[in]maxMaximum number of input bytes to consume. SIZE_MAX consumes all remaining input.
[in]ttToken terminal strings in the encompassing grammar.
[in]u_rulesfor processing unescape sequences.
Returns
  • FR_SBUFF_OK the copy stopped at a terminal, at max, or at the end of the input.
  • FR_SBUFF_ERR_NO_SPACE out filled first. The partial copy is left in place.
  • FR_SBUFF_ERR_EXTEND in's extend callback failed. The partial copy is left in place.

Definition at line 1002 of file sbuff.c.

+ Here is the call graph for this function:

◆ fr_sbuff_parse_rules_debug()

void fr_sbuff_parse_rules_debug ( FILE *  fp,
fr_sbuff_parse_rules_t const *  p_rules 
)

Definition at line 2420 of file sbuff.c.

+ Here is the call graph for this function:

◆ fr_sbuff_reset_talloc()

int fr_sbuff_reset_talloc ( fr_sbuff_t *  sbuff)

Reset a talloced buffer to its initial length, clearing any data stored.

Parameters
[in]sbuffto reset.
Returns
  • 0 on success.
  • -1 on failure - markers present pointing past the end of string data.

Definition at line 479 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_shift()

size_t fr_sbuff_shift ( fr_sbuff_t *  sbuff,
size_t  shift,
bool  move_end 
)

Shift the contents of the sbuff, returning the number of bytes we managed to shift.

Parameters
[in]sbuffto shift.
[in]shiftthe contents of the buffer this many bytes towards the start of the buffer.
[in]move_endIf the buffer is used for reading, then this should be true so we cannot read passed the end of valid data.
Returns
  • 0 the shift failed due to constraining pointers.
  • >0 the number of bytes we managed to shift pointers in the sbuff. memmove should be used to move the existing contents of the buffer, and fill the free space at the end of the buffer with additional data.

Definition at line 212 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_terminal_debug()

void fr_sbuff_terminal_debug ( FILE *  fp,
fr_sbuff_term_t const *  tt 
)

Definition at line 2411 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_terminal_idx_init()

static void fr_sbuff_terminal_idx_init ( size_t *  needle_len,
uint8_t  idx[static SBUFF_CHAR_CLASS],
fr_sbuff_term_t const *  term 
)
inlinestatic

Populate a terminal index.

Parameters
[out]needle_lenthe longest needle. Will not be set if the terminal array is empty.
[out]idxto populate.
[in]termTerminals to populate the index with.

Definition at line 537 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_terminal_search()

static bool fr_sbuff_terminal_search ( fr_sbuff_t *  in,
char const *  p,
uint8_t  idx[static SBUFF_CHAR_CLASS],
fr_sbuff_term_t const *  term,
UNUSED size_t  needle_len 
)
inlinestatic

Efficient terminal string search.

Caller should ensure that a buffer extension of needle_len bytes has been requested before calling this function.

Parameters
[in]inSbuff to search in.
[in]pCurrent position (may be ahead of in->p).
[in]idxFastpath index, populated by fr_sbuff_terminal_idx_init.
[in]termterminals to search in.
[in]needle_lenLength of the longest needle.
Returns
  • true if found.
  • false if not.

Definition at line 572 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_terminals_amerge()

fr_sbuff_term_t * fr_sbuff_terminals_amerge ( TALLOC_CTX *  ctx,
fr_sbuff_term_t const *  a,
fr_sbuff_term_t const *  b 
)

Merge two sets of terminal strings.

Parameters
[in]ctxto allocate the new terminal array in.
[in]afirst set of terminals to merge.
[in]bsecond set of terminals to merge.
Returns
A new set of de-duplicated and sorted terminals.

Definition at line 675 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_trim()

size_t fr_sbuff_trim ( fr_sbuff_t *  sbuff,
bool const  to_trim[static SBUFF_CHAR_CLASS] 
)

Trim trailing characters from a string we're composing.

Parameters
[in]sbuffto trim trailing characters from.
[in]to_trimCharset to trim.
Returns
how many chars we removed.

Definition at line 2287 of file sbuff.c.

+ Here is the caller graph for this function:

◆ fr_sbuff_trim_talloc()

int fr_sbuff_trim_talloc ( fr_sbuff_t *  sbuff,
size_t  len 
)

Trim a talloced sbuff to the minimum length required to represent the contained string.

Parameters
[in]sbuffto trim.
[in]lenLength to trim to. Passing SIZE_MAX will result in the buffer being trimmed to the length of the content.
Returns
  • 0 on success.
  • -1 on failure - markers present pointing past the end of string data.

Definition at line 444 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_unescape_debug()

void fr_sbuff_unescape_debug ( FILE *  fp,
fr_sbuff_unescape_rules_t const *  escapes 
)

Definition at line 2390 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_sbuff_update()

void fr_sbuff_update ( fr_sbuff_t *  sbuff,
char *  new_buff,
size_t  new_len 
)

Update all markers and pointers in the set of sbuffs to point to new_buff.

This function should be used if the underlying buffer is realloced.

Parameters
[in]sbuffto update.
[in]new_buffto assign to to sbuff.
[in]new_lenLength of the new buffer.

Definition at line 171 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ min()

static size_t min ( size_t  x,
size_t  y 
)
inlinestatic

Definition at line 158 of file sbuff.c.

+ Here is the caller graph for this function:

◆ safecpy()

static ssize_t safecpy ( char *  o_start,
char *  o_end,
char const *  i_start,
char const *  i_end 
)
inlinestatic

Copy function that allows overlapping memory ranges to be copied.

Parameters
[out]o_startstart of output buffer.
[in]o_endend of the output buffer.
[in]i_startstart of the input buffer.
[in]i_endend of data to copy.
Returns
  • >0 the number of bytes copied.
  • 0 invalid args.
  • -1 the copy would not fit in the output buffer.

Definition at line 138 of file sbuff.c.

+ Here is the caller graph for this function:

◆ sbuff_print_char()

static char const * sbuff_print_char ( char  c)
static

Print a char in a friendly format.

Definition at line 2344 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sbuff_scratch_init()

static void sbuff_scratch_init ( TALLOC_CTX **  out)
inlinestatic

Initialise a thread local scratch context.

The scratch pool is an optimisation. When it is unavailable, because thread local allocation has been disabled at shutdown or the pool could not be allocated, out is set to NULL and callers allocate at top level.

Parameters
[out]outthe scratch context, or NULL.

Definition at line 1606 of file sbuff.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ terminal_cmp()

static int8_t terminal_cmp ( fr_sbuff_term_elem_t const *  a,
fr_sbuff_term_elem_t const *  b 
)
inlinestatic

Compare two terminal elements for ordering purposes.

Parameters
[in]afirst terminal to compare.
[in]bsecond terminal to compare.
Returns
CMP(a,b)

Definition at line 652 of file sbuff.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ sbuff_char_alpha_num

bool const sbuff_char_alpha_num[SBUFF_CHAR_CLASS] = { SBUFF_CHAR_CLASS_ALPHA_NUM }

Definition at line 110 of file sbuff.c.

◆ sbuff_char_blank

bool const sbuff_char_blank[SBUFF_CHAR_CLASS]
Initial value:
= {
['\t'] = true, [' '] = true,
}

Definition at line 123 of file sbuff.c.

◆ sbuff_char_class_float

bool const sbuff_char_class_float[SBUFF_CHAR_CLASS]
Initial value:
= {
['-'] = true, ['+'] = true, ['e'] = true, ['E'] = true, ['.'] = true,
}
#define SBUFF_CHAR_CLASS_NUM

Definition at line 85 of file sbuff.c.

◆ sbuff_char_class_hex

bool const sbuff_char_class_hex[SBUFF_CHAR_CLASS] = { SBUFF_CHAR_CLASS_HEX }

Definition at line 109 of file sbuff.c.

◆ sbuff_char_class_hostname

bool const sbuff_char_class_hostname[SBUFF_CHAR_CLASS]
Initial value:
= {
['.'] = true,
[':'] = true,
['-'] = true,
['/'] = true,
['['] = true,
[']'] = true,
['_'] = true,
['*'] = true,
}
#define SBUFF_CHAR_CLASS_ALPHA_NUM

Definition at line 97 of file sbuff.c.

◆ sbuff_char_class_int

bool const sbuff_char_class_int[SBUFF_CHAR_CLASS]
Initial value:
= {
['+'] = true, ['-'] = true
}

Definition at line 80 of file sbuff.c.

◆ sbuff_char_class_uint

bool const sbuff_char_class_uint[SBUFF_CHAR_CLASS]
Initial value:
= {
['+'] = true
}

Definition at line 75 of file sbuff.c.

◆ sbuff_char_class_zero

bool const sbuff_char_class_zero[SBUFF_CHAR_CLASS]
Initial value:
= {
['0'] = true
}

Definition at line 90 of file sbuff.c.

◆ sbuff_char_line_endings

bool const sbuff_char_line_endings[SBUFF_CHAR_CLASS]
Initial value:
= {
['\n'] = true, ['\r'] = true
}

Definition at line 119 of file sbuff.c.

◆ sbuff_char_whitespace

bool const sbuff_char_whitespace[SBUFF_CHAR_CLASS]
Initial value:
= {
['\t'] = true, ['\n'] = true, ['\r'] = true, ['\f'] = true, ['\v'] = true, [' '] = true,
}

Definition at line 115 of file sbuff.c.

◆ sbuff_char_word

bool const sbuff_char_word[SBUFF_CHAR_CLASS]
Initial value:
= {
['-'] = true, ['_'] = true,
}

Definition at line 111 of file sbuff.c.

◆ sbuff_err_table

fr_table_num_ordered_t const sbuff_err_table[]
Initial value:
= {
{ L("ok"), FR_SBUFF_OK },
{ L("out of space"), FR_SBUFF_ERR_NO_SPACE },
{ L("failed extending input"), FR_SBUFF_ERR_EXTEND },
{ L("empty input is invalid"), FR_SBUFF_ERR_INPUT_EMPTY },
{ L("input too short"), FR_SBUFF_ERR_INPUT_SHORT },
{ L("token not found"), FR_SBUFF_ERR_NOT_FOUND },
{ L("trailing data"), FR_SBUFF_ERR_TRAILING },
{ L("token format invalid"), FR_SBUFF_ERR_FORMAT },
{ L("integer overflow"), FR_SBUFF_ERR_OVERFLOW },
{ L("integer underflow"), FR_SBUFF_ERR_UNDERFLOW },
{ L("sbuff not initialised"), FR_SBUFF_ERR_UNINITIALISED },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:228
@ FR_SBUFF_ERR_FORMAT
@ FR_SBUFF_ERR_UNINITIALISED
@ FR_SBUFF_ERR_EXTEND
@ FR_SBUFF_ERR_INPUT_SHORT

Definition at line 43 of file sbuff.c.

◆ sbuff_err_table_len

size_t sbuff_err_table_len = NUM_ELEMENTS(sbuff_err_table)

Definition at line 56 of file sbuff.c.

◆ sbuff_scratch

_Thread_local char* sbuff_scratch
static

Definition at line 30 of file sbuff.c.

◆ sbuff_scratch_freed

_Thread_local bool sbuff_scratch_freed
static

When true, prevent use of the scratch space.

This prevents us from initialising a pool after the thread local destructors have run.

The destructors may be called manually before thread exit, and we don't want to re-initialise the pool

Definition at line 38 of file sbuff.c.