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