The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Implements the evaluation and parsing functions for the FreeRADIUS version of jpath. More...
Go to the source code of this file.
Data Structures | |
struct | fr_jpath_node |
Node in a jpath selector sequence. More... | |
struct | jpath_expr_t |
A jpath expression for performing complex comparisons against field values. More... | |
union | jpath_operand_t |
Operand in a jpath expression. More... | |
struct | jpath_selector |
union | jpath_selector.__unnamed39__ |
Macros | |
#define | NODE_NEW(_node) |
#define | SELECTOR_INDEX_UNSET INT32_MAX |
Typedefs | |
typedef struct jpath_selector | jpath_selector_t |
Selects a subset of JSON child nodes. More... | |
Functions | |
char * | fr_jpath_asprint (TALLOC_CTX *ctx, fr_jpath_node_t const *head) |
Print a node list to a string for debugging. More... | |
ssize_t | fr_jpath_escape_func (UNUSED request_t *request, char *out, size_t outlen, char const *in, UNUSED void *arg) |
Escapes special chars. More... | |
int | fr_jpath_evaluate_leaf (TALLOC_CTX *ctx, fr_value_box_list_t *out, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, json_object *root, fr_jpath_node_t const *jpath) |
Evaluate a parsed jpath expression against a json-c tree. More... | |
ssize_t | fr_jpath_parse (TALLOC_CTX *ctx, fr_jpath_node_t **head, char const *in, size_t inlen) |
Parse a jpath string. More... | |
static ssize_t | jpath_array_parse (jpath_selector_t *selector, char const *in, size_t inlen) |
Parse index/slice notation. More... | |
static int | jpath_evaluate (TALLOC_CTX *ctx, fr_value_box_list_t *tail, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, json_object *object, fr_jpath_node_t const *jpath) |
Recursive function for jpath_expr_evaluate. More... | |
static ssize_t | jpath_expr_parse (UNUSED jpath_selector_t *selector, UNUSED char const *in, UNUSED size_t inlen) |
Parse a jpath expression. More... | |
static size_t | jpath_field_parse (fr_jpath_node_t *node, char const *in, size_t inlen) |
Parse a jpath field. More... | |
static ssize_t | jpath_filter_expr_parse (UNUSED jpath_selector_t *selector, UNUSED char const *in, UNUSED size_t inlen) |
Parse a jpath filter expression, which in our case, is a FreeRADIUS condition. More... | |
static size_t | jpath_selector_parse (fr_jpath_node_t *node, char const *in, size_t inlen) |
parse a jpath selector More... | |
Variables | |
static char const | escape_chars [] = "[],*.:()?" |
Implements the evaluation and parsing functions for the FreeRADIUS version of jpath.
Definition in file jpath.c.
struct fr_jpath_node |
Data Fields | ||
---|---|---|
fr_jpath_node_t * | next | Next in the jpath chain. |
jpath_selector_t * | selector | Jpath selector head (there may be multiple). |
struct jpath_expr_t |
A jpath expression for performing complex comparisons against field values.
Data Fields | ||
---|---|---|
jpath_operand_t | lhs | LHS value. |
jpath_operand_t | rhs | RHS value. |
union jpath_operand_t |
Data Fields | ||
---|---|---|
fr_jpath_node_t * | jpath | Operand is a jpath expression. |
char const * | literal | Operand is a literal (value) |
struct jpath_selector |
Data Fields | ||
---|---|---|
union jpath_selector | __unnamed__ | |
jpath_selector_t * | next | |
jpath_type_t | type | Type of the Jpath node. |
union jpath_selector.__unnamed39__ |
Data Fields | ||
---|---|---|
jpath_expr_t | expr | Expression. |
char const * | field | JSON object name. |
int32_t | slice[3] | Array index, or slice, or step. |
#define NODE_NEW | ( | _node | ) |
typedef struct jpath_selector jpath_selector_t |
enum jpath_operand_type |
enum jpath_type_t |
char* fr_jpath_asprint | ( | TALLOC_CTX * | ctx, |
fr_jpath_node_t const * | head | ||
) |
Print a node list to a string for debugging.
Will not be identical to the original parsed string, but should be sufficient for testing purposes.
ctx | to allocate string in. |
head | of the node list. |
Definition at line 411 of file jpath.c.
ssize_t fr_jpath_escape_func | ( | UNUSED request_t * | request, |
char * | out, | ||
size_t | outlen, | ||
char const * | in, | ||
UNUSED void * | arg | ||
) |
Escapes special chars.
Escapes any characters that may have special meaning within a jpath expression
request | Current request (unused may be NULL). |
out | Where to write the escaped string. |
outlen | Length of the output buffer. |
in | data to escape. |
arg | uctx data, not used. |
Definition at line 106 of file jpath.c.
int fr_jpath_evaluate_leaf | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t * | out, | ||
fr_type_t | dst_type, | ||
fr_dict_attr_t const * | dst_enumv, | ||
json_object * | root, | ||
fr_jpath_node_t const * | jpath | ||
) |
Evaluate a parsed jpath expression against a json-c tree.
Will produce one or more fr_value_box_t structures of the desired type, or error out if the conversion between types fails.
[in,out] | ctx | to allocate fr_value_box_t in. |
[out] | out | Where to write fr_value_box_t. |
[in] | dst_type | FreeRADIUS type to convert to. |
[in] | dst_enumv | Enumeration values to allow string to integer conversions. |
[in] | root | of the json-c tree. |
[in] | jpath | to evaluate. |
Definition at line 383 of file jpath.c.
ssize_t fr_jpath_parse | ( | TALLOC_CTX * | ctx, |
fr_jpath_node_t ** | head, | ||
char const * | in, | ||
size_t | inlen | ||
) |
Parse a jpath string.
Based on the syntax described here http://goessner.net/articles/JsonPath/
Implements parser for everything except unions and expressions
Definition at line 813 of file jpath.c.
|
static |
Parse index/slice notation.
Expects in to point to a buffer containing:
[<int0>:<int1>:<int2>]
Where each of the integers and its accompanying delimiter is optional.
selector | to populate with index/slice info. |
in | input. |
inlen | length of in. |
Definition at line 544 of file jpath.c.
|
static |
Recursive function for jpath_expr_evaluate.
[in,out] | ctx | to allocate fr_value_box_t in. |
[out] | tail | Where to write fr_value_box_t. |
[in] | dst_type | FreeRADIUS type to convert to. |
[in] | dst_enumv | Enumeration values to allow string to integer conversions. |
[in] | object | current node in the json tree. |
[in] | jpath | to evaluate. |
Definition at line 141 of file jpath.c.
|
static |
|
static |