Fixes to improve portability (especially to OS X, Solaris, OpenBSD).
[ircu2.10.12-pk.git] / ircd / ircd_lexer.l
1 /*
2  * ircd_lexer.l: A lexical scanner for ircd config files.
3  * This is part of ircu, an Internet Relay Chat server.
4  * The contents of this file are Copyright(C) 2001 by Andrew Miller, the
5  * ircd-hybrid team and the ircu team.
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19  *  USA.
20  * $Id$
21  */
22
23 %{
24 #include <unistd.h>
25 #include <stdio.h>
26 #include "ircd.h"
27 #include "y.tab.h"
28
29 extern int lineno;
30
31 void
32 init_lexer(void)
33 {
34   yyin = fopen(configfile, "r");
35   if (yyin == NULL)
36   {
37 #ifdef YY_FATAL_ERROR
38     YY_FATAL_ERROR("Could not open the configuration file.");
39 #else
40     fprintf(stderr, "Could not open the configuration file.");
41 #endif
42   }
43 #ifdef YY_NEW_FILE
44   YY_NEW_FILE;
45 #endif
46   lineno = 1;
47 }
48 %}
49
50 %e 1500
51 %p 3000
52 %n 1000
53
54 WHITE [ \t\r]+
55 SHCOMMENT #[^\n]*
56 NUMBER [0-9]+
57 QSTRING \"[^"\n]+[\"\n]
58 %%
59
60 {QSTRING} {yytext[yyleng-1] = 0; yylval.text = yytext+1; return QSTRING;}
61 {NUMBER} {yylval.num = strtoul(yytext, NULL, 10); return NUMBER;}
62 {WHITE} ;
63 {SHCOMMENT} ;
64
65 admin return ADMIN;
66 administrator return ADMIN;
67 general return GENERAL;
68 location return LOCATION;
69 contact return CONTACT;
70 connect return CONNECT;
71 class return CLASS;
72 pingfreq return PINGFREQ;
73 connectfreq return CONNECTFREQ;
74 maxlinks return MAXLINKS;
75 sendq return SENDQ;
76 name return NAME;
77 host return HOST;
78 password return PASS;
79 pass return PASS;
80 seconds return SECONDS;
81 minutes return MINUTES;
82 hours return HOURS;
83 days return DAYS;
84 weeks return WEEKS;
85 months return MONTHS;
86 years return YEARS;
87 decades return DECADES;
88 bytes return BYTES;
89 b return BYTES;
90 kbytes return KBYTES;
91 kilobytes return KBYTES;
92 kb return KBYTES;
93 mbytes return MBYTES;
94 megabytes return MBYTES;
95 mb return MBYTES;
96 gbytes return GBYTES;
97 gigabytes return GBYTES;
98 gb return GBYTES;
99 tbytes return TBYTES;
100 terabytes return TBYTES;
101 tb return TBYTES;
102 port return PORT;
103 server return SERVER;
104 yes return YES;
105 no return NO;
106 hub return HUB;
107 leaf return LEAF;
108 uworld return UWORLD;
109 operator return OPER;
110 oper return OPER;
111 local return LOCAL;
112 vhost return VHOST;
113 mask return MASK;
114 hidden return HIDDEN;
115 motd return MOTD;
116 numeric return NUMERIC;
117 nick return NICK;
118 jupe return JUPE;
119 description return DESCRIPTION;
120 client return CLIENT;
121 real return REAL;
122 realname return REAL;
123 reason return REASON;
124 file return TFILE;
125 rule return RULE;
126 all return ALL;
127 ip return IP;
128 crule return CRULE;
129 kill return KILL;
130 quarantine return QUARANTINE;
131 iauth return IAUTH;
132 timeout return TIMEOUT;
133 features return FEATURES;
134 channel return CHANNEL;
135 chan_limit return TPRIV_CHAN_LIMIT;
136 mode_lchan return TPRIV_MODE_LCHAN;
137 deop_lchan return TPRIV_DEOP_LCHAN;
138 walk_lchan return TPRIV_WALK_LCHAN;
139 local_kill return TPRIV_LOCAL_KILL;
140 rehash return TPRIV_REHASH;
141 restart return TPRIV_RESTART;
142 die return TPRIV_DIE;
143 gline return TPRIV_GLINE;
144 local_gline return TPRIV_LOCAL_GLINE;
145 local_jupe return TPRIV_LOCAL_JUPE;
146 opmode return TPRIV_OPMODE;
147 set return TPRIV_SET;
148 whox return TPRIV_WHOX;
149 badchan return TPRIV_BADCHAN;
150 local_badchan return TPRIV_LOCAL_BADCHAN;
151 see_chan return TPRIV_SEE_CHAN;
152 show_invis return TPRIV_SHOW_INVIS;
153 show_all_invis return TPRIV_SHOW_ALL_INVIS;
154 propagate return TPRIV_PROPAGATE;
155 unlimit_query return TPRIV_UNLIMIT_QUERY;
156 display return TPRIV_DISPLAY;
157 see_opers return TPRIV_SEE_OPERS;
158 wide_gline return TPRIV_WIDE_GLINE;
159 force_opmode return TPRIV_FORCE_OPMODE;
160 force_local_opmode return TPRIV_FORCE_LOCAL_OPMODE;
161 pseudo return PSEUDO;
162 prepend return PREPEND;
163 usermode return USERMODE;
164 \n lineno++;
165 . return yytext[0];