| 1 |
|
/* |
| 2 |
|
* Copyright (c) 2002 Erik Fears |
| 3 |
< |
* Copyright (c) 2014-2016 ircd-hybrid development team |
| 3 |
> |
* Copyright (c) 2014-2018 ircd-hybrid development team |
| 4 |
|
* |
| 5 |
|
* This program is free software; you can redistribute it and/or modify |
| 6 |
|
* it under the terms of the GNU General Public License as published by |
| 20 |
|
|
| 21 |
|
%option case-insensitive |
| 22 |
|
%option noyywrap |
| 23 |
+ |
%option noinput |
| 24 |
|
%option nounput |
| 25 |
|
%option never-interactive |
| 26 |
|
|
| 27 |
+ |
%x IN_COMMENT |
| 28 |
+ |
|
| 29 |
|
%{ |
| 30 |
|
#include <stdio.h> |
| 31 |
|
#include <string.h> |
| 35 |
|
#include "config-parser.h" /* autogenerated header file */ |
| 36 |
|
#include "log.h" |
| 37 |
|
|
| 38 |
+ |
/* libopm includes */ |
| 39 |
+ |
#include "libopm/src/opm_types.h" |
| 40 |
+ |
|
| 41 |
|
#undef YY_FATAL_ERROR |
| 42 |
|
#define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg) |
| 43 |
|
|
| 63 |
|
static unsigned int include_stack_ptr; |
| 64 |
|
|
| 65 |
|
|
| 60 |
– |
static void ccomment(void); |
| 66 |
|
static void conf_include(void); |
| 67 |
|
static int conf_eof(void); |
| 68 |
|
|
| 86 |
|
include \.include{WS}(\<.*\>|\".*\") |
| 87 |
|
|
| 88 |
|
%% |
| 89 |
+ |
|
| 90 |
+ |
"/*" { BEGIN IN_COMMENT; } |
| 91 |
+ |
<IN_COMMENT>"*/" { BEGIN INITIAL; } |
| 92 |
+ |
<IN_COMMENT>. ; /* Eat everything but a newline */ |
| 93 |
+ |
<IN_COMMENT>\n { ++lineno; } |
| 94 |
+ |
<IN_COMMENT><<EOF>> { BEGIN INITIAL; if (conf_eof()) yyterminate(); } |
| 95 |
+ |
|
| 96 |
|
{include} { conf_include(); } |
| 85 |
– |
"/*" { ccomment(); } |
| 97 |
|
\n.* { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); } |
| 98 |
|
{WS} ; |
| 99 |
|
{COMMENT} ; |
| 139 |
|
} |
| 140 |
|
} |
| 141 |
|
|
| 142 |
+ |
ADDRESS_FAMILY { return ADDRESS_FAMILY; } |
| 143 |
|
AWAY { return AWAY; } |
| 144 |
|
BAN_UNKNOWN { return BAN_UNKNOWN; } |
| 145 |
|
BLACKLIST { return BLACKLIST; } |
| 155 |
|
EXEMPT { return EXEMPT; } |
| 156 |
|
FD { return FD; } |
| 157 |
|
INVITE { return INVITE; } |
| 158 |
+ |
IPV4 { return IPV4; } |
| 159 |
+ |
IPV6 { return IPV6; } |
| 160 |
|
IRC { return IRC; } |
| 161 |
|
KLINE { return KLINE; } |
| 162 |
|
KEY { return KEY; } |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
|
| 271 |
+ |
SSH { |
| 272 |
+ |
yylval.number = OPM_TYPE_SSH; |
| 273 |
+ |
return PROTOCOLTYPE; |
| 274 |
+ |
} |
| 275 |
+ |
|
| 276 |
|
TRUE { |
| 277 |
|
yylval.number=1; |
| 278 |
|
return NUMBER; |
| 308 |
|
|
| 309 |
|
%% |
| 310 |
|
|
| 292 |
– |
|
| 293 |
– |
/* C-comment ignoring routine -kre*/ |
| 294 |
– |
static void |
| 295 |
– |
ccomment(void) |
| 296 |
– |
{ |
| 297 |
– |
int c = 0; |
| 298 |
– |
|
| 299 |
– |
/* log(L_NOTICE, "got comment"); */ |
| 300 |
– |
while (1) |
| 301 |
– |
{ |
| 302 |
– |
while ((c = input()) != '*' && c != EOF) |
| 303 |
– |
if (c == '\n') |
| 304 |
– |
++lineno; |
| 305 |
– |
|
| 306 |
– |
if (c == '*') |
| 307 |
– |
{ |
| 308 |
– |
while ((c = input()) == '*') |
| 309 |
– |
/* Nothing */ ; |
| 310 |
– |
if (c == '/') |
| 311 |
– |
break; |
| 312 |
– |
else if (c == '\n') |
| 313 |
– |
++lineno; |
| 314 |
– |
} |
| 315 |
– |
|
| 316 |
– |
if (c == EOF) |
| 317 |
– |
{ |
| 318 |
– |
YY_FATAL_ERROR("EOF in comment"); |
| 319 |
– |
|
| 320 |
– |
/* XXX hack alert this disables |
| 321 |
– |
* the stupid unused function warning |
| 322 |
– |
* gcc generates |
| 323 |
– |
*/ |
| 324 |
– |
if (1 == 0) |
| 325 |
– |
yy_fatal_error("EOF in comment"); |
| 326 |
– |
break; |
| 327 |
– |
} |
| 328 |
– |
} |
| 329 |
– |
} |
| 330 |
– |
|
| 311 |
|
static void |
| 312 |
|
conf_include(void) |
| 313 |
|
{ |
| 347 |
|
|
| 348 |
|
lineno = 1; |
| 349 |
|
conf_file = tmp_fbfile_in; |
| 350 |
+ |
strlcpy(conffilebuf, filenamebuf, sizeof(conffilebuf)); |
| 351 |
|
|
| 371 |
– |
snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf); |
| 352 |
|
yy_switch_to_buffer(yy_create_buffer(NULL, YY_BUF_SIZE)); |
| 353 |
|
} |
| 354 |
|
|
| 356 |
|
conf_eof(void) |
| 357 |
|
{ |
| 358 |
|
if (include_stack_ptr == 0) |
| 379 |
– |
{ |
| 380 |
– |
lineno = 1; |
| 359 |
|
return 1; |
| 382 |
– |
} |
| 360 |
|
|
| 361 |
|
/* switch buffer */ |
| 362 |
|
struct included_file *file = &include_stack[--include_stack_ptr]; |