ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.0beta2/src/conf_lexer.l
Revision: 1851
Committed: Wed Apr 24 18:31:06 2013 UTC (13 years, 3 months ago) by michael
Original Path: ircd-hybrid/trunk/src/conf_lexer.l
File size: 15663 byte(s)
Log Message:
- Cleanup m_map.c
- Implemented serverhide::hide_services configuration option

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

Properties

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