ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_lexer.l
Revision: 1316
Committed: Tue Mar 27 17:05:51 2012 UTC (14 years, 4 months ago) by michael
Original Path: ircd-hybrid-8/src/conf_lexer.l
File size: 16051 byte(s)
Log Message:
- Removed 'ssl_server_protocol' configuration directive and
  added 'ssl_client_method' and 'ssl_server_method' instead.

  Both of these options can now be changed at runtime.

- src/Makefile.am: swapped order of conf_parser.y and conf_lexer.l
- Update example configuration files

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 adx 30 #include "memory.h"
36     #include "hostmask.h"
37 michael 1309 #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 967 if (!(result = conf_fbgets(buf, max_size, conf_parser_ctx.conf_file))) \
43 adx 30 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 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     static FBFILE *inc_fbfile_in[MAX_INCLUDE_DEPTH];
55     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     %}
60    
61     WS [[:blank:]]*
62     DIGIT [[:digit:]]+
63     COMMENT ("//"|"#").*
64     qstring \"[^\"\n]*[\"\n]
65     include \.include{WS}(\<.*\>|\".*\")
66    
67     %%
68     {include} { cinclude(); }
69     "/*" { ccomment(); }
70    
71     \n.* { strcpy(linebuf, yytext+1); ++lineno; yyless(1); }
72    
73     {WS} ;
74     {COMMENT} ;
75    
76     {DIGIT} { yylval.number = atoi(yytext); return NUMBER; }
77    
78     {qstring} { if (yytext[yyleng-2] == '\\')
79     {
80     yyless(yyleng-1); /* return last quote */
81     yymore(); /* append next string */
82     }
83     else
84     {
85     yylval.string = yytext+1;
86     if(yylval.string[yyleng-2] != '"')
87 michael 1247 ilog(LOG_TYPE_IRCD, "Unterminated character string");
88 adx 30 else
89     {
90     int i,j;
91    
92     yylval.string[yyleng-2] = '\0'; /* remove close
93     * quote
94     */
95    
96     for (j=i=0 ;yylval.string[i] != '\0'; i++,j++)
97     {
98     if (yylval.string[i] != '\\')
99     {
100     yylval.string[j] = yylval.string[i];
101     }
102     else
103     {
104     i++;
105     if (yylval.string[i] == '\0') /* XXX
106     * should not
107     * happen
108     */
109     {
110 michael 1247 ilog(LOG_TYPE_IRCD,
111 adx 30 "Unterminated character string");
112     break;
113     }
114     yylval.string[j] = yylval.string[i];
115     }
116     }
117     yylval.string[j] = '\0';
118     return QSTRING;
119     }
120     }
121     }
122    
123     accept_password { return ACCEPT_PASSWORD; }
124     action { return ACTION; }
125     admin { return ADMIN; }
126     administrator { return ADMIN; }
127     aftype { return AFTYPE; }
128     all { return T_ALL; }
129     allow { return T_ALLOW; }
130     auth { return IRCD_AUTH; }
131     autoconn { return AUTOCONN; }
132     block { return T_BLOCK; }
133     burst_away { return BURST_AWAY; }
134     burst_topicwho { return BURST_TOPICWHO; }
135     can_flood { return CAN_FLOOD; }
136     caller_id_wait { return CALLER_ID_WAIT; }
137     opers_bypass_callerid { return OPERS_BYPASS_CALLERID; }
138     channel { return CHANNEL; }
139     cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; }
140     cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; }
141     class { return CLASS; }
142     client_flood { return T_CLIENT_FLOOD; }
143     cluster { return T_CLUSTER; }
144     connect { return CONNECT; }
145     connectfreq { return CONNECTFREQ; }
146     default_floodcount { return DEFAULT_FLOODCOUNT; }
147     default_split_server_count { return DEFAULT_SPLIT_SERVER_COUNT; }
148     default_split_user_count { return DEFAULT_SPLIT_USER_COUNT; }
149     deny { return DENY; }
150     description { return DESCRIPTION; }
151     die { return DIE; }
152     disable_auth { return DISABLE_AUTH; }
153 michael 632 disable_fake_channels { return DISABLE_FAKE_CHANNELS; }
154 adx 30 disable_hidden { return DISABLE_HIDDEN; }
155     disable_local_channels { return DISABLE_LOCAL_CHANNELS; }
156     disable_remote_commands { return DISABLE_REMOTE_COMMANDS; }
157 michael 1250 dline { return T_DLINE; }
158 adx 30 dots_in_ident { return DOTS_IN_IDENT; }
159     duration { return DURATION; }
160     egdpool_path { return EGDPOOL_PATH; }
161     email { return EMAIL; }
162     enable { return ENABLE; }
163     encrypted { return ENCRYPTED; }
164     exceed_limit { return EXCEED_LIMIT; }
165     exempt { return EXEMPT; }
166 michael 1247 file { return T_FILE; }
167 adx 30 flags { return IRCD_FLAGS; }
168     flatten_links { return FLATTEN_LINKS; }
169     gecos { return GECOS; }
170     general { return GENERAL; }
171     gline { return GLINE; }
172     glines { return GLINES; }
173     gline_exempt { return GLINE_EXEMPT; }
174     gline_min_cidr { return GLINE_MIN_CIDR; }
175     gline_min_cidr6 { return GLINE_MIN_CIDR6; }
176 michael 1216 globops { return T_GLOBOPS; }
177 adx 30 global_kill { return GLOBAL_KILL; }
178     have_ident { return NEED_IDENT; }
179     need_ident { return NEED_IDENT; }
180     havent_read_conf { return HAVENT_READ_CONF; }
181     hidden { return HIDDEN; }
182     hidden_name { return HIDDEN_NAME; }
183     hide_server_ips { return HIDE_SERVER_IPS; }
184     hide_servers { return HIDE_SERVERS; }
185     hide_spoof_ips { return HIDE_SPOOF_IPS; }
186     host { return HOST; }
187     hub { return HUB; }
188     hub_mask { return HUB_MASK; }
189     ignore_bogus_ts { return IGNORE_BOGUS_TS; }
190     invisible_on_connect { return INVISIBLE_ON_CONNECT; }
191     ip { return IP; }
192     ipv4 { return T_IPV4; }
193     ipv6 { return T_IPV6; }
194     join_flood_count { return JOIN_FLOOD_COUNT; }
195     join_flood_time { return JOIN_FLOOD_TIME; }
196     kill { return KILL; }
197     kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; }
198     kline { return KLINE; }
199     kline_exempt { return KLINE_EXEMPT; }
200     leaf_mask { return LEAF_MASK; }
201     listen { return LISTEN; }
202 michael 1247 log { return T_LOG; }
203 adx 30 masked { return TMASKED; }
204     max_clients { return T_MAX_CLIENTS; }
205     max_ident { return MAX_IDENT; }
206     max_local { return MAX_LOCAL; }
207     max_global { return MAX_GLOBAL; }
208     max_number { return MAX_NUMBER; }
209 michael 876 max_watch { return MAX_WATCH; }
210 adx 30 message_locale { return MESSAGE_LOCALE; }
211     min_nonwildcard { return MIN_NONWILDCARD; }
212     min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; }
213     name { return NAME; }
214     need_password { return NEED_PASSWORD; }
215     network_desc { return NETWORK_DESC; }
216     network_name { return NETWORK_NAME; }
217     nick { return NICK; }
218     nick_changes { return NICK_CHANGES; }
219 michael 1243 no { yylval.number = 0; return TBOOL; }
220 adx 30 no_create_on_split { return NO_CREATE_ON_SPLIT; }
221     no_join_on_split { return NO_JOIN_ON_SPLIT; }
222     no_oper_flood { return NO_OPER_FLOOD; }
223     no_tilde { return NO_TILDE; }
224     number_per_cidr { return NUMBER_PER_CIDR; }
225     number_per_ip { return NUMBER_PER_IP; }
226     oper { return OPERATOR; }
227     oper_pass_resv { return OPER_PASS_RESV; }
228     operator { return OPERATOR; }
229     passwd { return PASSWORD; }
230     password { return PASSWORD; }
231     ping_cookie { return PING_COOKIE; }
232     ping_time { return PING_TIME; }
233     ping_warning { return PING_WARNING; }
234     port { return PORT; }
235     quarantine { return RESV; }
236     quiet_on_ban { return QUIET_ON_BAN; }
237     reason { return REASON; }
238     redirport { return REDIRPORT; }
239     redirserv { return REDIRSERV; }
240     regex { return REGEX_T; }
241     rehash { return REHASH; }
242     reject { return T_REJECT; }
243     reject_hold_time { return TREJECT_HOLD_TIME; }
244     remote { return REMOTE; }
245     remoteban { return REMOTEBAN; }
246 michael 1228 restart { return T_RESTART; }
247 adx 30 restrict_channels { return RESTRICT_CHANNELS; }
248     resv { return RESV; }
249     resv_exempt { return RESV_EXEMPT; }
250     rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; }
251     rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; }
252     ssl { return T_SSL; }
253     ssl_certificate_file { return SSL_CERTIFICATE_FILE; }
254 michael 1316 ssl_client_method { return T_SSL_CLIENT_METHOD; }
255     ssl_server_method { return T_SSL_SERVER_METHOD; }
256 michael 1306 ssl_dh_param_file { return SSL_DH_PARAM_FILE; }
257     ssl_cipher_list { return T_SSL_CIPHER_LIST; }
258 michael 967 sslv3 { return T_SSLV3; }
259     tlsv1 { return T_TLSV1; }
260 adx 30 send_password { return SEND_PASSWORD; }
261     sendq { return SENDQ; }
262 michael 900 server { return T_SERVER; }
263 adx 30 serverhide { return SERVERHIDE; }
264     serverinfo { return SERVERINFO; }
265 michael 1175 service { return T_SERVICE; }
266 michael 1176 services_name { return T_SERVICES_NAME; }
267 adx 30 shared { return T_SHARED; }
268     short_motd { return SHORT_MOTD; }
269     sid { return IRCD_SID; }
270     silent { return SILENT; }
271 michael 1247 size { return T_SIZE; }
272 adx 30 spoof { return SPOOF; }
273     spoof_notice { return SPOOF_NOTICE; }
274 michael 1247 timestamp { return T_TIMESTAMP; }
275 adx 30 tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; }
276     type { return TYPE; }
277     true_no_oper_flood { return TRUE_NO_OPER_FLOOD; }
278 michael 56 umodes { return T_UMODES; }
279 adx 30 unkline { return UNKLINE; }
280 michael 1301 undline { return T_UNDLINE; }
281 michael 1250 unlimited { return T_UNLIMITED; }
282 adx 30 use_egd { return USE_EGD; }
283     use_except { return USE_EXCEPT; }
284     use_invex { return USE_INVEX; }
285     use_knock { return USE_KNOCK; }
286     use_logging { return USE_LOGGING; }
287     use_whois_actually { return USE_WHOIS_ACTUALLY; }
288     throttle_time { return THROTTLE_TIME; }
289     user { return USER; }
290     tkline { return TKLINE; }
291     txline { return TXLINE; }
292     tresv { return TRESV; }
293     vhost { return VHOST; }
294     vhost6 { return VHOST6; }
295     warn { return WARN; }
296     xline { return XLINE; }
297 michael 1243 yes { yylval.number = 1; return TBOOL; }
298 adx 30
299     failed_oper_notice { return FAILED_OPER_NOTICE; }
300     max_accept { return MAX_ACCEPT; }
301     max_nick_changes { return MAX_NICK_CHANGES; }
302     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     kline_reason { return KLINE_REASON; }
310     kline_with_reason { return KLINE_WITH_REASON; }
311     warn_no_nline { return WARN_NO_NLINE; }
312    
313 michael 584 stats_e_disabled { return STATS_E_DISABLED; }
314 adx 30 stats_o_oper_only { return STATS_O_OPER_ONLY; }
315     stats_k_oper_only { return STATS_K_OPER_ONLY; }
316     stats_i_oper_only { return STATS_I_OPER_ONLY; }
317     stats_P_oper_only { return STATS_P_OPER_ONLY; }
318     pace_wait { return PACE_WAIT; }
319     pace_wait_simple { return PACE_WAIT_SIMPLE; }
320     knock_delay { return KNOCK_DELAY; }
321     knock_delay_channel { return KNOCK_DELAY_CHANNEL; }
322     max_bans { return MAX_BANS; }
323     modules { return MODULES; }
324     module { return MODULE; }
325     path { return PATH; }
326     max_targets { return MAX_TARGETS; }
327    
328     unxline { return T_UNXLINE; }
329     unresv { return T_UNRESV; }
330    
331     oper_only_umodes { return OPER_ONLY_UMODES; }
332     oper_umodes { return OPER_UMODES; }
333     bots { return T_BOTS; }
334     cconn { return T_CCONN; }
335 db 849 cconn_full { return T_CCONN_FULL; }
336 adx 30 deaf { return T_DEAF; }
337     debug { return T_DEBUG; }
338     full { return T_FULL; }
339     skill { return T_SKILL; }
340     nchange { return T_NCHANGE; }
341     rej { return T_REJ; }
342     unauth { return T_UNAUTH; }
343     spy { return T_SPY; }
344     external { return T_EXTERNAL; }
345     operwall { return T_OPERWALL; }
346     servnotice { return T_SERVNOTICE; }
347     invisible { return T_INVISIBLE; }
348     wallop { return T_WALLOP; }
349     callerid { return T_CALLERID; }
350     softcallerid { return T_SOFTCALLERID; }
351     drone { return T_DRONE; }
352     locops { return T_LOCOPS; }
353     topicburst { return TOPICBURST; }
354    
355     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     gigabytes { return GBYTES; }
379     gigabyte { return GBYTES; }
380     gbytes { return GBYTES; }
381     gbyte { return GBYTES; }
382     gb { return GBYTES; }
383     terabytes { return TBYTES; }
384     terabyte { return TBYTES; }
385     tbytes { return TBYTES; }
386     tbyte { return TBYTES; }
387     tb { return TBYTES; }
388     \.\. { return TWODOTS; }
389    
390     . { return yytext[0]; }
391     <<EOF>> { if (ieof()) yyterminate(); }
392    
393     %%
394    
395     /* C-comment ignoring routine -kre*/
396     static void
397     ccomment(void)
398     {
399     int c = 0;
400    
401     /* log(L_NOTICE, "got comment"); */
402     while (1)
403     {
404     while ((c = input()) != '*' && c != EOF)
405     if (c == '\n')
406     ++lineno;
407    
408     if (c == '*')
409     {
410     while ((c = input()) == '*')
411     /* Nothing */ ;
412     if (c == '/')
413     break;
414     else if (c == '\n')
415     ++lineno;
416     }
417    
418     if (c == EOF)
419     {
420     YY_FATAL_ERROR("EOF in comment");
421     /* XXX hack alert this disables
422     * the stupid unused function warning
423     * gcc generates
424     */
425     if (1 == 0)
426     yy_fatal_error("EOF in comment");
427     break;
428     }
429     }
430     }
431    
432     /* C-style .includes. This function will properly swap input conf buffers,
433     * and lineno -kre */
434     static void
435     cinclude(void)
436     {
437     char *p = NULL;
438    
439     if ((p = strchr(yytext, '<')) == NULL)
440     *strchr(p = strchr(yytext, '"') + 1, '"') = '\0';
441     else
442     *strchr(++p, '>') = '\0';
443    
444     /* log(L_NOTICE, "got include %s!", c); */
445    
446     /* do stacking and co. */
447     if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
448 michael 1247 ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p);
449 adx 30 else
450     {
451     FBFILE *tmp_fbfile_in = NULL;
452     char filenamebuf[IRCD_BUFSIZE];
453    
454     if (*p == '/') /* if it is an absolute path */
455     snprintf(filenamebuf, sizeof(filenamebuf), "%s", p);
456     else
457     snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p);
458    
459     tmp_fbfile_in = fbopen(filenamebuf, "r");
460    
461     if (tmp_fbfile_in == NULL)
462     {
463 michael 1247 ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
464 adx 30 filenamebuf, strerror(errno));
465     return;
466     }
467    
468     lineno_stack[include_stack_ptr] = lineno;
469     lineno = 1;
470 michael 967 inc_fbfile_in[include_stack_ptr] = conf_parser_ctx.conf_file;
471 adx 30 strlcpy(conffile_stack[include_stack_ptr], conffilebuf, IRCD_BUFSIZE);
472     include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
473 michael 967 conf_parser_ctx.conf_file = tmp_fbfile_in;
474 michael 711 snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf);
475 adx 30 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
476     }
477     }
478    
479     /* This is function that will be called on EOF in conf file. It will
480     * apropriately close conf if it not main conf and swap input buffers -kre
481     * */
482     static int
483     ieof(void)
484     {
485     /* log(L_NOTICE, "return from include stack!"); */
486     if (include_stack_ptr)
487 michael 967 fbclose(conf_parser_ctx.conf_file);
488 adx 30 if (--include_stack_ptr < 0)
489     {
490     /* log(L_NOTICE, "terminating lexer"); */
491     /* We will now exit the lexer - restore init values if we get /rehash
492     * later and reenter lexer -kre */
493     include_stack_ptr = 0;
494     lineno = 1;
495     return 1;
496     }
497    
498     /* switch buffer */
499     /* log(L_NOTICE, "deleting include_stack_ptr=%d", include_stack_ptr); */
500     yy_delete_buffer(YY_CURRENT_BUFFER);
501     lineno = lineno_stack[include_stack_ptr];
502 michael 967 conf_parser_ctx.conf_file = inc_fbfile_in[include_stack_ptr];
503 adx 30 strlcpy(conffilebuf, conffile_stack[include_stack_ptr], sizeof(conffilebuf));
504     yy_switch_to_buffer(include_stack[include_stack_ptr]);
505    
506     return 0;
507     }

Properties

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