ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
Revision: 5876
Committed: Wed Apr 29 11:25:48 2015 UTC (8 years, 11 months ago) by michael
File size: 9184 byte(s)
Log Message:
- Removed trailing whitespaces

File Contents

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

Properties

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