The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations
sbuff.h File Reference

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

#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/talloc.h>
+ Include dependency graph for sbuff.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_sbuff_ptr_s
 
union  fr_sbuff_ptr_s.__unnamed138__
 
struct  fr_sbuff_s
 
union  fr_sbuff_s.__unnamed140__
 
union  fr_sbuff_s.__unnamed142__
 
union  fr_sbuff_s.__unnamed144__
 
union  fr_sbuff_s.__unnamed146__
 
struct  fr_sbuff_term_elem_t
 Terminal element with pre-calculated lengths. More...
 
struct  fr_sbuff_term_t
 Set of terminal elements. More...
 
struct  fr_sbuff_uctx_file_t
 File sbuff extension structure. More...
 
struct  fr_sbuff_uctx_talloc_t
 Talloc sbuff extension structure. More...
 
struct  fr_sbuff_unescape_rules_t
 Set of parsing rules for *unescape_until functions. More...
 

Macros

#define _fr_sbuff_out_size(_err, _out, _in)   size_t * : fr_sbuff_out_size(_err, (size_t *)_out, _in, true),
 
#define _fr_sbuff_out_ssize(_err, _out, _in)   ssize_t * : fr_sbuff_out_ssize(_err, (ssize_t *)_out, _in, true),
 
#define FR_SBUFF(_sbuff_or_marker)
 
#define FR_SBUFF_ABS(_sbuff_or_marker)
 
#define fr_sbuff_adv_past_blank(_sbuff, _len, _tt)   fr_sbuff_adv_past_allowed(_sbuff, _len, sbuff_char_blank, _tt)
 
#define fr_sbuff_adv_past_str_literal(_sbuff, _needle)   fr_sbuff_adv_past_str(_sbuff, _needle, sizeof(_needle) - 1)
 
#define fr_sbuff_adv_past_strcase_literal(_sbuff, _needle)   fr_sbuff_adv_past_strcase(_sbuff, _needle, sizeof(_needle) - 1)
 
#define fr_sbuff_adv_past_whitespace(_sbuff, _len, _tt)   fr_sbuff_adv_past_allowed(_sbuff, _len, sbuff_char_whitespace, _tt)
 
#define fr_sbuff_adv_past_zeros(_sbuff, _len, _tt)   fr_sbuff_adv_past_allowed(_sbuff, _len, sbuff_char_class_zero, _tt)
 
#define fr_sbuff_adv_to_str_literal(_sbuff, _len, _needle)   fr_sbuff_adv_to_str(_sbuff, _len, _needle, sizeof(_needle) - 1)
 
#define fr_sbuff_adv_to_strcase_literal(_sbuff, _len, _needle)   fr_sbuff_adv_to_strcase(_sbuff, _len, _needle, sizeof(_needle) - 1)
 
#define fr_sbuff_advance(_sbuff_or_marker, _len)   fr_sbuff_set(_sbuff_or_marker, (fr_sbuff_current(_sbuff_or_marker) + (_len)))
 
#define FR_SBUFF_ADVANCE_RETURN(_sbuff, _len)   FR_SBUFF_RETURN(fr_sbuff_advance, _sbuff, _len)
 
#define fr_sbuff_ahead(_sbuff_or_marker)
 
#define fr_sbuff_as_percent_s(_sbuff)   (int) fr_sbuff_remaining(_sbuff), fr_sbuff_current(_sbuff)
 
#define fr_sbuff_behind(_sbuff_or_marker)
 
#define FR_SBUFF_BIND_CURRENT(_sbuff_or_marker)
 
#define FR_SBUFF_BIND_CURRENT_ABS(_sbuff_or_marker)
 
#define fr_sbuff_buff(_sbuff_or_marker)
 
#define fr_sbuff_char(_sbuff_or_marker, _eob)    (fr_sbuff_current(_sbuff_or_marker) >= fr_sbuff_end(_sbuff_or_marker) ? _eob : *fr_sbuff_current(_sbuff_or_marker))
 
#define FR_SBUFF_CHECK_REMAINING_RETURN(_sbuff, _len)    if ((_len) > fr_sbuff_remaining(_sbuff)) return -((_len) - fr_sbuff_remaining(_sbuff))
 
#define fr_sbuff_current(_sbuff_or_marker)
 
#define fr_sbuff_diff(_a, _b)    ((ssize_t)(fr_sbuff_current(_a) - fr_sbuff_current(_b)))
 
#define fr_sbuff_end(_sbuff_or_marker)
 
#define fr_sbuff_error(_sbuff_or_marker)    _fr_sbuff_error(fr_sbuff_ptr(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker))
 
#define FR_SBUFF_ERROR_RETURN(_sbuff_or_marker)   return fr_sbuff_error(_sbuff_or_marker)
 
#define fr_sbuff_extend(_sbuff_or_marker)   fr_sbuff_extend_lowat(NULL, _sbuff_or_marker, 1)
 
#define fr_sbuff_extend_lowat(_status, _sbuff_or_marker, _lowat)
 
#define FR_SBUFF_EXTEND_LOWAT_OR_RETURN(_sbuff, _len)
 
#define FR_SBUFF_IN(_start, _len_or_end)
 
#define FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_bstrcpy_buffer, ##__VA_ARGS__)
 
#define FR_SBUFF_IN_BSTRNCPY_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_bstrncpy, ##__VA_ARGS__)
 
#define fr_sbuff_in_char(_sbuff, ...)   fr_sbuff_in_bstrncpy(_sbuff, ((char []){ __VA_ARGS__ }), sizeof((char []){ __VA_ARGS__ }))
 
#define FR_SBUFF_IN_CHAR_RETURN(_sbuff, ...)   FR_SBUFF_RETURN(fr_sbuff_in_bstrncpy, _sbuff, ((char []){ __VA_ARGS__ }), sizeof((char []){ __VA_ARGS__ }))
 
#define FR_SBUFF_IN_ESCAPE_BUFFER_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_escape_buffer, ##__VA_ARGS__)
 
#define FR_SBUFF_IN_ESCAPE_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_escape, ##__VA_ARGS__)
 
#define FR_SBUFF_IN_SPRINTF_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_sprintf, ##__VA_ARGS__)
 
#define fr_sbuff_in_strcpy_literal(_sbuff, _str)   fr_sbuff_in_bstrncpy(_sbuff, _str, sizeof(_str) - 1)
 
#define FR_SBUFF_IN_STRCPY_LITERAL_RETURN(_sbuff, _str)   FR_SBUFF_RETURN(fr_sbuff_in_bstrncpy, _sbuff, _str, sizeof(_str) - 1)
 
#define FR_SBUFF_IN_STRCPY_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_strcpy, ##__VA_ARGS__)
 
#define fr_sbuff_in_table_str(_slen, _sbuff, _table, _number, _def)    _slen = fr_sbuff_in_strcpy(_sbuff, fr_table_str_by_value(_table, _number, _def))
 
