/[svn]/hopm/trunk/src/config-lexer.l
ViewVC logotype

Contents of /hopm/trunk/src/config-lexer.l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5135 - (show annotations)
Thu Dec 25 18:51:51 2014 UTC (5 years, 5 months ago) by michael
File size: 9137 byte(s)
- propset svn:eol-style native

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 "inet.h"
36 #include "compat.h"
37 #include "config.h"
38 #include "config-parser.h"
39
40
41 void ccomment(void);
42
43 int linenum = 1;
44 char linebuf[512];
45
46 %}
47
48 string \"[^\"\n]*[\"\n]
49 comment ("//"|"#").*
50 whitespace [ \t\r]*
51
52 %%
53
54 "/*" { ccomment(); }
55
56 {comment} ;
57
58 {string} {
59 /* QSTRING from Hybrid7. Why re-invent the wheel? */
60
61 if(yytext[yyleng-2] == '\\')
62 {
63 yyless(yyleng-1); /* return last quote */
64 yymore(); /* append next string */
65 }
66 else
67 {
68 yylval.string = yytext+1;
69 if(yylval.string[yyleng-2] != '"') ; /* log error */
70 else
71 {
72 int i,j;
73
74 yylval.string[yyleng-2] = '\0'; /* remove close
75 * quote
76 */
77
78 for (j=i=0 ;yylval.string[i] != '\0'; i++,j++)
79 {
80 if (yylval.string[i] != '\\')
81 {
82 yylval.string[j] = yylval.string[i];
83 }
84 else
85 {
86 i++;
87 yylval.string[j] = yylval.string[i];
88 }
89 }
90 yylval.string[j] = '\0';
91 return STRING;
92 }
93 }
94
95 }
96
97 AWAY { return AWAY; }
98 BAN_UNKNOWN { return BAN_UNKNOWN; }
99 BLACKLIST { return BLACKLIST; }
100 CHANNEL { return CHANNEL; }
101 CONNREGEX { return CONNREGEX; }
102 DNS_FDLIMIT { return DNS_FDLIMIT; }
103 DNSBL_FROM { return DNSBL_FROM; }
104 DNSBL_TO { return DNSBL_TO; }
105 EXEMPT { return EXEMPT; }
106 FD { return FD; }
107 INVITE { return INVITE; }
108 IRC { return IRC; }
109 KLINE { return KLINE; }
110 KEY { return KEY; }
111 MASK { return MASK; }
112 MAX_READ { return MAX_READ; }
113 MODE { return MODE; }
114 NAME { return NAME; }
115 NEGCACHE { return NEGCACHE; }
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 REALNAME { return REALNAME; }
127 REPLY { return REPLY; }
128 SCANLOG { return SCANLOG; }
129 SCANNER { return SCANNER; }
130 SENDMAIL { return SENDMAIL; }
131 SERVER { return SERVER; }
132 TARGET_IP { return TARGET_IP; }
133 TARGET_PORT { return TARGET_PORT; }
134 TARGET_STRING { return TARGET_STRING;}
135 TIMEOUT { return TIMEOUT; }
136 TYPE { return TYPE; }
137 USER { return USER; }
138 USERNAME { return USERNAME; }
139 VHOST { return VHOST; }
140
141 years { return YEARS; }
142 year { return YEARS; }
143 months { return MONTHS; }
144 month { return MONTHS; }
145 weeks { return WEEKS; }
146 week { return WEEKS; }
147 days { return DAYS; }
148 day { return DAYS; }
149 hours { return HOURS; }
150 hour { return HOURS; }
151 minutes { return MINUTES; }
152 minute { return MINUTES; }
153 seconds { return SECONDS; }
154 second { return SECONDS; }
155
156 bytes { return BYTES; }
157 byte { return BYTES; }
158 kilobytes { return KBYTES; }
159 kilobyte { return KBYTES; }
160 kbytes { return KBYTES; }
161 kbyte { return KBYTES; }
162 kb { return KBYTES; }
163 megabytes { return MBYTES; }
164 megabyte { return MBYTES; }
165 mbytes { return MBYTES; }
166 mbyte { return MBYTES; }
167 mb { return MBYTES; }
168
169 HTTP {
170 yylval.number = OPM_TYPE_HTTP;
171 return PROTOCOLTYPE;
172 }
173
174 HTTPPOST {
175 yylval.number = OPM_TYPE_HTTPPOST;
176 return PROTOCOLTYPE;
177 }
178
179 SOCKS4 {
180 yylval.number = OPM_TYPE_SOCKS4;
181 return PROTOCOLTYPE;
182 }
183
184 SOCKS5 {
185 yylval.number = OPM_TYPE_SOCKS5;
186 return PROTOCOLTYPE;
187 }
188
189 WINGATE {
190 yylval.number = OPM_TYPE_WINGATE;
191 return PROTOCOLTYPE;
192 }
193
194 ROUTER {
195 yylval.number = OPM_TYPE_ROUTER;
196 return PROTOCOLTYPE;
197 }
198
199
200 [0-9]+ {
201 yylval.number=atoi(yytext);
202 return NUMBER;
203 }
204
205
206
207
208
209 TRUE {
210 yylval.number=1;
211 return NUMBER;
212 }
213 YES {
214 yylval.number=1;
215 return NUMBER;
216 }
217 ON {
218 yylval.number=1;
219 return NUMBER;
220 }
221
222
223
224 FALSE {
225 yylval.number=0;
226 return NUMBER;
227 }
228
229 NO {
230 yylval.number=0;
231 return NUMBER;
232 }
233
234 OFF {
235 yylval.number=0;
236 return NUMBER;
237 }
238
239
240 \n.* {
241 strlcpy(linebuf, yytext + 1, sizeof(linebuf));
242 ++linenum;
243 yyless(1);
244 }
245
246 {whitespace} /* ignore whitespace */;
247
248 . return yytext[0];
249
250 %%
251
252
253 /* C-comment ignoring routine -kre*/
254 void ccomment(void)
255 {
256 int c;
257
258 /* log(L_NOTICE, "got comment"); */
259 while (1)
260 {
261 while ((c = input()) != '*' && c != EOF)
262 if (c == '\n') ++linenum;
263 if (c == '*')
264 {
265 while ((c = input()) == '*');
266 if (c == '/') break;
267 }
268 if (c == EOF)
269 {
270 YY_FATAL_ERROR("EOF in comment");
271 /* XXX hack alert this disables
272 * the stupid unused function warning
273 * gcc generates
274 */
275 if(1 == 0)
276 yy_fatal_error("EOF in comment");
277 break;
278 }
279 }
280 }
281

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28