The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions | Variables
token.h File Reference

Tokenisation code and constants. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/table.h>
+ Include dependency graph for token.h:

Go to the source code of this file.

Macros

#define FR_TABLE_NOT_FOUND   INT32_MIN
 Macro to use as dflt.
 
#define T_EQEND   (T_HASH)
 
#define T_EQSTART   T_OP_ADD_EQ
 
#define T_OP_XOR_EQ   T_OP_PREPEND
 
#define T_TOKEN_LAST   (T_SOLIDUS_QUOTED_STRING + 1)
 

Typedefs

typedef enum fr_token fr_token_t
 

Enumerations

enum  fr_token {
  T_INVALID = 0 ,
  T_EOL ,
  T_LCBRACE ,
  T_RCBRACE ,
  T_LBRACE ,
  T_RBRACE ,
  T_COMMA ,
  T_SEMICOLON ,
  T_ADD ,
  T_SUB ,
  T_MUL ,
  T_DIV ,
  T_AND ,
  T_OR ,
  T_NOT ,
  T_XOR ,
  T_COMPLEMENT ,
  T_MOD ,
  T_RSHIFT ,
  T_LSHIFT ,
  T_OP_ADD_EQ ,
  T_OP_SUB_EQ ,
  T_OP_MUL_EQ ,
  T_OP_DIV_EQ ,
  T_OP_OR_EQ ,
  T_OP_AND_EQ ,
  T_OP_RSHIFT_EQ ,
  T_OP_LSHIFT_EQ ,
  T_OP_EQ ,
  T_OP_SET ,
  T_OP_PREPEND ,
  T_LAND ,
  T_LOR ,
  T_OP_NE ,
  T_OP_GE ,
  T_OP_GT ,
  T_OP_LE ,
  T_OP_LT ,
  T_OP_REG_EQ ,
  T_OP_REG_NE ,
  T_OP_CMP_TRUE ,
  T_OP_CMP_FALSE ,
  T_OP_CMP_EQ ,
  T_OP_CMP_EQ_TYPE ,
  T_OP_CMP_NE_TYPE ,
  T_OP_INCRM ,
  T_HASH ,
  T_BARE_WORD ,
  T_DOUBLE_QUOTED_STRING ,
  T_SINGLE_QUOTED_STRING ,
  T_BACK_QUOTED_STRING ,
  T_SOLIDUS_QUOTED_STRING
}
 

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)
 
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)
 
fr_token_t gettoken (char const **ptr, char *buf, int buflen, bool unescape)
 
int getword (char const **ptr, char *buf, int buflen, bool unescape)
 

Variables

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]
 
const char fr_token_quote [T_TOKEN_LAST]
 Convert tokens back to a quoting character.
 
fr_table_num_sorted_t const fr_token_quotes_table []
 
size_t fr_token_quotes_table_len
 
const char * fr_tokens [T_TOKEN_LAST]
 
fr_table_num_ordered_t const fr_tokens_table []
 
size_t fr_tokens_table_len
 

Detailed Description

Tokenisation code and constants.

This is mostly for the attribute filter and user files.

Definition in file token.h.

Macro Definition Documentation

◆ FR_TABLE_NOT_FOUND

#define FR_TABLE_NOT_FOUND   INT32_MIN

Macro to use as dflt.

Definition at line 135 of file token.h.

◆ T_EQEND

#define T_EQEND   (T_HASH)

Definition at line 130 of file token.h.

◆ T_EQSTART

#define T_EQSTART   T_OP_ADD_EQ

Definition at line 129 of file token.h.

◆ T_OP_XOR_EQ

#define T_OP_XOR_EQ   T_OP_PREPEND

Definition at line 84 of file token.h.

◆ T_TOKEN_LAST

#define T_TOKEN_LAST   (T_SOLIDUS_QUOTED_STRING + 1)

Definition at line 127 of file token.h.

Typedef Documentation

◆ fr_token_t

typedef enum fr_token fr_token_t

Enumeration Type Documentation

◆ fr_token

