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: 8787
Committed: Wed Jan 16 18:47:10 2019 UTC (7 years, 6 months ago) by michael
File size: 19291 byte(s)
Log Message:
- The 'general::ignore_bogus_ts' configuration option has been deprecated

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 8751 * Copyright (c) 2000-2019 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 7677 /*! \file conf_lexer.l
23 michael 2916 * \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 8761 if ((result = conf_yy_input(buf, max_size)) == 0) \
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 michael 7706 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 adx 30 static void ccomment(void);
62     static void cinclude(void);
63 michael 8761 static bool ieof(void);
64 michael 1353
65     static int
66     conf_yy_input(char *lbuf, unsigned int max_size)
67     {
68 michael 8761 return fgets(lbuf, max_size, conf_parser_ctx.conf_file) == NULL ? 0 : strlen(lbuf);
69 michael 1353 }
70    
71     static int
72     conf_yy_fatal_error(const char *msg)
73     {
74     return 0;
75     }
76    
77 adx 30 %}
78    
79     WS [[:blank:]]*
80     DIGIT [[:digit:]]+
81     COMMENT ("//"|"#").*
82     qstring \"[^\"\n]*[\"\n]
83     include \.include{WS}(\<.*\>|\".*\")
84    
85     %%
86     {include} { cinclude(); }
87 michael 2916 "/*" { ccomment(); }
88 michael 4299 \n.* { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); }
89 adx 30 {WS} ;
90     {COMMENT} ;
91     {DIGIT} { yylval.number = atoi(yytext); return NUMBER; }
92 michael 4299 {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 adx 30
101 michael 4299 if (yylval.string[yyleng - 2] != '"')
102     ilog(LOG_TYPE_IRCD, "Unterminated character string");
103     else
104     {
105     unsigned int i = 0, j = 0;
106 adx 30
107 michael 4299 yylval.string[yyleng - 2] = '\0'; /* Remove close quote */
108 michael 2916
109 michael 4299 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 adx 30
117 michael 4299 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 michael 2129 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 michael 4314 away_count { return AWAY_COUNT; }
143     away_time { return AWAY_TIME; }
144 michael 2129 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     cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; }
151     cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; }
152     class { return CLASS; }
153 michael 6487 close { return CLOSE; }
154 michael 2129 cluster { return T_CLUSTER; }
155 michael 4533 command { return T_COMMAND; }
156 michael 2129 connect { return CONNECT; }
157     connectfreq { return CONNECTFREQ; }
158 michael 2283 cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; }
159 michael 2129 deaf { return T_DEAF; }
160     debug { return T_DEBUG; }
161     default_floodcount { return DEFAULT_FLOODCOUNT; }
162 michael 7859 default_floodtime { return DEFAULT_FLOODTIME; }
163 michael 5488 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 michael 2129 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 michael 5810 dline_min_cidr { return DLINE_MIN_CIDR; }
174     dline_min_cidr6 { return DLINE_MIN_CIDR6; }
175 michael 2129 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 michael 6598 flatten_links_delay { return FLATTEN_LINKS_DELAY; }
187 michael 6600 flatten_links_file { return FLATTEN_LINKS_FILE; }
188 michael 2129 full { return T_FULL; }
189     gecos { return GECOS; }
190     general { return GENERAL; }
191 michael 5810 kline_min_cidr { return KLINE_MIN_CIDR; }
192     kline_min_cidr6 { return KLINE_MIN_CIDR6; }
193 michael 2129 globops { return T_GLOBOPS; }
194     have_ident { return NEED_IDENT; }
195     hidden { return HIDDEN; }
196     hidden_name { return HIDDEN_NAME; }
197 michael 3514 hidechans { return HIDE_CHANS; }
198 michael 3507 hideidle { return HIDE_IDLE; }
199 michael 2129 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     invisible { return T_INVISIBLE; }
207     invisible_on_connect { return INVISIBLE_ON_CONNECT; }
208 michael 3863 invite_client_count { return INVITE_CLIENT_COUNT; }
209     invite_client_time { return INVITE_CLIENT_TIME; }
210 michael 6794 invite_delay_channel { return INVITE_DELAY_CHANNEL; }
211 michael 7792 invite_expire_time { return INVITE_EXPIRE_TIME; }
212 michael 2129 ip { return IP; }
213     ipv4 { return T_IPV4; }
214     ipv6 { return T_IPV6; }
215 michael 6448 join { return JOIN; }
216 michael 2129 kill { return KILL; }
217     kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; }
218     kline { return KLINE; }
219     kline_exempt { return KLINE_EXEMPT; }
220 michael 3863 knock_client_count { return KNOCK_CLIENT_COUNT; }
221     knock_client_time { return KNOCK_CLIENT_TIME; }
222 michael 2129 knock_delay_channel { return KNOCK_DELAY_CHANNEL; }
223     leaf_mask { return LEAF_MASK; }
224     listen { return LISTEN; }
225     locops { return T_LOCOPS; }
226     log { return T_LOG; }
227     mask { return MASK; }
228     masked { return TMASKED; }
229     max_accept { return MAX_ACCEPT; }
230     max_bans { return MAX_BANS; }
231 michael 8045 max_bans_large { return MAX_BANS_LARGE; }
232 michael 3934 max_channels { return MAX_CHANNELS; }
233 michael 2129 max_idle { return MAX_IDLE; }
234 michael 7765 max_invites { return MAX_INVITES; }
235 michael 2129 max_nick_changes { return MAX_NICK_CHANGES; }
236     max_nick_length { return MAX_NICK_LENGTH; }
237     max_nick_time { return MAX_NICK_TIME; }
238     max_number { return MAX_NUMBER; }
239     max_targets { return MAX_TARGETS; }
240     max_topic_length { return MAX_TOPIC_LENGTH; }
241     max_watch { return MAX_WATCH; }
242     min_idle { return MIN_IDLE; }
243     min_nonwildcard { return MIN_NONWILDCARD; }
244     min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; }
245     module { return MODULE; }
246     modules { return MODULES; }
247 michael 2150 motd { return MOTD; }
248 michael 2129 name { return NAME; }
249     nchange { return T_NCHANGE; }
250     need_ident { return NEED_IDENT; }
251     need_password { return NEED_PASSWORD; }
252     network_desc { return NETWORK_DESC; }
253     network_name { return NETWORK_NAME; }
254     nick { return NICK; }
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 michael 8495 number_per_ip_global { return NUMBER_PER_IP_GLOBAL; }
260     number_per_ip_local { return NUMBER_PER_IP_LOCAL; }
261 michael 2129 oper { return OPERATOR; }
262     oper_only_umodes { return OPER_ONLY_UMODES; }
263     oper_umodes { return OPER_UMODES; }
264     operator { return OPERATOR; }
265     opers_bypass_callerid { return OPERS_BYPASS_CALLERID; }
266 michael 5005 opme { return T_OPME; }
267 michael 2129 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 michael 4533 prepend { return T_PREPEND; }
276     pseudo { return T_PSEUDO; }
277 michael 2129 quarantine { return RESV; }
278     random_idle { return RANDOM_IDLE; }
279     reason { return REASON; }
280     recvq { return T_RECVQ; }
281     redirport { return REDIRPORT; }
282     redirserv { return REDIRSERV; }
283     rehash { return REHASH; }
284     rej { return T_REJ; }
285     remote { return REMOTE; }
286     remoteban { return REMOTEBAN; }
287     restart { return T_RESTART; }
288     resv { return RESV; }
289     resv_exempt { return RESV_EXEMPT; }
290     rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; }
291     send_password { return SEND_PASSWORD; }
292     sendq { return SENDQ; }
293     server { return T_SERVER; }
294     serverhide { return SERVERHIDE; }
295     serverinfo { return SERVERINFO; }
296     service { return T_SERVICE; }
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 adx 30 ssl_certificate_file { return SSL_CERTIFICATE_FILE; }
311 michael 2244 ssl_certificate_fingerprint { return SSL_CERTIFICATE_FINGERPRINT; }
312 michael 2129 ssl_cipher_list { return T_SSL_CIPHER_LIST; }
313 michael 2248 ssl_connection_required { return SSL_CONNECTION_REQUIRED; }
314 michael 4071 ssl_dh_elliptic_curve { return SSL_DH_ELLIPTIC_CURVE; }
315 michael 2129 ssl_dh_param_file { return SSL_DH_PARAM_FILE; }
316 michael 4115 ssl_message_digest_algorithm { return SSL_MESSAGE_DIGEST_ALGORITHM; }
317 michael 2129 stats_e_disabled { return STATS_E_DISABLED; }
318     stats_i_oper_only { return STATS_I_OPER_ONLY; }
319     stats_k_oper_only { return STATS_K_OPER_ONLY; }
320 michael 5024 stats_m_oper_only { return STATS_M_OPER_ONLY; }
321 michael 2129 stats_o_oper_only { return STATS_O_OPER_ONLY; }
322     stats_P_oper_only { return STATS_P_OPER_ONLY; }
323 michael 2269 stats_u_oper_only { return STATS_U_OPER_ONLY; }
324 michael 4533 target { return T_TARGET; }
325 michael 3876 throttle_count { return THROTTLE_COUNT; }
326 michael 2129 throttle_time { return THROTTLE_TIME; }
327     tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; }
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_logging { return USE_LOGGING; }
339 michael 2916 user { return USER; }
340 michael 2129 vhost { return VHOST; }
341     vhost6 { return VHOST6; }
342     wallop { return T_WALLOP; }
343     wallops { return T_WALLOPS; }
344 michael 3474 warn_no_connect_block { return WARN_NO_CONNECT_BLOCK; }
345 michael 2129 webirc { return T_WEBIRC; }
346 michael 5559 whois { return WHOIS; }
347 michael 7436 whowas_history_length { return WHOWAS_HISTORY_LENGTH; }
348 michael 2129 xline { return XLINE; }
349 michael 5989 xline_exempt { return XLINE_EXEMPT; }
350 adx 30
351 michael 2129 yes { yylval.number = 1; return TBOOL; }
352     no { yylval.number = 0; return TBOOL; }
353 adx 30
354 michael 2129 years { return YEARS; }
355     year { return YEARS; }
356     months { return MONTHS; }
357     month { return MONTHS; }
358     weeks { return WEEKS; }
359     week { return WEEKS; }
360     days { return DAYS; }
361     day { return DAYS; }
362     hours { return HOURS; }
363     hour { return HOURS; }
364     minutes { return MINUTES; }
365     minute { return MINUTES; }
366     seconds { return SECONDS; }
367     second { return SECONDS; }
368 adx 30
369 michael 2129 bytes { return BYTES; }
370     byte { return BYTES; }
371     kilobytes { return KBYTES; }
372     kilobyte { return KBYTES; }
373     kbytes { return KBYTES; }
374     kbyte { return KBYTES; }
375     kb { return KBYTES; }
376     megabytes { return MBYTES; }
377     megabyte { return MBYTES; }
378     mbytes { return MBYTES; }
379     mbyte { return MBYTES; }
380     mb { return MBYTES; }
381     \.\. { return TWODOTS; }
382 adx 30
383 michael 2129 . { return yytext[0]; }
384 michael 8761 <<EOF>> { if (ieof() == true) yyterminate(); }
385 adx 30
386     %%
387    
388     /* C-comment ignoring routine -kre*/
389     static void
390     ccomment(void)
391     {
392     int c = 0;
393    
394     /* log(L_NOTICE, "got comment"); */
395     while (1)
396     {
397     while ((c = input()) != '*' && c != EOF)
398     if (c == '\n')
399     ++lineno;
400    
401     if (c == '*')
402     {
403     while ((c = input()) == '*')
404     /* Nothing */ ;
405     if (c == '/')
406     break;
407     else if (c == '\n')
408     ++lineno;
409     }
410    
411     if (c == EOF)
412     {
413     YY_FATAL_ERROR("EOF in comment");
414     /* XXX hack alert this disables
415     * the stupid unused function warning
416 michael 2916 * gcc generates
417 adx 30 */
418     if (1 == 0)
419     yy_fatal_error("EOF in comment");
420     break;
421     }
422     }
423     }
424    
425     /* C-style .includes. This function will properly swap input conf buffers,
426     * and lineno -kre */
427     static void
428     cinclude(void)
429     {
430 michael 8761 char *p;
431 michael 7706 char filenamebuf[IRCD_BUFSIZE];
432 adx 30
433     if ((p = strchr(yytext, '<')) == NULL)
434     *strchr(p = strchr(yytext, '"') + 1, '"') = '\0';
435     else
436     *strchr(++p, '>') = '\0';
437    
438 michael 2916 /* do stacking and co. */
439 adx 30 if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
440 michael 7706 {
441 michael 1247 ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p);
442 michael 7706 return;
443     }
444    
445     if (*p == '/') /* if it is an absolute path */
446     snprintf(filenamebuf, sizeof(filenamebuf), "%s", p);
447 adx 30 else
448 michael 7706 snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p);
449    
450     FILE *tmp_fbfile_in = fopen(filenamebuf, "r");
451 michael 8761 if (tmp_fbfile_in == NULL)
452 adx 30 {
453 michael 7706 ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
454     filenamebuf, strerror(errno));
455     return;
456     }
457 adx 30
458 michael 7706 struct included_file *file = &include_stack[include_stack_ptr++];
459     file->lineno = lineno;
460     file->file = conf_parser_ctx.conf_file;
461     file->state = YY_CURRENT_BUFFER;
462     strlcpy(file->conffile, conffilebuf, sizeof(file->conffile));
463 adx 30
464 michael 7706 lineno = 1;
465     conf_parser_ctx.conf_file = tmp_fbfile_in;
466 michael 7743 strlcpy(conffilebuf, filenamebuf, sizeof(conffilebuf));
467 michael 2916
468 michael 7732 yy_switch_to_buffer(yy_create_buffer(NULL, YY_BUF_SIZE));
469 adx 30 }
470    
471     /* This is function that will be called on EOF in conf file. It will
472     * apropriately close conf if it not main conf and swap input buffers -kre
473     * */
474 michael 8761 static bool
475 adx 30 ieof(void)
476     {
477 michael 7706 if (include_stack_ptr == 0)
478 adx 30 {
479     lineno = 1;
480 michael 8761 return true;
481 adx 30 }
482    
483     /* switch buffer */
484 michael 7706 struct included_file *file = &include_stack[--include_stack_ptr];
485    
486     /* close current file */
487     fclose(conf_parser_ctx.conf_file);
488    
489     /* switch buffers */
490 adx 30 yy_delete_buffer(YY_CURRENT_BUFFER);
491 michael 7706 yy_switch_to_buffer(file->state);
492 adx 30
493 michael 7706 /* switch lineno */
494     lineno = file->lineno;
495    
496     /* switch file */
497     conf_parser_ctx.conf_file = file->file;
498    
499     strlcpy(conffilebuf, file->conffile, sizeof(conffilebuf));
500 michael 8761 return false;
501 adx 30 }

Properties

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