All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
parser.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_PARSER_H
17 #define _FR_PARSER_H
18 /**
19  * $Id: 31fd2179c98ac8be584306ee87ff030bdf52fe58 $
20  *
21  * @file include/parser.h
22  * @brief Condition parser API
23  *
24  * @copyright 2013 Alan DeKok <aland@freeradius.org>
25  */
26 RCSIDH(parser_h, "$Id: 31fd2179c98ac8be584306ee87ff030bdf52fe58 $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #ifndef RADIUSD_H
33 /*
34  * Also defined in radiusd.h for radius_evalute_cond()
35  */
36 typedef struct fr_cond_t fr_cond_t;
37 #endif
38 
39 typedef enum {
40  COND_NONE = 0,
41  COND_AND = '&',
42  COND_OR = '|'
43 } fr_cond_op_t;
44 
45 typedef enum {
53 
54 typedef enum {
60 
61 /*
62  * Allow for the following structures:
63  *
64  * FOO no OP, RHS is NULL
65  * FOO OP BAR
66  * (COND) no LHS/RHS, child is COND, child OP is true
67  * (!(COND)) no LHS/RHS, child is COND, child OP is NOT
68  * (COND1 OP COND2) no LHS/RHS, next is COND2, next OP is OP
69  */
70 struct fr_cond_t {
72 
73  CONF_ITEM const *ci;
74  union {
75  vp_map_t *map;
76  vp_tmpl_t *vpt;
77  fr_cond_t *child;
78  } data;
79 
80  bool negate;
82 
84 
87 };
88 
89 /*
90  * One pass over the conditions means that all references must
91  * exist at parse time.
92  *
93  * Two pass means "soft fail", that some invalid references are
94  * left for pass 2.
95  */
96 #define FR_COND_ONE_PASS (0)
97 #define FR_COND_TWO_PASS (1)
98 
99 ssize_t fr_condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *start, fr_cond_t **head, char const **error, int flag);
100 size_t fr_cond_snprint(char *buffer, size_t bufsize, fr_cond_t const *c);
101 
102 bool fr_condition_walk(fr_cond_t *head, bool (*callback)(void *, fr_cond_t *), void *ctx);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 #endif /* _FR_PARSER_H */
#define RCSIDH(h, id)
Definition: build.h:136
bool fr_condition_walk(fr_cond_t *head, bool(*callback)(void *, fr_cond_t *), void *ctx)
Definition: parser.c:1720
Definition: parser.h:42
Dictionary attribute.
Definition: dict.h:77
union fr_cond_t::@6 data
fr_cond_pass2_t
Definition: parser.h:54
fr_cond_type_t
Definition: parser.h:45
fr_dict_attr_t const * cast
Definition: parser.h:83
fr_cond_t * next
Definition: parser.h:86
static expr_map_t map[]
Definition: rlm_expr.c:169
bool negate
Definition: parser.h:80
CONF_ITEM const * ci
Definition: parser.h:73
size_t fr_cond_snprint(char *buffer, size_t bufsize, fr_cond_t const *c)
Definition: parser.c:50
fr_cond_pass2_t pass2_fixup
Definition: parser.h:81
ssize_t fr_condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *start, fr_cond_t **head, char const **error, int flag)
Tokenize a conditional check.
Definition: parser.c:1711
fr_cond_op_t
Definition: parser.h:39
Value pair map.
Definition: map.h:46
A source or sink of value data.
Definition: tmpl.h:187
fr_cond_op_t next_op
Definition: parser.h:85
fr_cond_type_t type
Definition: parser.h:71