ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
Revision: 5175
Committed: Fri Dec 26 21:09:41 2014 UTC (11 years, 7 months ago) by michael
File size: 9119 byte(s)
Log Message:
- Removed now unused inet.c and inet.h

File Contents

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

Properties

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