Add "extern C {...} to header files for C++ builds.
[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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 typedef enum fr_token_t {
34   T_OP_INVALID = 0,             /* invalid token */
35   T_EOL,                        /* end of line */
36   T_LCBRACE,                    /* { */
37   T_RCBRACE,                    /* } */
38   T_LBRACE,                     /* ( */
39   T_RBRACE,                     /* )             5 */
40   T_COMMA,                      /* , */
41   T_SEMICOLON,                  /* ; */
42
43   T_OP_ADD,                     /* += */
44   T_OP_SUB,                     /* -= */
45   T_OP_SET,                     /* :=           10 */
46   T_OP_EQ,                      /* = */
47   T_OP_NE,                      /* != */
48   T_OP_GE,                      /* >= */
49   T_OP_GT,                      /* > */
50   T_OP_LE,                      /* <=           15 */
51   T_OP_LT,                      /* < */
52   T_OP_REG_EQ,                  /* =~ */
53   T_OP_REG_NE,                  /* !~ */
54   T_OP_CMP_TRUE,                /* =* */
55   T_OP_CMP_FALSE,               /* !*           20 */
56   T_OP_CMP_EQ,                  /* == */
57   T_HASH,                       /* # */
58   T_BARE_WORD,                  /* bare word */
59   T_DOUBLE_QUOTED_STRING,       /* "foo" */
60   T_SINGLE_QUOTED_STRING,       /* 'foo'        25 */
61   T_BACK_QUOTED_STRING,         /* `foo` */
62   T_TOKEN_LAST
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         const char      *name;
70         int             number;
71 } FR_NAME_NUMBER;
72
73 int fr_str2int(const FR_NAME_NUMBER *table, const char *name, int def);
74 const char *fr_int2str(const FR_NAME_NUMBER *table, int number,
75                          const char *def);
76
77
78 int             getword (const char **ptr, char *buf, int buflen);
79 int             getbareword (const char **ptr, char *buf, int buflen);
80 FR_TOKEN        gettoken(const char **ptr, char *buf, int buflen);
81 FR_TOKEN        getstring(const char **ptr, char *buf, int buflen);
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /* FR_TOKEN_H */