| 1 |
/* |
| 2 |
* Copyright (c) 2002 Erik Fears |
| 3 |
* Copyright (c) 2014-2015 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 |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 18 |
* USA |
| 19 |
*/ |
| 20 |
|
| 21 |
%option case-insensitive |
| 22 |
%option noyywrap |
| 23 |
%option nounput |
| 24 |
%option never-interactive |
| 25 |
|
| 26 |
%{ |
| 27 |
#include <stdio.h> |
| 28 |
#include <string.h> |
| 29 |
|
| 30 |
#include "compat.h" |
| 31 |
#include "config.h" |
| 32 |
#include "config-parser.h" |
| 33 |
|
| 34 |
|
| 35 |
void ccomment(void); |
| 36 |
|
| 37 |
unsigned int linenum = 1; |
| 38 |
char linebuf[512]; |
| 39 |
|
| 40 |
%} |
| 41 |
|
| 42 |
string \"[^\"\n]*[\"\n] |
| 43 |
comment ("//"|"#").* |
| 44 |
whitespace [ \t\r]* |
| 45 |
|
| 46 |
%% |
| 47 |
|
| 48 |
"/*" { ccomment(); } |
| 49 |
|
| 50 |
{comment} ; |
| 51 |
|
| 52 |
{string} { |
| 53 |
/* QSTRING from Hybrid7. Why re-invent the wheel? */ |
| 54 |
|
| 55 |
if(yytext[yyleng-2] == '\\') |
| 56 |
{ |
| 57 |
yyless(yyleng-1); /* return last quote */ |
| 58 |
yymore(); /* append next string */ |
| 59 |
} |
| 60 |
else |
| 61 |
{ |
| 62 |
yylval.string = yytext+1; |
| 63 |
if(yylval.string[yyleng-2] != '"') ; /* log error */ |
| 64 |
else |
| 65 |
{ |
| 66 |
int i,j; |
| 67 |
|
| 68 |
yylval.string[yyleng-2] = '\0'; /* remove close |
| 69 |
* quote |
| 70 |
*/ |
| 71 |
|
| 72 |
for (j=i=0 ;yylval.string[i] != '\0'; i++,j++) |
| 73 |
{ |
| 74 |
if (yylval.string[i] != '\\') |
| 75 |
{ |
| 76 |
yylval.string[j] = yylval.string[i]; |
| 77 |
} |
| 78 |
else |
| 79 |
{ |
| 80 |
i++; |
| 81 |
yylval.string[j] = yylval.string[i]; |
| 82 |
} |
| 83 |
} |
| 84 |
yylval.string[j] = '\0'; |
| 85 |
return STRING; |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
AWAY { return AWAY; } |
| 91 |
BAN_UNKNOWN { return BAN_UNKNOWN; } |
| 92 |
BLACKLIST { return BLACKLIST; } |
| 93 |
CHANNEL { return CHANNEL; } |
| 94 |
CONNREGEX { return CONNREGEX; } |
| 95 |
DNS_FDLIMIT { return DNS_FDLIMIT; } |
| 96 |
DNSBL_FROM { return DNSBL_FROM; } |
| 97 |
DNSBL_TO { return DNSBL_TO; } |
| 98 |
EXEMPT { return EXEMPT; } |
| 99 |
FD { return FD; } |
| 100 |
INVITE { return INVITE; } |
| 101 |
IRC { return IRC; } |
| 102 |
KLINE { return KLINE; } |
| 103 |
KEY { return KEY; } |
| 104 |
MASK { return MASK; } |
| 105 |
MAX_READ { return MAX_READ; } |
| 106 |
MODE { return MODE; } |
| 107 |
NAME { return NAME; } |
| 108 |
NEGCACHE { return NEGCACHE; } |
| 109 |
NEGCACHE_REBUILD { return NEGCACHE_REBUILD; } |
| 110 |
NICK { return NICK; } |
| 111 |
NICKSERV { return NICKSERV; } |
| 112 |
NOTICE { return NOTICE; } |
| 113 |
OPER { return OPER; } |
| 114 |
OPM { return OPM; } |
| 115 |
OPTIONS { return OPTIONS; } |
| 116 |
PASSWORD { return PASSWORD; } |
| 117 |
PERFORM { return PERFORM; } |
| 118 |
PIDFILE { return PIDFILE; } |
| 119 |
PORT { return PORT; } |
| 120 |
PROTOCOL { return PROTOCOL; } |
| 121 |
READTIMEOUT { return READTIMEOUT; } |
| 122 |
REALNAME { return REALNAME; } |
| 123 |
REPLY { return REPLY; } |
| 124 |
SCANLOG { return SCANLOG; } |
| 125 |
SCANNER { return SCANNER; } |
| 126 |
SENDMAIL { return SENDMAIL; } |
| 127 |
SERVER { return SERVER; } |
| 128 |
TARGET_IP { return TARGET_IP; } |
| 129 |
TARGET_PORT { return TARGET_PORT; } |
| 130 |
TARGET_STRING { return TARGET_STRING;} |
| 131 |
TIMEOUT { return TIMEOUT; } |
| 132 |
TYPE { return TYPE; } |
| 133 |
USER { return USER; } |
| 134 |
USERNAME { return USERNAME; } |
| 135 |
VHOST { return VHOST; } |
| 136 |
|
| 137 |
years { return YEARS; } |
| 138 |
year { return YEARS; } |
| 139 |
months { return MONTHS; } |
| 140 |
month { return MONTHS; } |
| 141 |
weeks { return WEEKS; } |
| 142 |
week { return WEEKS; } |
| 143 |
days { return DAYS; } |
| 144 |
day { return DAYS; } |
| 145 |
hours { return HOURS; } |
| 146 |
hour { return HOURS; } |
| 147 |
minutes { return MINUTES; } |
| 148 |
minute { return MINUTES; } |
| 149 |
seconds { return SECONDS; } |
| 150 |
second { return SECONDS; } |
| 151 |
|
| 152 |
bytes { return BYTES; } |
| 153 |
byte { return BYTES; } |
| 154 |
kilobytes { return KBYTES; } |
| 155 |
kilobyte { return KBYTES; } |
| 156 |
kbytes { return KBYTES; } |
| 157 |
kbyte { return KBYTES; } |
| 158 |
kb { return KBYTES; } |
| 159 |
megabytes { return MBYTES; } |
| 160 |
megabyte { return MBYTES; } |
| 161 |
mbytes { return MBYTES; } |
| 162 |
mbyte { return MBYTES; } |
| 163 |
mb { return MBYTES; } |
| 164 |
|
| 165 |
HTTP { |
| 166 |
yylval.number = OPM_TYPE_HTTP; |
| 167 |
return PROTOCOLTYPE; |
| 168 |
} |
| 169 |
|
| 170 |
HTTPPOST { |
| 171 |
yylval.number = OPM_TYPE_HTTPPOST; |
| 172 |
return PROTOCOLTYPE; |
| 173 |
} |
| 174 |
|
| 175 |
SOCKS4 { |
| 176 |
yylval.number = OPM_TYPE_SOCKS4; |
| 177 |
return PROTOCOLTYPE; |
| 178 |
} |
| 179 |
|
| 180 |
SOCKS5 { |
| 181 |
yylval.number = OPM_TYPE_SOCKS5; |
| 182 |
return PROTOCOLTYPE; |
| 183 |
} |
| 184 |
|
| 185 |
WINGATE { |
| 186 |
yylval.number = OPM_TYPE_WINGATE; |
| 187 |
return PROTOCOLTYPE; |
| 188 |
} |
| 189 |
|
| 190 |
ROUTER { |
| 191 |
yylval.number = OPM_TYPE_ROUTER; |
| 192 |
return PROTOCOLTYPE; |
| 193 |
} |
| 194 |
|
| 195 |
DREAMBOX { |
| 196 |
yylval.number = OPM_TYPE_DREAMBOX; |
| 197 |
return PROTOCOLTYPE; |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
[0-9]+ { |
| 203 |
yylval.number=atoi(yytext); |
| 204 |
return NUMBER; |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
TRUE { |
| 212 |
yylval.number=1; |
| 213 |
return NUMBER; |
| 214 |
} |
| 215 |
YES { |
| 216 |
yylval.number=1; |
| 217 |
return NUMBER; |
| 218 |
} |
| 219 |
ON { |
| 220 |
yylval.number=1; |
| 221 |
return NUMBER; |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
FALSE { |
| 227 |
yylval.number=0; |
| 228 |
return NUMBER; |
| 229 |
} |
| 230 |
|
| 231 |
NO { |
| 232 |
yylval.number=0; |
| 233 |
return NUMBER; |
| 234 |
} |
| 235 |
|
| 236 |
OFF { |
| 237 |
yylval.number=0; |
| 238 |
return NUMBER; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
\n.* { |
| 243 |
strlcpy(linebuf, yytext + 1, sizeof(linebuf)); |
| 244 |
++linenum; |
| 245 |
yyless(1); |
| 246 |
} |
| 247 |
|
| 248 |
{whitespace} /* ignore whitespace */; |
| 249 |
|
| 250 |
. return yytext[0]; |
| 251 |
|
| 252 |
%% |
| 253 |
|
| 254 |
|
| 255 |
/* C-comment ignoring routine -kre*/ |
| 256 |
void |
| 257 |
ccomment(void) |
| 258 |
{ |
| 259 |
int c = 0; |
| 260 |
|
| 261 |
/* log(L_NOTICE, "got comment"); */ |
| 262 |
while (1) |
| 263 |
{ |
| 264 |
while ((c = input()) != '*' && c != EOF) |
| 265 |
if (c == '\n') |
| 266 |
++linenum; |
| 267 |
|
| 268 |
if (c == '*') |
| 269 |
{ |
| 270 |
while ((c = input()) == '*') |
| 271 |
/* Nothing */ ; |
| 272 |
if (c == '/') |
| 273 |
break; |
| 274 |
else if (c == '\n') |
| 275 |
++linenum; |
| 276 |
} |
| 277 |
|
| 278 |
if (c == EOF) |
| 279 |
{ |
| 280 |
YY_FATAL_ERROR("EOF in comment"); |
| 281 |
|
| 282 |
/* XXX hack alert this disables |
| 283 |
* the stupid unused function warning |
| 284 |
* gcc generates |
| 285 |
*/ |
| 286 |
if (1 == 0) |
| 287 |
yy_fatal_error("EOF in comment"); |
| 288 |
break; |
| 289 |
} |
| 290 |
} |
| 291 |
} |