ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
Revision: 5332
Committed: Wed Jan 7 18:01:01 2015 UTC (11 years, 7 months ago) by michael
File size: 9221 byte(s)
Log Message:
- Added options::negcache_rebuild configuration option

File Contents

# Content
1 /*
2 * Copyright (C) 2002 Erik Fears
3 *
4 * QSTRING , ccomment and hashcomment taken from Hybrid7:
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to
19 *
20 * The Free Software Foundation, Inc.
21 * 59 Temple Place - Suite 330
22 * Boston, MA 02111-1307, USA.
23 *
24 *
25 */
26
27 %option case-insensitive
28 %option noyywrap
29 %option nounput
30
31 %{
32 #include <stdio.h>
33 #include <string.h>
34
35 #include "compat.h"
36 #include "config.h"
37 #include "config-parser.h"
38
39
40 void ccomment(void);
41
42 int linenum = 1;
43 char linebuf[512];
44
45 %}
46
47 string \"[^\"\n]*[\"\n]
48 comment ("//"|"#").*
49 whitespace [ \t\r]*
50
51 %%
52
53 "/*" { ccomment(); }
54
55 {comment} ;
56
57 {string} {
58 /* QSTRING from Hybrid7. Why re-invent the wheel? */
59
60 if(yytext[yyleng-2] == '\\')
61 {
62 yyless(yyleng-1); /* return last quote */
63 yymore(); /* append next string */
64 }
65 else
66 {
67 yylval.string = yytext+1;
68 if(yylval.string[yyleng-2] != '"') ; /* log error */
69 else
70 {
71 int i,j;
72
73 yylval.string[yyleng-2] = '\0'; /* remove close
74 * quote
75 */
76
77 for (j=i=0 ;yylval.string[i] != '\0'; i++,j++)
78 {
79 if (yylval.string[i] != '\\')
80 {
81 yylval.string[j] = yylval.string[i];
82 }
83 else
84 {
85 i++;
86 yylval.string[j] = yylval.string[i];
87 }
88 }
89 yylval.string[j] = '\0';
90 return STRING;
91 }
92 }
93
94 }
95
96 AWAY { return AWAY; }
97 BAN_UNKNOWN { return BAN_UNKNOWN; }
98 BLACKLIST { return BLACKLIST; }
99 CHANNEL { return CHANNEL; }
100 CONNREGEX { return CONNREGEX; }
101 DNS_FDLIMIT { return DNS_FDLIMIT; }
102 DNSBL_FROM { return DNSBL_FROM; }
103 DNSBL_TO { return DNSBL_TO; }
104 EXEMPT { return EXEMPT; }
105 FD { return FD; }
106 INVITE { return INVITE; }
107 IRC { return IRC; }
108 KLINE { return KLINE; }
109 KEY { return KEY; }
110 MASK { return MASK; }
111 MAX_READ { return MAX_READ; }
112 MODE { return MODE; }
113 NAME { return NAME; }
114 NEGCACHE { return NEGCACHE; }
115 NEGCACHE_REBUILD { return NEGCACHE_REBUILD; }
116 NICK { return NICK; }
117 NICKSERV { return NICKSERV; }
118 OPER { return OPER; }
119 OPM { return OPM; }
120 OPTIONS { return OPTIONS; }
121 PASSWORD { return PASSWORD; }
122 PERFORM { return PERFORM; }
123 PIDFILE { return PIDFILE; }
124 PORT { return PORT; }
125 PROTOCOL { return PROTOCOL; }
126 READTIMEOUT { return READTIMEOUT; }
127 REALNAME { return REALNAME; }
128 REPLY { return REPLY; }
129 SCANLOG { return SCANLOG; }
130 SCANNER { return SCANNER; }
131 SENDMAIL { return SENDMAIL; }
132 SERVER { return SERVER; }
133 TARGET_IP { return TARGET_IP; }
134 TARGET_PORT { return TARGET_PORT; }
135 TARGET_STRING { return TARGET_STRING;}
136 TIMEOUT { return TIMEOUT; }
137 TYPE { return TYPE; }
138 USER { return USER; }
139 USERNAME { return USERNAME; }
140 VHOST { return VHOST; }
141
142 years { return YEARS; }
143 year { return YEARS; }
144 months { return MONTHS; }
145 month { return MONTHS; }
146 weeks { return WEEKS; }
147 week { return WEEKS; }
148 days { return DAYS; }
149 day { return DAYS; }
150 hours { return HOURS; }
151 hour { return HOURS; }
152 minutes { return MINUTES; }
153 minute { return MINUTES; }
154 seconds { return SECONDS; }
155 second { return SECONDS; }
156
157 bytes { return BYTES; }
158 byte { return BYTES; }
159 kilobytes { return KBYTES; }
160 kilobyte { return KBYTES; }
161 kbytes { return KBYTES; }
162 kbyte { return KBYTES; }
163 kb { return KBYTES; }
164 megabytes { return MBYTES; }
165 megabyte { return MBYTES; }
166 mbytes { return MBYTES; }
167 mbyte { return MBYTES; }
168 mb { return MBYTES; }
169
170 HTTP {
171 yylval.number = OPM_TYPE_HTTP;
172 return PROTOCOLTYPE;
173 }
174
175 HTTPPOST {
176 yylval.number = OPM_TYPE_HTTPPOST;
177 return PROTOCOLTYPE;
178 }
179
180 SOCKS4 {
181 yylval.number = OPM_TYPE_SOCKS4;
182 return PROTOCOLTYPE;
183 }
184
185 SOCKS5 {
186 yylval.number = OPM_TYPE_SOCKS5;
187 return PROTOCOLTYPE;
188 }
189
190 WINGATE {
191 yylval.number = OPM_TYPE_WINGATE;
192 return PROTOCOLTYPE;
193 }
194
195 ROUTER {
196 yylval.number = OPM_TYPE_ROUTER;
197 return PROTOCOLTYPE;
198 }
199
200
201 [0-9]+ {
202 yylval.number=atoi(yytext);
203 return NUMBER;
204 }
205
206
207
208
209
210 TRUE {
211 yylval.number=1;
212 return NUMBER;
213 }
214 YES {
215 yylval.number=1;
216 return NUMBER;
217 }
218 ON {
219 yylval.number=1;
220 return NUMBER;
221 }
222
223
224
225 FALSE {
226 yylval.number=0;
227 return NUMBER;
228 }
229
230 NO {
231 yylval.number=0;
232 return NUMBER;
233 }
234
235 OFF {
236 yylval.number=0;
237 return NUMBER;
238 }
239
240
241 \n.* {
242 strlcpy(linebuf, yytext + 1, sizeof(linebuf));
243 ++linenum;
244 yyless(1);
245 }
246
247 {whitespace} /* ignore whitespace */;
248
249 . return yytext[0];
250
251 %%
252
253
254 /* C-comment ignoring routine -kre*/
255 void ccomment(void)
256 {
257 int c;
258
259 /* log(L_NOTICE, "got comment"); */
260 while (1)
261 {
262 while ((c = input()) != '*' && c != EOF)
263 if (c == '\n') ++linenum;
264 if (c == '*')
265 {
266 while ((c = input()) == '*');
267 if (c == '/') break;
268 }
269 if (c == EOF)
270 {
271 YY_FATAL_ERROR("EOF in comment");
272 /* XXX hack alert this disables
273 * the stupid unused function warning
274 * gcc generates
275 */
276 if(1 == 0)
277 yy_fatal_error("EOF in comment");
278 break;
279 }
280 }
281 }
282

Properties

Name Value
svn:eol-style native
svn:keywords Id