ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
Revision: 5351
Committed: Sun Jan 11 13:24:19 2015 UTC (11 years, 6 months ago) by michael
File size: 9125 byte(s)
Log Message:
- Update license headers

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

Properties

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