ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_lexer.l
Revision: 7766
Committed: Fri Oct 7 16:27:37 2016 UTC (9 years, 11 months ago) by michael
File size: 19588 byte(s)
Log Message:
- Added 'channel::max_invites' configuration directive

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2000-2016 ircd-hybrid development team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file conf_lexer.l
23 * \brief Scans the ircd configuration file for tokens.
24 * \version $Id$
25 */
26
27 %option case-insensitive
28 %option noyywrap
29 %option nounput
30 %option never-interactive
31
32 %{
33 #include "stdinc.h"
34 #include "irc_string.h"
35 #include "conf.h"
36 #include "conf_parser.h" /* autogenerated header file */
37 #include "log.h"
38
39 #undef YY_INPUT
40 #define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg)
41 #define YY_INPUT(buf,result,max_size) \
42 if (!(result = conf_yy_input(buf, max_size))) \
43 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 struct included_file
52 {
53 YY_BUFFER_STATE state;
54 unsigned int lineno;
55 FILE *file;
56 char conffile[IRCD_BUFSIZE];
57 } include_stack[MAX_INCLUDE_DEPTH];
58
59 static unsigned int include_stack_ptr;
60
61 static void ccomment(void);
62 static void cinclude(void);
63 static int ieof(void);
64
65 static int
66 conf_yy_input(char *lbuf, unsigned int max_size)
67 {
68 return !fgets(lbuf, max_size, conf_parser_ctx.conf_file) ? 0 : strlen(lbuf);
69 }
70
71 static int
72 conf_yy_fatal_error(const char *msg)
73 {
74 return 0;
75 }
76
77 %}
78
79 WS [[:blank:]]*
80 DIGIT [[:digit:]]+
81 COMMENT ("//"|"#").*
82 qstring \"[^\"\n]*[\"\n]
83 include \.include{WS}(\<.*\>|\".*\")
84
85 %%
86 {include} { cinclude(); }
87 "/*" { ccomment(); }
88 \n.* { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); }
89 {WS} ;
90 {COMMENT} ;
91 {DIGIT} { yylval.number = atoi(yytext); return NUMBER; }
92 {qstring} { if (yytext[yyleng - 2] == '\\')
93 {
94 yyless(yyleng - 1); /* Return last quote */
95 yymore(); /* Append next string */
96 }
97 else
98 {
99 yylval.string = yytext + 1;
100
101 if (yylval.string[yyleng - 2] != '"')
102 ilog(LOG_TYPE_IRCD, "Unterminated character string");
103 else
104 {
105 unsigned int i = 0, j = 0;
106
107 yylval.string[yyleng - 2] = '\0'; /* Remove close quote */
108
109 for (; yylval.string[i] != '\0'; ++i, ++j)
110 {
111 if (yylval.string[i] != '\\')
112 yylval.string[j] = yylval.string[i];
113 else
114 {
115 ++i;
116
117 if (yylval.string[i] == '\0') /* XXX: should not happen */
118 {
119 ilog(LOG_TYPE_IRCD, "Unterminated character string");
120 break;
121 }
122
123 yylval.string[j] = yylval.string[i];
124 }
125 }
126
127 yylval.string[j] = '\0';
128 return QSTRING;
129 }
130 }
131 }
132
133 accept_password { return ACCEPT_PASSWORD; }
134 admin { return ADMIN; }
135 administrator { return ADMIN; }
136 aftype { return AFTYPE; }
137 all { return T_ALL; }
138 anti_nick_flood { return ANTI_NICK_FLOOD; }
139 anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; }
140 auth { return IRCD_AUTH; }
141 autoconn { return AUTOCONN; }
142 away_count { return AWAY_COUNT; }
143 away_time { return AWAY_TIME; }
144 bots { return T_BOTS; }
145 caller_id_wait { return CALLER_ID_WAIT; }
146 callerid { return T_CALLERID; }
147 can_flood { return CAN_FLOOD; }
148 cconn { return T_CCONN; }
149 channel { return CHANNEL; }
150 check_cache { return CHECK_CACHE; }
151 cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; }
152 cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; }
153 class { return CLASS; }
154 close { return CLOSE; }
155 cluster { return T_CLUSTER; }
156 command { return T_COMMAND; }
157 connect { return CONNECT; }
158 connectfreq { return CONNECTFREQ; }
159 cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; }
160 deaf { return T_DEAF; }
161 debug { return T_DEBUG; }
162 default_floodcount { return DEFAULT_FLOODCOUNT; }
163 default_join_flood_count { return DEFAULT_JOIN_FLOOD_COUNT; }
164 default_join_flood_time { return DEFAULT_JOIN_FLOOD_TIME; }
165 default_max_clients { return DEFAULT_MAX_CLIENTS; }
166 deny { return DENY; }
167 description { return DESCRIPTION; }
168 die { return DIE; }
169 disable_auth { return DISABLE_AUTH; }
170 disable_fake_channels { return DISABLE_FAKE_CHANNELS; }
171 disable_remote_commands { return DISABLE_REMOTE_COMMANDS; }
172 dline { return T_DLINE; }
173 dline_min_cidr { return DLINE_MIN_CIDR; }
174 dline_min_cidr6 { return DLINE_MIN_CIDR6; }
175 dots_in_ident { return DOTS_IN_IDENT; }
176 email { return EMAIL; }
177 encrypted { return ENCRYPTED; }
178 exceed_limit { return EXCEED_LIMIT; }
179 exempt { return EXEMPT; }
180 external { return T_EXTERNAL; }
181 failed_oper_notice { return FAILED_OPER_NOTICE; }
182 farconnect { return T_FARCONNECT; }
183 file { return T_FILE; }
184 flags { return IRCD_FLAGS; }
185 flatten_links { return FLATTEN_LINKS; }
186 flatten_links_delay { return FLATTEN_LINKS_DELAY; }
187 flatten_links_file { return FLATTEN_LINKS_FILE; }
188 full { return T_FULL; }
189 gecos { return GECOS; }
190 general { return GENERAL; }
191 kline_min_cidr { return KLINE_MIN_CIDR; }
192 kline_min_cidr6 { return KLINE_MIN_CIDR6; }
193 globops { return T_GLOBOPS; }
194 have_ident { return NEED_IDENT; }
195 hidden { return HIDDEN; }
196 hidden_name { return HIDDEN_NAME; }
197 hidechans { return HIDE_CHANS; }
198 hideidle { return HIDE_IDLE; }
199 hide_idle_from_opers { return HIDE_IDLE_FROM_OPERS; }
200 hide_server_ips { return HIDE_SERVER_IPS; }
201 hide_servers { return HIDE_SERVERS; }
202 hide_services { return HIDE_SERVICES; }
203 host { return HOST; }
204 hub { return HUB; }
205 hub_mask { return HUB_MASK; }
206 ignore_bogus_ts { return IGNORE_BOGUS_TS; }
207 invisible { return T_INVISIBLE; }
208 invisible_on_connect { return INVISIBLE_ON_CONNECT; }
209 invite_client_count { return INVITE_CLIENT_COUNT; }
210 invite_client_time { return INVITE_CLIENT_TIME; }
211 invite_delay_channel { return INVITE_DELAY_CHANNEL; }
212 ip { return IP; }
213 ipv4 { return T_IPV4; }
214 ipv6 { return T_IPV6; }
215 join { return JOIN; }
216 kill { return KILL; }
217 kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; }
218 kline { return KLINE; }
219 kline_exempt { return KLINE_EXEMPT; }
220 knock_client_count { return KNOCK_CLIENT_COUNT; }
221 knock_client_time { return KNOCK_CLIENT_TIME; }
222 knock_delay_channel { return KNOCK_DELAY_CHANNEL; }
223 leaf_mask { return LEAF_MASK; }
224 libgeoip_database_options { return LIBGEOIP_DATABASE_OPTIONS; }
225 libgeoip_ipv4_database_file { return LIBGEOIP_IPV4_DATABASE_FILE; }
226 libgeoip_ipv6_database_file { return LIBGEOIP_IPV6_DATABASE_FILE; }
227 listen { return LISTEN; }
228 locops { return T_LOCOPS; }
229 log { return T_LOG; }
230 mask { return MASK; }
231 masked { return TMASKED; }
232 max_accept { return MAX_ACCEPT; }
233 max_bans { return MAX_BANS; }
234 max_channels { return MAX_CHANNELS; }
235 max_global { return MAX_GLOBAL; }
236 max_idle { return MAX_IDLE; }
237 max_invites { return MAX_INVITES; }
238 max_local { return MAX_LOCAL; }
239 max_nick_changes { return MAX_NICK_CHANGES; }
240 max_nick_length { return MAX_NICK_LENGTH; }
241 max_nick_time { return MAX_NICK_TIME; }
242 max_number { return MAX_NUMBER; }
243 max_targets { return MAX_TARGETS; }
244 max_topic_length { return MAX_TOPIC_LENGTH; }
245 max_watch { return MAX_WATCH; }
246 memory_cache { return MEMORY_CACHE; }
247 min_idle { return MIN_IDLE; }
248 min_nonwildcard { return MIN_NONWILDCARD; }
249 min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; }
250 mmap_cache { return MMAP_CACHE; }
251 module { return MODULE; }
252 modules { return MODULES; }
253 motd { return MOTD; }
254 name { return NAME; }
255 nchange { return T_NCHANGE; }
256 need_ident { return NEED_IDENT; }
257 need_password { return NEED_PASSWORD; }
258 network_desc { return NETWORK_DESC; }
259 network_name { return NETWORK_NAME; }
260 nick { return NICK; }
261 no_oper_flood { return NO_OPER_FLOOD; }
262 no_tilde { return NO_TILDE; }
263 nononreg { return T_NONONREG; }
264 number_per_cidr { return NUMBER_PER_CIDR; }
265 number_per_ip { return NUMBER_PER_IP; }
266 oper { return OPERATOR; }
267 oper_only_umodes { return OPER_ONLY_UMODES; }
268 oper_umodes { return OPER_UMODES; }
269 operator { return OPERATOR; }
270 opers_bypass_callerid { return OPERS_BYPASS_CALLERID; }
271 opme { return T_OPME; }
272 pace_wait { return PACE_WAIT; }
273 pace_wait_simple { return PACE_WAIT_SIMPLE; }
274 passwd { return PASSWORD; }
275 password { return PASSWORD; }
276 path { return PATH; }
277 ping_cookie { return PING_COOKIE; }
278 ping_time { return PING_TIME; }
279 port { return PORT; }
280 prepend { return T_PREPEND; }
281 pseudo { return T_PSEUDO; }
282 quarantine { return RESV; }
283 random_idle { return RANDOM_IDLE; }
284 reason { return REASON; }
285 recvq { return T_RECVQ; }
286 redirport { return REDIRPORT; }
287 redirserv { return REDIRSERV; }
288 rehash { return REHASH; }
289 rej { return T_REJ; }
290 remote { return REMOTE; }
291 remoteban { return REMOTEBAN; }
292 restart { return T_RESTART; }
293 resv { return RESV; }
294 resv_exempt { return RESV_EXEMPT; }
295 rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; }
296 send_password { return SEND_PASSWORD; }
297 sendq { return SENDQ; }
298 server { return T_SERVER; }
299 serverhide { return SERVERHIDE; }
300 serverinfo { return SERVERINFO; }
301 service { return T_SERVICE; }
302 servnotice { return T_SERVNOTICE; }
303 set { return T_SET; }
304 shared { return T_SHARED; }
305 short_motd { return SHORT_MOTD; }
306 sid { return IRCD_SID; }
307 size { return T_SIZE; }
308 skill { return T_SKILL; }
309 softcallerid { return T_SOFTCALLERID; }
310 spoof { return SPOOF; }
311 spoof_notice { return SPOOF_NOTICE; }
312 spy { return T_SPY; }
313 squit { return SQUIT; }
314 ssl { return T_SSL; }
315 ssl_certificate_file { return SSL_CERTIFICATE_FILE; }
316 ssl_certificate_fingerprint { return SSL_CERTIFICATE_FINGERPRINT; }
317 ssl_cipher_list { return T_SSL_CIPHER_LIST; }
318 ssl_connection_required { return SSL_CONNECTION_REQUIRED; }
319 ssl_dh_elliptic_curve { return SSL_DH_ELLIPTIC_CURVE; }
320 ssl_dh_param_file { return SSL_DH_PARAM_FILE; }
321 ssl_message_digest_algorithm { return SSL_MESSAGE_DIGEST_ALGORITHM; }
322 standard { return STANDARD; }
323 stats_e_disabled { return STATS_E_DISABLED; }
324 stats_i_oper_only { return STATS_I_OPER_ONLY; }
325 stats_k_oper_only { return STATS_K_OPER_ONLY; }
326 stats_m_oper_only { return STATS_M_OPER_ONLY; }
327 stats_o_oper_only { return STATS_O_OPER_ONLY; }
328 stats_P_oper_only { return STATS_P_OPER_ONLY; }
329 stats_u_oper_only { return STATS_U_OPER_ONLY; }
330 target { return T_TARGET; }
331 throttle_count { return THROTTLE_COUNT; }
332 throttle_time { return THROTTLE_TIME; }
333 tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; }
334 ts_max_delta { return TS_MAX_DELTA; }
335 ts_warn_delta { return TS_WARN_DELTA; }
336 type { return TYPE; }
337 umodes { return T_UMODES; }
338 unauth { return T_UNAUTH; }
339 undline { return T_UNDLINE; }
340 unkline { return UNKLINE; }
341 unlimited { return T_UNLIMITED; }
342 unresv { return T_UNRESV; }
343 unxline { return T_UNXLINE; }
344 use_logging { return USE_LOGGING; }
345 user { return USER; }
346 vhost { return VHOST; }
347 vhost6 { return VHOST6; }
348 wallop { return T_WALLOP; }
349 wallops { return T_WALLOPS; }
350 warn_no_connect_block { return WARN_NO_CONNECT_BLOCK; }
351 webirc { return T_WEBIRC; }
352 whois { return WHOIS; }
353 whowas_history_length { return WHOWAS_HISTORY_LENGTH; }
354 xline { return XLINE; }
355 xline_exempt { return XLINE_EXEMPT; }
356
357 yes { yylval.number = 1; return TBOOL; }
358 no { yylval.number = 0; return TBOOL; }
359
360 years { return YEARS; }
361 year { return YEARS; }
362 months { return MONTHS; }
363 month { return MONTHS; }
364 weeks { return WEEKS; }
365 week { return WEEKS; }
366 days { return DAYS; }
367 day { return DAYS; }
368 hours { return HOURS; }
369 hour { return HOURS; }
370 minutes { return MINUTES; }
371 minute { return MINUTES; }
372 seconds { return SECONDS; }
373 second { return SECONDS; }
374
375 bytes { return BYTES; }
376 byte { return BYTES; }
377 kilobytes { return KBYTES; }
378 kilobyte { return KBYTES; }
379 kbytes { return KBYTES; }
380 kbyte { return KBYTES; }
381 kb { return KBYTES; }
382 megabytes { return MBYTES; }
383 megabyte { return MBYTES; }
384 mbytes { return MBYTES; }
385 mbyte { return MBYTES; }
386 mb { return MBYTES; }
387 \.\. { return TWODOTS; }
388
389 . { return yytext[0]; }
390 <<EOF>> { if (ieof()) yyterminate(); }
391
392 %%
393
394 /* C-comment ignoring routine -kre*/
395 static void
396 ccomment(void)
397 {
398 int c = 0;
399
400 /* log(L_NOTICE, "got comment"); */
401 while (1)
402 {
403 while ((c = input()) != '*' && c != EOF)
404 if (c == '\n')
405 ++lineno;
406
407 if (c == '*')
408 {
409 while ((c = input()) == '*')
410 /* Nothing */ ;
411 if (c == '/')
412 break;
413 else if (c == '\n')
414 ++lineno;
415 }
416
417 if (c == EOF)
418 {
419 YY_FATAL_ERROR("EOF in comment");
420 /* XXX hack alert this disables
421 * the stupid unused function warning
422 * gcc generates
423 */
424 if (1 == 0)
425 yy_fatal_error("EOF in comment");
426 break;
427 }
428 }
429 }
430
431 /* C-style .includes. This function will properly swap input conf buffers,
432 * and lineno -kre */
433 static void
434 cinclude(void)
435 {
436 char *p = NULL;
437 char filenamebuf[IRCD_BUFSIZE];
438
439 if ((p = strchr(yytext, '<')) == NULL)
440 *strchr(p = strchr(yytext, '"') + 1, '"') = '\0';
441 else
442 *strchr(++p, '>') = '\0';
443
444 /* do stacking and co. */
445 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
446 {
447 ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p);
448 return;
449 }
450
451 if (*p == '/') /* if it is an absolute path */
452 snprintf(filenamebuf, sizeof(filenamebuf), "%s", p);
453 else
454 snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p);
455
456 FILE *tmp_fbfile_in = fopen(filenamebuf, "r");
457 if (!tmp_fbfile_in)
458 {
459 ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
460 filenamebuf, strerror(errno));
461 return;
462 }
463
464 struct included_file *file = &include_stack[include_stack_ptr++];
465 file->lineno = lineno;
466 file->file = conf_parser_ctx.conf_file;
467 file->state = YY_CURRENT_BUFFER;
468 strlcpy(file->conffile, conffilebuf, sizeof(file->conffile));
469
470 lineno = 1;
471 conf_parser_ctx.conf_file = tmp_fbfile_in;
472 strlcpy(conffilebuf, filenamebuf, sizeof(conffilebuf));
473
474 yy_switch_to_buffer(yy_create_buffer(NULL, YY_BUF_SIZE));
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 if (include_stack_ptr == 0)
484 {
485 lineno = 1;
486 return 1;
487 }
488
489 /* switch buffer */
490 struct included_file *file = &include_stack[--include_stack_ptr];
491
492 /* close current file */
493 fclose(conf_parser_ctx.conf_file);
494
495 /* switch buffers */
496 yy_delete_buffer(YY_CURRENT_BUFFER);
497 yy_switch_to_buffer(file->state);
498
499 /* switch lineno */
500 lineno = file->lineno;
501
502 /* switch file */
503 conf_parser_ctx.conf_file = file->file;
504
505 strlcpy(conffilebuf, file->conffile, sizeof(conffilebuf));
506 return 0;
507 }

Properties

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