1 |
adx |
30 |
/* |
2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
|
|
* ircd_lexer.l: Scans the ircd configuration file for tokens. |
4 |
|
|
* |
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 "tools.h" |
33 |
|
|
#include "irc_string.h" |
34 |
|
|
#include "common.h" |
35 |
|
|
#include "s_conf.h" |
36 |
|
|
#include "memory.h" |
37 |
|
|
#include "hostmask.h" |
38 |
|
|
#include "s_log.h" |
39 |
|
|
|
40 |
|
|
#include "y.tab.h" |
41 |
|
|
|
42 |
|
|
#undef YY_INPUT |
43 |
|
|
#define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg) |
44 |
|
|
#define YY_INPUT(buf,result,max_size) \ |
45 |
|
|
if (!(result = conf_fbgets(buf, max_size, conf_fbfile_in))) \ |
46 |
|
|
YY_FATAL_ERROR("input in flex scanner failed"); |
47 |
|
|
#define MAX_INCLUDE_DEPTH 10 |
48 |
|
|
|
49 |
|
|
|
50 |
|
|
unsigned int lineno = 1; |
51 |
|
|
char linebuf[IRCD_BUFSIZE]; |
52 |
|
|
char conffilebuf[IRCD_BUFSIZE]; |
53 |
|
|
|
54 |
|
|
static int include_stack_ptr = 0; |
55 |
|
|
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; |
56 |
|
|
static unsigned int lineno_stack[MAX_INCLUDE_DEPTH]; |
57 |
|
|
static FBFILE *inc_fbfile_in[MAX_INCLUDE_DEPTH]; |
58 |
|
|
static char conffile_stack[MAX_INCLUDE_DEPTH][IRCD_BUFSIZE]; |
59 |
|
|
static void ccomment(void); |
60 |
|
|
static void cinclude(void); |
61 |
|
|
static int ieof(void); |
62 |
|
|
%} |
63 |
|
|
|
64 |
|
|
WS [[:blank:]]* |
65 |
|
|
DIGIT [[:digit:]]+ |
66 |
|
|
COMMENT ("//"|"#").* |
67 |
|
|
qstring \"[^\"\n]*[\"\n] |
68 |
|
|
include \.include{WS}(\<.*\>|\".*\") |
69 |
|
|
|
70 |
|
|
%% |
71 |
|
|
{include} { cinclude(); } |
72 |
|
|
"/*" { ccomment(); } |
73 |
|
|
|
74 |
|
|
\n.* { strcpy(linebuf, yytext+1); ++lineno; yyless(1); } |
75 |
|
|
|
76 |
|
|
{WS} ; |
77 |
|
|
{COMMENT} ; |
78 |
|
|
|
79 |
|
|
{DIGIT} { yylval.number = atoi(yytext); return NUMBER; } |
80 |
|
|
|
81 |
|
|
{qstring} { if (yytext[yyleng-2] == '\\') |
82 |
|
|
{ |
83 |
|
|
yyless(yyleng-1); /* return last quote */ |
84 |
|
|
yymore(); /* append next string */ |
85 |
|
|
} |
86 |
|
|
else |
87 |
|
|
{ |
88 |
|
|
yylval.string = yytext+1; |
89 |
|
|
if(yylval.string[yyleng-2] != '"') |
90 |
|
|
ilog(L_ERROR, "Unterminated character string"); |
91 |
|
|
else |
92 |
|
|
{ |
93 |
|
|
int i,j; |
94 |
|
|
|
95 |
|
|
yylval.string[yyleng-2] = '\0'; /* remove close |
96 |
|
|
* quote |
97 |
|
|
*/ |
98 |
|
|
|
99 |
|
|
for (j=i=0 ;yylval.string[i] != '\0'; i++,j++) |
100 |
|
|
{ |
101 |
|
|
if (yylval.string[i] != '\\') |
102 |
|
|
{ |
103 |
|
|
yylval.string[j] = yylval.string[i]; |
104 |
|
|
} |
105 |
|
|
else |
106 |
|
|
{ |
107 |
|
|
i++; |
108 |
|
|
if (yylval.string[i] == '\0') /* XXX |
109 |
|
|
* should not |
110 |
|
|
* happen |
111 |
|
|
*/ |
112 |
|
|
{ |
113 |
|
|
ilog(L_ERROR, |
114 |
|
|
"Unterminated character string"); |
115 |
|
|
break; |
116 |
|
|
} |
117 |
|
|
yylval.string[j] = yylval.string[i]; |
118 |
|
|
} |
119 |
|
|
} |
120 |
|
|
yylval.string[j] = '\0'; |
121 |
|
|
return QSTRING; |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
~ { return NOT; } |
127 |
|
|
accept_password { return ACCEPT_PASSWORD; } |
128 |
|
|
action { return ACTION; } |
129 |
|
|
admin { return ADMIN; } |
130 |
|
|
administrator { return ADMIN; } |
131 |
|
|
aftype { return AFTYPE; } |
132 |
|
|
all { return T_ALL; } |
133 |
|
|
allow { return T_ALLOW; } |
134 |
|
|
auth { return IRCD_AUTH; } |
135 |
|
|
autoconn { return AUTOCONN; } |
136 |
|
|
block { return T_BLOCK; } |
137 |
|
|
burst_away { return BURST_AWAY; } |
138 |
|
|
burst_topicwho { return BURST_TOPICWHO; } |
139 |
|
|
can_flood { return CAN_FLOOD; } |
140 |
|
|
can_idle { return CAN_IDLE; } |
141 |
|
|
caller_id_wait { return CALLER_ID_WAIT; } |
142 |
|
|
opers_bypass_callerid { return OPERS_BYPASS_CALLERID; } |
143 |
|
|
channel { return CHANNEL; } |
144 |
|
|
cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; } |
145 |
|
|
cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; } |
146 |
|
|
cipher_preference { return CIPHER_PREFERENCE; } |
147 |
|
|
class { return CLASS; } |
148 |
|
|
client_flood { return T_CLIENT_FLOOD; } |
149 |
|
|
cluster { return T_CLUSTER; } |
150 |
|
|
compressed { return COMPRESSED; } |
151 |
|
|
compression_level { return COMPRESSION_LEVEL; } |
152 |
|
|
connect { return CONNECT; } |
153 |
|
|
connectfreq { return CONNECTFREQ; } |
154 |
|
|
cryptlink { return CRYPTLINK; } |
155 |
|
|
default_cipher_preference { return DEFAULT_CIPHER_PREFERENCE; } |
156 |
|
|
default_floodcount { return DEFAULT_FLOODCOUNT; } |
157 |
|
|
default_split_server_count { return DEFAULT_SPLIT_SERVER_COUNT; } |
158 |
|
|
default_split_user_count { return DEFAULT_SPLIT_USER_COUNT; } |
159 |
|
|
deny { return DENY; } |
160 |
|
|
description { return DESCRIPTION; } |
161 |
|
|
die { return DIE; } |
162 |
|
|
disable_auth { return DISABLE_AUTH; } |
163 |
|
|
disable_hidden { return DISABLE_HIDDEN; } |
164 |
|
|
disable_local_channels { return DISABLE_LOCAL_CHANNELS; } |
165 |
|
|
disable_remote_commands { return DISABLE_REMOTE_COMMANDS; } |
166 |
|
|
dot_in_ip6_addr { return DOT_IN_IP6_ADDR; } |
167 |
|
|
dots_in_ident { return DOTS_IN_IDENT; } |
168 |
|
|
duration { return DURATION; } |
169 |
|
|
egdpool_path { return EGDPOOL_PATH; } |
170 |
|
|
email { return EMAIL; } |
171 |
|
|
enable { return ENABLE; } |
172 |
|
|
encrypted { return ENCRYPTED; } |
173 |
|
|
exceed_limit { return EXCEED_LIMIT; } |
174 |
|
|
exempt { return EXEMPT; } |
175 |
|
|
fakename { return FAKENAME; } |
176 |
|
|
flags { return IRCD_FLAGS; } |
177 |
|
|
flatten_links { return FLATTEN_LINKS; } |
178 |
|
|
fglinelog { return FGLINELOG; } |
179 |
|
|
fname_glinelog { return FGLINELOG; } |
180 |
|
|
fkilllog { return FKILLLOG; } |
181 |
|
|
fioerrlog { return FIOERRLOG; } |
182 |
|
|
fname_ioerrlog { return FIOERRLOG; } |
183 |
|
|
fname_killlog { return FKILLLOG; } |
184 |
|
|
fklinelog { return FKLINELOG; } |
185 |
|
|
fname_klinelog { return FKLINELOG; } |
186 |
|
|
ffailed_operlog { return FFAILED_OPERLOG; } |
187 |
|
|
fname_operlog { return FOPERLOG; } |
188 |
|
|
foperlog { return FOPERLOG; } |
189 |
|
|
fname_userlog { return FUSERLOG; } |
190 |
|
|
fuserlog { return FUSERLOG; } |
191 |
|
|
gecos { return GECOS; } |
192 |
|
|
general { return GENERAL; } |
193 |
|
|
gline { return GLINE; } |
194 |
|
|
glines { return GLINES; } |
195 |
|
|
gline_exempt { return GLINE_EXEMPT; } |
196 |
|
|
gline_min_cidr { return GLINE_MIN_CIDR; } |
197 |
|
|
gline_min_cidr6 { return GLINE_MIN_CIDR6; } |
198 |
|
|
global_kill { return GLOBAL_KILL; } |
199 |
|
|
have_ident { return NEED_IDENT; } |
200 |
|
|
need_ident { return NEED_IDENT; } |
201 |
|
|
havent_read_conf { return HAVENT_READ_CONF; } |
202 |
|
|
hidden { return HIDDEN; } |
203 |
|
|
hidden_admin { return HIDDEN_ADMIN; } |
204 |
|
|
hidden_name { return HIDDEN_NAME; } |
205 |
|
|
hidden_oper { return HIDDEN_OPER; } |
206 |
|
|
hide_server_ips { return HIDE_SERVER_IPS; } |
207 |
|
|
hide_servers { return HIDE_SERVERS; } |
208 |
|
|
hide_spoof_ips { return HIDE_SPOOF_IPS; } |
209 |
|
|
host { return HOST; } |
210 |
|
|
hub { return HUB; } |
211 |
|
|
hub_mask { return HUB_MASK; } |
212 |
|
|
idletime { return IDLETIME; } |
213 |
|
|
ignore_bogus_ts { return IGNORE_BOGUS_TS; } |
214 |
|
|
invite_ops_only { return INVITE_OPS_ONLY; } |
215 |
|
|
invisible_on_connect { return INVISIBLE_ON_CONNECT; } |
216 |
|
|
ip { return IP; } |
217 |
|
|
ipv4 { return T_IPV4; } |
218 |
|
|
ipv6 { return T_IPV6; } |
219 |
|
|
join_flood_count { return JOIN_FLOOD_COUNT; } |
220 |
|
|
join_flood_time { return JOIN_FLOOD_TIME; } |
221 |
|
|
kill { return KILL; } |
222 |
|
|
kill_chase_time_limit { return KILL_CHASE_TIME_LIMIT; } |
223 |
|
|
kline { return KLINE; } |
224 |
|
|
kline_exempt { return KLINE_EXEMPT; } |
225 |
|
|
l_crit { return T_L_CRIT; } |
226 |
|
|
l_debug { return T_L_DEBUG; } |
227 |
|
|
l_error { return T_L_ERROR; } |
228 |
|
|
l_info { return T_L_INFO; } |
229 |
|
|
l_notice { return T_L_NOTICE; } |
230 |
|
|
l_trace { return T_L_TRACE; } |
231 |
|
|
l_warn { return T_L_WARN; } |
232 |
|
|
lazylink { return LAZYLINK; } |
233 |
|
|
leaf_mask { return LEAF_MASK; } |
234 |
|
|
listen { return LISTEN; } |
235 |
|
|
log_level { return LOG_LEVEL; } |
236 |
|
|
log { return LOGGING; } |
237 |
|
|
logging { return LOGGING; } |
238 |
|
|
logpath { return T_LOGPATH; } |
239 |
|
|
masked { return TMASKED; } |
240 |
|
|
max_clients { return T_MAX_CLIENTS; } |
241 |
|
|
max_ident { return MAX_IDENT; } |
242 |
|
|
max_local { return MAX_LOCAL; } |
243 |
|
|
max_global { return MAX_GLOBAL; } |
244 |
|
|
max_number { return MAX_NUMBER; } |
245 |
|
|
message_locale { return MESSAGE_LOCALE; } |
246 |
|
|
min_nonwildcard { return MIN_NONWILDCARD; } |
247 |
|
|
min_nonwildcard_simple { return MIN_NONWILDCARD_SIMPLE; } |
248 |
|
|
name { return NAME; } |
249 |
|
|
need_password { return NEED_PASSWORD; } |
250 |
|
|
network_desc { return NETWORK_DESC; } |
251 |
|
|
network_name { return NETWORK_NAME; } |
252 |
|
|
nick { return NICK; } |
253 |
|
|
nick_changes { return NICK_CHANGES; } |
254 |
|
|
no { yylval.number = NO; return TBOOL; } |
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 |
|
|
number_per_cidr { return NUMBER_PER_CIDR; } |
260 |
|
|
number_per_ip { return NUMBER_PER_IP; } |
261 |
|
|
oper { return OPERATOR; } |
262 |
|
|
oper_log { return OPER_LOG; } |
263 |
|
|
oper_pass_resv { return OPER_PASS_RESV; } |
264 |
|
|
operator { return OPERATOR; } |
265 |
|
|
passwd { return PASSWORD; } |
266 |
|
|
password { return PASSWORD; } |
267 |
|
|
ping_cookie { return PING_COOKIE; } |
268 |
|
|
ping_time { return PING_TIME; } |
269 |
|
|
ping_warning { return PING_WARNING; } |
270 |
|
|
port { return PORT; } |
271 |
|
|
quarantine { return RESV; } |
272 |
|
|
quiet_on_ban { return QUIET_ON_BAN; } |
273 |
|
|
reason { return REASON; } |
274 |
|
|
redirport { return REDIRPORT; } |
275 |
|
|
redirserv { return REDIRSERV; } |
276 |
|
|
regex { return REGEX_T; } |
277 |
|
|
rehash { return REHASH; } |
278 |
|
|
reject { return T_REJECT; } |
279 |
|
|
reject_hold_time { return TREJECT_HOLD_TIME; } |
280 |
|
|
remote { return REMOTE; } |
281 |
|
|
remoteban { return REMOTEBAN; } |
282 |
|
|
restrict_channels { return RESTRICT_CHANNELS; } |
283 |
|
|
resv { return RESV; } |
284 |
|
|
resv_exempt { return RESV_EXEMPT; } |
285 |
|
|
rsa_private_key_file { return RSA_PRIVATE_KEY_FILE; } |
286 |
|
|
rsa_public_key_file { return RSA_PUBLIC_KEY_FILE; } |
287 |
|
|
ssl { return T_SSL; } |
288 |
|
|
ssl_certificate_file { return SSL_CERTIFICATE_FILE; } |
289 |
|
|
send_password { return SEND_PASSWORD; } |
290 |
|
|
sendq { return SENDQ; } |
291 |
|
|
serverhide { return SERVERHIDE; } |
292 |
|
|
serverinfo { return SERVERINFO; } |
293 |
|
|
servlink_path { return SERVLINK_PATH; } |
294 |
|
|
shared { return T_SHARED; } |
295 |
|
|
short_motd { return SHORT_MOTD; } |
296 |
|
|
sid { return IRCD_SID; } |
297 |
|
|
silent { return SILENT; } |
298 |
|
|
spoof { return SPOOF; } |
299 |
|
|
spoof_notice { return SPOOF_NOTICE; } |
300 |
|
|
tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; } |
301 |
|
|
type { return TYPE; } |
302 |
|
|
true_no_oper_flood { return TRUE_NO_OPER_FLOOD; } |
303 |
|
|
unkline { return UNKLINE; } |
304 |
|
|
use_egd { return USE_EGD; } |
305 |
|
|
use_except { return USE_EXCEPT; } |
306 |
|
|
use_invex { return USE_INVEX; } |
307 |
|
|
use_knock { return USE_KNOCK; } |
308 |
|
|
use_logging { return USE_LOGGING; } |
309 |
|
|
use_whois_actually { return USE_WHOIS_ACTUALLY; } |
310 |
|
|
throttle_time { return THROTTLE_TIME; } |
311 |
|
|
user { return USER; } |
312 |
|
|
tkline { return TKLINE; } |
313 |
|
|
txline { return TXLINE; } |
314 |
|
|
tresv { return TRESV; } |
315 |
|
|
vhost { return VHOST; } |
316 |
|
|
vhost6 { return VHOST6; } |
317 |
|
|
warn { return WARN; } |
318 |
|
|
xline { return XLINE; } |
319 |
|
|
yes { yylval.number = YES; return TBOOL; } |
320 |
|
|
|
321 |
|
|
failed_oper_notice { return FAILED_OPER_NOTICE; } |
322 |
|
|
max_accept { return MAX_ACCEPT; } |
323 |
|
|
max_nick_changes { return MAX_NICK_CHANGES; } |
324 |
|
|
max_chans_per_user { return MAX_CHANS_PER_USER; } |
325 |
|
|
max_nick_time { return MAX_NICK_TIME; } |
326 |
|
|
anti_nick_flood { return ANTI_NICK_FLOOD; } |
327 |
|
|
anti_spam_exit_message_time { return ANTI_SPAM_EXIT_MESSAGE_TIME; } |
328 |
|
|
ts_max_delta { return TS_MAX_DELTA; } |
329 |
|
|
ts_warn_delta { return TS_WARN_DELTA; } |
330 |
|
|
links_delay { return LINKS_DELAY; } |
331 |
|
|
kline_reason { return KLINE_REASON; } |
332 |
|
|
kline_with_reason { return KLINE_WITH_REASON; } |
333 |
|
|
warn_no_nline { return WARN_NO_NLINE; } |
334 |
|
|
|
335 |
|
|
stats_o_oper_only { return STATS_O_OPER_ONLY; } |
336 |
|
|
stats_k_oper_only { return STATS_K_OPER_ONLY; } |
337 |
|
|
stats_i_oper_only { return STATS_I_OPER_ONLY; } |
338 |
|
|
stats_P_oper_only { return STATS_P_OPER_ONLY; } |
339 |
|
|
pace_wait { return PACE_WAIT; } |
340 |
|
|
pace_wait_simple { return PACE_WAIT_SIMPLE; } |
341 |
|
|
knock_delay { return KNOCK_DELAY; } |
342 |
|
|
knock_delay_channel { return KNOCK_DELAY_CHANNEL; } |
343 |
|
|
max_bans { return MAX_BANS; } |
344 |
|
|
modules { return MODULES; } |
345 |
|
|
module { return MODULE; } |
346 |
|
|
path { return PATH; } |
347 |
|
|
max_targets { return MAX_TARGETS; } |
348 |
|
|
|
349 |
|
|
unxline { return T_UNXLINE; } |
350 |
|
|
unresv { return T_UNRESV; } |
351 |
|
|
|
352 |
|
|
oper_only_umodes { return OPER_ONLY_UMODES; } |
353 |
|
|
oper_umodes { return OPER_UMODES; } |
354 |
|
|
bots { return T_BOTS; } |
355 |
|
|
cconn { return T_CCONN; } |
356 |
|
|
deaf { return T_DEAF; } |
357 |
|
|
debug { return T_DEBUG; } |
358 |
|
|
full { return T_FULL; } |
359 |
|
|
skill { return T_SKILL; } |
360 |
|
|
nchange { return T_NCHANGE; } |
361 |
|
|
rej { return T_REJ; } |
362 |
|
|
unauth { return T_UNAUTH; } |
363 |
|
|
spy { return T_SPY; } |
364 |
|
|
external { return T_EXTERNAL; } |
365 |
|
|
operwall { return T_OPERWALL; } |
366 |
|
|
servnotice { return T_SERVNOTICE; } |
367 |
|
|
invisible { return T_INVISIBLE; } |
368 |
|
|
wallop { return T_WALLOP; } |
369 |
|
|
callerid { return T_CALLERID; } |
370 |
|
|
softcallerid { return T_SOFTCALLERID; } |
371 |
|
|
drone { return T_DRONE; } |
372 |
|
|
locops { return T_LOCOPS; } |
373 |
|
|
topicburst { return TOPICBURST; } |
374 |
|
|
|
375 |
|
|
weeks { return WEEKS; } |
376 |
|
|
week { return WEEKS; } |
377 |
|
|
days { return DAYS; } |
378 |
|
|
day { return DAYS; } |
379 |
|
|
hours { return HOURS; } |
380 |
|
|
hour { return HOURS; } |
381 |
|
|
minutes { return MINUTES; } |
382 |
|
|
minute { return MINUTES; } |
383 |
|
|
seconds { return SECONDS; } |
384 |
|
|
second { return SECONDS; } |
385 |
|
|
|
386 |
|
|
bytes { return BYTES; } |
387 |
|
|
byte { return BYTES; } |
388 |
|
|
kilobytes { return KBYTES; } |
389 |
|
|
kilobyte { return KBYTES; } |
390 |
|
|
kbytes { return KBYTES; } |
391 |
|
|
kbyte { return KBYTES; } |
392 |
|
|
kb { return KBYTES; } |
393 |
|
|
megabytes { return MBYTES; } |
394 |
|
|
megabyte { return MBYTES; } |
395 |
|
|
mbytes { return MBYTES; } |
396 |
|
|
mbyte { return MBYTES; } |
397 |
|
|
mb { return MBYTES; } |
398 |
|
|
gigabytes { return GBYTES; } |
399 |
|
|
gigabyte { return GBYTES; } |
400 |
|
|
gbytes { return GBYTES; } |
401 |
|
|
gbyte { return GBYTES; } |
402 |
|
|
gb { return GBYTES; } |
403 |
|
|
terabytes { return TBYTES; } |
404 |
|
|
terabyte { return TBYTES; } |
405 |
|
|
tbytes { return TBYTES; } |
406 |
|
|
tbyte { return TBYTES; } |
407 |
|
|
tb { return TBYTES; } |
408 |
|
|
\.\. { return TWODOTS; } |
409 |
|
|
|
410 |
|
|
. { return yytext[0]; } |
411 |
|
|
<<EOF>> { if (ieof()) yyterminate(); } |
412 |
|
|
|
413 |
|
|
%% |
414 |
|
|
|
415 |
|
|
/* C-comment ignoring routine -kre*/ |
416 |
|
|
static void |
417 |
|
|
ccomment(void) |
418 |
|
|
{ |
419 |
|
|
int c = 0; |
420 |
|
|
|
421 |
|
|
/* log(L_NOTICE, "got comment"); */ |
422 |
|
|
while (1) |
423 |
|
|
{ |
424 |
|
|
while ((c = input()) != '*' && c != EOF) |
425 |
|
|
if (c == '\n') |
426 |
|
|
++lineno; |
427 |
|
|
|
428 |
|
|
if (c == '*') |
429 |
|
|
{ |
430 |
|
|
while ((c = input()) == '*') |
431 |
|
|
/* Nothing */ ; |
432 |
|
|
if (c == '/') |
433 |
|
|
break; |
434 |
|
|
else if (c == '\n') |
435 |
|
|
++lineno; |
436 |
|
|
} |
437 |
|
|
|
438 |
|
|
if (c == EOF) |
439 |
|
|
{ |
440 |
|
|
YY_FATAL_ERROR("EOF in comment"); |
441 |
|
|
/* XXX hack alert this disables |
442 |
|
|
* the stupid unused function warning |
443 |
|
|
* gcc generates |
444 |
|
|
*/ |
445 |
|
|
if (1 == 0) |
446 |
|
|
yy_fatal_error("EOF in comment"); |
447 |
|
|
break; |
448 |
|
|
} |
449 |
|
|
} |
450 |
|
|
} |
451 |
|
|
|
452 |
|
|
/* C-style .includes. This function will properly swap input conf buffers, |
453 |
|
|
* and lineno -kre */ |
454 |
|
|
static void |
455 |
|
|
cinclude(void) |
456 |
|
|
{ |
457 |
|
|
char *p = NULL; |
458 |
|
|
|
459 |
|
|
if ((p = strchr(yytext, '<')) == NULL) |
460 |
|
|
*strchr(p = strchr(yytext, '"') + 1, '"') = '\0'; |
461 |
|
|
else |
462 |
|
|
*strchr(++p, '>') = '\0'; |
463 |
|
|
|
464 |
|
|
/* log(L_NOTICE, "got include %s!", c); */ |
465 |
|
|
|
466 |
|
|
/* do stacking and co. */ |
467 |
|
|
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) |
468 |
|
|
ilog(L_ERROR, "Includes nested too deep in %s", p); |
469 |
|
|
else |
470 |
|
|
{ |
471 |
|
|
FBFILE *tmp_fbfile_in = NULL; |
472 |
|
|
char filenamebuf[IRCD_BUFSIZE]; |
473 |
|
|
|
474 |
|
|
if (*p == '/') /* if it is an absolute path */ |
475 |
|
|
snprintf(filenamebuf, sizeof(filenamebuf), "%s", p); |
476 |
|
|
else |
477 |
|
|
snprintf(filenamebuf, sizeof(filenamebuf), "%s/%s", ETCPATH, p); |
478 |
|
|
|
479 |
|
|
tmp_fbfile_in = fbopen(filenamebuf, "r"); |
480 |
|
|
|
481 |
|
|
if (tmp_fbfile_in == NULL) |
482 |
|
|
{ |
483 |
|
|
ilog(L_ERROR, "Unable to read configuration file '%s': %s", |
484 |
|
|
filenamebuf, strerror(errno)); |
485 |
|
|
return; |
486 |
|
|
} |
487 |
|
|
|
488 |
|
|
lineno_stack[include_stack_ptr] = lineno; |
489 |
|
|
lineno = 1; |
490 |
|
|
inc_fbfile_in[include_stack_ptr] = conf_fbfile_in; |
491 |
|
|
strlcpy(conffile_stack[include_stack_ptr], conffilebuf, IRCD_BUFSIZE); |
492 |
|
|
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; |
493 |
|
|
conf_fbfile_in = tmp_fbfile_in; |
494 |
|
|
snprintf(conffilebuf, sizeof(conffilebuf), "%s", p); |
495 |
|
|
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); |
496 |
|
|
} |
497 |
|
|
} |
498 |
|
|
|
499 |
|
|
/* This is function that will be called on EOF in conf file. It will |
500 |
|
|
* apropriately close conf if it not main conf and swap input buffers -kre |
501 |
|
|
* */ |
502 |
|
|
static int |
503 |
|
|
ieof(void) |
504 |
|
|
{ |
505 |
|
|
/* log(L_NOTICE, "return from include stack!"); */ |
506 |
|
|
if (include_stack_ptr) |
507 |
|
|
fbclose(conf_fbfile_in); |
508 |
|
|
if (--include_stack_ptr < 0) |
509 |
|
|
{ |
510 |
|
|
/* log(L_NOTICE, "terminating lexer"); */ |
511 |
|
|
/* We will now exit the lexer - restore init values if we get /rehash |
512 |
|
|
* later and reenter lexer -kre */ |
513 |
|
|
include_stack_ptr = 0; |
514 |
|
|
lineno = 1; |
515 |
|
|
return 1; |
516 |
|
|
} |
517 |
|
|
|
518 |
|
|
/* switch buffer */ |
519 |
|
|
/* log(L_NOTICE, "deleting include_stack_ptr=%d", include_stack_ptr); */ |
520 |
|
|
yy_delete_buffer(YY_CURRENT_BUFFER); |
521 |
|
|
lineno = lineno_stack[include_stack_ptr]; |
522 |
|
|
conf_fbfile_in = inc_fbfile_in[include_stack_ptr]; |
523 |
|
|
strlcpy(conffilebuf, conffile_stack[include_stack_ptr], sizeof(conffilebuf)); |
524 |
|
|
yy_switch_to_buffer(include_stack[include_stack_ptr]); |
525 |
|
|
|
526 |
|
|
return 0; |
527 |
|
|
} |