ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_lexer.l
Revision: 1432
Committed: Sat Jun 9 19:40:08 2012 UTC (14 years, 1 month ago) by michael
Original Path: ircd-hybrid-8/src/conf_lexer.l
File size: 16220 byte(s)
Log Message:
- Added channel::max_chans_per_oper configuration directive. The old way
  was to let ircops join three times the amount of max_chans_per_user.

  I'd rather would make this a class{} based limit, but this would require us
  to reprint the ISUPPORT buffer every time a client connects.

File Contents

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

Properties

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