#define FR_SBUFF_IN_TABLE_STR_RETURN(_sbuff, _table, _number, _def)
 
#define FR_SBUFF_IN_VSPRINTF_RETURN(...)   FR_SBUFF_RETURN(fr_sbuff_in_vsprintf, ##__VA_ARGS__)
 
#define fr_sbuff_init_in(_out, _start, _len_or_end)
 
#define fr_sbuff_init_out(_out, _start, _len_or_end)
 
#define fr_sbuff_is_alnum(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, alnum)
 
#define fr_sbuff_is_alpha(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, alpha)
 
#define fr_sbuff_is_char(_sbuff_or_marker, _c)
 
#define fr_sbuff_is_digit(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, digit)
 
#define fr_sbuff_is_hex(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, hex)
 
#define fr_sbuff_is_lower(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, lower)
 
#define fr_sbuff_is_space(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, space)
 
#define fr_sbuff_is_str_literal(_sbuff, _str)   fr_sbuff_is_str(_sbuff, _str, sizeof(_str) - 1)
 
#define fr_sbuff_is_upper(_sbuff_or_marker)    SBUFF_IS_GENERIC(_sbuff_or_marker, upper)
 
#define fr_sbuff_len(_sbuff_or_marker)    ((size_t)(fr_sbuff_end(_sbuff_or_marker) - fr_sbuff_buff(_sbuff_or_marker)))
 
#define fr_sbuff_move(_out, _in, _len)
 
#define fr_sbuff_out(_err, _out, _in)
 
#define FR_SBUFF_OUT(_start, _len_or_end)
 
#define fr_sbuff_out_by_longest_prefix(_match_len, _out, _table, _sbuff, _def)
 
#define fr_sbuff_ptr(_sbuff_or_marker)
 
#define fr_sbuff_remaining(_sbuff_or_marker)
 
#define FR_SBUFF_REPARSE(_sbuff_or_marker)
 
#define FR_SBUFF_RETURN(_func, _sbuff, ...)
 
#define fr_sbuff_set(_dst, _src)
 
#define FR_SBUFF_SET_RETURN(_dst, _src)   return fr_sbuff_set(_dst, _src)
 
#define fr_sbuff_shifted(_sbuff_or_marker)
 
#define fr_sbuff_start(_sbuff_or_marker)
 
#define fr_sbuff_switch(_sbuff_or_marker, _eob)    switch (fr_sbuff_char(_sbuff_or_marker, _eob))
 
#define FR_SBUFF_TALLOC_THREAD_LOCAL(_out, _init, _max)
 
#define FR_SBUFF_TERM(_str)
 Initialise a terminal structure with a single string.
 
#define FR_SBUFF_TERMS(...)
 Initialise a terminal structure with a list of sorted strings.
 
#define fr_sbuff_used(_sbuff_or_marker)
 
#define fr_sbuff_used_total(_sbuff_or_marker)    ((size_t)((fr_sbuff_current(_sbuff_or_marker) + fr_sbuff_shifted(_sbuff_or_marker)) - fr_sbuff_start(_sbuff_or_marker)))
 
#define fr_sbuff_was_extended(_status)   (_status & FR_SBUFF_FLAG_EXTENDED)
 
#define SBUFF_CHAR_CLASS_ALPHA
 
#define SBUFF_CHAR_CLASS_ALPHA_NUM
 
#define SBUFF_CHAR_CLASS_HEX
 
#define SBUFF_CHAR_CLASS_NUM
 
#define SBUFF_CHAR_CLASS_SYMBOLS
 
#define SBUFF_CHAR_UNPRINTABLES_EXTENDED
 
#define SBUFF_CHAR_UNPRINTABLES_LOW
 
#define SBUFF_IS_FUNC(_name, _test)
 
#define SBUFF_IS_GENERIC(_sbuff_or_marker, _name)
 
#define SBUFF_OUT_TALLOC_ERR_FUNC_DEF(_func, _in, _len, ...)
 
#define SBUFF_OUT_TALLOC_FUNC_DEF(_func, _in, _len, ...)
 
#define SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(_func, ...)
 

Typedefs

typedef bool(* fr_sbuff_eof_t) (fr_sbuff_t *sbuff)
 For a given extension function, returns whether it is at EOF.
 
typedef size_t(* fr_sbuff_extend_t) (fr_sbuff_extend_status_t *status, fr_sbuff_t *sbuff, size_t req_extension)
 Extension callback.
 
typedef struct fr_sbuff_ptr_s fr_sbuff_marker_t
 
typedef struct fr_sbuff_s fr_sbuff_t
 
typedef ssize_t fr_slen_t
 Represents number of bytes parsed or location of parse error.
 

Enumerations

enum  fr_sbuff_extend_status_t {
  FR_SBUFF_FLAG_EXTENDED = 0x01 ,
  FR_SBUFF_FLAG_EXTEND_ERROR = 0x02
}
 Whether the buffer is currently extendable and whether it was extended. More...
 

Detailed Description

A generic buffer structure for string printing and parsing strings.

Because doing manual length checks is error prone and a waste of everyones time.

Definition in file sbuff.h.


Data Structure Documentation

◆ fr_sbuff_ptr_s

struct fr_sbuff_ptr_s

Definition at line 84 of file sbuff.h.

+ Collaboration diagram for fr_sbuff_ptr_s:
Data Fields
union fr_sbuff_ptr_s.__unnamed138__ __unnamed__
fr_sbuff_marker_t * next Next m in the list.
fr_sbuff_t * parent Owner of the marker.

◆ fr_sbuff_ptr_s.__unnamed138__

union fr_sbuff_ptr_s.__unnamed138__

Definition at line 85 of file sbuff.h.

Data Fields
char * p Mutable position pointer.
char const * p_i Immutable position pointer.

◆ fr_sbuff_s

struct fr_sbuff_s

Definition at line 93 of file sbuff.h.

+ Collaboration diagram for fr_sbuff_s:
Data Fields
union fr_sbuff_s.__unnamed140__ __unnamed__
union fr_sbuff_s.__unnamed142__ __unnamed__
union fr_sbuff_s.__unnamed144__ __unnamed__
union fr_sbuff_s.__unnamed146__ __unnamed__
uint8_t adv_parent:1 If true, advance the parent.
fr_sbuff_eof_t eof Function to determine if the buffer is at EOF.
char const * err Where the last error occurred.
fr_sbuff_extend_t extend Function to re-populate or extend the buffer.
uint8_t is_const:1 Can't be modified.
fr_sbuff_marker_t * m Pointers to update if the underlying buffer changes.
fr_sbuff_t * parent sbuff this sbuff was copied from.
size_t shifted How many bytes this sbuff has been shifted since its creation.
void * uctx Extend uctx data.

◆ fr_sbuff_s.__unnamed140__

union fr_sbuff_s.__unnamed140__

Definition at line 94 of file sbuff.h.

Data Fields
char * buff Mutable buffer pointer.
char const * buff_i Immutable buffer pointer.

