3a71d1844a6df688393e604f69d5ad4c50ed1742
[freeradius.git] / src / include / token.h
1 #ifndef FR_TOKEN_H
2 #define FR_TOKEN_H
3
4 /*
5  * token.h      Special tokens.
6  *
7  * $Id$
8  *
9  *   This program is free software; you can redistribute it and/or modify
10  *   it under the terms of the GNU General Public License as published by
11  *   the Free Software Foundation; either version 2 of the License, or
12  *   (at your option) any later version.
13  *
14  *   This program is distributed in the hope that it will be useful,
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *   GNU General Public License for more details.
18  *
19  *   You should have received a copy of the GNU General Public License
20  *   along with this program; if not, write to the Free Software
21  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  *
23  * Copyright 2001,2006  The FreeRADIUS server project
24  */
25
26 #include <freeradius-devel/ident.h>
27 RCSIDH(token_h, "$Id$")
28
29 typedef enum fr_token_t {
30   T_OP_INVALID = 0,             /* invalid token */
31   T_EOL,                        /* end of line */
32   T_LCBRACE,                    /* { */
33   T_RCBRACE,                    /* } */
34   T_LBRACE,                     /* ( */
35   T_RBRACE,                     /* )             5 */
36   T_COMMA,                      /* , */
37   T_SEMICOLON,                  /* ; */
38
39   T_OP_ADD,                     /* += */
40   T_OP_SUB,                     /* -= */
41   T_OP_SET,                     /* :=           10 */
42   T_OP_EQ,                      /* = */
43   T_OP_NE,                      /* != */
44   T_OP_GE,                      /* >= */
45   T_OP_GT,                      /* > */
46   T_OP_LE,                      /* <=           15 */
47   T_OP_LT,                      /* < */
48   T_OP_REG_EQ,                  /* =~ */
49   T_OP_REG_NE,                  /* !~ */
50   T_OP_CMP_TRUE,                /* =* */
51   T_OP_CMP_FALSE,               /* !*           20 */
52   T_OP_CMP_EQ,                  /* == */
53   T_HASH,                       /* # */
54   T_BARE_WORD,                  /* bare word */
55   T_DOUBLE_QUOTED_STRING,       /* "foo" */
56   T_SINGLE_QUOTED_STRING,       /* 'foo'        25 */
57   T_BACK_QUOTED_STRING,         /* `foo` */
58   T_TOKEN_LAST
59 } FR_TOKEN;
60
61 #define T_EQSTART       T_OP_ADD
62 #define T_EQEND         (T_OP_CMP_EQ + 1)
63
64 typedef struct FR_NAME_NUMBER {
65         const char      *name;
66         int             number;
67 } FR_NAME_NUMBER;
68
69 int fr_str2int(const FR_NAME_NUMBER *table, const char *name, int def);
70 const char *fr_int2str(const FR_NAME_NUMBER *table, int number,
71                          const char *def);
72
73
74 int             getword (const char **ptr, char *buf, int buflen);
75 int             getbareword (const char **ptr, char *buf, int buflen);
76 FR_TOKEN        gettoken(const char **ptr, char *buf, int buflen);
77 FR_TOKEN        getstring(const char **ptr, char *buf, int buflen);
78
79 #endif /* FR_TOKEN_H */