25RCSID(
"$Id: 9fb1b39f02230880e8eee89f9f800e0e0407a391 $")
29#include <freeradius-devel/util/skip.h>
30#include <freeradius-devel/util/token.h>
217#pragma clang diagnostic ignored "-Wgnu-designator"
234#define T(_x) [T_OP_ ## _x] = true
282#define T(_x) [T_ ## _x] = true
298#define T(_x) [T_## _x] = true
301 T(DOUBLE_QUOTED_STRING),
302 T(SINGLE_QUOTED_STRING),
303 T(BACK_QUOTED_STRING),
310#define TOKEN_MATCH(bptr, tptr) \
311 ( (tptr)[0] == (bptr)[0] && \
312 ((tptr)[1] == (bptr)[1] || (tptr)[1] == 0))
348 for (i = 0; i < tokenlist_len; i++) {
359 token = tokenlist[i].
value;
391 if ((buflen >= 3) && (p[1] == quote) && (p[2] == quote)) {
400 while (*p && buflen-- > 1) {
407 if (isspace((
uint8_t) *p))
break;
411 for (i = 0; i < tokenlist_len; i++) {
418 if (*p ==
',')
break;
437 if ((buflen >= 3) && (p[1] == quote) && (p[2] == quote)) {
478 if (*p >=
'0' && *p <=
'9' &&
479 sscanf(p,
"%3o", &x) == 1) {
527int getword(
char const **ptr,
char *buf,
int buflen,
bool unescape)
564 if (!ptr || !*ptr || !buf)
return T_INVALID;
572 if ((*p ==
'"') || (*p ==
'\'') || (*p ==
'`')) {
573 return gettoken(ptr, buf, buflen, unescape);
strcpy(log_entry->msg, buffer)
#define L(_str)
Helper for initialising arrays of string literals.
#define fr_skip_whitespace(_p)
Skip whitespace ('\t', '\n', '\v', '\f', '\r', ' ')
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
#define FR_TABLE_INDEXED_ENTRY(_v)
Build a single fr_table_num_indexed_t entry from an enum identifier.
fr_table_elem_name_t name
size_t len
Literal string length.
An element in a table indexed by numeric value.
An element in an arbitrarily ordered array of name to num mappings.
An element in a lexicographically sorted array of name to num mappings.
const bool fr_assignment_op[T_TOKEN_LAST]
const bool fr_list_assignment_op[T_TOKEN_LAST]
static size_t fr_token_to_enum_str_table_len
#define TOKEN_MATCH(bptr, tptr)
char const * fr_token_name(int token)
fr_token_t gettoken(char const **ptr, char *buf, int buflen, bool unescape)
fr_table_num_ordered_t const fr_tokens_table[]
static fr_token_t getthing(char const **ptr, char *buf, int buflen, bool tok, fr_table_num_ordered_t const *tokenlist, size_t tokenlist_len, bool unescape)
static fr_table_num_sorted_t const fr_token_from_quote_enum_str_table[]
Quote-token names that radconf2json's JSON output uses.
static size_t fr_token_from_quote_enum_str_table_len
const bool fr_str_tok[T_TOKEN_LAST]
fr_table_num_sorted_t const fr_token_quotes_table[]
char const * fr_token_to_enum_str(fr_token_t t)
Return the source-identifier name for a token (e.g.
size_t fr_token_quotes_table_len
size_t fr_tokens_table_len
fr_token_t getop(char const **ptr)
const char fr_token_quote[T_TOKEN_LAST]
Convert tokens back to a quoting character.
static fr_table_num_indexed_t const fr_token_to_enum_str_table[]
Map each fr_token_t to the C identifier of its enum constant.
char const * fr_tokens[T_TOKEN_LAST]
fr_token_t getstring(char const **ptr, char *buf, int buflen, bool unescape)
int getword(char const **ptr, char *buf, int buflen, bool unescape)
fr_token_t fr_token_from_quote_enum_str(char const *s, fr_token_t dflt)
Look up a quote token by its source-identifier name.
const bool fr_comparison_op[T_TOKEN_LAST]
const bool fr_binary_op[T_TOKEN_LAST]
@ T_SOLIDUS_QUOTED_STRING
#define fr_strerror_const(_msg)