Port patch from branch_1_1 to the HEAD
[freeradius.git] / src / include / token.h
1 #ifndef LRAD_TOKEN_H
2 #define LRAD_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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  * Copyright 2001  The FreeRADIUS server project
24  */
25
26 typedef enum lrad_token_t {
27   T_OP_INVALID = 0,             /* invalid token */
28   T_EOL,                        /* end of line */
29   T_LCBRACE,                    /* { */
30   T_RCBRACE,                    /* } */
31   T_LBRACE,                     /* ( */
32   T_RBRACE,                     /* ) */
33   T_COMMA,                      /* , */
34   T_SEMICOLON,                  /* ; */
35
36   T_OP_ADD,                     /* += */
37   T_OP_SUB,                     /* -= */
38   T_OP_SET,                     /* := */
39   T_OP_EQ,                      /* = */
40   T_OP_NE,                      /* != */
41   T_OP_GE,                      /* >= */
42   T_OP_GT,                      /* > */
43   T_OP_LE,                      /* <= */
44   T_OP_LT,                      /* < */
45   T_OP_REG_EQ,                  /* =~ */
46   T_OP_REG_NE,                  /* !~ */
47   T_OP_CMP_TRUE,                /* =* */
48   T_OP_CMP_FALSE,               /* !* */
49   T_OP_CMP_EQ,                  /* == */
50   T_HASH,                       /* # */
51   T_BARE_WORD,                  /* bare word */
52   T_DOUBLE_QUOTED_STRING,       /* "foo" */
53   T_SINGLE_QUOTED_STRING,       /* 'foo' */
54   T_BACK_QUOTED_STRING,         /* `foo` */
55   T_TOKEN_LAST
56 } LRAD_TOKEN;
57
58 #define T_EQSTART       T_OP_ADD
59 #define T_EQEND         (T_OP_CMP_EQ + 1)
60
61 typedef struct LRAD_NAME_NUMBER {
62         const char      *name;
63         int             number;
64 } LRAD_NAME_NUMBER;
65
66 int lrad_str2int(const LRAD_NAME_NUMBER *table, const char *name, int def);
67 const char *lrad_int2str(const LRAD_NAME_NUMBER *table, int number,
68                          const char *def);
69
70
71 int             getword (char **ptr, char *buf, int buflen);
72 int             getbareword (char **ptr, char *buf, int buflen);
73 LRAD_TOKEN      gettoken(char **ptr, char *buf, int buflen);
74
75 #endif /* LRAD_TOKEN_H */