ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
Revision: 5687
Committed: Sat Mar 14 18:45:55 2015 UTC (11 years, 5 months ago) by michael
File size: 9200 byte(s)
Log Message:
- config-lexer.l: added 'never-interactive' to scanner options

File Contents

# User Rev Content
1 michael 5052 /*
2 michael 5351 * Copyright (c) 2002 Erik Fears
3     * Copyright (c) 2014-2015 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     void ccomment(void);
36    
37     int linenum = 1;
38     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    
91     AWAY { return AWAY; }
92     BAN_UNKNOWN { return BAN_UNKNOWN; }
93     BLACKLIST { return BLACKLIST; }
94     CHANNEL { return CHANNEL; }
95     CONNREGEX { return CONNREGEX; }
96     DNS_FDLIMIT { return DNS_FDLIMIT; }
97     DNSBL_FROM { return DNSBL_FROM; }
98     DNSBL_TO { return DNSBL_TO; }
99     EXEMPT { return EXEMPT; }
100     FD { return FD; }
101     INVITE { return INVITE; }
102     IRC { return IRC; }
103     KLINE { return KLINE; }
104     KEY { return KEY; }
105     MASK { return MASK; }
106     MAX_READ { return MAX_READ; }
107     MODE { return MODE; }
108     NAME { return NAME; }
109     NEGCACHE { return NEGCACHE; }
110 michael 5332 NEGCACHE_REBUILD { return NEGCACHE_REBUILD; }
111 michael 5052 NICK { return NICK; }
112     NICKSERV { return NICKSERV; }
113 michael 5405 NOTICE { return NOTICE; }
114 michael 5052 OPER { return OPER; }
115     OPM { return OPM; }
116     OPTIONS { return OPTIONS; }
117     PASSWORD { return PASSWORD; }
118     PERFORM { return PERFORM; }
119     PIDFILE { return PIDFILE; }
120     PORT { return PORT; }
121     PROTOCOL { return PROTOCOL; }
122 michael 5198 READTIMEOUT { return READTIMEOUT; }
123 michael 5052 REALNAME { return REALNAME; }
124     REPLY { return REPLY; }
125     SCANLOG { return SCANLOG; }
126     SCANNER { return SCANNER; }
127     SENDMAIL { return SENDMAIL; }
128     SERVER { return SERVER; }
129     TARGET_IP { return TARGET_IP; }
130     TARGET_PORT { return TARGET_PORT; }
131     TARGET_STRING { return TARGET_STRING;}
132     TIMEOUT { return TIMEOUT; }
133     TYPE { return TYPE; }
134     USER { return USER; }
135     USERNAME { return USERNAME; }
136     VHOST { return VHOST; }
137    
138 michael 5080 years { return YEARS; }
139     year { return YEARS; }
140     months { return MONTHS; }
141     month { return MONTHS; }
142     weeks { return WEEKS; }
143     week { return WEEKS; }
144     days { return DAYS; }
145     day { return DAYS; }
146     hours { return HOURS; }
147     hour { return HOURS; }
148     minutes { return MINUTES; }
149     minute { return MINUTES; }
150     seconds { return SECONDS; }
151     second { return SECONDS; }
152 michael 5052
153 michael 5080 bytes { return BYTES; }
154     byte { return BYTES; }
155     kilobytes { return KBYTES; }
156     kilobyte { return KBYTES; }
157     kbytes { return KBYTES; }
158     kbyte { return KBYTES; }
159     kb { return KBYTES; }
160     megabytes { return MBYTES; }
161     megabyte { return MBYTES; }
162     mbytes { return MBYTES; }
163     mbyte { return MBYTES; }
164     mb { return MBYTES; }
165    
166 michael 5052 HTTP {
167     yylval.number = OPM_TYPE_HTTP;
168     return PROTOCOLTYPE;
169     }
170    
171     HTTPPOST {
172     yylval.number = OPM_TYPE_HTTPPOST;
173     return PROTOCOLTYPE;
174     }
175    
176     SOCKS4 {
177     yylval.number = OPM_TYPE_SOCKS4;
178     return PROTOCOLTYPE;
179     }
180    
181     SOCKS5 {
182     yylval.number = OPM_TYPE_SOCKS5;
183     return PROTOCOLTYPE;
184     }
185    
186     WINGATE {
187     yylval.number = OPM_TYPE_WINGATE;
188     return PROTOCOLTYPE;
189     }
190    
191     ROUTER {
192     yylval.number = OPM_TYPE_ROUTER;
193     return PROTOCOLTYPE;
194     }
195    
196    
197     [0-9]+ {
198     yylval.number=atoi(yytext);
199     return NUMBER;
200     }
201    
202    
203    
204    
205    
206     TRUE {
207     yylval.number=1;
208     return NUMBER;
209     }
210     YES {
211     yylval.number=1;
212     return NUMBER;
213     }
214     ON {
215     yylval.number=1;
216     return NUMBER;
217     }
218    
219    
220    
221     FALSE {
222     yylval.number=0;
223     return NUMBER;
224     }
225    
226     NO {
227     yylval.number=0;
228     return NUMBER;
229     }
230    
231     OFF {
232     yylval.number=0;
233     return NUMBER;
234     }
235    
236    
237 michael 5078 \n.* {
238     strlcpy(linebuf, yytext + 1, sizeof(linebuf));
239     ++linenum;
240     yyless(1);
241     }
242 michael 5052
243     {whitespace} /* ignore whitespace */;
244    
245     . return yytext[0];
246    
247     %%
248    
249    
250     /* C-comment ignoring routine -kre*/
251     void ccomment(void)
252     {
253     int c;
254    
255     /* log(L_NOTICE, "got comment"); */
256     while (1)
257     {
258     while ((c = input()) != '*' && c != EOF)
259     if (c == '\n') ++linenum;
260     if (c == '*')
261     {
262     while ((c = input()) == '*');
263     if (c == '/') break;
264     }
265     if (c == EOF)
266     {
267     YY_FATAL_ERROR("EOF in comment");
268     /* XXX hack alert this disables
269     * the stupid unused function warning
270     * gcc generates
271     */
272     if(1 == 0)
273     yy_fatal_error("EOF in comment");
274     break;
275     }
276     }
277     }
278    

Properties

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