ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/conf_lexer.l
Revision: 6448
Committed: Sat Aug 29 18:51:51 2015 UTC (10 years, 10 months ago) by michael
File size: 19439 byte(s)
Log Message:
- The general::oper_pass_resv configuration directive has been deprecated. Added the join:resv and nick:resv operator flags for better fine tuning

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2916 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 5346 * Copyright (c) 2000-2015 ircd-hybrid development team
5 adx 30 *
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 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2916 /*! \file ircd_lexer.l
23     * \brief Scans the ircd configuration file for tokens.
24     * \version $Id$
25     */
26    
27 adx 30 %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 michael 1309 #include "conf.h"
36     #include "conf_parser.h" /* autogenerated header file */
37     #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 michael 2916 YY_FATAL_ERROR("input in flex scanner failed");
44 adx 30 #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 michael 2916 "/*" { ccomment(); }
83 michael 4299 \n.* { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); }
84 adx 30 {WS} ;
85     {COMMENT} ;
86     {DIGIT} { yylval.number = atoi(yytext); return NUMBER; }
87 michael 4299 {qstring} { if (yytext[yyleng - 2] == '\\')
88     {
89     yyless(yyleng - 1); /* Return last quote */
90     yymore(); /* Append next string */
91     }
92     else
93     {
94     yylval.string = yytext + 1;
95 adx 30
96 michael 4299 if (yylval.string[yyleng - 2] != '"')
97     ilog(LOG_TYPE_IRCD, "Unterminated character string");
98     else
99     {
100     unsigned int i = 0, j = 0;
101 adx 30
102 michael 4299 yylval.string[yyleng - 2] = '\0'; /* Remove close quote */
103 michael 2916
104 michael 4299 for (; yylval.string[i] != '\0'; ++i, ++j)
105     {
106     if (yylval.string[i] != '\\')
107     yylval.string[j] = yylval.string[i];
108     else
109     {
110     ++i;
111 adx 30
112 michael 4299 if (yylval.string[i] == '\0') /* XXX: should not happen */
113     {
114     ilog(LOG_TYPE_IRCD, "Unterminated character string");
115     break;
116     }
117    
118     yylval.string[j] = yylval.string[i];
119     }
120     }
121    
122     yylval.string[j] = '\0';
123     return QSTRING;
124     }
125     }
126     }
127    
128 michael 2129 accept_password { return ACCEPT_PASSWORD; }
129     admin { return ADMIN; }
130     administrator { return ADMIN; }
131     aftype { return AFTYPE; }
132     all { return T_ALL; }
133     anti_nick_flood { return ANTI_NICK_FLOOD; }
134     anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; }
135     auth { return IRCD_AUTH; }
136     autoconn { return AUTOCONN; }
137 michael 4314 away_count { return AWAY_COUNT; }
138     away_time { return AWAY_TIME; }
139 michael 2129 bots { return T_BOTS; }
140     caller_id_wait { return CALLER_ID_WAIT; }
141     callerid { return T_CALLERID; }
142     can_flood { return CAN_FLOOD; }
143     cconn { return T_CCONN; }
144     channel { return CHANNEL; }
145     cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; }
146     cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; }
147     class { return CLASS; }
148     cluster { return T_CLUSTER; }
149 michael 4533 command { return T_COMMAND; }
150 michael 2129 connect { return CONNECT; }
151     connectfreq { return CONNECTFREQ; }
152 michael 2283 cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; }
153 michael 2129 deaf { return T_DEAF; }
154     debug { return T_DEBUG; }
155     default_floodcount { return DEFAULT_FLOODCOUNT; }
156 michael 5488 default_join_flood_count { return DEFAULT_JOIN_FLOOD_COUNT; }
157     default_join_flood_time { return DEFAULT_JOIN_FLOOD_TIME; }
158     default_max_clients { return DEFAULT_MAX_CLIENTS; }
159 michael 2129 deny { return DENY; }
160     description { return DESCRIPTION; }
161     die { return DIE; }
162     disable_auth { return DISABLE_AUTH; }
163     disable_fake_channels { return DISABLE_FAKE_CHANNELS; }
164     disable_remote_commands { return DISABLE_REMOTE_COMMANDS; }
165     dline { return T_DLINE; }
166 michael 5810 dline_min_cidr { return DLINE_MIN_CIDR; }
167     dline_min_cidr6 { return DLINE_MIN_CIDR6; }
168 michael 2129 dots_in_ident { return DOTS_IN_IDENT; }
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 michael 5810 kline_min_cidr { return KLINE_MIN_CIDR; }
183     kline_min_cidr6 { return KLINE_MIN_CIDR6; }
184 michael 2129 globops { return T_GLOBOPS; }
185     have_ident { return NEED_IDENT; }
186     hidden { return HIDDEN; }
187     hidden_name { return HIDDEN_NAME; }
188 michael 3514 hidechans { return HIDE_CHANS; }
189 michael 3507 hideidle { return HIDE_IDLE; }
190 michael 2129 hide_idle_from_opers { return HIDE_IDLE_FROM_OPERS; }
191     hide_server_ips { return HIDE_SERVER_IPS; }
192     hide_servers { return HIDE_SERVERS; }
193     hide_services { return HIDE_SERVICES; }
194     host { return HOST; }
195     hub { return HUB; }
196     hub_mask { return HUB_MASK; }
197     ignore_bogus_ts { return IGNORE_BOGUS_TS; }
198     invisible { return T_INVISIBLE; }
199     invisible_on_connect { return INVISIBLE_ON_CONNECT; }
200 michael 3863 invite_client_count { return INVITE_CLIENT_COUNT; }
201     invite_client_time { return INVITE_CLIENT_TIME; }
202 michael 2129 ip { return IP; }
203     ipv4 { return T_IPV4; }
204     ipv6 { return T_IPV6; }
205 michael 6448 join { return JOIN; }
206 michael 2129 kill { return KILL; }
207     kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; }
208     kline { return KLINE; }
209     kline_exempt { return KLINE_EXEMPT; }
210 michael 3863 knock_client_count { return KNOCK_CLIENT_COUNT; }
211     knock_client_time { return KNOCK_CLIENT_TIME; }
212 michael 2129 knock_delay_channel { return KNOCK_DELAY_CHANNEL; }
213     leaf_mask { return LEAF_MASK; }
214     links_delay { return LINKS_DELAY; }
215     listen { return LISTEN; }
216     locops { return T_LOCOPS; }
217     log { return T_LOG; }
218     mask { return MASK; }
219     masked { return TMASKED; }
220     max_accept { return MAX_ACCEPT; }
221     max_bans { return MAX_BANS; }
222 michael 3934 max_channels { return MAX_CHANNELS; }
223 michael 2129 max_global { return MAX_GLOBAL; }
224     max_ident { return MAX_IDENT; }
225     max_idle { return MAX_IDLE; }
226     max_local { return MAX_LOCAL; }
227     max_nick_changes { return MAX_NICK_CHANGES; }
228     max_nick_length { return MAX_NICK_LENGTH; }
229     max_nick_time { return MAX_NICK_TIME; }
230     max_number { return MAX_NUMBER; }
231     max_targets { return MAX_TARGETS; }
232     max_topic_length { return MAX_TOPIC_LENGTH; }
233     max_watch { return MAX_WATCH; }
234     min_idle { return MIN_IDLE; }
235     min_nonwildcard { return MIN_NONWILDCARD; }
236     min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; }
237     module { return MODULE; }
238     modules { return MODULES; }
239 michael 2150 motd { return MOTD; }
240 michael 2129 name { return NAME; }
241     nchange { return T_NCHANGE; }
242     need_ident { return NEED_IDENT; }
243     need_password { return NEED_PASSWORD; }
244     network_desc { return NETWORK_DESC; }
245     network_name { return NETWORK_NAME; }
246     nick { return NICK; }
247     no_oper_flood { return NO_OPER_FLOOD; }
248     no_tilde { return NO_TILDE; }
249     nononreg { return T_NONONREG; }
250     number_per_cidr { return NUMBER_PER_CIDR; }
251     number_per_ip { return NUMBER_PER_IP; }
252     oper { return OPERATOR; }
253     oper_only_umodes { return OPER_ONLY_UMODES; }
254     oper_umodes { return OPER_UMODES; }
255     operator { return OPERATOR; }
256     opers_bypass_callerid { return OPERS_BYPASS_CALLERID; }
257 michael 5005 opme { return T_OPME; }
258 michael 2129 pace_wait { return PACE_WAIT; }
259     pace_wait_simple { return PACE_WAIT_SIMPLE; }
260     passwd { return PASSWORD; }
261     password { return PASSWORD; }
262     path { return PATH; }
263     ping_cookie { return PING_COOKIE; }
264     ping_time { return PING_TIME; }
265     port { return PORT; }
266 michael 4533 prepend { return T_PREPEND; }
267     pseudo { return T_PSEUDO; }
268 michael 2129 quarantine { return RESV; }
269     random_idle { return RANDOM_IDLE; }
270     reason { return REASON; }
271     recvq { return T_RECVQ; }
272     redirport { return REDIRPORT; }
273     redirserv { return REDIRSERV; }
274     rehash { return REHASH; }
275     rej { return T_REJ; }
276     remote { return REMOTE; }
277     remoteban { return REMOTEBAN; }
278     restart { return T_RESTART; }
279     resv { return RESV; }
280     resv_exempt { return RESV_EXEMPT; }
281     rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; }
282     rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; }
283     send_password { return SEND_PASSWORD; }
284     sendq { return SENDQ; }
285     server { return T_SERVER; }
286     serverhide { return SERVERHIDE; }
287     serverinfo { return SERVERINFO; }
288     service { return T_SERVICE; }
289     servnotice { return T_SERVNOTICE; }
290     set { return T_SET; }
291     shared { return T_SHARED; }
292     short_motd { return SHORT_MOTD; }
293     sid { return IRCD_SID; }
294     size { return T_SIZE; }
295     skill { return T_SKILL; }
296     softcallerid { return T_SOFTCALLERID; }
297     spoof { return SPOOF; }
298     spoof_notice { return SPOOF_NOTICE; }
299     spy { return T_SPY; }
300     squit { return SQUIT; }
301     ssl { return T_SSL; }
302 adx 30 ssl_certificate_file { return SSL_CERTIFICATE_FILE; }
303 michael 2244 ssl_certificate_fingerprint { return SSL_CERTIFICATE_FINGERPRINT; }
304 michael 2129 ssl_cipher_list { return T_SSL_CIPHER_LIST; }
305 michael 2248 ssl_connection_required { return SSL_CONNECTION_REQUIRED; }
306 michael 4071 ssl_dh_elliptic_curve { return SSL_DH_ELLIPTIC_CURVE; }
307 michael 2129 ssl_dh_param_file { return SSL_DH_PARAM_FILE; }
308 michael 4115 ssl_message_digest_algorithm { return SSL_MESSAGE_DIGEST_ALGORITHM; }
309 michael 2129 stats_e_disabled { return STATS_E_DISABLED; }
310     stats_i_oper_only { return STATS_I_OPER_ONLY; }
311     stats_k_oper_only { return STATS_K_OPER_ONLY; }
312 michael 5024 stats_m_oper_only { return STATS_M_OPER_ONLY; }
313 michael 2129 stats_o_oper_only { return STATS_O_OPER_ONLY; }
314     stats_P_oper_only { return STATS_P_OPER_ONLY; }
315 michael 2269 stats_u_oper_only { return STATS_U_OPER_ONLY; }
316 michael 4533 target { return T_TARGET; }
317 michael 3876 throttle_count { return THROTTLE_COUNT; }
318 michael 2129 throttle_time { return THROTTLE_TIME; }
319     tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; }
320     ts_max_delta { return TS_MAX_DELTA; }
321     ts_warn_delta { return TS_WARN_DELTA; }
322     type { return TYPE; }
323     umodes { return T_UMODES; }
324     unauth { return T_UNAUTH; }
325     undline { return T_UNDLINE; }
326     unkline { return UNKLINE; }
327     unlimited { return T_UNLIMITED; }
328     unresv { return T_UNRESV; }
329     unxline { return T_UNXLINE; }
330     use_logging { return USE_LOGGING; }
331 michael 2916 user { return USER; }
332 michael 2129 vhost { return VHOST; }
333     vhost6 { return VHOST6; }
334     wallop { return T_WALLOP; }
335     wallops { return T_WALLOPS; }
336 michael 3474 warn_no_connect_block { return WARN_NO_CONNECT_BLOCK; }
337 michael 2129 webirc { return T_WEBIRC; }
338 michael 5559 whois { return WHOIS; }
339 michael 2129 xline { return XLINE; }
340 michael 5989 xline_exempt { return XLINE_EXEMPT; }
341 adx 30
342 michael 2129 yes { yylval.number = 1; return TBOOL; }
343     no { yylval.number = 0; return TBOOL; }
344 adx 30
345 michael 2129 years { return YEARS; }
346     year { return YEARS; }
347     months { return MONTHS; }
348     month { return MONTHS; }
349     weeks { return WEEKS; }
350     week { return WEEKS; }
351     days { return DAYS; }
352     day { return DAYS; }
353     hours { return HOURS; }
354     hour { return HOURS; }
355     minutes { return MINUTES; }
356     minute { return MINUTES; }
357     seconds { return SECONDS; }
358     second { return SECONDS; }
359 adx 30
360 michael 2129 bytes { return BYTES; }
361     byte { return BYTES; }
362     kilobytes { return KBYTES; }
363     kilobyte { return KBYTES; }
364     kbytes { return KBYTES; }
365     kbyte { return KBYTES; }
366     kb { return KBYTES; }
367     megabytes { return MBYTES; }
368     megabyte { return MBYTES; }
369     mbytes { return MBYTES; }
370     mbyte { return MBYTES; }
371     mb { return MBYTES; }
372     \.\. { return TWODOTS; }
373 adx 30
374 michael 2129 . { return yytext[0]; }
375     <<EOF>> { if (ieof()) yyterminate(); }
376 adx 30
377     %%
378    
379     /* C-comment ignoring routine -kre*/
380     static void
381     ccomment(void)
382     {
383     int c = 0;
384    
385     /* log(L_NOTICE, "got comment"); */
386     while (1)
387     {
388     while ((c = input()) != '*' && c != EOF)
389     if (c == '\n')
390     ++lineno;
391    
392     if (c == '*')
393     {
394     while ((c = input()) == '*')
395     /* Nothing */ ;
396     if (c == '/')
397     break;
398     else if (c == '\n')
399     ++lineno;
400     }
401    
402     if (c == EOF)
403     {
404     YY_FATAL_ERROR("EOF in comment");
405     /* XXX hack alert this disables
406     * the stupid unused function warning
407 michael 2916 * gcc generates
408 adx 30 */
409     if (1 == 0)
410     yy_fatal_error("EOF in comment");
411     break;
412     }
413     }
414     }
415    
416     /* C-style .includes. This function will properly swap input conf buffers,
417     * and lineno -kre */
418     static void
419     cinclude(void)
420     {
421     char *p = NULL;
422    
423     if ((p = strchr(yytext, '<')) == NULL)
424     *strchr(p = strchr(yytext, '"') + 1, '"') = '\0';
425     else
426     *strchr(++p, '>') = '\0';
427    
428     /* log(L_NOTICE, "got include %s!", c); */
429    
430 michael 2916 /* do stacking and co. */
431 adx 30 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
432 michael 1247 ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p);
433 adx 30 else
434     {
435 michael 1325 FILE *tmp_fbfile_in = NULL;
436 adx 30 char filenamebuf[IRCD_BUFSIZE];
437    
438     if (*p == '/') /* if it is an absolute path */
439     snprintf(filenamebuf, sizeof(filenamebuf), "%s", p);
440     else
441     snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p);
442    
443 michael 1325 tmp_fbfile_in = fopen(filenamebuf, "r");
444 michael 2916
445 adx 30 if (tmp_fbfile_in == NULL)
446     {
447 michael 1247 ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
448 adx 30 filenamebuf, strerror(errno));
449     return;
450     }
451    
452     lineno_stack[include_stack_ptr] = lineno;
453     lineno = 1;
454 michael 967 inc_fbfile_in[include_stack_ptr] = conf_parser_ctx.conf_file;
455 adx 30 strlcpy(conffile_stack[include_stack_ptr], conffilebuf, IRCD_BUFSIZE);
456     include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
457 michael 967 conf_parser_ctx.conf_file = tmp_fbfile_in;
458 michael 711 snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf);
459 adx 30 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
460     }
461     }
462    
463     /* This is function that will be called on EOF in conf file. It will
464     * apropriately close conf if it not main conf and swap input buffers -kre
465     * */
466     static int
467     ieof(void)
468     {
469     /* log(L_NOTICE, "return from include stack!"); */
470     if (include_stack_ptr)
471 michael 1325 fclose(conf_parser_ctx.conf_file);
472 adx 30 if (--include_stack_ptr < 0)
473     {
474     /* log(L_NOTICE, "terminating lexer"); */
475     /* We will now exit the lexer - restore init values if we get /rehash
476     * later and reenter lexer -kre */
477     include_stack_ptr = 0;
478     lineno = 1;
479     return 1;
480     }
481    
482     /* switch buffer */
483     /* log(L_NOTICE, "deleting include_stack_ptr=%d", include_stack_ptr); */
484     yy_delete_buffer(YY_CURRENT_BUFFER);
485     lineno = lineno_stack[include_stack_ptr];
486 michael 967 conf_parser_ctx.conf_file = inc_fbfile_in[include_stack_ptr];
487 michael 2916 strlcpy(conffilebuf, conffile_stack[include_stack_ptr], sizeof(conffilebuf));
488 adx 30 yy_switch_to_buffer(include_stack[include_stack_ptr]);
489    
490     return 0;
491     }

Properties

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