◆ fr_sbuff_s.__unnamed142__

union fr_sbuff_s.__unnamed142__

Definition at line 99 of file sbuff.h.

Data Fields
char * start Mutable start pointer.
char const * start_i Immutable start pointer.

◆ fr_sbuff_s.__unnamed144__

union fr_sbuff_s.__unnamed144__

Definition at line 104 of file sbuff.h.

Data Fields
char * end Mutable end pointer.
char const * end_i Immutable end pointer.

◆ fr_sbuff_s.__unnamed146__

union fr_sbuff_s.__unnamed146__

Definition at line 109 of file sbuff.h.

Data Fields
char * p Mutable position pointer.
char const * p_i Immutable position pointer.

◆ fr_sbuff_term_elem_t

struct fr_sbuff_term_elem_t

Terminal element with pre-calculated lengths.

Definition at line 161 of file sbuff.h.

Data Fields
size_t len Length of string.
char const * str Terminal string.

◆ fr_sbuff_term_t

struct fr_sbuff_term_t

Set of terminal elements.

The elements MUST be listed in sorted order. If the inputs are not sorted, then all kinds of things will break.

Definition at line 161 of file merged_model.c.

+ Collaboration diagram for fr_sbuff_term_t:
Data Fields
fr_sbuff_term_elem_t * elem A sorted list of terminal strings.
size_t len Length of the list.

◆ fr_sbuff_uctx_file_t

struct fr_sbuff_uctx_file_t

File sbuff extension structure.

Holds the data necessary for creating dynamically extensible file buffers.

Definition at line 150 of file sbuff.h.

Data Fields
char * buff_end The true end of the buffer.
bool eof are we at EOF?
FILE * file FILE * we're reading from.
size_t max Maximum number of bytes to read.
size_t shifted How much we've read from this file.

◆ fr_sbuff_uctx_talloc_t

struct fr_sbuff_uctx_talloc_t

Talloc sbuff extension structure.

Holds the data necessary for creating dynamically extensible buffers.

Definition at line 139 of file sbuff.h.

Data Fields
TALLOC_CTX * ctx Context to alloc new buffers in.
size_t init How much to allocate initially.
size_t max Maximum size of the buffer.

◆ fr_sbuff_unescape_rules_t

struct fr_sbuff_unescape_rules_t

Set of parsing rules for *unescape_until functions.

Definition at line 163 of file merged_model.c.

Data Fields
char chr Character at the start of an escape sequence.
bool do_hex Process hex sequences i.e.
\x<hex><hex>.
bool do_oct Process oct sequences i.e.
\<oct><oct><oct>.
char const * name Name for rule set to aid we debugging.
bool skip[UINT8_MAX+1] Characters that are escaped, but left in the output along with the escape character.

This is useful where we need to interpret escape sequences for parsing, but where the string will be passed off to a 3rd party library which will need to interpret the same sequences.

char subs[UINT8_MAX+1] Special characters and their substitutions.

Indexed by the printable representation i.e. 'n' for
.

Macro Definition Documentation

◆ _fr_sbuff_out_size

#define _fr_sbuff_out_size (   _err,
  _out,
  _in 
)    size_t * : fr_sbuff_out_size(_err, (size_t *)_out, _in, true),

◆ _fr_sbuff_out_ssize

#define _fr_sbuff_out_ssize (   _err,
  _out,
  _in 
)    ssize_t * : fr_sbuff_out_ssize(_err, (ssize_t *)_out, _in, true),

◆ FR_SBUFF

#define FR_SBUFF (   _sbuff_or_marker)
Value:
_FR_SBUFF(_sbuff_or_marker, \
fr_sbuff_current(_sbuff_or_marker), \
fr_sbuff_current(_sbuff_or_marker), \
fr_sbuff_end(_sbuff_or_marker), \
fr_sbuff_ptr(_sbuff_or_marker)->extend, \
fr_sbuff_ptr(_sbuff_or_marker)->eof, \
0x00)
#define fr_sbuff_current(_sbuff_or_marker)
#define fr_sbuff_ptr(_sbuff_or_marker)
#define fr_sbuff_end(_sbuff_or_marker)

◆ FR_SBUFF_ABS

#define FR_SBUFF_ABS (   _sbuff_or_marker)
Value:
_FR_SBUFF(_sbuff_or_marker, \
fr_sbuff_start(_sbuff_or_marker), \
fr_sbuff_current(_sbuff_or_marker), \
fr_sbuff_end(_sbuff_or_marker), \
fr_sbuff_ptr(_sbuff_or_marker)->extend, \
0x00)
#define fr_sbuff_start(_sbuff_or_marker)

◆ fr_sbuff_adv_past_blank

#define fr_sbuff_adv_past_blank (   _sbuff,
  _len,
  _tt 
)    fr_sbuff_adv_past_allowed(_sbuff, _len, sbuff_char_blank, _tt)

◆ fr_sbuff_adv_past_str_literal

#define fr_sbuff_adv_past_str_literal (   _sbuff,
  _needle 
)    fr_sbuff_adv_past_str(_sbuff, _needle, sizeof(_needle) - 1)

◆ fr_sbuff_adv_past_strcase_literal

#define fr_sbuff_adv_past_strcase_literal (   _sbuff,
  _needle 
)    fr_sbuff_adv_past_strcase(_sbuff, _needle, sizeof(_needle) - 1)

◆ fr_sbuff_adv_past_whitespace

#define fr_sbuff_adv_past_whitespace (   _sbuff,
  _len,
  _tt 
)    fr_sbuff_adv_past_allowed(_sbuff, _len, sbuff_char_whitespace, _tt)

◆ fr_sbuff_adv_past_zeros

#define fr_sbuff_adv_past_zeros (   _sbuff,
  _len,
  _tt 
)    fr_sbuff_adv_past_allowed(_sbuff, _len, sbuff_char_class_zero, _tt)

◆ fr_sbuff_adv_to_str_literal

#define fr_sbuff_adv_to_str_literal (   _sbuff,
  _len,
  _needle 
)    fr_sbuff_adv_to_str(_sbuff, _len, _needle, sizeof(_needle) - 1)

◆ fr_sbuff_adv_to_strcase_literal

#define fr_sbuff_adv_to_strcase_literal (   _sbuff,
  _len,
  _needle 
)    fr_sbuff_adv_to_strcase(_sbuff, _len, _needle, sizeof(_needle) - 1)

◆ fr_sbuff_advance

#define fr_sbuff_advance (   _sbuff_or_marker,
  _len 
)    fr_sbuff_set(_sbuff_or_marker, (fr_sbuff_current(_sbuff_or_marker) + (_len)))

◆ FR_SBUFF_ADVANCE_RETURN

#define FR_SBUFF_ADVANCE_RETURN (   _sbuff,
  _len 
)    FR_SBUFF_RETURN(fr_sbuff_advance, _sbuff, _len)

◆ fr_sbuff_ahead

