All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
token.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_TOKEN_H
17 #define _FR_TOKEN_H
18 /**
19  * $Id: 3352d6764506bf1b2e2b9a3df2f64b656ed69f00 $
20  *
21  * @file include/token.h
22  * @brief Tokenisation code and constants.
23  *
24  * @copyright 2001,2006 The FreeRADIUS server project
25  */
26 RCSIDH(token_h, "$Id: 3352d6764506bf1b2e2b9a3df2f64b656ed69f00 $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef enum fr_token {
33  T_INVALID = 0, /* invalid token */
34  T_EOL, /* end of line */
35  T_LCBRACE, /* { */
36  T_RCBRACE, /* } */
37  T_LBRACE, /* ( */
38  T_RBRACE, /* ) 5 */
39  T_COMMA, /* , */
40  T_SEMICOLON, /* ; */
41 
42  T_OP_INCRM, /* ++ */
43  T_OP_ADD, /* += */
44  T_OP_SUB, /* -= 10 */
45  T_OP_SET, /* := */
46  T_OP_EQ, /* = */
47  T_OP_NE, /* != */
48  T_OP_GE, /* >= */
49  T_OP_GT, /* > 15 */
50  T_OP_LE, /* <= */
51  T_OP_LT, /* < */
52  T_OP_REG_EQ, /* =~ */
53  T_OP_REG_NE, /* !~ */
54  T_OP_CMP_TRUE, /* =* 20 */
55  T_OP_CMP_FALSE, /* !* */
56  T_OP_CMP_EQ, /* == */
57  T_HASH, /* # */
58  T_BARE_WORD, /* bare word */
59  T_DOUBLE_QUOTED_STRING, /* "foo" 25 */
61  T_BACK_QUOTED_STRING, /* `foo` */
63 } FR_TOKEN;
64 
65 #define T_EQSTART T_OP_ADD
66 #define T_EQEND (T_OP_CMP_EQ + 1)
67 
68 typedef struct FR_NAME_NUMBER {
69  char const *name;
70  int number;
72 
73 extern const FR_NAME_NUMBER fr_tokens_table[];
74 extern const char *fr_tokens[];
75 extern const char fr_token_quote[];
76 extern const bool fr_assignment_op[];
77 extern const bool fr_equality_op[];
78 extern const bool fr_str_tok[];
79 
80 int fr_str2int(FR_NAME_NUMBER const *table, char const *name, int def);
81 int fr_substr2int(FR_NAME_NUMBER const *table, char const *name, int def, int len);
82 char const *fr_int2str(FR_NAME_NUMBER const *table, int number, char const *def);
83 
84 int getword (char const **ptr, char *buf, int buflen, bool unescape);
85 FR_TOKEN gettoken(char const **ptr, char *buf, int buflen, bool unescape);
86 FR_TOKEN getop(char const **ptr);
87 FR_TOKEN getstring(char const **ptr, char *buf, int buflen, bool unescape);
88 char const *fr_token_name(int);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 #endif /* _FR_TOKEN_H */
#define RCSIDH(h, id)
Definition: build.h:136
FR_TOKEN getop(char const **ptr)
Definition: token.c:413
const char fr_token_quote[]
Convert tokens back to a quoting character.
Definition: token.c:96
FR_TOKEN getstring(char const **ptr, char *buf, int buflen, bool unescape)
Definition: token.c:429
Definition: token.h:47
Definition: token.h:34
char const * fr_token_name(int)
Definition: token.c:520
static char const * name
const FR_NAME_NUMBER fr_tokens_table[]
Definition: token.c:30
Definition: token.h:39
Definition: token.h:38
Definition: token.h:46
int number
Definition: token.h:70
Definition: token.h:37
const bool fr_equality_op[]
Definition: token.c:162
Definition: token.h:50
int fr_str2int(FR_NAME_NUMBER const *table, char const *name, int def)
Definition: token.c:451
char const * name
Definition: token.h:69
const bool fr_str_tok[]
Definition: token.c:195
const bool fr_assignment_op[]
Definition: token.c:129
Definition: token.h:43
int getword(char const **ptr, char *buf, int buflen, bool unescape)
Definition: token.c:396
Definition: token.h:49
Definition: token.h:44
const char * fr_tokens[]
Definition: token.c:60
Definition: token.h:45
fr_token
Definition: token.h:32
Definition: token.h:57
Definition: token.h:48
struct FR_NAME_NUMBER FR_NAME_NUMBER
FR_TOKEN gettoken(char const **ptr, char *buf, int buflen, bool unescape)
Definition: token.c:405
enum fr_token FR_TOKEN
char const * fr_int2str(FR_NAME_NUMBER const *table, int number, char const *def)
Definition: token.c:506
int fr_substr2int(FR_NAME_NUMBER const *table, char const *name, int def, int len)
Definition: token.c:471
Definition: token.h:51