1 |
adx |
30 |
/* |
2 |
michael |
2916 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
9857 |
* Copyright (c) 2000-2021 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 |
4565 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
adx |
30 |
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
michael |
7678 |
/*! \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 |
michael |
9886 |
%option noinput |
30 |
adx |
30 |
%option nounput |
31 |
|
|
%option never-interactive |
32 |
|
|
|
33 |
michael |
9886 |
%x IN_COMMENT |
34 |
|
|
|
35 |
adx |
30 |
%{ |
36 |
|
|
#include "stdinc.h" |
37 |
|
|
#include "irc_string.h" |
38 |
michael |
1309 |
#include "conf.h" |
39 |
|
|
#include "conf_parser.h" /* autogenerated header file */ |
40 |
|
|
#include "log.h" |
41 |
adx |
30 |
|
42 |
|
|
#undef YY_INPUT |
43 |
|
|
#define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg) |
44 |
|
|
#define YY_INPUT(buf,result,max_size) \ |
45 |
michael |
8759 |
if ((result = conf_yy_input(buf, max_size)) == 0) \ |
46 |
michael |
2916 |
YY_FATAL_ERROR("input in flex scanner failed"); |
47 |
adx |
30 |
|
48 |
|
|
|
49 |
|
|
unsigned int lineno = 1; |
50 |
|
|
char linebuf[IRCD_BUFSIZE]; |
51 |
|
|
char conffilebuf[IRCD_BUFSIZE]; |
52 |
|
|
|
53 |
michael |
9907 |
enum { MAX_INCLUDE_DEPTH = 5 }; |
54 |
|
|
static unsigned int include_stack_ptr; |
55 |
|
|
|
56 |
michael |
7705 |
static struct included_file |
57 |
|
|
{ |
58 |
|
|
YY_BUFFER_STATE state; |
59 |
|
|
unsigned int lineno; |
60 |
|
|
FILE *file; |
61 |
|
|
char conffile[IRCD_BUFSIZE]; |
62 |
|
|
} include_stack[MAX_INCLUDE_DEPTH]; |
63 |
|
|
|
64 |
|
|
|
65 |
michael |
9886 |
static void conf_include(void); |
66 |
|
|
static bool conf_eof(void); |
67 |
michael |
1353 |
|
68 |
|
|
static int |
69 |
|
|
conf_yy_input(char *lbuf, unsigned int max_size) |
70 |
|
|
{ |
71 |
michael |
8759 |
return fgets(lbuf, max_size, conf_parser_ctx.conf_file) == NULL ? 0 : strlen(lbuf); |
72 |
michael |
1353 |
} |
73 |
|
|
|
74 |
|
|
static int |
75 |
|
|
conf_yy_fatal_error(const char *msg) |
76 |
|
|
{ |
77 |
|
|
return 0; |
78 |
|
|
} |
79 |
|
|
|
80 |
adx |
30 |
%} |
81 |
|
|
|
82 |
|
|
WS [[:blank:]]* |
83 |
|
|
DIGIT [[:digit:]]+ |
84 |
|
|
COMMENT ("//"|"#").* |
85 |
michael |
9909 |
qstring \"[^\"\n]*[\"\n] |
86 |
adx |
30 |
include \.include{WS}(\<.*\>|\".*\") |
87 |
|
|
|
88 |
|
|
%% |
89 |
michael |
9886 |
|
90 |
|
|
"/*" { BEGIN IN_COMMENT; } |
91 |
|
|
<IN_COMMENT>"*/" { BEGIN INITIAL; } |
92 |
|
|
<IN_COMMENT>. ; /* Eat everything but a newline */ |
93 |
|
|
<IN_COMMENT>\n { ++lineno; } |
94 |
michael |
9907 |
<IN_COMMENT><<EOF>> { BEGIN INITIAL; if (conf_eof() == true) yyterminate(); } |
95 |
michael |
9886 |
|
96 |
|
|
{include} { conf_include(); } |
97 |
michael |
4298 |
\n.* { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); } |
98 |
adx |
30 |
{WS} ; |
99 |
|
|
{COMMENT} ; |
100 |
|
|
{DIGIT} { yylval.number = atoi(yytext); return NUMBER; } |
101 |
michael |
4298 |
{qstring} { if (yytext[yyleng - 2] == '\\') |
102 |
|
|
{ |
103 |
|
|
yyless(yyleng - 1); /* Return last quote */ |
104 |
|
|
yymore(); /* Append next string */ |
105 |
|
|
} |
106 |
|
|
else |
107 |
|
|
{ |
108 |
|
|
yylval.string = yytext + 1; |
109 |
adx |
30 |
|
110 |
michael |
4298 |
if (yylval.string[yyleng - 2] != '"') |
111 |
|
|
ilog(LOG_TYPE_IRCD, "Unterminated character string"); |
112 |
|
|
else |
113 |
|
|
{ |
114 |
|
|
unsigned int i = 0, j = 0; |
115 |
adx |
30 |
|
116 |
michael |
4298 |
yylval.string[yyleng - 2] = '\0'; /* Remove close quote */ |
117 |
michael |
2916 |
|
118 |
michael |
4298 |
for (; yylval.string[i] != '\0'; ++i, ++j) |
119 |
|
|
{ |
120 |
|
|
if (yylval.string[i] != '\\') |
121 |
|
|
yylval.string[j] = yylval.string[i]; |
122 |
|
|
else |
123 |
|
|
{ |
124 |
|
|
++i; |
125 |
adx |
30 |
|
126 |
michael |
4298 |
if (yylval.string[i] == '\0') /* XXX: should not happen */ |
127 |
|
|
{ |
128 |
|
|
ilog(LOG_TYPE_IRCD, "Unterminated character string"); |
129 |
|
|
break; |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
yylval.string[j] = yylval.string[i]; |
133 |
|
|
} |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
yylval.string[j] = '\0'; |
137 |
|
|
return QSTRING; |
138 |
|
|
} |
139 |
|
|
} |
140 |
|
|
} |
141 |
|
|
|
142 |
michael |
2129 |
accept_password { return ACCEPT_PASSWORD; } |
143 |
|
|
admin { return ADMIN; } |
144 |
|
|
administrator { return ADMIN; } |
145 |
|
|
aftype { return AFTYPE; } |
146 |
|
|
all { return T_ALL; } |
147 |
|
|
anti_nick_flood { return ANTI_NICK_FLOOD; } |
148 |
|
|
anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; } |
149 |
|
|
auth { return IRCD_AUTH; } |
150 |
|
|
autoconn { return AUTOCONN; } |
151 |
michael |
4313 |
away_count { return AWAY_COUNT; } |
152 |
|
|
away_time { return AWAY_TIME; } |
153 |
michael |
8864 |
bind { return T_BIND; } |
154 |
michael |
9775 |
bot { return BOT; } |
155 |
michael |
2129 |
caller_id_wait { return CALLER_ID_WAIT; } |
156 |
|
|
callerid { return T_CALLERID; } |
157 |
|
|
can_flood { return CAN_FLOOD; } |
158 |
|
|
cconn { return T_CCONN; } |
159 |
|
|
channel { return CHANNEL; } |
160 |
|
|
cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; } |
161 |
|
|
cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; } |
162 |
|
|
class { return CLASS; } |
163 |
michael |
9586 |
client { return CLIENT; } |
164 |
michael |
6488 |
close { return CLOSE; } |
165 |
michael |
2129 |
cluster { return T_CLUSTER; } |
166 |
michael |
4545 |
command { return T_COMMAND; } |
167 |
michael |
2129 |
connect { return CONNECT; } |
168 |
|
|
connectfreq { return CONNECTFREQ; } |
169 |
michael |
2283 |
cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; } |
170 |
michael |
2129 |
deaf { return T_DEAF; } |
171 |
|
|
debug { return T_DEBUG; } |
172 |
|
|
default_floodcount { return DEFAULT_FLOODCOUNT; } |
173 |
michael |
7858 |
default_floodtime { return DEFAULT_FLOODTIME; } |
174 |
michael |
5489 |
default_join_flood_count { return DEFAULT_JOIN_FLOOD_COUNT; } |
175 |
|
|
default_join_flood_time { return DEFAULT_JOIN_FLOOD_TIME; } |
176 |
|
|
default_max_clients { return DEFAULT_MAX_CLIENTS; } |
177 |
michael |
9610 |
defer { return DEFER; } |
178 |
michael |
2129 |
deny { return DENY; } |
179 |
|
|
description { return DESCRIPTION; } |
180 |
|
|
die { return DIE; } |
181 |
|
|
disable_auth { return DISABLE_AUTH; } |
182 |
|
|
disable_fake_channels { return DISABLE_FAKE_CHANNELS; } |
183 |
|
|
disable_remote_commands { return DISABLE_REMOTE_COMMANDS; } |
184 |
|
|
dline { return T_DLINE; } |
185 |
michael |
5805 |
dline_min_cidr { return DLINE_MIN_CIDR; } |
186 |
|
|
dline_min_cidr6 { return DLINE_MIN_CIDR6; } |
187 |
michael |
2129 |
email { return EMAIL; } |
188 |
michael |
9234 |
enable_extbans { return ENABLE_EXTBANS; } |
189 |
michael |
2129 |
encrypted { return ENCRYPTED; } |
190 |
|
|
exceed_limit { return EXCEED_LIMIT; } |
191 |
|
|
exempt { return EXEMPT; } |
192 |
michael |
8963 |
expiration { return EXPIRATION; } |
193 |
michael |
2129 |
external { return T_EXTERNAL; } |
194 |
|
|
failed_oper_notice { return FAILED_OPER_NOTICE; } |
195 |
|
|
farconnect { return T_FARCONNECT; } |
196 |
|
|
file { return T_FILE; } |
197 |
|
|
flags { return IRCD_FLAGS; } |
198 |
|
|
flatten_links { return FLATTEN_LINKS; } |
199 |
michael |
6597 |
flatten_links_delay { return FLATTEN_LINKS_DELAY; } |
200 |
michael |
6599 |
flatten_links_file { return FLATTEN_LINKS_FILE; } |
201 |
michael |
9638 |
flood { return T_FLOOD; } |
202 |
michael |
2129 |
gecos { return GECOS; } |
203 |
|
|
general { return GENERAL; } |
204 |
michael |
5805 |
kline_min_cidr { return KLINE_MIN_CIDR; } |
205 |
|
|
kline_min_cidr6 { return KLINE_MIN_CIDR6; } |
206 |
michael |
2129 |
globops { return T_GLOBOPS; } |
207 |
|
|
have_ident { return NEED_IDENT; } |
208 |
|
|
hidden { return HIDDEN; } |
209 |
|
|
hidden_name { return HIDDEN_NAME; } |
210 |
michael |
3513 |
hidechans { return HIDE_CHANS; } |
211 |
michael |
3506 |
hideidle { return HIDE_IDLE; } |
212 |
michael |
2129 |
hide_idle_from_opers { return HIDE_IDLE_FROM_OPERS; } |
213 |
|
|
hide_server_ips { return HIDE_SERVER_IPS; } |
214 |
|
|
hide_servers { return HIDE_SERVERS; } |
215 |
|
|
hide_services { return HIDE_SERVICES; } |
216 |
|
|
host { return HOST; } |
217 |
|
|
hub { return HUB; } |
218 |
|
|
hub_mask { return HUB_MASK; } |
219 |
|
|
invisible { return T_INVISIBLE; } |
220 |
|
|
invisible_on_connect { return INVISIBLE_ON_CONNECT; } |
221 |
michael |
3860 |
invite_client_count { return INVITE_CLIENT_COUNT; } |
222 |
|
|
invite_client_time { return INVITE_CLIENT_TIME; } |
223 |
michael |
6792 |
invite_delay_channel { return INVITE_DELAY_CHANNEL; } |
224 |
michael |
7793 |
invite_expire_time { return INVITE_EXPIRE_TIME; } |
225 |
michael |
2129 |
ip { return IP; } |
226 |
|
|
ipv4 { return T_IPV4; } |
227 |
|
|
ipv6 { return T_IPV6; } |
228 |
michael |
6447 |
join { return JOIN; } |
229 |
michael |
2129 |
kill { return KILL; } |
230 |
|
|
kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; } |
231 |
|
|
kline { return KLINE; } |
232 |
|
|
kline_exempt { return KLINE_EXEMPT; } |
233 |
michael |
3860 |
knock_client_count { return KNOCK_CLIENT_COUNT; } |
234 |
|
|
knock_client_time { return KNOCK_CLIENT_TIME; } |
235 |
michael |
2129 |
knock_delay_channel { return KNOCK_DELAY_CHANNEL; } |
236 |
|
|
leaf_mask { return LEAF_MASK; } |
237 |
|
|
listen { return LISTEN; } |
238 |
|
|
locops { return T_LOCOPS; } |
239 |
|
|
log { return T_LOG; } |
240 |
|
|
mask { return MASK; } |
241 |
|
|
max_accept { return MAX_ACCEPT; } |
242 |
|
|
max_bans { return MAX_BANS; } |
243 |
michael |
8046 |
max_bans_large { return MAX_BANS_LARGE; } |
244 |
michael |
3933 |
max_channels { return MAX_CHANNELS; } |
245 |
michael |
2129 |
max_idle { return MAX_IDLE; } |
246 |
michael |
7766 |
max_invites { return MAX_INVITES; } |
247 |
michael |
9750 |
max_monitor { return MAX_MONITOR; } |
248 |
michael |
2129 |
max_nick_changes { return MAX_NICK_CHANGES; } |
249 |
|
|
max_nick_length { return MAX_NICK_LENGTH; } |
250 |
|
|
max_nick_time { return MAX_NICK_TIME; } |
251 |
|
|
max_number { return MAX_NUMBER; } |
252 |
|
|
max_targets { return MAX_TARGETS; } |
253 |
|
|
max_topic_length { return MAX_TOPIC_LENGTH; } |
254 |
|
|
min_idle { return MIN_IDLE; } |
255 |
|
|
min_nonwildcard { return MIN_NONWILDCARD; } |
256 |
|
|
min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; } |
257 |
|
|
module { return MODULE; } |
258 |
|
|
modules { return MODULES; } |
259 |
michael |
2150 |
motd { return MOTD; } |
260 |
michael |
2129 |
name { return NAME; } |
261 |
|
|
nchange { return T_NCHANGE; } |
262 |
|
|
need_ident { return NEED_IDENT; } |
263 |
|
|
need_password { return NEED_PASSWORD; } |
264 |
michael |
9692 |
network_description { return NETWORK_DESCRIPTION; } |
265 |
michael |
2129 |
network_name { return NETWORK_NAME; } |
266 |
|
|
nick { return NICK; } |
267 |
|
|
no_oper_flood { return NO_OPER_FLOOD; } |
268 |
|
|
no_tilde { return NO_TILDE; } |
269 |
|
|
nononreg { return T_NONONREG; } |
270 |
|
|
number_per_cidr { return NUMBER_PER_CIDR; } |
271 |
michael |
8496 |
number_per_ip_global { return NUMBER_PER_IP_GLOBAL; } |
272 |
|
|
number_per_ip_local { return NUMBER_PER_IP_LOCAL; } |
273 |
michael |
2129 |
oper { return OPERATOR; } |
274 |
|
|
oper_only_umodes { return OPER_ONLY_UMODES; } |
275 |
|
|
oper_umodes { return OPER_UMODES; } |
276 |
|
|
operator { return OPERATOR; } |
277 |
|
|
opers_bypass_callerid { return OPERS_BYPASS_CALLERID; } |
278 |
michael |
5004 |
opme { return T_OPME; } |
279 |
michael |
2129 |
pace_wait { return PACE_WAIT; } |
280 |
|
|
pace_wait_simple { return PACE_WAIT_SIMPLE; } |
281 |
|
|
password { return PASSWORD; } |
282 |
|
|
path { return PATH; } |
283 |
|
|
ping_cookie { return PING_COOKIE; } |
284 |
|
|
ping_time { return PING_TIME; } |
285 |
|
|
port { return PORT; } |
286 |
michael |
4545 |
prepend { return T_PREPEND; } |
287 |
|
|
pseudo { return T_PSEUDO; } |
288 |
michael |
2129 |
random_idle { return RANDOM_IDLE; } |
289 |
|
|
reason { return REASON; } |
290 |
|
|
recvq { return T_RECVQ; } |
291 |
|
|
redirport { return REDIRPORT; } |
292 |
|
|
redirserv { return REDIRSERV; } |
293 |
|
|
rehash { return REHASH; } |
294 |
|
|
rej { return T_REJ; } |
295 |
|
|
remote { return REMOTE; } |
296 |
|
|
remoteban { return REMOTEBAN; } |
297 |
|
|
restart { return T_RESTART; } |
298 |
|
|
resv { return RESV; } |
299 |
|
|
resv_exempt { return RESV_EXEMPT; } |
300 |
|
|
rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; } |
301 |
|
|
send_password { return SEND_PASSWORD; } |
302 |
|
|
sendq { return SENDQ; } |
303 |
|
|
server { return T_SERVER; } |
304 |
|
|
serverhide { return SERVERHIDE; } |
305 |
|
|
serverinfo { return SERVERINFO; } |
306 |
|
|
service { return T_SERVICE; } |
307 |
|
|
servnotice { return T_SERVNOTICE; } |
308 |
|
|
set { return T_SET; } |
309 |
|
|
shared { return T_SHARED; } |
310 |
|
|
short_motd { return SHORT_MOTD; } |
311 |
|
|
sid { return IRCD_SID; } |
312 |
|
|
size { return T_SIZE; } |
313 |
|
|
skill { return T_SKILL; } |
314 |
|
|
softcallerid { return T_SOFTCALLERID; } |
315 |
michael |
9898 |
specials_in_ident { return SPECIALS_IN_IDENT; } |
316 |
michael |
2129 |
spoof { return SPOOF; } |
317 |
|
|
spy { return T_SPY; } |
318 |
|
|
squit { return SQUIT; } |
319 |
michael |
9157 |
ssl { return T_TLS; } |
320 |
michael |
2129 |
stats_e_disabled { return STATS_E_DISABLED; } |
321 |
|
|
stats_i_oper_only { return STATS_I_OPER_ONLY; } |
322 |
|
|
stats_k_oper_only { return STATS_K_OPER_ONLY; } |
323 |
michael |
5025 |
stats_m_oper_only { return STATS_M_OPER_ONLY; } |
324 |
michael |
2129 |
stats_o_oper_only { return STATS_O_OPER_ONLY; } |
325 |
|
|
stats_P_oper_only { return STATS_P_OPER_ONLY; } |
326 |
michael |
2269 |
stats_u_oper_only { return STATS_U_OPER_ONLY; } |
327 |
michael |
4545 |
target { return T_TARGET; } |
328 |
michael |
3877 |
throttle_count { return THROTTLE_COUNT; } |
329 |
michael |
2129 |
throttle_time { return THROTTLE_TIME; } |
330 |
michael |
9096 |
timeout { return TIMEOUT; } |
331 |
michael |
9157 |
tls { return T_TLS; } |
332 |
michael |
9145 |
tls_certificate_file { return TLS_CERTIFICATE_FILE; } |
333 |
|
|
tls_certificate_fingerprint { return TLS_CERTIFICATE_FINGERPRINT; } |
334 |
|
|
tls_cipher_list { return TLS_CIPHER_LIST; } |
335 |
michael |
9139 |
tls_cipher_suites { return TLS_CIPHER_SUITES; } |
336 |
michael |
9145 |
tls_connection_required { return TLS_CONNECTION_REQUIRED; } |
337 |
|
|
tls_dh_param_file { return TLS_DH_PARAM_FILE; } |
338 |
|
|
tls_message_digest_algorithm { return TLS_MESSAGE_DIGEST_ALGORITHM; } |
339 |
|
|
tls_supported_groups { return TLS_SUPPORTED_GROUPS; } |
340 |
michael |
2129 |
ts_max_delta { return TS_MAX_DELTA; } |
341 |
|
|
ts_warn_delta { return TS_WARN_DELTA; } |
342 |
|
|
type { return TYPE; } |
343 |
|
|
umodes { return T_UMODES; } |
344 |
|
|
undline { return T_UNDLINE; } |
345 |
|
|
unkline { return UNKLINE; } |
346 |
|
|
unlimited { return T_UNLIMITED; } |
347 |
|
|
unresv { return T_UNRESV; } |
348 |
|
|
unxline { return T_UNXLINE; } |
349 |
|
|
use_logging { return USE_LOGGING; } |
350 |
michael |
2916 |
user { return USER; } |
351 |
michael |
2129 |
wallop { return T_WALLOP; } |
352 |
|
|
wallops { return T_WALLOPS; } |
353 |
michael |
3473 |
warn_no_connect_block { return WARN_NO_CONNECT_BLOCK; } |
354 |
michael |
2129 |
webirc { return T_WEBIRC; } |
355 |
michael |
5556 |
whois { return WHOIS; } |
356 |
michael |
7437 |
whowas_history_length { return WHOWAS_HISTORY_LENGTH; } |
357 |
michael |
2129 |
xline { return XLINE; } |
358 |
michael |
5990 |
xline_exempt { return XLINE_EXEMPT; } |
359 |
adx |
30 |
|
360 |
michael |
2129 |
yes { yylval.number = 1; return TBOOL; } |
361 |
|
|
no { yylval.number = 0; return TBOOL; } |
362 |
adx |
30 |
|
363 |
michael |
2129 |
years { return YEARS; } |
364 |
|
|
year { return YEARS; } |
365 |
|
|
months { return MONTHS; } |
366 |
|
|
month { return MONTHS; } |
367 |
|
|
weeks { return WEEKS; } |
368 |
|
|
week { return WEEKS; } |
369 |
|
|
days { return DAYS; } |
370 |
|
|
day { return DAYS; } |
371 |
|
|
hours { return HOURS; } |
372 |
|
|
hour { return HOURS; } |
373 |
|
|
minutes { return MINUTES; } |
374 |
|
|
minute { return MINUTES; } |
375 |
|
|
seconds { return SECONDS; } |
376 |
|
|
second { return SECONDS; } |
377 |
adx |
30 |
|
378 |
michael |
2129 |
bytes { return BYTES; } |
379 |
|
|
byte { return BYTES; } |
380 |
|
|
kilobytes { return KBYTES; } |
381 |
|
|
kilobyte { return KBYTES; } |
382 |
|
|
kbytes { return KBYTES; } |
383 |
|
|
kbyte { return KBYTES; } |
384 |
|
|
kb { return KBYTES; } |
385 |
|
|
megabytes { return MBYTES; } |
386 |
|
|
megabyte { return MBYTES; } |
387 |
|
|
mbytes { return MBYTES; } |
388 |
|
|
mbyte { return MBYTES; } |
389 |
|
|
mb { return MBYTES; } |
390 |
|
|
\.\. { return TWODOTS; } |
391 |
adx |
30 |
|
392 |
michael |
2129 |
. { return yytext[0]; } |
393 |
michael |
9886 |
<<EOF>> { if (conf_eof() == true) yyterminate(); } |
394 |
adx |
30 |
|
395 |
|
|
%% |
396 |
|
|
|
397 |
|
|
/* C-style .includes. This function will properly swap input conf buffers, |
398 |
|
|
* and lineno -kre */ |
399 |
|
|
static void |
400 |
michael |
9886 |
conf_include(void) |
401 |
adx |
30 |
{ |
402 |
michael |
8759 |
char *p; |
403 |
michael |
7705 |
char filenamebuf[IRCD_BUFSIZE]; |
404 |
adx |
30 |
|
405 |
|
|
if ((p = strchr(yytext, '<')) == NULL) |
406 |
|
|
*strchr(p = strchr(yytext, '"') + 1, '"') = '\0'; |
407 |
|
|
else |
408 |
|
|
*strchr(++p, '>') = '\0'; |
409 |
|
|
|
410 |
michael |
2916 |
/* do stacking and co. */ |
411 |
adx |
30 |
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) |
412 |
michael |
7705 |
{ |
413 |
michael |
1247 |
ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p); |
414 |
michael |
7705 |
return; |
415 |
|
|
} |
416 |
|
|
|
417 |
|
|
if (*p == '/') /* if it is an absolute path */ |
418 |
|
|
snprintf(filenamebuf, sizeof(filenamebuf), "%s", p); |
419 |
adx |
30 |
else |
420 |
michael |
7705 |
snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p); |
421 |
|
|
|
422 |
|
|
FILE *tmp_fbfile_in = fopen(filenamebuf, "r"); |
423 |
michael |
8759 |
if (tmp_fbfile_in == NULL) |
424 |
adx |
30 |
{ |
425 |
michael |
7705 |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
426 |
|
|
filenamebuf, strerror(errno)); |
427 |
|
|
return; |
428 |
|
|
} |
429 |
adx |
30 |
|
430 |
michael |
7705 |
struct included_file *file = &include_stack[include_stack_ptr++]; |
431 |
|
|
file->lineno = lineno; |
432 |
|
|
file->file = conf_parser_ctx.conf_file; |
433 |
|
|
file->state = YY_CURRENT_BUFFER; |
434 |
|
|
strlcpy(file->conffile, conffilebuf, sizeof(file->conffile)); |
435 |
adx |
30 |
|
436 |
michael |
7705 |
lineno = 1; |
437 |
|
|
conf_parser_ctx.conf_file = tmp_fbfile_in; |
438 |
michael |
7744 |
strlcpy(conffilebuf, filenamebuf, sizeof(conffilebuf)); |
439 |
michael |
2916 |
|
440 |
michael |
7731 |
yy_switch_to_buffer(yy_create_buffer(NULL, YY_BUF_SIZE)); |
441 |
adx |
30 |
} |
442 |
|
|
|
443 |
|
|
/* This is function that will be called on EOF in conf file. It will |
444 |
|
|
* apropriately close conf if it not main conf and swap input buffers -kre |
445 |
|
|
* */ |
446 |
michael |
8759 |
static bool |
447 |
michael |
9886 |
conf_eof(void) |
448 |
adx |
30 |
{ |
449 |
michael |
7705 |
if (include_stack_ptr == 0) |
450 |
adx |
30 |
{ |
451 |
|
|
lineno = 1; |
452 |
michael |
8759 |
return true; |
453 |
adx |
30 |
} |
454 |
|
|
|
455 |
|
|
/* switch buffer */ |
456 |
michael |
7705 |
struct included_file *file = &include_stack[--include_stack_ptr]; |
457 |
|
|
|
458 |
|
|
/* close current file */ |
459 |
|
|
fclose(conf_parser_ctx.conf_file); |
460 |
|
|
|
461 |
|
|
/* switch buffers */ |
462 |
adx |
30 |
yy_delete_buffer(YY_CURRENT_BUFFER); |
463 |
michael |
7705 |
yy_switch_to_buffer(file->state); |
464 |
adx |
30 |
|
465 |
michael |
7705 |
/* switch lineno */ |
466 |
|
|
lineno = file->lineno; |
467 |
|
|
|
468 |
|
|
/* switch file */ |
469 |
|
|
conf_parser_ctx.conf_file = file->file; |
470 |
|
|
|
471 |
|
|
strlcpy(conffilebuf, file->conffile, sizeof(conffilebuf)); |
472 |
michael |
8759 |
return false; |
473 |
adx |
30 |
} |