#define fr_sbuff_ahead (   _sbuff_or_marker)
Value:
(fr_sbuff_current((_sbuff_or_marker)->parent) > fr_sbuff_current(_sbuff_or_marker) ? \
0 : fr_sbuff_current(_sbuff_or_marker) - fr_sbuff_current((_sbuff_or_marker)->parent))
static fr_slen_t parent
Definition pair.h:851

◆ fr_sbuff_as_percent_s

#define fr_sbuff_as_percent_s (   _sbuff)    (int) fr_sbuff_remaining(_sbuff), fr_sbuff_current(_sbuff)

◆ fr_sbuff_behind

#define fr_sbuff_behind (   _sbuff_or_marker)
Value:
(fr_sbuff_current(_sbuff_or_marker) > fr_sbuff_current((_sbuff_or_marker)->parent) ? \
0 : fr_sbuff_current((_sbuff_or_marker)->parent) - fr_sbuff_current(_sbuff_or_marker))

◆ FR_SBUFF_BIND_CURRENT

#define FR_SBUFF_BIND_CURRENT (   _sbuff_or_marker)
Value:
_FR_SBUFF(_sbuff_or_marker, \
fr_sbuff_current(_sbuff_or_marker), \
fr_sbuff_current(_sbuff_or_marker), \
fr_sbuff_end(_sbuff_or_marker), \
fr_sbuff_ptr(_sbuff_or_marker)->extend, \
fr_sbuff_ptr(_sbuff_or_marker)->eof, \
0x01)

◆ FR_SBUFF_BIND_CURRENT_ABS

#define FR_SBUFF_BIND_CURRENT_ABS (   _sbuff_or_marker)
Value:
FR_SBUFF_ABS(_sbuff_or_marker, \
fr_sbuff_start(_sbuff_or_marker), \
fr_sbuff_current(_sbuff_or_marker), \
fr_sbuff_end(_sbuff_or_marker), \
fr_sbuff_ptr(_sbuff_or_marker)->extend, \
fr_sbuff_ptr(_sbuff_or_marker)->eof, \
0x01)
#define FR_SBUFF_ABS(_sbuff_or_marker)

◆ fr_sbuff_buff

#define fr_sbuff_buff (   _sbuff_or_marker)
Value:
_Generic((_sbuff_or_marker), \
fr_sbuff_t * : ((fr_sbuff_t const *)(_sbuff_or_marker))->buff, \
fr_sbuff_t const * : ((fr_sbuff_t const *)(_sbuff_or_marker))->buff, \
fr_sbuff_marker_t * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->buff, \
fr_sbuff_marker_t const * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->buff \
)
static char buff[sizeof("18446744073709551615")+3]
Definition size_tests.c:41

◆ fr_sbuff_char

#define fr_sbuff_char (   _sbuff_or_marker,
  _eob 
)     (fr_sbuff_current(_sbuff_or_marker) >= fr_sbuff_end(_sbuff_or_marker) ? _eob : *fr_sbuff_current(_sbuff_or_marker))

◆ FR_SBUFF_CHECK_REMAINING_RETURN

#define FR_SBUFF_CHECK_REMAINING_RETURN (   _sbuff,
  _len 
)     if ((_len) > fr_sbuff_remaining(_sbuff)) return -((_len) - fr_sbuff_remaining(_sbuff))

◆ fr_sbuff_current

#define fr_sbuff_current (   _sbuff_or_marker)
Value:
(_Generic((_sbuff_or_marker), \
fr_sbuff_t * : ((fr_sbuff_t const *)(_sbuff_or_marker))->p, \
fr_sbuff_t const * : ((fr_sbuff_t const *)(_sbuff_or_marker))->p, \
fr_sbuff_marker_t * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->p, \
fr_sbuff_marker_t const * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->p \
))

◆ fr_sbuff_diff

#define fr_sbuff_diff (   _a,
  _b 
)     ((ssize_t)(fr_sbuff_current(_a) - fr_sbuff_current(_b)))

◆ fr_sbuff_end

#define fr_sbuff_end (   _sbuff_or_marker)
Value:
(_Generic((_sbuff_or_marker), \
fr_sbuff_t * : ((fr_sbuff_t const *)(_sbuff_or_marker))->end, \
fr_sbuff_t const * : ((fr_sbuff_t const *)(_sbuff_or_marker))->end, \
fr_sbuff_marker_t * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->end, \
fr_sbuff_marker_t const * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->end \
))

◆ fr_sbuff_error

#define fr_sbuff_error (   _sbuff_or_marker)     _fr_sbuff_error(fr_sbuff_ptr(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker))

◆ FR_SBUFF_ERROR_RETURN

#define FR_SBUFF_ERROR_RETURN (   _sbuff_or_marker)    return fr_sbuff_error(_sbuff_or_marker)

◆ fr_sbuff_extend

#define fr_sbuff_extend (   _sbuff_or_marker)    fr_sbuff_extend_lowat(NULL, _sbuff_or_marker, 1)

◆ fr_sbuff_extend_lowat

#define fr_sbuff_extend_lowat (   _status,
  _sbuff_or_marker,
  _lowat 
)
Value:
_fr_sbuff_extend_lowat(_status, \
fr_sbuff_ptr(_sbuff_or_marker), \
fr_sbuff_remaining(_sbuff_or_marker), _lowat)
#define fr_sbuff_remaining(_sbuff_or_marker)

◆ FR_SBUFF_EXTEND_LOWAT_OR_RETURN

#define FR_SBUFF_EXTEND_LOWAT_OR_RETURN (   _sbuff,
  _len 
)
Value:
do { \
size_t _remaining = fr_sbuff_extend_lowat(NULL, _sbuff, _len); \
if (_remaining < _len) return -(_len - _remaining); \
} while (0)
#define fr_sbuff_extend_lowat(_status, _sbuff_or_marker, _lowat)

◆ FR_SBUFF_IN

#define FR_SBUFF_IN (   _start,
  _len_or_end 
)
Value:
.buff_i = _start, \
.start_i = _start, \
.end_i = _Generic((_len_or_end), \
size_t : (char const *)(_start) + (size_t)(_len_or_end), \
long : (char const *)(_start) + (size_t)(_len_or_end), \
int : (char const *)(_start) + (size_t)(_len_or_end), \
unsigned int : (char const *)(_start) + (size_t)(_len_or_end), \
char * : (char const *)(_len_or_end), \
char const * : (char const *)(_len_or_end) \
), \
.p_i = _start, \
.is_const = IS_CONST(char *, _start) \
})
#define IS_CONST(_type, _var)
Check if a given variable is the _const or not.
Definition build.h:279
unsigned long int size_t
struct fr_sbuff_s fr_sbuff_t
Definition sbuff.h:52

◆ FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN

#define FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_bstrcpy_buffer, ##__VA_ARGS__)

◆ FR_SBUFF_IN_BSTRNCPY_RETURN

