ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
Revision: 7014
Committed: Fri Jan 1 16:08:57 2016 UTC (10 years, 7 months ago) by michael
File size: 10024 byte(s)
Log Message:
- Added 'command_queue_size', 'command_interval', and 'command_timeout', configuration directives to the options {} block. Removed hardcoded settings from options.h.

File Contents

# User Rev Content
1 michael 5052 /*
2 michael 5351 * Copyright (c) 2002 Erik Fears
3 michael 7005 * Copyright (c) 2014-2016 ircd-hybrid development team
4 michael 5052 *
5 michael 5351 * 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 michael 5052 *
10 michael 5351 * 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 michael 5052 *
15 michael 5351 * 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 michael 5052 */
20    
21     %option case-insensitive
22     %option noyywrap
23     %option nounput
24 michael 5687 %option never-interactive
25 michael 5052
26     %{
27     #include <stdio.h>
28     #include <string.h>
29 michael 5078
30     #include "compat.h"
31 michael 5052 #include "config.h"
32     #include "config-parser.h"
33    
34    
35 michael 6046 static void ccomment(void);
36 michael 5052
37 michael 6043 unsigned int linenum = 1;
38 michael 5052 char linebuf[512];
39    
40     %}
41    
42     string \"[^\"\n]*[\"\n]
43 michael 5078 comment ("//"|"#").*
44 michael 5052 whitespace [ \t\r]*
45    
46     %%
47    
48     "/*" { ccomment(); }
49    
50 michael 5078 {comment} ;
51 michael 5052
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 michael 7014 COMMAND_INTERVAL { return COMMAND_INTERVAL; }
95     COMMAND_QUEUE_SIZE { return COMMAND_QUEUE_SIZE; }
96     COMMAND_TIMEOUT { return COMMAND_TIMEOUT; }
97 michael 5052 CONNREGEX { return CONNREGEX; }
98     DNS_FDLIMIT { return DNS_FDLIMIT; }
99 michael 6200 DNS_TIMEOUT { return DNS_TIMEOUT; }
100 michael 5052 DNSBL_FROM { return DNSBL_FROM; }
101     DNSBL_TO { return DNSBL_TO; }
102     EXEMPT { return EXEMPT; }
103     FD { return FD; }
104     INVITE { return INVITE; }
105     IRC { return IRC; }
106     KLINE { return KLINE; }
107     KEY { return KEY; }
108     MASK { return MASK; }
109     MAX_READ { return MAX_READ; }
110     MODE { return MODE; }
111     NAME { return NAME; }
112     NEGCACHE { return NEGCACHE; }
113 michael 5332 NEGCACHE_REBUILD { return NEGCACHE_REBUILD; }
114 michael 5052 NICK { return NICK; }
115     NICKSERV { return NICKSERV; }
116 michael 5405 NOTICE { return NOTICE; }
117 michael 5052 OPER { return OPER; }
118     OPM { return OPM; }
119     OPTIONS { return OPTIONS; }
120     PASSWORD { return PASSWORD; }
121     PERFORM { return PERFORM; }
122     PIDFILE { return PIDFILE; }
123     PORT { return PORT; }
124     PROTOCOL { return PROTOCOL; }
125 michael 5198 READTIMEOUT { return READTIMEOUT; }
126 michael 5052 REALNAME { return REALNAME; }
127 michael 6078 RECONNECTINTERVAL { return RECONNECTINTERVAL; }
128 michael 5052 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 michael 5080 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 michael 5052
157 michael 5080 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 michael 5052 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 michael 6222 HTTPS {
181     yylval.number = OPM_TYPE_HTTPS;
182     return PROTOCOLTYPE;
183     }
184    
185     HTTPSPOST {
186     yylval.number = OPM_TYPE_HTTPSPOST;
187     return PROTOCOLTYPE;
188     }
189    
190 michael 5052 SOCKS4 {
191     yylval.number = OPM_TYPE_SOCKS4;
192     return PROTOCOLTYPE;
193     }
194    
195     SOCKS5 {
196     yylval.number = OPM_TYPE_SOCKS5;
197     return PROTOCOLTYPE;
198     }
199    
200     WINGATE {
201     yylval.number = OPM_TYPE_WINGATE;
202     return PROTOCOLTYPE;
203     }
204    
205     ROUTER {
206     yylval.number = OPM_TYPE_ROUTER;
207     return PROTOCOLTYPE;
208     }
209    
210 michael 5998 DREAMBOX {
211     yylval.number = OPM_TYPE_DREAMBOX;
212     return PROTOCOLTYPE;
213     }
214 michael 5052
215 michael 5998
216    
217 michael 5052 [0-9]+ {
218 michael 5876 yylval.number=atoi(yytext);
219 michael 5052 return NUMBER;
220     }
221    
222    
223    
224    
225    
226     TRUE {
227     yylval.number=1;
228     return NUMBER;
229     }
230     YES {
231     yylval.number=1;
232     return NUMBER;
233     }
234     ON {
235     yylval.number=1;
236     return NUMBER;
237     }
238    
239    
240    
241     FALSE {
242     yylval.number=0;
243     return NUMBER;
244     }
245    
246     NO {
247     yylval.number=0;
248     return NUMBER;
249     }
250    
251     OFF {
252     yylval.number=0;
253     return NUMBER;
254     }
255    
256    
257 michael 5078 \n.* {
258     strlcpy(linebuf, yytext + 1, sizeof(linebuf));
259     ++linenum;
260     yyless(1);
261     }
262 michael 5052
263     {whitespace} /* ignore whitespace */;
264    
265 michael 5876 . return yytext[0];
266 michael 5052
267     %%
268    
269    
270     /* C-comment ignoring routine -kre*/
271 michael 6046 static void
272 michael 6042 ccomment(void)
273 michael 5052 {
274 michael 6042 int c = 0;
275 michael 5052
276     /* log(L_NOTICE, "got comment"); */
277     while (1)
278     {
279 michael 6042 while ((c = input()) != '*' && c != EOF)
280     if (c == '\n')
281     ++linenum;
282    
283     if (c == '*')
284     {
285     while ((c = input()) == '*')
286     /* Nothing */ ;
287     if (c == '/')
288     break;
289     else if (c == '\n')
290     ++linenum;
291     }
292    
293 michael 5052 if (c == EOF)
294     {
295 michael 6042 YY_FATAL_ERROR("EOF in comment");
296    
297     /* XXX hack alert this disables
298     * the stupid unused function warning
299     * gcc generates
300     */
301     if (1 == 0)
302     yy_fatal_error("EOF in comment");
303     break;
304 michael 5052 }
305     }
306     }

Properties

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