25 RCSID(
"$Id: 8acd36299d8ad726735ceffea5a6ed233cebe9fc $")
27 #include <freeradius-devel/util/misc.h>
28 #include <freeradius-devel/util/strerror.h>
29 #include <freeradius-devel/util/token.h>
149 #pragma clang diagnostic ignored "-Wgnu-designator"
166 #define T(_x) [T_OP_ ## _x] = true
214 #define T(_x) [T_ ## _x] = true
230 #define T(_x) [T_## _x] = true
233 T(DOUBLE_QUOTED_STRING),
234 T(SINGLE_QUOTED_STRING),
235 T(BACK_QUOTED_STRING),
242 #define TOKEN_MATCH(bptr, tptr) \
243 ( (tptr)[0] == (bptr)[0] && \
244 ((tptr)[1] == (bptr)[1] || (tptr)[1] == 0))
280 for (i = 0; i < tokenlist_len; i++) {
291 token = tokenlist[i].
value;
323 if ((buflen >= 3) && (p[1] == quote) && (p[2] == quote)) {
332 while (*p && buflen-- > 1) {
339 if (isspace((
uint8_t) *p))
break;
343 for (i = 0; i < tokenlist_len; i++) {
350 if (*p ==
',')
break;
369 if ((buflen >= 3) && (p[1] == quote) && (p[2] == quote)) {
410 if (*p >=
'0' && *p <=
'9' &&
411 sscanf(p,
"%3o", &x) == 1) {
459 int getword(
char const **ptr,
char *buf,
int buflen,
bool unescape)
496 if (!ptr || !*ptr || !buf)
return T_INVALID;
504 if ((*p ==
'"') || (*p ==
'\'') || (*p ==
'`')) {
505 return gettoken(ptr, buf, buflen, unescape);
527 char const *p = start;
532 while ((end && (p < end)) || *p) {
549 if (end && ((p + 2) >= end)) {
558 if (p[1] <
' ')
goto fail;
563 if (!isdigit((
uint8_t) p[1])) {
577 if (end && ((p + 4) >= end))
goto fail;
582 if ((quote ==
'\'') && isxdigit((
uint8_t) p[1]) && isxdigit((
uint8_t) p[2])) {
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_str_by_value(_table, _number, _def)
Convert an integer to a string.
fr_table_elem_name_t name
size_t len
Literal string length.
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]
char const * fr_token_name(int token)
#define TOKEN_MATCH(bptr, tptr)
ssize_t fr_skip_string(char const *start, char const *end)
Skip a quoted string.
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)
const bool fr_str_tok[T_TOKEN_LAST]
fr_table_num_sorted_t const fr_token_quotes_table[]
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.
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)
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)