![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Tokenisation code and constants. More...
#include <stdio.h>#include <freeradius-devel/util/skip.h>#include <freeradius-devel/util/token.h>
Include dependency graph for token.c:Go to the source code of this file.
Macros | |
| #define | T(_x) [T_OP_ ## _x] = true |
| #define | T(_x) [T_ ## _x] = true |
| #define | T(_x) [T_## _x] = true |
| #define | TOKEN_MATCH(bptr, tptr) |
Functions | |
| 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. | |
| char const * | fr_token_name (int token) |
| char const * | fr_token_to_enum_str (fr_token_t t) |
| Return the source-identifier name for a token (e.g. | |
| fr_token_t | getop (char const **ptr) |
| fr_token_t | getstring (char const **ptr, char *buf, int buflen, bool unescape) |
| 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) |
| fr_token_t | gettoken (char const **ptr, char *buf, int buflen, bool unescape) |
| int | getword (char const **ptr, char *buf, int buflen, bool unescape) |
Tokenisation code and constants.
This is mostly for the attribute filter and user files.
Definition in file token.c.
| #define TOKEN_MATCH | ( | bptr, | |
| tptr | |||
| ) |
| 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.
Inverse of fr_token_to_enum_str restricted to the five quote-typed tokens (T_BARE_WORD, T_DOUBLE_QUOTED_STRING, ...) - the only forms radconf2json emits as lhs_quote / rhs_quote JSON values.
| [in] | s | enum-identifier name (e.g. "T_DOUBLE_QUOTED_STRING"), or NULL. |
| [in] | dflt | value to return if s is NULL or unrecognised. |
fr_token_t, or dflt. | char const * fr_token_name | ( | int | token | ) |
| char const * fr_token_to_enum_str | ( | fr_token_t | t | ) |
Return the source-identifier name for a token (e.g.
"T_BARE_WORD", "T_OP_SET").
Counterpart to fr_tokens[] which returns the operator-character / human-display form (":=", "<BARE-WORD>", ...). Tooling that wants to emit grep-friendly enum identifiers (radconf2json, radmod2json) uses this.
| [in] | t | token to look up. |
t is out of range / has no symbolic entry. | fr_token_t getop | ( | char const ** | ptr | ) |
| fr_token_t getstring | ( | char const ** | ptr, |
| char * | buf, | ||
| int | buflen, | ||
| bool | unescape | ||
| ) |
|
static |
| fr_token_t gettoken | ( | char const ** | ptr, |
| char * | buf, | ||
| int | buflen, | ||
| bool | unescape | ||
| ) |
| int getword | ( | char const ** | ptr, |
| char * | buf, | ||
| int | buflen, | ||
| bool | unescape | ||
| ) |
| const bool fr_assignment_op[T_TOKEN_LAST] |
| const bool fr_binary_op[T_TOKEN_LAST] |
| const bool fr_comparison_op[T_TOKEN_LAST] |
| const bool fr_list_assignment_op[T_TOKEN_LAST] |
| const bool fr_str_tok[T_TOKEN_LAST] |
|
static |
Quote-token names that radconf2json's JSON output uses.
Only the five quote-typed tokens, kept sorted by name so the fr_table_value_by_str binary search can find them. Used by radjson2conf when rebuilding a CF tree from JSON.
|
static |
| const char fr_token_quote[T_TOKEN_LAST] |
Convert tokens back to a quoting character.
Non-string types convert to '?' to screw ups can be identified easily
| fr_table_num_sorted_t const fr_token_quotes_table[] |
| size_t fr_token_quotes_table_len = NUM_ELEMENTS(fr_token_quotes_table) |
|
static |
Map each fr_token_t to the C identifier of its enum constant.
Complement of fr_tokens[] (the operator-character / human-display form like ":=" / "<BARE-WORD>") - this one returns the source-identical T_OP_SET / T_BARE_WORD form so tooling (radconf2json, etc.) can round-trip enum names through a JSON intermediate.
|
static |
| char const* fr_tokens[T_TOKEN_LAST] |
| fr_table_num_ordered_t const fr_tokens_table[] |
| size_t fr_tokens_table_len = NUM_ELEMENTS(fr_tokens_table) |
1.9.8