#define FR_SBUFF_IN_BSTRNCPY_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_bstrncpy, ##__VA_ARGS__)

◆ fr_sbuff_in_char

#define fr_sbuff_in_char (   _sbuff,
  ... 
)    fr_sbuff_in_bstrncpy(_sbuff, ((char []){ __VA_ARGS__ }), sizeof((char []){ __VA_ARGS__ }))

◆ FR_SBUFF_IN_CHAR_RETURN

#define FR_SBUFF_IN_CHAR_RETURN (   _sbuff,
  ... 
)    FR_SBUFF_RETURN(fr_sbuff_in_bstrncpy, _sbuff, ((char []){ __VA_ARGS__ }), sizeof((char []){ __VA_ARGS__ }))

◆ FR_SBUFF_IN_ESCAPE_BUFFER_RETURN

#define FR_SBUFF_IN_ESCAPE_BUFFER_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_escape_buffer, ##__VA_ARGS__)

◆ FR_SBUFF_IN_ESCAPE_RETURN

#define FR_SBUFF_IN_ESCAPE_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_escape, ##__VA_ARGS__)

◆ FR_SBUFF_IN_SPRINTF_RETURN

#define FR_SBUFF_IN_SPRINTF_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_sprintf, ##__VA_ARGS__)

◆ fr_sbuff_in_strcpy_literal

#define fr_sbuff_in_strcpy_literal (   _sbuff,
  _str 
)    fr_sbuff_in_bstrncpy(_sbuff, _str, sizeof(_str) - 1)

◆ FR_SBUFF_IN_STRCPY_LITERAL_RETURN

#define FR_SBUFF_IN_STRCPY_LITERAL_RETURN (   _sbuff,
  _str 
)    FR_SBUFF_RETURN(fr_sbuff_in_bstrncpy, _sbuff, _str, sizeof(_str) - 1)

◆ FR_SBUFF_IN_STRCPY_RETURN

#define FR_SBUFF_IN_STRCPY_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_strcpy, ##__VA_ARGS__)

◆ fr_sbuff_in_table_str

#define fr_sbuff_in_table_str (   _slen,
  _sbuff,
  _table,
  _number,
  _def 
)     _slen = fr_sbuff_in_strcpy(_sbuff, fr_table_str_by_value(_table, _number, _def))

◆ FR_SBUFF_IN_TABLE_STR_RETURN

#define FR_SBUFF_IN_TABLE_STR_RETURN (   _sbuff,
  _table,
  _number,
  _def 
)
Value:
do { \
ssize_t _slen; \
fr_sbuff_in_table_str(_slen, _sbuff, _table, _number, _def); \
if (_slen < 0) return _slen; \
} while (0)
while(1)
Definition acutest.h:856
long int ssize_t

◆ FR_SBUFF_IN_VSPRINTF_RETURN

#define FR_SBUFF_IN_VSPRINTF_RETURN (   ...)    FR_SBUFF_RETURN(fr_sbuff_in_vsprintf, ##__VA_ARGS__)

◆ fr_sbuff_init_in

#define fr_sbuff_init_in (   _out,
  _start,
  _len_or_end 
)
Value:
_fr_sbuff_init(_out, _start, \
_Generic((_len_or_end), \
size_t : (char const *)(_start) + (size_t)(_len_or_end), \
long : (char const *)(_start) + (size_t)(_len_or_end), \
int : (char const *)(_start) + (size_t)(_len_or_end), \
char * : (char const *)(_len_or_end), \
char const * : (char const *)(_len_or_end) \
), \
IS_CONST(char *, _start), false)

◆ fr_sbuff_init_out

#define fr_sbuff_init_out (   _out,
  _start,
  _len_or_end 
)
Value:
_fr_sbuff_init(_out, _start, \
_Generic((_len_or_end), \
size_t : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
long : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
int : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
char * : (char const *)(_len_or_end), \
char const * : (char const *)(_len_or_end) \
), \
IS_CONST(char *, _start), true)

◆ fr_sbuff_is_alnum

#define fr_sbuff_is_alnum (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, alnum)

◆ fr_sbuff_is_alpha

#define fr_sbuff_is_alpha (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, alpha)

◆ fr_sbuff_is_char

#define fr_sbuff_is_char (   _sbuff_or_marker,
  _c 
)
Value:
_Generic((_sbuff_or_marker), \
fr_sbuff_t * : _fr_sbuff_is_char((fr_sbuff_t *)(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker), _c), \
fr_sbuff_marker_t * : _fr_marker_is_char((fr_sbuff_marker_t *)(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker), _c) \
)

◆ fr_sbuff_is_digit

#define fr_sbuff_is_digit (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, digit)

◆ fr_sbuff_is_hex

#define fr_sbuff_is_hex (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, hex)

◆ fr_sbuff_is_lower

#define fr_sbuff_is_lower (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, lower)

◆ fr_sbuff_is_space

#define fr_sbuff_is_space (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, space)

◆ fr_sbuff_is_str_literal

#define fr_sbuff_is_str_literal (   _sbuff,
  _str 
)    fr_sbuff_is_str(_sbuff, _str, sizeof(_str) - 1)

◆ fr_sbuff_is_upper

#define fr_sbuff_is_upper (   _sbuff_or_marker)     SBUFF_IS_GENERIC(_sbuff_or_marker, upper)

◆ fr_sbuff_len

#define fr_sbuff_len (   _sbuff_or_marker)     ((size_t)(fr_sbuff_end(_sbuff_or_marker) - fr_sbuff_buff(_sbuff_or_marker)))

◆ fr_sbuff_move

#define fr_sbuff_move (   _out,
  _in,
  _len 
)
Value:
_Generic((_out), \
fr_sbuff_t * : \
_Generic((_in), \
), \
_Generic((_in), \
) \
)
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.
Definition sbuff.c:1395
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.
Definition sbuff.c:1415
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.
Definition sbuff.c:1435
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.
Definition sbuff.c:1375

◆ fr_sbuff_out

#define fr_sbuff_out (   _err,
  _out,
  _in 
)
Value:
_Generic((_out), \
bool * : fr_sbuff_out_bool((bool *)_out, _in), \
int8_t * : fr_sbuff_out_int8(_err, (int8_t *)_out, _in, true), \
int16_t * : fr_sbuff_out_int16(_err, (int16_t *)_out, _in, true), \
int32_t * : fr_sbuff_out_int32(_err, (int32_t *)_out, _in, true), \
int64_t * : fr_sbuff_out_int64(_err, (int64_t *)_out, _in, true), \
_fr_sbuff_out_ssize(_err, _out, _in) \
uint8_t * : fr_sbuff_out_uint8(_err, (uint8_t *)_out, _in, true), \
uint16_t * : fr_sbuff_out_uint16(_err, (uint16_t *)_out, _in, true), \
uint32_t * : fr_sbuff_out_uint32(_err, (uint32_t *)_out, _in, true), \
uint64_t * : fr_sbuff_out_uint64(_err, (uint64_t *)_out, _in, true), \
_fr_sbuff_out_size(_err, _out, _in) \
float * : fr_sbuff_out_float32(_err, (float *)_out, _in, true), \
double * : fr_sbuff_out_float64(_err, (double *)_out, _in, true) \
)
unsigned short uint16_t
unsigned int uint32_t
unsigned char bool
unsigned char uint8_t
fr_slen_t fr_sbuff_out_bool(bool *out, fr_sbuff_t *in)
See if the string contains a truth value.
Definition sbuff.c:1109
#define _fr_sbuff_out_ssize(_err, _out, _in)
#define _fr_sbuff_out_size(_err, _out, _in)

