1 |
adx |
30 |
/* |
2 |
michael |
2916 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2916 |
* Copyright (c) 2000-2014 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 |
2916 |
/*! \file ircd_lexer.l |
23 |
|
|
* \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 |
1353 |
if (!(result = conf_yy_input(buf, max_size))) \ |
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 |
|
|
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 |
michael |
1325 |
static FILE *inc_fbfile_in[MAX_INCLUDE_DEPTH]; |
55 |
adx |
30 |
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 |
michael |
1353 |
|
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 |
adx |
30 |
%} |
73 |
|
|
|
74 |
|
|
WS [[:blank:]]* |
75 |
|
|
DIGIT [[:digit:]]+ |
76 |
|
|
COMMENT ("//"|"#").* |
77 |
|
|
qstring \"[^\"\n]*[\"\n] |
78 |
|
|
include \.include{WS}(\<.*\>|\".*\") |
79 |
|
|
|
80 |
|
|
%% |
81 |
|
|
{include} { cinclude(); } |
82 |
michael |
2916 |
"/*" { ccomment(); } |
83 |
michael |
4298 |
\n.* { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); } |
84 |
adx |
30 |
{WS} ; |
85 |
|
|
{COMMENT} ; |
86 |
|
|
{DIGIT} { yylval.number = atoi(yytext); return NUMBER; } |
87 |
michael |
4298 |
{qstring} { if (yytext[yyleng - 2] == '\\') |
88 |
|
|
{ |
89 |
|
|
yyless(yyleng - 1); /* Return last quote */ |
90 |
|
|
yymore(); /* Append next string */ |
91 |
|
|
} |
92 |
|
|
else |
93 |
|
|
{ |
94 |
|
|
yylval.string = yytext + 1; |
95 |
adx |
30 |
|
96 |
michael |
4298 |
if (yylval.string[yyleng - 2] != '"') |
97 |
|
|
ilog(LOG_TYPE_IRCD, "Unterminated character string"); |
98 |
|
|
else |
99 |
|
|
{ |
100 |
|
|
unsigned int i = 0, j = 0; |
101 |
adx |
30 |
|
102 |
michael |
4298 |
yylval.string[yyleng - 2] = '\0'; /* Remove close quote */ |
103 |
michael |
2916 |
|
104 |
michael |
4298 |
for (; yylval.string[i] != '\0'; ++i, ++j) |
105 |
|
|
{ |
106 |
|
|
if (yylval.string[i] != '\\') |
107 |
|
|
yylval.string[j] = yylval.string[i]; |
108 |
|
|
else |
109 |
|
|
{ |
110 |
|
|
++i; |
111 |
adx |
30 |
|
112 |
michael |
4298 |
if (yylval.string[i] == '\0') /* XXX: should not happen */ |
113 |
|
|
{ |
114 |
|
|
ilog(LOG_TYPE_IRCD, "Unterminated character string"); |
115 |
|
|
break; |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
yylval.string[j] = yylval.string[i]; |
119 |
|
|
} |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
yylval.string[j] = '\0'; |
123 |
|
|
return QSTRING; |
124 |
|
|
} |
125 |
|
|
} |
126 |
|
|
} |
127 |
|
|
|
128 |
michael |
2129 |
accept_password { return ACCEPT_PASSWORD; } |
129 |
|
|
admin { return ADMIN; } |
130 |
|
|
administrator { return ADMIN; } |
131 |
|
|
aftype { return AFTYPE; } |
132 |
|
|
all { return T_ALL; } |
133 |
|
|
anti_nick_flood { return ANTI_NICK_FLOOD; } |
134 |
|
|
anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; } |
135 |
|
|
auth { return IRCD_AUTH; } |
136 |
|
|
autoconn { return AUTOCONN; } |
137 |
michael |
4313 |
away_count { return AWAY_COUNT; } |
138 |
|
|
away_time { return AWAY_TIME; } |
139 |
michael |
2129 |
bots { return T_BOTS; } |
140 |
|
|
caller_id_wait { return CALLER_ID_WAIT; } |
141 |
|
|
callerid { return T_CALLERID; } |
142 |
|
|
can_flood { return CAN_FLOOD; } |
143 |
|
|
cconn { return T_CCONN; } |
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 |
michael |
4545 |
command { return T_COMMAND; } |
150 |
michael |
2129 |
connect { return CONNECT; } |
151 |
|
|
connectfreq { return CONNECTFREQ; } |
152 |
michael |
2283 |
cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; } |
153 |
michael |
2129 |
deaf { return T_DEAF; } |
154 |
|
|
debug { return T_DEBUG; } |
155 |
|
|
default_floodcount { return DEFAULT_FLOODCOUNT; } |
156 |
|
|
default_split_server_count { return DEFAULT_SPLIT_SERVER_COUNT; } |
157 |
|
|
default_split_user_count { return DEFAULT_SPLIT_USER_COUNT; } |
158 |
|
|
deny { return DENY; } |
159 |
|
|
description { return DESCRIPTION; } |
160 |
|
|
die { return DIE; } |
161 |
|
|
disable_auth { return DISABLE_AUTH; } |
162 |
|
|
disable_fake_channels { return DISABLE_FAKE_CHANNELS; } |
163 |
|
|
disable_remote_commands { return DISABLE_REMOTE_COMMANDS; } |
164 |
|
|
dline { return T_DLINE; } |
165 |
|
|
dots_in_ident { return DOTS_IN_IDENT; } |
166 |
|
|
egdpool_path { return EGDPOOL_PATH; } |
167 |
|
|
email { return EMAIL; } |
168 |
|
|
encrypted { return ENCRYPTED; } |
169 |
|
|
exceed_limit { return EXCEED_LIMIT; } |
170 |
|
|
exempt { return EXEMPT; } |
171 |
|
|
external { return T_EXTERNAL; } |
172 |
|
|
failed_oper_notice { return FAILED_OPER_NOTICE; } |
173 |
|
|
farconnect { return T_FARCONNECT; } |
174 |
|
|
file { return T_FILE; } |
175 |
|
|
flags { return IRCD_FLAGS; } |
176 |
|
|
flatten_links { return FLATTEN_LINKS; } |
177 |
|
|
full { return T_FULL; } |
178 |
|
|
gecos { return GECOS; } |
179 |
|
|
general { return GENERAL; } |
180 |
|
|
gline { return GLINE; } |
181 |
|
|
gline_duration { return GLINE_DURATION; } |
182 |
|
|
gline_enable { return GLINE_ENABLE; } |
183 |
|
|
gline_exempt { return GLINE_EXEMPT; } |
184 |
|
|
gline_min_cidr { return GLINE_MIN_CIDR; } |
185 |
|
|
gline_min_cidr6 { return GLINE_MIN_CIDR6; } |
186 |
|
|
gline_request_duration { return GLINE_REQUEST_DURATION; } |
187 |
|
|
global_kill { return GLOBAL_KILL; } |
188 |
|
|
globops { return T_GLOBOPS; } |
189 |
|
|
have_ident { return NEED_IDENT; } |
190 |
|
|
havent_read_conf { return HAVENT_READ_CONF; } |
191 |
|
|
hidden { return HIDDEN; } |
192 |
|
|
hidden_name { return HIDDEN_NAME; } |
193 |
michael |
3513 |
hidechans { return HIDE_CHANS; } |
194 |
michael |
3506 |
hideidle { return HIDE_IDLE; } |
195 |
michael |
2129 |
hide_idle_from_opers { return HIDE_IDLE_FROM_OPERS; } |
196 |
|
|
hide_server_ips { return HIDE_SERVER_IPS; } |
197 |
|
|
hide_servers { return HIDE_SERVERS; } |
198 |
|
|
hide_services { return HIDE_SERVICES; } |
199 |
|
|
hide_spoof_ips { return HIDE_SPOOF_IPS; } |
200 |
|
|
host { return HOST; } |
201 |
|
|
hub { return HUB; } |
202 |
|
|
hub_mask { return HUB_MASK; } |
203 |
|
|
ignore_bogus_ts { return IGNORE_BOGUS_TS; } |
204 |
|
|
invisible { return T_INVISIBLE; } |
205 |
|
|
invisible_on_connect { return INVISIBLE_ON_CONNECT; } |
206 |
michael |
3860 |
invite_client_count { return INVITE_CLIENT_COUNT; } |
207 |
|
|
invite_client_time { return INVITE_CLIENT_TIME; } |
208 |
michael |
2129 |
ip { return IP; } |
209 |
|
|
ipv4 { return T_IPV4; } |
210 |
|
|
ipv6 { return T_IPV6; } |
211 |
|
|
join_flood_count { return JOIN_FLOOD_COUNT; } |
212 |
|
|
join_flood_time { return JOIN_FLOOD_TIME; } |
213 |
|
|
kill { return KILL; } |
214 |
|
|
kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; } |
215 |
|
|
kline { return KLINE; } |
216 |
|
|
kline_exempt { return KLINE_EXEMPT; } |
217 |
michael |
3860 |
knock_client_count { return KNOCK_CLIENT_COUNT; } |
218 |
|
|
knock_client_time { return KNOCK_CLIENT_TIME; } |
219 |
michael |
2129 |
knock_delay_channel { return KNOCK_DELAY_CHANNEL; } |
220 |
|
|
leaf_mask { return LEAF_MASK; } |
221 |
|
|
links_delay { return LINKS_DELAY; } |
222 |
|
|
listen { return LISTEN; } |
223 |
|
|
locops { return T_LOCOPS; } |
224 |
|
|
log { return T_LOG; } |
225 |
|
|
mask { return MASK; } |
226 |
|
|
masked { return TMASKED; } |
227 |
|
|
max_accept { return MAX_ACCEPT; } |
228 |
|
|
max_bans { return MAX_BANS; } |
229 |
michael |
3933 |
max_channels { return MAX_CHANNELS; } |
230 |
michael |
2129 |
max_clients { return T_MAX_CLIENTS; } |
231 |
|
|
max_global { return MAX_GLOBAL; } |
232 |
|
|
max_ident { return MAX_IDENT; } |
233 |
|
|
max_idle { return MAX_IDLE; } |
234 |
|
|
max_local { return MAX_LOCAL; } |
235 |
|
|
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_create_on_split { return NO_CREATE_ON_SPLIT; } |
256 |
|
|
no_join_on_split { return NO_JOIN_ON_SPLIT; } |
257 |
|
|
no_oper_flood { return NO_OPER_FLOOD; } |
258 |
|
|
no_tilde { return NO_TILDE; } |
259 |
|
|
nononreg { return T_NONONREG; } |
260 |
|
|
number_per_cidr { return NUMBER_PER_CIDR; } |
261 |
|
|
number_per_ip { return NUMBER_PER_IP; } |
262 |
|
|
oper { return OPERATOR; } |
263 |
|
|
oper_only_umodes { return OPER_ONLY_UMODES; } |
264 |
|
|
oper_pass_resv { return OPER_PASS_RESV; } |
265 |
|
|
oper_umodes { return OPER_UMODES; } |
266 |
|
|
operator { return OPERATOR; } |
267 |
|
|
opers_bypass_callerid { return OPERS_BYPASS_CALLERID; } |
268 |
|
|
pace_wait { return PACE_WAIT; } |
269 |
|
|
pace_wait_simple { return PACE_WAIT_SIMPLE; } |
270 |
|
|
passwd { return PASSWORD; } |
271 |
|
|
password { return PASSWORD; } |
272 |
|
|
path { return PATH; } |
273 |
|
|
ping_cookie { return PING_COOKIE; } |
274 |
|
|
ping_time { return PING_TIME; } |
275 |
|
|
port { return PORT; } |
276 |
michael |
4545 |
prepend { return T_PREPEND; } |
277 |
|
|
pseudo { return T_PSEUDO; } |
278 |
michael |
2129 |
quarantine { return RESV; } |
279 |
|
|
random_idle { return RANDOM_IDLE; } |
280 |
|
|
reason { return REASON; } |
281 |
|
|
recvq { return T_RECVQ; } |
282 |
|
|
redirport { return REDIRPORT; } |
283 |
|
|
redirserv { return REDIRSERV; } |
284 |
|
|
rehash { return REHASH; } |
285 |
|
|
rej { return T_REJ; } |
286 |
|
|
remote { return REMOTE; } |
287 |
|
|
remoteban { return REMOTEBAN; } |
288 |
|
|
restart { return T_RESTART; } |
289 |
|
|
resv { return RESV; } |
290 |
|
|
resv_exempt { return RESV_EXEMPT; } |
291 |
|
|
rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; } |
292 |
|
|
rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; } |
293 |
|
|
send_password { return SEND_PASSWORD; } |
294 |
|
|
sendq { return SENDQ; } |
295 |
|
|
server { return T_SERVER; } |
296 |
|
|
serverhide { return SERVERHIDE; } |
297 |
|
|
serverinfo { return SERVERINFO; } |
298 |
|
|
service { return T_SERVICE; } |
299 |
|
|
servnotice { return T_SERVNOTICE; } |
300 |
|
|
set { return T_SET; } |
301 |
|
|
shared { return T_SHARED; } |
302 |
|
|
short_motd { return SHORT_MOTD; } |
303 |
|
|
sid { return IRCD_SID; } |
304 |
|
|
size { return T_SIZE; } |
305 |
|
|
skill { return T_SKILL; } |
306 |
|
|
softcallerid { return T_SOFTCALLERID; } |
307 |
|
|
spoof { return SPOOF; } |
308 |
|
|
spoof_notice { return SPOOF_NOTICE; } |
309 |
|
|
spy { return T_SPY; } |
310 |
|
|
squit { return SQUIT; } |
311 |
|
|
ssl { return T_SSL; } |
312 |
adx |
30 |
ssl_certificate_file { return SSL_CERTIFICATE_FILE; } |
313 |
michael |
2244 |
ssl_certificate_fingerprint { return SSL_CERTIFICATE_FINGERPRINT; } |
314 |
michael |
2129 |
ssl_cipher_list { return T_SSL_CIPHER_LIST; } |
315 |
michael |
2248 |
ssl_connection_required { return SSL_CONNECTION_REQUIRED; } |
316 |
michael |
4070 |
ssl_dh_elliptic_curve { return SSL_DH_ELLIPTIC_CURVE; } |
317 |
michael |
2129 |
ssl_dh_param_file { return SSL_DH_PARAM_FILE; } |
318 |
michael |
4114 |
ssl_message_digest_algorithm { return SSL_MESSAGE_DIGEST_ALGORITHM; } |
319 |
michael |
2129 |
stats_e_disabled { return STATS_E_DISABLED; } |
320 |
|
|
stats_i_oper_only { return STATS_I_OPER_ONLY; } |
321 |
|
|
stats_k_oper_only { return STATS_K_OPER_ONLY; } |
322 |
|
|
stats_o_oper_only { return STATS_O_OPER_ONLY; } |
323 |
|
|
stats_P_oper_only { return STATS_P_OPER_ONLY; } |
324 |
michael |
2269 |
stats_u_oper_only { return STATS_U_OPER_ONLY; } |
325 |
michael |
4545 |
target { return T_TARGET; } |
326 |
michael |
3877 |
throttle_count { return THROTTLE_COUNT; } |
327 |
michael |
2129 |
throttle_time { return THROTTLE_TIME; } |
328 |
|
|
tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; } |
329 |
|
|
true_no_oper_flood { return TRUE_NO_OPER_FLOOD; } |
330 |
|
|
ts_max_delta { return TS_MAX_DELTA; } |
331 |
|
|
ts_warn_delta { return TS_WARN_DELTA; } |
332 |
|
|
type { return TYPE; } |
333 |
|
|
umodes { return T_UMODES; } |
334 |
|
|
unauth { return T_UNAUTH; } |
335 |
|
|
undline { return T_UNDLINE; } |
336 |
|
|
unkline { return UNKLINE; } |
337 |
|
|
unlimited { return T_UNLIMITED; } |
338 |
|
|
unresv { return T_UNRESV; } |
339 |
|
|
unxline { return T_UNXLINE; } |
340 |
|
|
use_egd { return USE_EGD; } |
341 |
|
|
use_logging { return USE_LOGGING; } |
342 |
michael |
2916 |
user { return USER; } |
343 |
michael |
2129 |
vhost { return VHOST; } |
344 |
|
|
vhost6 { return VHOST6; } |
345 |
|
|
wallop { return T_WALLOP; } |
346 |
|
|
wallops { return T_WALLOPS; } |
347 |
michael |
3473 |
warn_no_connect_block { return WARN_NO_CONNECT_BLOCK; } |
348 |
michael |
2129 |
webirc { return T_WEBIRC; } |
349 |
|
|
xline { return XLINE; } |
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 |
|
|
<<EOF>> { if (ieof()) 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 |
|
|
char *p = NULL; |
431 |
|
|
|
432 |
|
|
if ((p = strchr(yytext, '<')) == NULL) |
433 |
|
|
*strchr(p = strchr(yytext, '"') + 1, '"') = '\0'; |
434 |
|
|
else |
435 |
|
|
*strchr(++p, '>') = '\0'; |
436 |
|
|
|
437 |
|
|
/* log(L_NOTICE, "got include %s!", c); */ |
438 |
|
|
|
439 |
michael |
2916 |
/* do stacking and co. */ |
440 |
adx |
30 |
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) |
441 |
michael |
1247 |
ilog(LOG_TYPE_IRCD, "Includes nested too deep in %s", p); |
442 |
adx |
30 |
else |
443 |
|
|
{ |
444 |
michael |
1325 |
FILE *tmp_fbfile_in = NULL; |
445 |
adx |
30 |
char filenamebuf[IRCD_BUFSIZE]; |
446 |
|
|
|
447 |
|
|
if (*p == '/') /* if it is an absolute path */ |
448 |
|
|
snprintf(filenamebuf, sizeof(filenamebuf), "%s", p); |
449 |
|
|
else |
450 |
|
|
snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p); |
451 |
|
|
|
452 |
michael |
1325 |
tmp_fbfile_in = fopen(filenamebuf, "r"); |
453 |
michael |
2916 |
|
454 |
adx |
30 |
if (tmp_fbfile_in == NULL) |
455 |
|
|
{ |
456 |
michael |
1247 |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
457 |
adx |
30 |
filenamebuf, strerror(errno)); |
458 |
|
|
return; |
459 |
|
|
} |
460 |
|
|
|
461 |
|
|
lineno_stack[include_stack_ptr] = lineno; |
462 |
|
|
lineno = 1; |
463 |
michael |
967 |
inc_fbfile_in[include_stack_ptr] = conf_parser_ctx.conf_file; |
464 |
adx |
30 |
strlcpy(conffile_stack[include_stack_ptr], conffilebuf, IRCD_BUFSIZE); |
465 |
|
|
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; |
466 |
michael |
967 |
conf_parser_ctx.conf_file = tmp_fbfile_in; |
467 |
michael |
711 |
snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf); |
468 |
adx |
30 |
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); |
469 |
|
|
} |
470 |
|
|
} |
471 |
|
|
|
472 |
|
|
/* This is function that will be called on EOF in conf file. It will |
473 |
|
|
* apropriately close conf if it not main conf and swap input buffers -kre |
474 |
|
|
* */ |
475 |
|
|
static int |
476 |
|
|
ieof(void) |
477 |
|
|
{ |
478 |
|
|
/* log(L_NOTICE, "return from include stack!"); */ |
479 |
|
|
if (include_stack_ptr) |
480 |
michael |
1325 |
fclose(conf_parser_ctx.conf_file); |
481 |
adx |
30 |
if (--include_stack_ptr < 0) |
482 |
|
|
{ |
483 |
|
|
/* log(L_NOTICE, "terminating lexer"); */ |
484 |
|
|
/* We will now exit the lexer - restore init values if we get /rehash |
485 |
|
|
* later and reenter lexer -kre */ |
486 |
|
|
include_stack_ptr = 0; |
487 |
|
|
lineno = 1; |
488 |
|
|
return 1; |
489 |
|
|
} |
490 |
|
|
|
491 |
|
|
/* switch buffer */ |
492 |
|
|
/* log(L_NOTICE, "deleting include_stack_ptr=%d", include_stack_ptr); */ |
493 |
|
|
yy_delete_buffer(YY_CURRENT_BUFFER); |
494 |
|
|
lineno = lineno_stack[include_stack_ptr]; |
495 |
michael |
967 |
conf_parser_ctx.conf_file = inc_fbfile_in[include_stack_ptr]; |
496 |
michael |
2916 |
strlcpy(conffilebuf, conffile_stack[include_stack_ptr], sizeof(conffilebuf)); |
497 |
adx |
30 |
yy_switch_to_buffer(include_stack[include_stack_ptr]); |
498 |
|
|
|
499 |
|
|
return 0; |
500 |
|
|
} |