ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_lexer.l
Revision: 2269
Committed: Tue Jun 18 15:07:26 2013 UTC (12 years, 2 months ago) by michael
File size: 18996 byte(s)
Log Message:
- Added general::stats_u_oper_only configuration option

File Contents

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

Properties

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