◆ FR_SBUFF_OUT

#define FR_SBUFF_OUT (   _start,
  _len_or_end 
)
Value:
.buff_i = _start, \
.start_i = _start, \
.end_i = _Generic((_len_or_end), \
size_t : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
long : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
int : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
unsigned int : (char const *)(_start) + ((size_t)(_len_or_end) - 1), \
char * : (char const *)(_len_or_end), \
char const * : (char const *)(_len_or_end) \
), \
.p_i = _start, \
.is_const = IS_CONST(char *, _start) \
})

◆ fr_sbuff_out_by_longest_prefix

#define fr_sbuff_out_by_longest_prefix (   _match_len,
  _out,
  _table,
  _sbuff,
  _def 
)
Value:
do { \
size_t _match_len_tmp; \
fr_sbuff_extend_lowat(NULL, _sbuff, fr_table_max_needle_len(_table)); \
*(_out) = fr_table_value_by_longest_prefix(&_match_len_tmp, _table, \
_def); \
(void) fr_sbuff_advance(_sbuff, _match_len_tmp); /* can't fail */ \
*(_match_len) = _match_len_tmp; \
} while (0)
#define fr_sbuff_advance(_sbuff_or_marker, _len)
#define fr_table_max_needle_len(_table)
Definition table.h:803
#define fr_table_value_by_longest_prefix(_match_len, _table, _name, _name_len, _def)
Find the longest string match using a sorted or ordered table.
Definition table.h:732

◆ fr_sbuff_ptr

#define fr_sbuff_ptr (   _sbuff_or_marker)
Value:
_Generic((_sbuff_or_marker), \
fr_sbuff_t * : ((fr_sbuff_t *)(_sbuff_or_marker)), \
fr_sbuff_marker_t * : ((fr_sbuff_marker_t *)(_sbuff_or_marker))->parent \
)

◆ fr_sbuff_remaining

#define fr_sbuff_remaining (   _sbuff_or_marker)
Value:
((size_t)(fr_sbuff_end(_sbuff_or_marker) < fr_sbuff_current(_sbuff_or_marker) ? \
0 : (fr_sbuff_end(_sbuff_or_marker) - fr_sbuff_current(_sbuff_or_marker))))

◆ FR_SBUFF_REPARSE

#define FR_SBUFF_REPARSE (   _sbuff_or_marker)
Value:
_FR_SBUFF(_sbuff_or_marker, \
fr_sbuff_start(_sbuff_or_marker), \
fr_sbuff_start(_sbuff_or_marker), \
fr_sbuff_current(_sbuff_or_marker), \
NULL, \
NULL, \
0x00)

◆ FR_SBUFF_RETURN

#define FR_SBUFF_RETURN (   _func,
  _sbuff,
  ... 
)
Value:
do { \
ssize_t _slen; \
_slen = _func(_sbuff, ## __VA_ARGS__ ); \
if (_slen < 0) return _slen; \
} while (0)

◆ fr_sbuff_set

#define fr_sbuff_set (   _dst,
  _src 
)
Value:
_Generic((_dst), \
fr_sbuff_t * : _fr_sbuff_set, \
fr_sbuff_marker_t * : _fr_sbuff_marker_set \
)(_dst, \
_Generic((_src), \
fr_sbuff_t * : fr_sbuff_current((fr_sbuff_t const *)(_src)), \
fr_sbuff_t const * : fr_sbuff_current((fr_sbuff_t const *)(_src)), \
char const * : (char const *)(_src), \
char * : (char const *)(_src), \
size_t : (fr_sbuff_start(_dst) + (uintptr_t)(_src)) \
))

◆ FR_SBUFF_SET_RETURN

#define FR_SBUFF_SET_RETURN (   _dst,
  _src 
)    return fr_sbuff_set(_dst, _src)

◆ fr_sbuff_shifted

#define fr_sbuff_shifted (   _sbuff_or_marker)
Value:
(_Generic((_sbuff_or_marker), \
fr_sbuff_t * : ((fr_sbuff_t const *)(_sbuff_or_marker))->shifted, \
fr_sbuff_t const * : ((fr_sbuff_t const *)(_sbuff_or_marker))->shifted, \
fr_sbuff_marker_t * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->shifted, \
fr_sbuff_marker_t const * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->shifted \
))

◆ fr_sbuff_start

#define fr_sbuff_start (   _sbuff_or_marker)
Value:
(_Generic((_sbuff_or_marker), \
fr_sbuff_t * : ((fr_sbuff_t const *)(_sbuff_or_marker))->start, \
fr_sbuff_t const * : ((fr_sbuff_t const *)(_sbuff_or_marker))->start, \
fr_sbuff_marker_t * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->start, \
fr_sbuff_marker_t const * : ((fr_sbuff_marker_t const *)(_sbuff_or_marker))->parent->start \
))

◆ fr_sbuff_switch

#define fr_sbuff_switch (   _sbuff_or_marker,
  _eob 
)     switch (fr_sbuff_char(_sbuff_or_marker, _eob))

◆ FR_SBUFF_TALLOC_THREAD_LOCAL

#define FR_SBUFF_TALLOC_THREAD_LOCAL (   _out,
  _init,
  _max 
)
Value:
do { \
static _Thread_local fr_sbuff_thread_local_t *_sbuff_t_local; \
if (!_sbuff_t_local) { \
fr_sbuff_thread_local_t *sbtl = talloc_zero(NULL, fr_sbuff_thread_local_t); \
fr_sbuff_init_talloc(sbtl, &sbtl->sbuff, &sbtl->tctx, _init, _max); \
fr_atexit_thread_local(_sbuff_t_local, _sbuff_thread_local_free, sbtl); \
*(_out) = &_sbuff_t_local->sbuff; \
} else { \
fr_sbuff_reset_talloc(&_sbuff_t_local->sbuff); \
*(_out) = &_sbuff_t_local->sbuff; \
} \
} while (0)

◆ FR_SBUFF_TERM

#define FR_SBUFF_TERM (   _str)
Value:
.len = 1, \
.elem = (fr_sbuff_term_elem_t[]){ L(_str) }, \
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:209
Terminal element with pre-calculated lengths.
Definition sbuff.h:161
Set of terminal elements.

Initialise a terminal structure with a single string.

Parameters
[in]_strterminal string.

