ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_lexer.l
Revision: 1302
Committed: Wed Mar 21 17:48:54 2012 UTC (13 years, 5 months ago) by michael
Original Path: ircd-hybrid-8/src/ircd_lexer.l
File size: 15866 byte(s)
Log Message:
- remove servlink in preparation for tls links/compression

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * ircd_lexer.l: Scans the ircd configuration file for tokens.
4     *
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 modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (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 the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     %option case-insensitive
26     %option noyywrap
27     %option nounput
28     %option never-interactive
29    
30     %{
31     #include "stdinc.h"
32     #include "irc_string.h"
33     #include "s_conf.h"
34     #include "memory.h"
35     #include "hostmask.h"
36     #include "s_log.h"
37    
38 stu 908 #include "ircd_parser.h"
39 adx 30
40     #undef YY_INPUT
41     #define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg)
42     #define YY_INPUT(buf,result,max_size) \
43 michael 967 if (!(result = conf_fbgets(buf, max_size, conf_parser_ctx.conf_file))) \
44 adx 30 YY_FATAL_ERROR("input in flex scanner failed");
45     #define MAX_INCLUDE_DEPTH 10
46    
47    
48     unsigned int lineno = 1;
49     char linebuf[IRCD_BUFSIZE];
50     char conffilebuf[IRCD_BUFSIZE];
51    
52     static int include_stack_ptr = 0;
53     static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
54     static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
55     static FBFILE *inc_fbfile_in[MAX_INCLUDE_DEPTH];
56     static char conffile_stack[MAX_INCLUDE_DEPTH][IRCD_BUFSIZE];
57     static void ccomment(void);
58     static void cinclude(void);
59     static int ieof(void);
60     %}
61    
62     WS [[:blank:]]*
63     DIGIT [[:digit:]]+
64     COMMENT ("//"|"#").*
65     qstring \"[^\"\n]*[\"\n]
66     include \.include{WS}(\<.*\>|\".*\")
67    
68     %%
69     {include} { cinclude(); }
70     "/*" { ccomment(); }
71    
72     \n.* { strcpy(linebuf, yytext+1); ++lineno; yyless(1); }
73    
74     {WS} ;
75     {COMMENT} ;
76    
77     {DIGIT} { yylval.number = atoi(yytext); return NUMBER; }
78    
79     {qstring} { if (yytext[yyleng-2] == '\\')
80     {
81     yyless(yyleng-1); /* return last quote */
82     yymore(); /* append next string */
83     }
84     else
85     {
86     yylval.string = yytext+1;
87     if(yylval.string[yyleng-2] != '"')
88 michael 1247 ilog(LOG_TYPE_IRCD, "Unterminated character string");
89 adx 30 else
90     {
91     int i,j;
92    
93     yylval.string[yyleng-2] = '\0'; /* remove close
94     * quote
95     */
96    
97     for (j=i=0 ;yylval.string[i] != '\0'; i++,j++)
98     {
99     if (yylval.string[i] != '\\')
100     {
101     yylval.string[j] = yylval.string[i];
102     }
103     else
104     {
105     i++;
106     if (yylval.string[i] == '\0') /* XXX
107     * should not
108     * happen
109     */
110     {
111 michael 1247 ilog(LOG_TYPE_IRCD,
112 adx 30 "Unterminated character string");
113     break;
114     }
115     yylval.string[j] = yylval.string[i];
116     }
117     }
118     yylval.string[j] = '\0';
119     return QSTRING;
120     }
121     }
122     }
123    
124     accept_password { return ACCEPT_PASSWORD; }
125     action { return ACTION; }
126     admin { return ADMIN; }
127     administrator { return ADMIN; }
128     aftype { return AFTYPE; }
129     all { return T_ALL; }
130     allow { return T_ALLOW; }
131     auth { return IRCD_AUTH; }
132     autoconn { return AUTOCONN; }
133     block { return T_BLOCK; }
134     burst_away { return BURST_AWAY; }
135     burst_topicwho { return BURST_TOPICWHO; }
136     can_flood { return CAN_FLOOD; }
137     caller_id_wait { return CALLER_ID_WAIT; }
138     opers_bypass_callerid { return OPERS_BYPASS_CALLERID; }
139     channel { return CHANNEL; }
140     cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; }
141     cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; }
142     class { return CLASS; }
143     client_flood { return T_CLIENT_FLOOD; }
144     cluster { return T_CLUSTER; }
145     connect { return CONNECT; }
146     connectfreq { return CONNECTFREQ; }
147     default_floodcount { return DEFAULT_FLOODCOUNT; }
148     default_split_server_count { return DEFAULT_SPLIT_SERVER_COUNT; }
149     default_split_user_count { return DEFAULT_SPLIT_USER_COUNT; }
150     deny { return DENY; }
151     description { return DESCRIPTION; }
152     die { return DIE; }
153     disable_auth { return DISABLE_AUTH; }
154 michael 632 disable_fake_channels { return DISABLE_FAKE_CHANNELS; }
155 adx 30 disable_hidden { return DISABLE_HIDDEN; }
156     disable_local_channels { return DISABLE_LOCAL_CHANNELS; }
157     disable_remote_commands { return DISABLE_REMOTE_COMMANDS; }
158 michael 1250 dline { return T_DLINE; }
159 adx 30 dots_in_ident { return DOTS_IN_IDENT; }
160     duration { return DURATION; }
161     egdpool_path { return EGDPOOL_PATH; }
162     email { return EMAIL; }
163     enable { return ENABLE; }
164     encrypted { return ENCRYPTED; }
165     exceed_limit { return EXCEED_LIMIT; }
166     exempt { return EXEMPT; }
167 michael 1247 file { return T_FILE; }
168 adx 30 flags { return IRCD_FLAGS; }
169     flatten_links { return FLATTEN_LINKS; }
170     gecos { return GECOS; }
171     general { return GENERAL; }
172     gline { return GLINE; }
173     glines { return GLINES; }
174     gline_exempt { return GLINE_EXEMPT; }
175     gline_min_cidr { return GLINE_MIN_CIDR; }
176     gline_min_cidr6 { return GLINE_MIN_CIDR6; }
177 michael 1216 globops { return T_GLOBOPS; }
178 adx 30 global_kill { return GLOBAL_KILL; }
179     have_ident { return NEED_IDENT; }
180     need_ident { return NEED_IDENT; }
181     havent_read_conf { return HAVENT_READ_CONF; }
182     hidden { return HIDDEN; }
183     hidden_name { return HIDDEN_NAME; }
184     hide_server_ips { return HIDE_SERVER_IPS; }
185     hide_servers { return HIDE_SERVERS; }
186     hide_spoof_ips { return HIDE_SPOOF_IPS; }
187     host { return HOST; }
188     hub { return HUB; }
189     hub_mask { return HUB_MASK; }
190     ignore_bogus_ts { return IGNORE_BOGUS_TS; }
191     invisible_on_connect { return INVISIBLE_ON_CONNECT; }
192     ip { return IP; }
193     ipv4 { return T_IPV4; }
194     ipv6 { return T_IPV6; }
195     join_flood_count { return JOIN_FLOOD_COUNT; }
196     join_flood_time { return JOIN_FLOOD_TIME; }
197     kill { return KILL; }
198     kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; }
199     kline { return KLINE; }
200     kline_exempt { return KLINE_EXEMPT; }
201     leaf_mask { return LEAF_MASK; }
202     listen { return LISTEN; }
203 michael 1247 log { return T_LOG; }
204 adx 30 masked { return TMASKED; }
205     max_clients { return T_MAX_CLIENTS; }
206     max_ident { return MAX_IDENT; }
207     max_local { return MAX_LOCAL; }
208     max_global { return MAX_GLOBAL; }
209     max_number { return MAX_NUMBER; }
210 michael 876 max_watch { return MAX_WATCH; }
211 adx 30 message_locale { return MESSAGE_LOCALE; }
212     min_nonwildcard { return MIN_NONWILDCARD; }
213     min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; }
214     name { return NAME; }
215     need_password { return NEED_PASSWORD; }
216     network_desc { return NETWORK_DESC; }
217     network_name { return NETWORK_NAME; }
218     nick { return NICK; }
219     nick_changes { return NICK_CHANGES; }
220 michael 1243 no { yylval.number = 0; return TBOOL; }
221 adx 30 no_create_on_split { return NO_CREATE_ON_SPLIT; }
222     no_join_on_split { return NO_JOIN_ON_SPLIT; }
223     no_oper_flood { return NO_OPER_FLOOD; }
224     no_tilde { return NO_TILDE; }
225     number_per_cidr { return NUMBER_PER_CIDR; }
226     number_per_ip { return NUMBER_PER_IP; }
227     oper { return OPERATOR; }
228     oper_pass_resv { return OPER_PASS_RESV; }
229     operator { return OPERATOR; }
230     passwd { return PASSWORD; }
231     password { return PASSWORD; }
232     ping_cookie { return PING_COOKIE; }
233     ping_time { return PING_TIME; }
234     ping_warning { return PING_WARNING; }
235     port { return PORT; }
236     quarantine { return RESV; }
237     quiet_on_ban { return QUIET_ON_BAN; }
238     reason { return REASON; }
239     redirport { return REDIRPORT; }
240     redirserv { return REDIRSERV; }
241     regex { return REGEX_T; }
242     rehash { return REHASH; }
243     reject { return T_REJECT; }
244     reject_hold_time { return TREJECT_HOLD_TIME; }
245     remote { return REMOTE; }
246     remoteban { return REMOTEBAN; }
247 michael 1228 restart { return T_RESTART; }
248 adx 30 restrict_channels { return RESTRICT_CHANNELS; }
249     resv { return RESV; }
250     resv_exempt { return RESV_EXEMPT; }
251     rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; }
252     rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; }
253     ssl { return T_SSL; }
254     ssl_certificate_file { return SSL_CERTIFICATE_FILE; }
255 michael 967 ssl_server_protocol { return T_SSL_CONNECTION_METHOD; }
256     sslv3 { return T_SSLV3; }
257     tlsv1 { return T_TLSV1; }
258 adx 30 send_password { return SEND_PASSWORD; }
259     sendq { return SENDQ; }
260 michael 900 server { return T_SERVER; }
261 adx 30 serverhide { return SERVERHIDE; }
262     serverinfo { return SERVERINFO; }
263 michael 1175 service { return T_SERVICE; }
264 michael 1176 services_name { return T_SERVICES_NAME; }
265 adx 30 shared { return T_SHARED; }
266     short_motd { return SHORT_MOTD; }
267     sid { return IRCD_SID; }
268     silent { return SILENT; }
269 michael 1247 size { return T_SIZE; }
270 adx 30 spoof { return SPOOF; }
271     spoof_notice { return SPOOF_NOTICE; }
272 michael 1247 timestamp { return T_TIMESTAMP; }
273 adx 30 tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; }
274     type { return TYPE; }
275     true_no_oper_flood { return TRUE_NO_OPER_FLOOD; }
276 michael 56 umodes { return T_UMODES; }
277 adx 30 unkline { return UNKLINE; }
278 michael 1301 undline { return T_UNDLINE; }
279 michael 1250 unlimited { return T_UNLIMITED; }
280 adx 30 use_egd { return USE_EGD; }
281     use_except { return USE_EXCEPT; }
282     use_invex { return USE_INVEX; }
283     use_knock { return USE_KNOCK; }
284     use_logging { return USE_LOGGING; }
285     use_whois_actually { return USE_WHOIS_ACTUALLY; }
286     throttle_time { return THROTTLE_TIME; }
287     user { return USER; }
288     tkline { return TKLINE; }
289     txline { return TXLINE; }
290     tresv { return TRESV; }
291     vhost { return VHOST; }
292     vhost6 { return VHOST6; }
293     warn { return WARN; }
294     xline { return XLINE; }
295 michael 1243 yes { yylval.number = 1; return TBOOL; }
296 adx 30
297     failed_oper_notice { return FAILED_OPER_NOTICE; }
298     max_accept { return MAX_ACCEPT; }
299     max_nick_changes { return MAX_NICK_CHANGES; }
300     max_chans_per_user { return MAX_CHANS_PER_USER; }
301     max_nick_time { return MAX_NICK_TIME; }
302     anti_nick_flood { return ANTI_NICK_FLOOD; }
303     anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; }
304     ts_max_delta { return TS_MAX_DELTA; }
305     ts_warn_delta { return TS_WARN_DELTA; }
306     links_delay { return LINKS_DELAY; }
307     kline_reason { return KLINE_REASON; }
308     kline_with_reason { return KLINE_WITH_REASON; }
309     warn_no_nline { return WARN_NO_NLINE; }
310    
311 michael 584 stats_e_disabled { return STATS_E_DISABLED; }
312 adx 30 stats_o_oper_only { return STATS_O_OPER_ONLY; }
313     stats_k_oper_only { return STATS_K_OPER_ONLY; }
314     stats_i_oper_only { return STATS_I_OPER_ONLY; }
315     stats_P_oper_only { return STATS_P_OPER_ONLY; }
316     pace_wait { return PACE_WAIT; }
317     pace_wait_simple { return PACE_WAIT_SIMPLE; }
318     knock_delay { return KNOCK_DELAY; }
319     knock_delay_channel { return KNOCK_DELAY_CHANNEL; }
320     max_bans { return MAX_BANS; }
321     modules { return MODULES; }
322     module { return MODULE; }
323     path { return PATH; }
324     max_targets { return MAX_TARGETS; }
325    
326     unxline { return T_UNXLINE; }
327     unresv { return T_UNRESV; }
328    
329     oper_only_umodes { return OPER_ONLY_UMODES; }
330     oper_umodes { return OPER_UMODES; }
331     bots { return T_BOTS; }
332     cconn { return T_CCONN; }
333 db 849 cconn_full { return T_CCONN_FULL; }
334 adx 30 deaf { return T_DEAF; }
335     debug { return T_DEBUG; }
336     full { return T_FULL; }
337     skill { return T_SKILL; }
338     nchange { return T_NCHANGE; }
339     rej { return T_REJ; }
340     unauth { return T_UNAUTH; }
341     spy { return T_SPY; }
342     external { return T_EXTERNAL; }
343     operwall { return T_OPERWALL; }
344     servnotice { return T_SERVNOTICE; }
345     invisible { return T_INVISIBLE; }
346     wallop { return T_WALLOP; }
347     callerid { return T_CALLERID; }
348     softcallerid { return T_SOFTCALLERID; }
349     drone { return T_DRONE; }
350     locops { return T_LOCOPS; }
351     topicburst { return TOPICBURST; }
352    
353     weeks { return WEEKS; }
354     week { return WEEKS; }
355     days { return DAYS; }
356     day { return DAYS; }
357     hours { return HOURS; }
358     hour { return HOURS; }
359     minutes { return MINUTES; }
360     minute { return MINUTES; }
361     seconds { return SECONDS; }
362     second { return SECONDS; }
363    
364     bytes { return BYTES; }
365     byte { return BYTES; }
366     kilobytes { return KBYTES; }
367     kilobyte { return KBYTES; }
368     kbytes { return KBYTES; }
369     kbyte { return KBYTES; }
370     kb { return KBYTES; }
371     megabytes { return MBYTES; }
372     megabyte { return MBYTES; }
373     mbytes { return MBYTES; }
374     mbyte { return MBYTES; }
375     mb { return MBYTES; }
376     gigabytes { return GBYTES; }
377     gigabyte { return GBYTES; }
378     gbytes { return GBYTES; }
379     gbyte { return GBYTES; }
380     gb { return GBYTES; }
381     terabytes { return TBYTES; }
382     terabyte { return TBYTES; }
383     tbytes { return TBYTES; }
384     tbyte { return TBYTES; }
385     tb { return TBYTES; }
386     \.\. { return TWODOTS; }
387    
388     . { return yytext[0]; }
389     <<EOF>> { if (ieof()) yyterminate(); }
390    
391     %%
392    
393     /* C-comment ignoring routine -kre*/
394     static void
395     ccomment(void)
396     {
397     int c = 0;
398    
399     /* log(L_NOTICE, "got comment"); */
400     while (1)
401     {
402     while ((c = input()) != '*' && c != EOF)
403     if (c == '\n')
404     ++lineno;
405    
406     if (c == '*')
407     {
408     while ((c = input()) == '*')
409     /* Nothing */ ;
410     if (c == '/')
411     break;
412     else if (c == '\n')
413     ++lineno;
414     }
415    
416     if (c == EOF)
417     {
418     YY_FATAL_ERROR("EOF in comment");
419     /* XXX hack alert this disables
420     * the stupid unused function warning
421     * gcc generates
422     */
423     if (1 == 0)
424     yy_fatal_error("EOF in comment");
425     break;
426     }
427     }
428     }
429    
430     /* C-style .includes. This function will properly swap input conf buffers,
431     * and lineno -kre */
432     static void
433     cinclude(void)
434     {
435     char *p = NULL;
436    
437     if ((p = strchr(yytext, '<')) == NULL)
438     *strchr(p = strchr(yytext, '"') + 1, '"') = '\0';
439     else
440     *strchr(++p, '>') = '\0';
441    
442     /* log(L_NOTICE, "got include %s!", c); */
443    
444     /* do stacking and co. */
445     if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
446 michael 1247 ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p);
447 adx 30 else
448     {
449     FBFILE *tmp_fbfile_in = NULL;
450     char filenamebuf[IRCD_BUFSIZE];
451    
452     if (*p == '/') /* if it is an absolute path */
453     snprintf(filenamebuf, sizeof(filenamebuf), "%s", p);
454     else
455     snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p);
456    
457     tmp_fbfile_in = fbopen(filenamebuf, "r");
458    
459     if (tmp_fbfile_in == NULL)
460     {
461 michael 1247 ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
462 adx 30 filenamebuf, strerror(errno));
463     return;
464     }
465    
466     lineno_stack[include_stack_ptr] = lineno;
467     lineno = 1;
468 michael 967 inc_fbfile_in[include_stack_ptr] = conf_parser_ctx.conf_file;
469 adx 30 strlcpy(conffile_stack[include_stack_ptr], conffilebuf, IRCD_BUFSIZE);
470     include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
471 michael 967 conf_parser_ctx.conf_file = tmp_fbfile_in;
472 michael 711 snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf);
473 adx 30 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
474     }
475     }
476    
477     /* This is function that will be called on EOF in conf file. It will
478     * apropriately close conf if it not main conf and swap input buffers -kre
479     * */
480     static int
481     ieof(void)
482     {
483     /* log(L_NOTICE, "return from include stack!"); */
484     if (include_stack_ptr)
485 michael 967 fbclose(conf_parser_ctx.conf_file);
486 adx 30 if (--include_stack_ptr < 0)
487     {
488     /* log(L_NOTICE, "terminating lexer"); */
489     /* We will now exit the lexer - restore init values if we get /rehash
490     * later and reenter lexer -kre */
491     include_stack_ptr = 0;
492     lineno = 1;
493     return 1;
494     }
495    
496     /* switch buffer */
497     /* log(L_NOTICE, "deleting include_stack_ptr=%d", include_stack_ptr); */
498     yy_delete_buffer(YY_CURRENT_BUFFER);
499     lineno = lineno_stack[include_stack_ptr];
500 michael 967 conf_parser_ctx.conf_file = inc_fbfile_in[include_stack_ptr];
501 adx 30 strlcpy(conffilebuf, conffile_stack[include_stack_ptr], sizeof(conffilebuf));
502     yy_switch_to_buffer(include_stack[include_stack_ptr]);
503    
504     return 0;
505     }

Properties

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