| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
* |
| 4 |
* Copyright (c) 2000-2014 ircd-hybrid development team |
| 5 |
* |
| 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 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 19 |
* USA |
| 20 |
*/ |
| 21 |
|
| 22 |
/*! \file ircd_lexer.l |
| 23 |
* \brief Scans the ircd configuration file for tokens. |
| 24 |
* \version $Id$ |
| 25 |
*/ |
| 26 |
|
| 27 |
%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 |
#include "conf.h" |
| 36 |
#include "conf_parser.h" /* autogenerated header file */ |
| 37 |
#include "log.h" |
| 38 |
|
| 39 |
#undef YY_INPUT |
| 40 |
#define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg) |
| 41 |
#define YY_INPUT(buf,result,max_size) \ |
| 42 |
if (!(result = conf_yy_input(buf, max_size))) \ |
| 43 |
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 FILE *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 |
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 |
%} |
| 73 |
|
| 74 |
WS [[:blank:]]* |
| 75 |
DIGIT [[:digit:]]+ |
| 76 |
COMMENT ("//"|"#").* |
| 77 |
qstring \"[^\"\n]*[\"\n] |
| 78 |
include \.include{WS}(\<.*\>|\".*\") |
| 79 |
|
| 80 |
%% |
| 81 |
{include} { cinclude(); } |
| 82 |
"/*" { ccomment(); } |
| 83 |
|
| 84 |
\n.* { strlcpy(linebuf, yytext+1, sizeof(linebuf)); ++lineno; yyless(1); } |
| 85 |
|
| 86 |
{WS} ; |
| 87 |
{COMMENT} ; |
| 88 |
|
| 89 |
{DIGIT} { yylval.number = atoi(yytext); return NUMBER; } |
| 90 |
|
| 91 |
{qstring} { if (yytext[yyleng-2] == '\\') |
| 92 |
{ |
| 93 |
yyless(yyleng-1); /* return last quote */ |
| 94 |
yymore(); /* append next string */ |
| 95 |
} |
| 96 |
else |
| 97 |
{ |
| 98 |
yylval.string = yytext+1; |
| 99 |
if(yylval.string[yyleng-2] != '"') |
| 100 |
ilog(LOG_TYPE_IRCD, "Unterminated character string"); |
| 101 |
else |
| 102 |
{ |
| 103 |
int i,j; |
| 104 |
|
| 105 |
yylval.string[yyleng-2] = '\0'; /* remove close |
| 106 |
* quote |
| 107 |
*/ |
| 108 |
|
| 109 |
for (j=i=0 ;yylval.string[i] != '\0'; i++,j++) |
| 110 |
{ |
| 111 |
if (yylval.string[i] != '\\') |
| 112 |
{ |
| 113 |
yylval.string[j] = yylval.string[i]; |
| 114 |
} |
| 115 |
else |
| 116 |
{ |
| 117 |
i++; |
| 118 |
if (yylval.string[i] == '\0') /* XXX |
| 119 |
* should not |
| 120 |
* happen |
| 121 |
*/ |
| 122 |
{ |
| 123 |
ilog(LOG_TYPE_IRCD, |
| 124 |
"Unterminated character string"); |
| 125 |
break; |
| 126 |
} |
| 127 |
yylval.string[j] = yylval.string[i]; |
| 128 |
} |
| 129 |
} |
| 130 |
yylval.string[j] = '\0'; |
| 131 |
return QSTRING; |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
accept_password { return ACCEPT_PASSWORD; } |
| 137 |
admin { return ADMIN; } |
| 138 |
administrator { return ADMIN; } |
| 139 |
aftype { return AFTYPE; } |
| 140 |
all { return T_ALL; } |
| 141 |
anti_nick_flood { return ANTI_NICK_FLOOD; } |
| 142 |
anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; } |
| 143 |
auth { return IRCD_AUTH; } |
| 144 |
autoconn { return AUTOCONN; } |
| 145 |
bots { return T_BOTS; } |
| 146 |
caller_id_wait { return CALLER_ID_WAIT; } |
| 147 |
callerid { return T_CALLERID; } |
| 148 |
can_flood { return CAN_FLOOD; } |
| 149 |
cconn { return T_CCONN; } |
| 150 |
channel { return CHANNEL; } |
| 151 |
cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; } |
| 152 |
cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; } |
| 153 |
class { return CLASS; } |
| 154 |
cluster { return T_CLUSTER; } |
| 155 |
connect { return CONNECT; } |
| 156 |
connectfreq { return CONNECTFREQ; } |
| 157 |
cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; } |
| 158 |
deaf { return T_DEAF; } |
| 159 |
debug { return T_DEBUG; } |
| 160 |
default_floodcount { return DEFAULT_FLOODCOUNT; } |
| 161 |
default_split_server_count { return DEFAULT_SPLIT_SERVER_COUNT; } |
| 162 |
default_split_user_count { return DEFAULT_SPLIT_USER_COUNT; } |
| 163 |
deny { return DENY; } |
| 164 |
description { return DESCRIPTION; } |
| 165 |
die { return DIE; } |
| 166 |
disable_auth { return DISABLE_AUTH; } |
| 167 |
disable_fake_channels { return DISABLE_FAKE_CHANNELS; } |
| 168 |
disable_remote_commands { return DISABLE_REMOTE_COMMANDS; } |
| 169 |
dline { return T_DLINE; } |
| 170 |
dots_in_ident { return DOTS_IN_IDENT; } |
| 171 |
egdpool_path { return EGDPOOL_PATH; } |
| 172 |
email { return EMAIL; } |
| 173 |
encrypted { return ENCRYPTED; } |
| 174 |
exceed_limit { return EXCEED_LIMIT; } |
| 175 |
exempt { return EXEMPT; } |
| 176 |
external { return T_EXTERNAL; } |
| 177 |
failed_oper_notice { return FAILED_OPER_NOTICE; } |
| 178 |
farconnect { return T_FARCONNECT; } |
| 179 |
file { return T_FILE; } |
| 180 |
flags { return IRCD_FLAGS; } |
| 181 |
flatten_links { return FLATTEN_LINKS; } |
| 182 |
full { return T_FULL; } |
| 183 |
gecos { return GECOS; } |
| 184 |
general { return GENERAL; } |
| 185 |
gline { return GLINE; } |
| 186 |
gline_duration { return GLINE_DURATION; } |
| 187 |
gline_enable { return GLINE_ENABLE; } |
| 188 |
gline_exempt { return GLINE_EXEMPT; } |
| 189 |
gline_min_cidr { return GLINE_MIN_CIDR; } |
| 190 |
gline_min_cidr6 { return GLINE_MIN_CIDR6; } |
| 191 |
gline_request_duration { return GLINE_REQUEST_DURATION; } |
| 192 |
global_kill { return GLOBAL_KILL; } |
| 193 |
globops { return T_GLOBOPS; } |
| 194 |
have_ident { return NEED_IDENT; } |
| 195 |
havent_read_conf { return HAVENT_READ_CONF; } |
| 196 |
hidden { return HIDDEN; } |
| 197 |
hidden_name { return HIDDEN_NAME; } |
| 198 |
hidechans { return HIDE_CHANS; } |
| 199 |
hideidle { return HIDE_IDLE; } |
| 200 |
hide_idle_from_opers { return HIDE_IDLE_FROM_OPERS; } |
| 201 |
hide_server_ips { return HIDE_SERVER_IPS; } |
| 202 |
hide_servers { return HIDE_SERVERS; } |
| 203 |
hide_services { return HIDE_SERVICES; } |
| 204 |
hide_spoof_ips { return HIDE_SPOOF_IPS; } |
| 205 |
host { return HOST; } |
| 206 |
hub { return HUB; } |
| 207 |
hub_mask { return HUB_MASK; } |
| 208 |
ignore_bogus_ts { return IGNORE_BOGUS_TS; } |
| 209 |
invisible { return T_INVISIBLE; } |
| 210 |
invisible_on_connect { return INVISIBLE_ON_CONNECT; } |
| 211 |
ip { return IP; } |
| 212 |
ipv4 { return T_IPV4; } |
| 213 |
ipv6 { return T_IPV6; } |
| 214 |
join_flood_count { return JOIN_FLOOD_COUNT; } |
| 215 |
join_flood_time { return JOIN_FLOOD_TIME; } |
| 216 |
kill { return KILL; } |
| 217 |
kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; } |
| 218 |
kline { return KLINE; } |
| 219 |
kline_exempt { return KLINE_EXEMPT; } |
| 220 |
knock_delay { return KNOCK_DELAY; } |
| 221 |
knock_delay_channel { return KNOCK_DELAY_CHANNEL; } |
| 222 |
leaf_mask { return LEAF_MASK; } |
| 223 |
links_delay { return LINKS_DELAY; } |
| 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 |
max_chans_per_oper { return MAX_CHANS_PER_OPER; } |
| 232 |
max_chans_per_user { return MAX_CHANS_PER_USER; } |
| 233 |
max_clients { return T_MAX_CLIENTS; } |
| 234 |
max_global { return MAX_GLOBAL; } |
| 235 |
max_ident { return MAX_IDENT; } |
| 236 |
max_idle { return MAX_IDLE; } |
| 237 |
max_local { return MAX_LOCAL; } |
| 238 |
max_nick_changes { return MAX_NICK_CHANGES; } |
| 239 |
max_nick_length { return MAX_NICK_LENGTH; } |
| 240 |
max_nick_time { return MAX_NICK_TIME; } |
| 241 |
max_number { return MAX_NUMBER; } |
| 242 |
max_targets { return MAX_TARGETS; } |
| 243 |
max_topic_length { return MAX_TOPIC_LENGTH; } |
| 244 |
max_watch { return MAX_WATCH; } |
| 245 |
min_idle { return MIN_IDLE; } |
| 246 |
min_nonwildcard { return MIN_NONWILDCARD; } |
| 247 |
min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; } |
| 248 |
module { return MODULE; } |
| 249 |
modules { return MODULES; } |
| 250 |
motd { return MOTD; } |
| 251 |
name { return NAME; } |
| 252 |
nchange { return T_NCHANGE; } |
| 253 |
need_ident { return NEED_IDENT; } |
| 254 |
need_password { return NEED_PASSWORD; } |
| 255 |
network_desc { return NETWORK_DESC; } |
| 256 |
network_name { return NETWORK_NAME; } |
| 257 |
nick { return NICK; } |
| 258 |
no_create_on_split { return NO_CREATE_ON_SPLIT; } |
| 259 |
no_join_on_split { return NO_JOIN_ON_SPLIT; } |
| 260 |
no_oper_flood { return NO_OPER_FLOOD; } |
| 261 |
no_tilde { return NO_TILDE; } |
| 262 |
nononreg { return T_NONONREG; } |
| 263 |
number_per_cidr { return NUMBER_PER_CIDR; } |
| 264 |
number_per_ip { return NUMBER_PER_IP; } |
| 265 |
oper { return OPERATOR; } |
| 266 |
oper_only_umodes { return OPER_ONLY_UMODES; } |
| 267 |
oper_pass_resv { return OPER_PASS_RESV; } |
| 268 |
oper_umodes { return OPER_UMODES; } |
| 269 |
operator { return OPERATOR; } |
| 270 |
opers_bypass_callerid { return OPERS_BYPASS_CALLERID; } |
| 271 |
operwall { return T_OPERWALL; } |
| 272 |
pace_wait { return PACE_WAIT; } |
| 273 |
pace_wait_simple { return PACE_WAIT_SIMPLE; } |
| 274 |
passwd { return PASSWORD; } |
| 275 |
password { return PASSWORD; } |
| 276 |
path { return PATH; } |
| 277 |
ping_cookie { return PING_COOKIE; } |
| 278 |
ping_time { return PING_TIME; } |
| 279 |
port { return PORT; } |
| 280 |
quarantine { return RESV; } |
| 281 |
random_idle { return RANDOM_IDLE; } |
| 282 |
reason { return REASON; } |
| 283 |
recvq { return T_RECVQ; } |
| 284 |
redirport { return REDIRPORT; } |
| 285 |
redirserv { return REDIRSERV; } |
| 286 |
rehash { return REHASH; } |
| 287 |
rej { return T_REJ; } |
| 288 |
remote { return REMOTE; } |
| 289 |
remoteban { return REMOTEBAN; } |
| 290 |
restart { return T_RESTART; } |
| 291 |
resv { return RESV; } |
| 292 |
resv_exempt { return RESV_EXEMPT; } |
| 293 |
rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; } |
| 294 |
rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; } |
| 295 |
send_password { return SEND_PASSWORD; } |
| 296 |
sendq { return SENDQ; } |
| 297 |
server { return T_SERVER; } |
| 298 |
serverhide { return SERVERHIDE; } |
| 299 |
serverinfo { return SERVERINFO; } |
| 300 |
service { return T_SERVICE; } |
| 301 |
services_name { return T_SERVICES_NAME; } |
| 302 |
servnotice { return T_SERVNOTICE; } |
| 303 |
set { return T_SET; } |
| 304 |
shared { return T_SHARED; } |
| 305 |
short_motd { return SHORT_MOTD; } |
| 306 |
sid { return IRCD_SID; } |
| 307 |
size { return T_SIZE; } |
| 308 |
skill { return T_SKILL; } |
| 309 |
softcallerid { return T_SOFTCALLERID; } |
| 310 |
spoof { return SPOOF; } |
| 311 |
spoof_notice { return SPOOF_NOTICE; } |
| 312 |
spy { return T_SPY; } |
| 313 |
squit { return SQUIT; } |
| 314 |
ssl { return T_SSL; } |
| 315 |
ssl_certificate_file { return SSL_CERTIFICATE_FILE; } |
| 316 |
ssl_certificate_fingerprint { return SSL_CERTIFICATE_FINGERPRINT; } |
| 317 |
ssl_cipher_list { return T_SSL_CIPHER_LIST; } |
| 318 |
ssl_client_method { return T_SSL_CLIENT_METHOD; } |
| 319 |
ssl_connection_required { return SSL_CONNECTION_REQUIRED; } |
| 320 |
ssl_dh_param_file { return SSL_DH_PARAM_FILE; } |
| 321 |
ssl_server_method { return T_SSL_SERVER_METHOD; } |
| 322 |
sslv3 { return T_SSLV3; } |
| 323 |
stats_e_disabled { return STATS_E_DISABLED; } |
| 324 |
stats_i_oper_only { return STATS_I_OPER_ONLY; } |
| 325 |
stats_k_oper_only { return STATS_K_OPER_ONLY; } |
| 326 |
stats_o_oper_only { return STATS_O_OPER_ONLY; } |
| 327 |
stats_P_oper_only { return STATS_P_OPER_ONLY; } |
| 328 |
stats_u_oper_only { return STATS_U_OPER_ONLY; } |
| 329 |
throttle_time { return THROTTLE_TIME; } |
| 330 |
tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; } |
| 331 |
tlsv1 { return T_TLSV1; } |
| 332 |
true_no_oper_flood { return TRUE_NO_OPER_FLOOD; } |
| 333 |
ts_max_delta { return TS_MAX_DELTA; } |
| 334 |
ts_warn_delta { return TS_WARN_DELTA; } |
| 335 |
type { return TYPE; } |
| 336 |
umodes { return T_UMODES; } |
| 337 |
unauth { return T_UNAUTH; } |
| 338 |
undline { return T_UNDLINE; } |
| 339 |
unkline { return UNKLINE; } |
| 340 |
unlimited { return T_UNLIMITED; } |
| 341 |
unresv { return T_UNRESV; } |
| 342 |
unxline { return T_UNXLINE; } |
| 343 |
use_egd { return USE_EGD; } |
| 344 |
use_logging { return USE_LOGGING; } |
| 345 |
user { return USER; } |
| 346 |
vhost { return VHOST; } |
| 347 |
vhost6 { return VHOST6; } |
| 348 |
wallop { return T_WALLOP; } |
| 349 |
wallops { return T_WALLOPS; } |
| 350 |
warn_no_connect_block { return WARN_NO_CONNECT_BLOCK; } |
| 351 |
webirc { return T_WEBIRC; } |
| 352 |
xline { return XLINE; } |
| 353 |
|
| 354 |
yes { yylval.number = 1; return TBOOL; } |
| 355 |
no { yylval.number = 0; return TBOOL; } |
| 356 |
|
| 357 |
years { return YEARS; } |
| 358 |
year { return YEARS; } |
| 359 |
months { return MONTHS; } |
| 360 |
month { return MONTHS; } |
| 361 |
weeks { return WEEKS; } |
| 362 |
week { return WEEKS; } |
| 363 |
days { return DAYS; } |
| 364 |
day { return DAYS; } |
| 365 |
hours { return HOURS; } |
| 366 |
hour { return HOURS; } |
| 367 |
minutes { return MINUTES; } |
| 368 |
minute { return MINUTES; } |
| 369 |
seconds { return SECONDS; } |
| 370 |
second { return SECONDS; } |
| 371 |
|
| 372 |
bytes { return BYTES; } |
| 373 |
byte { return BYTES; } |
| 374 |
kilobytes { return KBYTES; } |
| 375 |
kilobyte { return KBYTES; } |
| 376 |
kbytes { return KBYTES; } |
| 377 |
kbyte { return KBYTES; } |
| 378 |
kb { return KBYTES; } |
| 379 |
megabytes { return MBYTES; } |
| 380 |
megabyte { return MBYTES; } |
| 381 |
mbytes { return MBYTES; } |
| 382 |
mbyte { return MBYTES; } |
| 383 |
mb { return MBYTES; } |
| 384 |
\.\. { return TWODOTS; } |
| 385 |
|
| 386 |
. { return yytext[0]; } |
| 387 |
<<EOF>> { if (ieof()) yyterminate(); } |
| 388 |
|
| 389 |
%% |
| 390 |
|
| 391 |
/* C-comment ignoring routine -kre*/ |
| 392 |
static void |
| 393 |
ccomment(void) |
| 394 |
{ |
| 395 |
int c = 0; |
| 396 |
|
| 397 |
/* log(L_NOTICE, "got comment"); */ |
| 398 |
while (1) |
| 399 |
{ |
| 400 |
while ((c = input()) != '*' && c != EOF) |
| 401 |
if (c == '\n') |
| 402 |
++lineno; |
| 403 |
|
| 404 |
if (c == '*') |
| 405 |
{ |
| 406 |
while ((c = input()) == '*') |
| 407 |
/* Nothing */ ; |
| 408 |
if (c == '/') |
| 409 |
break; |
| 410 |
else if (c == '\n') |
| 411 |
++lineno; |
| 412 |
} |
| 413 |
|
| 414 |
if (c == EOF) |
| 415 |
{ |
| 416 |
YY_FATAL_ERROR("EOF in comment"); |
| 417 |
/* XXX hack alert this disables |
| 418 |
* the stupid unused function warning |
| 419 |
* gcc generates |
| 420 |
*/ |
| 421 |
if (1 == 0) |
| 422 |
yy_fatal_error("EOF in comment"); |
| 423 |
break; |
| 424 |
} |
| 425 |
} |
| 426 |
} |
| 427 |
|
| 428 |
/* C-style .includes. This function will properly swap input conf buffers, |
| 429 |
* and lineno -kre */ |
| 430 |
static void |
| 431 |
cinclude(void) |
| 432 |
{ |
| 433 |
char *p = NULL; |
| 434 |
|
| 435 |
if ((p = strchr(yytext, '<')) == NULL) |
| 436 |
*strchr(p = strchr(yytext, '"') + 1, '"') = '\0'; |
| 437 |
else |
| 438 |
*strchr(++p, '>') = '\0'; |
| 439 |
|
| 440 |
/* log(L_NOTICE, "got include %s!", c); */ |
| 441 |
|
| 442 |
/* do stacking and co. */ |
| 443 |
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) |
| 444 |
ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p); |
| 445 |
else |
| 446 |
{ |
| 447 |
FILE *tmp_fbfile_in = NULL; |
| 448 |
char filenamebuf[IRCD_BUFSIZE]; |
| 449 |
|
| 450 |
if (*p == '/') /* if it is an absolute path */ |
| 451 |
snprintf(filenamebuf, sizeof(filenamebuf), "%s", p); |
| 452 |
else |
| 453 |
snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p); |
| 454 |
|
| 455 |
tmp_fbfile_in = fopen(filenamebuf, "r"); |
| 456 |
|
| 457 |
if (tmp_fbfile_in == NULL) |
| 458 |
{ |
| 459 |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
| 460 |
filenamebuf, strerror(errno)); |
| 461 |
return; |
| 462 |
} |
| 463 |
|
| 464 |
lineno_stack[include_stack_ptr] = lineno; |
| 465 |
lineno = 1; |
| 466 |
inc_fbfile_in[include_stack_ptr] = conf_parser_ctx.conf_file; |
| 467 |
strlcpy(conffile_stack[include_stack_ptr], conffilebuf, IRCD_BUFSIZE); |
| 468 |
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; |
| 469 |
conf_parser_ctx.conf_file = tmp_fbfile_in; |
| 470 |
snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf); |
| 471 |
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
/* This is function that will be called on EOF in conf file. It will |
| 476 |
* apropriately close conf if it not main conf and swap input buffers -kre |
| 477 |
* */ |
| 478 |
static int |
| 479 |
ieof(void) |
| 480 |
{ |
| 481 |
/* log(L_NOTICE, "return from include stack!"); */ |
| 482 |
if (include_stack_ptr) |
| 483 |
fclose(conf_parser_ctx.conf_file); |
| 484 |
if (--include_stack_ptr < 0) |
| 485 |
{ |
| 486 |
/* log(L_NOTICE, "terminating lexer"); */ |
| 487 |
/* We will now exit the lexer - restore init values if we get /rehash |
| 488 |
* later and reenter lexer -kre */ |
| 489 |
include_stack_ptr = 0; |
| 490 |
lineno = 1; |
| 491 |
return 1; |
| 492 |
} |
| 493 |
|
| 494 |
/* switch buffer */ |
| 495 |
/* log(L_NOTICE, "deleting include_stack_ptr=%d", include_stack_ptr); */ |
| 496 |
yy_delete_buffer(YY_CURRENT_BUFFER); |
| 497 |
lineno = lineno_stack[include_stack_ptr]; |
| 498 |
conf_parser_ctx.conf_file = inc_fbfile_in[include_stack_ptr]; |
| 499 |
strlcpy(conffilebuf, conffile_stack[include_stack_ptr], sizeof(conffilebuf)); |
| 500 |
yy_switch_to_buffer(include_stack[include_stack_ptr]); |
| 501 |
|
| 502 |
return 0; |
| 503 |
} |