Definition at line 180 of file sbuff.h.

◆ FR_SBUFF_TERMS

#define FR_SBUFF_TERMS (   ...)
Value:
.len = (sizeof((fr_sbuff_term_elem_t[]){ __VA_ARGS__ }) / sizeof(fr_sbuff_term_elem_t)), \
.elem = (fr_sbuff_term_elem_t[]){ __VA_ARGS__ }, \
}

Initialise a terminal structure with a list of sorted strings.

Strings must be lexicographically sorted.

Parameters
[in]...Lexicographically sorted list of terminal strings.

Definition at line 192 of file sbuff.h.

◆ fr_sbuff_used

#define fr_sbuff_used (   _sbuff_or_marker)
Value:
((size_t)(fr_sbuff_start(_sbuff_or_marker) > fr_sbuff_current(_sbuff_or_marker) ? \
0 : (fr_sbuff_current(_sbuff_or_marker) - fr_sbuff_start(_sbuff_or_marker))))

◆ fr_sbuff_used_total

#define fr_sbuff_used_total (   _sbuff_or_marker)     ((size_t)((fr_sbuff_current(_sbuff_or_marker) + fr_sbuff_shifted(_sbuff_or_marker)) - fr_sbuff_start(_sbuff_or_marker)))

◆ fr_sbuff_was_extended

#define fr_sbuff_was_extended (   _status)    (_status & FR_SBUFF_FLAG_EXTENDED)

◆ SBUFF_CHAR_CLASS_ALPHA

#define SBUFF_CHAR_CLASS_ALPHA
Value:
['a'] = true, ['b'] = true, ['c'] = true, ['d'] = true, ['e'] = true, \
['f'] = true, ['g'] = true, ['h'] = true, ['i'] = true, ['j'] = true, \
['k'] = true, ['l'] = true, ['m'] = true, ['n'] = true, ['o'] = true, \
['p'] = true, ['q'] = true, ['r'] = true, ['s'] = true, ['t'] = true, \
['u'] = true, ['v'] = true, ['w'] = true, ['x'] = true, ['y'] = true, \
['z'] = true, \
['A'] = true, ['B'] = true, ['C'] = true, ['D'] = true, ['E'] = true, \
['F'] = true, ['G'] = true, ['H'] = true, ['I'] = true, ['J'] = true, \
['K'] = true, ['L'] = true, ['M'] = true, ['N'] = true, ['O'] = true, \
['P'] = true, ['Q'] = true, ['R'] = true, ['S'] = true, ['T'] = true, \
['U'] = true, ['V'] = true, ['W'] = true, ['X'] = true, ['Y'] = true, \
['Z'] = true

◆ SBUFF_CHAR_CLASS_ALPHA_NUM

#define SBUFF_CHAR_CLASS_ALPHA_NUM
Value:
#define SBUFF_CHAR_CLASS_ALPHA
#define SBUFF_CHAR_CLASS_NUM

◆ SBUFF_CHAR_CLASS_HEX

#define SBUFF_CHAR_CLASS_HEX
Value:
['a'] = true, ['b'] = true, ['c'] = true, ['d'] = true, ['e'] = true, \
['f'] = true, \
['A'] = true, ['B'] = true, ['C'] = true, ['D'] = true, ['E'] = true, \
['F'] = true

◆ SBUFF_CHAR_CLASS_NUM

#define SBUFF_CHAR_CLASS_NUM
Value:
['0'] = true, ['1'] = true, ['2'] = true, ['3'] = true, ['4'] = true, \
['5'] = true, ['6'] = true, ['7'] = true, ['8'] = true, ['9'] = true

◆ SBUFF_CHAR_CLASS_SYMBOLS

#define SBUFF_CHAR_CLASS_SYMBOLS
Value:
['!'] = true, ['"'] = true, ['#'] = true, ['$'] = true, ['%'] = true, \
['&'] = true, ['/'] = true, ['('] = true, [')'] = true, ['*'] = true, \
['+'] = true, ['`'] = true, ['-'] = true, ['.'] = true, ['/'] = true, \
[':'] = true, [';'] = true, ['<'] = true, ['='] = true, ['>'] = true, \
['?'] = true, ['@'] = true, ['['] = true, ['\''] = true, [']'] = true, \
['^'] = true, ['_'] = true, ['`'] = true, ['{'] = true, ['|'] = true, \
['}'] = true, ['~'] = true \

◆ SBUFF_CHAR_UNPRINTABLES_EXTENDED

#define SBUFF_CHAR_UNPRINTABLES_EXTENDED
Value:
[0x80] = true, \
[0x81] = true, [0x82] = true, [0x83] = true, [0x84] = true, [0x85] = true, [0x86] = true, [0x87] = true, [0x88] = true, \
[0x89] = true, [0x8a] = true, [0x8b] = true, [0x8c] = true, [0x8d] = true, [0x8e] = true, [0x8f] = true, [0x90] = true, \
[0x91] = true, [0x92] = true, [0x93] = true, [0x94] = true, [0x95] = true, [0x96] = true, [0x97] = true, [0x98] = true, \
[0x99] = true, [0x9a] = true, [0x9b] = true, [0x9c] = true, [0x9d] = true, [0x9e] = true, [0x9f] = true, [0xa0] = true, \
[0xa1] = true, [0xa2] = true, [0xa3] = true, [0xa4] = true, [0xa5] = true, [0xa6] = true, [0xa7] = true, [0xa8] = true, \
[0xa9] = true, [0xaa] = true, [0xab] = true, [0xac] = true, [0xad] = true, [0xae] = true, [0xaf] = true, [0xb0] = true, \
[0xb1] = true, [0xb2] = true, [0xb3] = true, [0xb4] = true, [0xb5] = true, [0xb6] = true, [0xb7] = true, [0xb8] = true, \
[0xb9] = true, [0xba] = true, [0xbb] = true, [0xbc] = true, [0xbd] = true, [0xbe] = true, [0xbf] = true, [0xc0] = true, \
[0xc1] = true, [0xc2] = true, [0xc3] = true, [0xc4] = true, [0xc5] = true, [0xc6] = true, [0xc7] = true, [0xc8] = true, \
[0xc9] = true, [0xca] = true, [0xcb] = true, [0xcc] = true, [0xcd] = true, [0xce] = true, [0xcf] = true, [0xd0] = true, \
[0xd1] = true, [0xd2] = true, [0xd3] = true, [0xd4] = true, [0xd5] = true, [0xd6] = true, [0xd7] = true, [0xd8] = true, \
[0xd9] = true, [0xda] = true, [0xdb] = true, [0xdc] = true, [0xdd] = true, [0xde] = true, [0xdf] = true, [0xe0] = true, \
[0xe1] = true, [0xe2] = true, [0xe3] = true, [0xe4] = true, [0xe5] = true, [0xe6] = true, [0xe7] = true, [0xe8] = true, \
[0xe9] = true, [0xea] = true, [0xeb] = true, [0xec] = true, [0xed] = true, [0xee] = true, [0xef] = true, [0xf0] = true, \
[0xf1] = true, [0xf2] = true, [0xf3] = true, [0xf4] = true, [0xf5] = true, [0xf6] = true, [0xf7] = true, [0xf8] = true, \
[0xf9] = true, [0xfa] = true, [0xfb] = true, [0xfc] = true, [0xfd] = true, [0xfe] = true, [0xff] = true