enum fr_token
Enumerator
T_INVALID 
T_EOL 
T_LCBRACE 
T_RCBRACE 
T_LBRACE 
T_RBRACE 
T_COMMA 
T_SEMICOLON 
T_ADD 
T_SUB 
T_MUL 
T_DIV 
T_AND 
T_OR 
T_NOT 
T_XOR 
T_COMPLEMENT 
T_MOD 
T_RSHIFT 
T_LSHIFT 
T_OP_ADD_EQ 
T_OP_SUB_EQ 
T_OP_MUL_EQ 
T_OP_DIV_EQ 
T_OP_OR_EQ 
T_OP_AND_EQ 
T_OP_RSHIFT_EQ 
T_OP_LSHIFT_EQ 
T_OP_EQ 
T_OP_SET 
T_OP_PREPEND 
T_LAND 
T_LOR 
T_OP_NE 
T_OP_GE 
T_OP_GT 
T_OP_LE 
T_OP_LT 
T_OP_REG_EQ 
T_OP_REG_NE 
T_OP_CMP_TRUE 
T_OP_CMP_FALSE 
T_OP_CMP_EQ 
T_OP_CMP_EQ_TYPE 
T_OP_CMP_NE_TYPE 
T_OP_INCRM 
T_HASH 
T_BARE_WORD 
T_DOUBLE_QUOTED_STRING 
T_SINGLE_QUOTED_STRING 
T_BACK_QUOTED_STRING 
T_SOLIDUS_QUOTED_STRING 

Definition at line 36 of file token.h.

Function Documentation

◆ fr_token_from_quote_enum_str()

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.

Parameters
[in]senum-identifier name (e.g. "T_DOUBLE_QUOTED_STRING"), or NULL.
[in]dfltvalue to return if s is NULL or unrecognised.
Returns
the matching fr_token_t, or dflt.

Definition at line 137 of file token.c.

◆ fr_token_name()

char const * fr_token_name ( int  token)

Definition at line 579 of file token.c.

+ Here is the caller graph for this function:

◆ fr_token_to_enum_str()

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.

Parameters
[in]ttoken to look up.
Returns
the enum-identifier name, or "T_INVALID" if t is out of range / has no symbolic entry.

Definition at line 117 of file token.c.

◆ getop()

fr_token_t getop ( char const **  ptr)

Definition at line 544 of file token.c.

+ Here is the call graph for this function:

◆ getstring()

fr_token_t getstring ( char const **  ptr,
char *  buf,
int  buflen,
bool  unescape 
)

Definition at line 560 of file token.c.

+ Here is the call graph for this function:

◆ gettoken()

fr_token_t gettoken ( char const **  ptr,
char *  buf,
int  buflen,
bool  unescape 
)

Definition at line 536 of file token.c.

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

◆ getword()

int getword ( char const **  ptr,
char *  buf,
int  buflen,
bool  unescape 
)

Definition at line 527 of file token.c.

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

Variable Documentation

◆ fr_assignment_op

const bool fr_assignment_op[T_TOKEN_LAST]
extern

Definition at line 236 of file token.c.

◆ fr_binary_op

const bool fr_binary_op[T_TOKEN_LAST]
extern

Definition at line 284 of file token.c.

◆ fr_comparison_op

const bool fr_comparison_op[T_TOKEN_LAST]
extern

Definition at line 266 of file token.c.

◆ fr_list_assignment_op

const bool fr_list_assignment_op[T_TOKEN_LAST]
extern

Definition at line 253 of file token.c.

◆ fr_str_tok

const bool fr_str_tok[T_TOKEN_LAST]
extern

Definition at line 299 of file token.c.

◆ fr_token_quote

const char fr_token_quote[T_TOKEN_LAST]
extern

Convert tokens back to a quoting character.

Non-string types convert to '?' to screw ups can be identified easily

Definition at line 224 of file token.c.

◆ fr_token_quotes_table

fr_table_num_sorted_t const fr_token_quotes_table[]
extern

Definition at line 68 of file token.c.

◆ fr_token_quotes_table_len

size_t fr_token_quotes_table_len
extern

Definition at line 75 of file token.c.

◆ fr_tokens

const char* fr_tokens[T_TOKEN_LAST]
extern

Definition at line 146 of file token.c.

◆ fr_tokens_table

fr_table_num_ordered_t const fr_tokens_table[]
extern

Definition at line 33 of file token.c.

◆ fr_tokens_table_len

size_t fr_tokens_table_len
extern

Definition at line 66 of file token.c.