The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
token.c File Reference

Tokenisation code and constants. More...

#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/token.h>
#include <ctype.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

ssize_t fr_skip_string (char const *start, char const *end)
 Skip a quoted string. More...
 
char const * fr_token_name (int token)
 
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)
 

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. More...
 
fr_table_num_sorted_t const fr_token_quotes_table []
 
size_t fr_token_quotes_table_len = NUM_ELEMENTS(fr_token_quotes_table)
 
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)
 

Detailed Description

Tokenisation code and constants.

This is mostly for the attribute filter and user files.

Definition in file token.c.

Macro Definition Documentation

◆ T [1/3]

#define T (   _x)    [T_OP_ ## _x] = true

Definition at line 230 of file token.c.

◆ T [2/3]

#define T (   _x)    [T_ ## _x] = true

Definition at line 230 of file token.c.

◆ T [3/3]

#define T (   _x)    [T_## _x] = true

Definition at line 230 of file token.c.

◆ TOKEN_MATCH

#define TOKEN_MATCH (   bptr,
  tptr 
)
Value:
( (tptr)[0] == (bptr)[0] && \
((tptr)[1] == (bptr)[1] || (tptr)[1] == 0))

Definition at line 242 of file token.c.

Function Documentation

◆ fr_skip_string()

ssize_t fr_skip_string ( char const *  start,
char const *  end 
)

Skip a quoted string.

Parameters
[in]startstart of the string, pointing to the quotation character
[in]endend of the string (or NULL for zero-terminated strings)
Returns
>0 length of the string which was parsed <=0 on error

Definition at line 504 of file token.c.

+ Here is the caller graph for this function:

◆ fr_token_name()

char const* fr_token_name ( int  token)

Definition at line 490 of file token.c.

+ Here is the caller graph for this function:

◆ getop()

fr_token_t getop ( char const **  ptr)

Definition at line 455 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 471 of file token.c.

+ Here is the call graph for this function:

◆ getthing()

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

Definition at line 253 of file token.c.

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

◆ gettoken()

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

Definition at line 447 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 438 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]
Initial value:
= {
T(INCRM),
T(ADD_EQ),
T(SUB_EQ),
T(MUL_EQ),
T(DIV_EQ),
T(AND_EQ),
T(OR_EQ),
T(RSHIFT_EQ),
T(LSHIFT_EQ),
T(SET),
T(EQ),
T(PREPEND),
}
#define T(_x)
Definition: token.c:230

Definition at line 168 of file token.c.

◆ fr_binary_op

const bool fr_binary_op[T_TOKEN_LAST]
Initial value:
= {
T(ADD),
T(SUB),
T(MUL),
T(DIV),
T(AND),
T(OR),
T(MOD),
T(RSHIFT),
T(LSHIFT),
}
#define MOD(a, b)

Definition at line 216 of file token.c.

◆ fr_comparison_op

const bool fr_comparison_op[T_TOKEN_LAST]
Initial value:
= {
T(NE),
T(GE),
T(GT),
T(LE),
T(LT),
T(REG_EQ),
T(REG_NE),
T(CMP_TRUE),
T(CMP_FALSE),
T(CMP_EQ),
T(CMP_EQ_TYPE),
T(CMP_NE_TYPE),
}

Definition at line 198 of file token.c.

◆ fr_list_assignment_op

const bool fr_list_assignment_op[T_TOKEN_LAST]
Initial value:
= {
T(ADD_EQ),
T(SUB_EQ),
T(AND_EQ),
T(OR_EQ),
T(LE),
T(GE),
T(SET),
T(EQ),
T(PREPEND),
}

Definition at line 185 of file token.c.

◆ fr_str_tok

const bool fr_str_tok[T_TOKEN_LAST]
Initial value:
= {
T(BARE_WORD),
T(DOUBLE_QUOTED_STRING),
T(SINGLE_QUOTED_STRING),
T(BACK_QUOTED_STRING),
}

Definition at line 231 of file token.c.

◆ fr_token_quote

const char fr_token_quote[T_TOKEN_LAST]
Initial value:
= {
[ 0 ... T_HASH ] = '?',
[T_BARE_WORD] = '\0',
}
@ T_SINGLE_QUOTED_STRING
Definition: token.h:122
@ T_BARE_WORD
Definition: token.h:120
@ T_BACK_QUOTED_STRING
Definition: token.h:123
@ T_HASH
Definition: token.h:119
@ T_DOUBLE_QUOTED_STRING
Definition: token.h:121
@ T_SOLIDUS_QUOTED_STRING
Definition: token.h:124

Convert tokens back to a quoting character.

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

Definition at line 156 of file token.c.

◆ fr_token_quotes_table

fr_table_num_sorted_t const fr_token_quotes_table[]
Initial value:
= {
{ L(""), T_BARE_WORD },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

Definition at line 66 of file token.c.

◆ fr_token_quotes_table_len

size_t fr_token_quotes_table_len = NUM_ELEMENTS(fr_token_quotes_table)

Definition at line 73 of file token.c.

◆ fr_tokens

char const* fr_tokens[T_TOKEN_LAST]

Definition at line 78 of file token.c.

◆ fr_tokens_table

fr_table_num_ordered_t const fr_tokens_table[]

Definition at line 33 of file token.c.

◆ fr_tokens_table_len

size_t fr_tokens_table_len = NUM_ELEMENTS(fr_tokens_table)

Definition at line 64 of file token.c.