◆ SBUFF_CHAR_UNPRINTABLES_LOW

#define SBUFF_CHAR_UNPRINTABLES_LOW
Value:
[0x00] = true, \
[0x01] = true, [0x02] = true, [0x03] = true, [0x04] = true, [0x05] = true, [0x06] = true, [0x07] = true, [0x08] = true, \
[0x09] = true, [0x0a] = true, [0x0b] = true, [0x0c] = true, [0x0d] = true, [0x0e] = true, [0x0f] = true, [0x10] = true, \
[0x11] = true, [0x12] = true, [0x13] = true, [0x14] = true, [0x15] = true, [0x16] = true, [0x17] = true, [0x18] = true, \
[0x19] = true, [0x1a] = true, [0x1b] = true, [0x1c] = true, [0x1d] = true, [0x1e] = true, [0x1f] = true, \
[0x7f] = true

◆ SBUFF_IS_FUNC

#define SBUFF_IS_FUNC (   _name,
  _test 
)
Value:
static inline bool _fr_sbuff_is_ ## _name(fr_sbuff_t *sbuff, char *p) \
{ \
if (!fr_sbuff_extend(sbuff)) return false; \
return _test; \
}\
static inline bool _fr_marker_is_ ## _name(fr_sbuff_marker_t *marker, char *p) \
{ \
if (!fr_sbuff_extend(marker)) return false; \
return _test; \
}
#define fr_sbuff_extend(_sbuff_or_marker)

◆ SBUFF_IS_GENERIC

#define SBUFF_IS_GENERIC (   _sbuff_or_marker,
  _name 
)
Value:
_Generic((_sbuff_or_marker), \
fr_sbuff_t * : _fr_sbuff_is_ ## _name((fr_sbuff_t *)(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker)), \
fr_sbuff_marker_t * : _fr_marker_is_ ## _name((fr_sbuff_marker_t *)(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker)) \
)

◆ SBUFF_OUT_TALLOC_ERR_FUNC_DEF

#define SBUFF_OUT_TALLOC_ERR_FUNC_DEF (   _func,
  _in,
  _len,
  ... 
)
Value:
{ \
fr_sbuff_t sbuff; \
fr_slen_t slen = -1; \
if (unlikely(fr_sbuff_init_talloc(ctx, &sbuff, &tctx, \
((_len) != SIZE_MAX) ? (_len) : 1024, \
((_len) != SIZE_MAX) ? (_len) : SIZE_MAX) == NULL)) { \
error: \
TALLOC_FREE(sbuff.buff); \
*out = NULL; \
return slen; \
} \
slen = _func(&err, &sbuff, _in, _len, ##__VA_ARGS__); \
if (slen < 0) goto error; \
if (unlikely(fr_sbuff_trim_talloc(&sbuff, SIZE_MAX) < 0)) { \
slen = -1; \
goto error; \
} \
*out = sbuff.buff; \
return slen; \
}
#define unlikely(_x)
Definition build.h:381
static fr_slen_t err
Definition dict.h:824
ssize_t fr_slen_t
fr_sbuff_parse_error_t
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.
Definition sbuff.c:419
Talloc sbuff extension structure.
Definition sbuff.h:139
static size_t char ** out
Definition value.h:997

◆ SBUFF_OUT_TALLOC_FUNC_DEF

#define SBUFF_OUT_TALLOC_FUNC_DEF (   _func,
  _in,
  _len,
  ... 
)
Value:
{ \
fr_sbuff_t sbuff; \
fr_slen_t slen = -1; \
if (unlikely(fr_sbuff_init_talloc(ctx, &sbuff, &tctx, \
((_len) != SIZE_MAX) ? (_len) : 1024, \
((_len) != SIZE_MAX) ? (_len) : SIZE_MAX) == NULL)) { \
error: \
TALLOC_FREE(sbuff.buff); \
*out = NULL; \
return slen; \
} \
slen = _func(&sbuff, _in, _len, ##__VA_ARGS__); \
if (slen < 0) goto error; \
if (unlikely(fr_sbuff_trim_talloc(&sbuff, SIZE_MAX) < 0)) { \
slen = -1; \
goto error; \
} \
*out = sbuff.buff; \
return slen; \
}

◆ SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF

#define SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF (   _func,
  ... 
)
Value:
{ \
fr_sbuff_t sbuff; \
fr_slen_t slen = -1; \
if (unlikely(fr_sbuff_init_talloc(ctx, &sbuff, &tctx, 0, SIZE_MAX) == NULL)) { \
error: \
TALLOC_FREE(sbuff.buff); \
*out = NULL; \
return slen; \
} \
slen = _func(&sbuff, ##__VA_ARGS__); \
if (slen < 0) goto error; \
if (unlikely(fr_sbuff_trim_talloc(&sbuff, SIZE_MAX) < 0)) { \
slen = -1; \
goto error; \
} \
*out = sbuff.buff; \
return slen; \
}

Typedef Documentation

◆ fr_sbuff_eof_t

typedef bool(* fr_sbuff_eof_t) (fr_sbuff_t *sbuff)

For a given extension function, returns whether it is at EOF.

Definition at line 81 of file sbuff.h.

◆ fr_sbuff_extend_t

typedef size_t(* fr_sbuff_extend_t) (fr_sbuff_extend_status_t *status, fr_sbuff_t *sbuff, size_t req_extension)

Extension callback.

Retrieves additional data from a source and adds it to a buffer.

Definition at line 76 of file sbuff.h.

◆ fr_sbuff_marker_t

Definition at line 53 of file sbuff.h.

◆ fr_sbuff_t

typedef struct fr_sbuff_s fr_sbuff_t

Definition at line 52 of file sbuff.h.

◆ fr_slen_t

typedef ssize_t fr_slen_t

Represents number of bytes parsed or location of parse error.

Number of bytes parsed will be >= 0.

If a parse error occurs the value will be the negative offset of the error -1. i.e. offset 0 will be -1.

This is to disambiguate between 0 bytes parsed and error at offset 0.

Definition at line 51 of file sbuff.h.

Enumeration Type Documentation

◆ fr_sbuff_extend_status_t

Whether the buffer is currently extendable and whether it was extended.

Enumerator
FR_SBUFF_FLAG_EXTENDED 

The last call to extend function actually extended the buffer.

FR_SBUFF_FLAG_EXTEND_ERROR 

The last call to an extend function resulted in an error.

Error should be provided using fr_strerror_const/fr_strerror_printf by the extension function.

Definition at line 64 of file sbuff.h.