| 1 |
michael |
5052 |
/* |
| 2 |
|
|
* Copyright (C) 2002 Erik Fears |
| 3 |
|
|
* |
| 4 |
|
|
* QSTRING , ccomment and hashcomment taken from Hybrid7: |
| 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 |
| 8 |
|
|
* modify it under the terms of the GNU General Public License |
| 9 |
|
|
* as published by the Free Software Foundation; either version 2 |
| 10 |
|
|
* of the License, or (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 |
| 19 |
|
|
* |
| 20 |
|
|
* The Free Software Foundation, Inc. |
| 21 |
|
|
* 59 Temple Place - Suite 330 |
| 22 |
|
|
* Boston, MA 02111-1307, USA. |
| 23 |
|
|
* |
| 24 |
|
|
* |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
|
|
%option case-insensitive |
| 28 |
|
|
%option noyywrap |
| 29 |
|
|
%option nounput |
| 30 |
|
|
|
| 31 |
|
|
%{ |
| 32 |
|
|
#include <stdio.h> |
| 33 |
|
|
#include <string.h> |
| 34 |
michael |
5078 |
|
| 35 |
|
|
#include "inet.h" |
| 36 |
|
|
#include "compat.h" |
| 37 |
michael |
5052 |
#include "config.h" |
| 38 |
|
|
#include "config-parser.h" |
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
void ccomment(void); |
| 42 |
|
|
|
| 43 |
|
|
int linenum = 1; |
| 44 |
|
|
char linebuf[512]; |
| 45 |
|
|
|
| 46 |
|
|
%} |
| 47 |
|
|
|
| 48 |
|
|
string \"[^\"\n]*[\"\n] |
| 49 |
michael |
5078 |
comment ("//"|"#").* |
| 50 |
michael |
5052 |
whitespace [ \t\r]* |
| 51 |
|
|
|
| 52 |
|
|
%% |
| 53 |
|
|
|
| 54 |
|
|
"/*" { ccomment(); } |
| 55 |
|
|
|
| 56 |
michael |
5078 |
{comment} ; |
| 57 |
michael |
5052 |
|
| 58 |
|
|
{string} { |
| 59 |
|
|
/* QSTRING from Hybrid7. Why re-invent the wheel? */ |
| 60 |
|
|
|
| 61 |
|
|
if(yytext[yyleng-2] == '\\') |
| 62 |
|
|
{ |
| 63 |
|
|
yyless(yyleng-1); /* return last quote */ |
| 64 |
|
|
yymore(); /* append next string */ |
| 65 |
|
|
} |
| 66 |
|
|
else |
| 67 |
|
|
{ |
| 68 |
|
|
yylval.string = yytext+1; |
| 69 |
|
|
if(yylval.string[yyleng-2] != '"') ; /* log error */ |
| 70 |
|
|
else |
| 71 |
|
|
{ |
| 72 |
|
|
int i,j; |
| 73 |
|
|
|
| 74 |
|
|
yylval.string[yyleng-2] = '\0'; /* remove close |
| 75 |
|
|
* quote |
| 76 |
|
|
*/ |
| 77 |
|
|
|
| 78 |
|
|
for (j=i=0 ;yylval.string[i] != '\0'; i++,j++) |
| 79 |
|
|
{ |
| 80 |
|
|
if (yylval.string[i] != '\\') |
| 81 |
|
|
{ |
| 82 |
|
|
yylval.string[j] = yylval.string[i]; |
| 83 |
|
|
} |
| 84 |
|
|
else |
| 85 |
|
|
{ |
| 86 |
|
|
i++; |
| 87 |
|
|
yylval.string[j] = yylval.string[i]; |
| 88 |
|
|
} |
| 89 |
|
|
} |
| 90 |
|
|
yylval.string[j] = '\0'; |
| 91 |
|
|
return STRING; |
| 92 |
|
|
} |
| 93 |
|
|
} |
| 94 |
|
|
|
| 95 |
|
|
} |
| 96 |
|
|
|
| 97 |
|
|
AWAY { return AWAY; } |
| 98 |
|
|
BAN_UNKNOWN { return BAN_UNKNOWN; } |
| 99 |
|
|
BLACKLIST { return BLACKLIST; } |
| 100 |
|
|
CHANNEL { return CHANNEL; } |
| 101 |
|
|
CONNREGEX { return CONNREGEX; } |
| 102 |
|
|
DNS_FDLIMIT { return DNS_FDLIMIT; } |
| 103 |
|
|
DNSBL_FROM { return DNSBL_FROM; } |
| 104 |
|
|
DNSBL_TO { return DNSBL_TO; } |
| 105 |
|
|
EXEMPT { return EXEMPT; } |
| 106 |
|
|
FD { return FD; } |
| 107 |
|
|
INVITE { return INVITE; } |
| 108 |
|
|
IRC { return IRC; } |
| 109 |
|
|
KLINE { return KLINE; } |
| 110 |
|
|
KEY { return KEY; } |
| 111 |
|
|
MASK { return MASK; } |
| 112 |
|
|
MAX_READ { return MAX_READ; } |
| 113 |
|
|
MODE { return MODE; } |
| 114 |
|
|
NAME { return NAME; } |
| 115 |
|
|
NEGCACHE { return NEGCACHE; } |
| 116 |
|
|
NICK { return NICK; } |
| 117 |
|
|
NICKSERV { return NICKSERV; } |
| 118 |
|
|
OPER { return OPER; } |
| 119 |
|
|
OPM { return OPM; } |
| 120 |
|
|
OPTIONS { return OPTIONS; } |
| 121 |
|
|
PASSWORD { return PASSWORD; } |
| 122 |
|
|
PERFORM { return PERFORM; } |
| 123 |
|
|
PIDFILE { return PIDFILE; } |
| 124 |
|
|
PORT { return PORT; } |
| 125 |
|
|
PROTOCOL { return PROTOCOL; } |
| 126 |
|
|
REALNAME { return REALNAME; } |
| 127 |
|
|
REPLY { return REPLY; } |
| 128 |
|
|
SCANLOG { return SCANLOG; } |
| 129 |
|
|
SCANNER { return SCANNER; } |
| 130 |
|
|
SENDMAIL { return SENDMAIL; } |
| 131 |
|
|
SERVER { return SERVER; } |
| 132 |
|
|
TARGET_IP { return TARGET_IP; } |
| 133 |
|
|
TARGET_PORT { return TARGET_PORT; } |
| 134 |
|
|
TARGET_STRING { return TARGET_STRING;} |
| 135 |
|
|
TIMEOUT { return TIMEOUT; } |
| 136 |
|
|
TYPE { return TYPE; } |
| 137 |
|
|
USER { return USER; } |
| 138 |
|
|
USERNAME { return USERNAME; } |
| 139 |
|
|
VHOST { return VHOST; } |
| 140 |
|
|
|
| 141 |
|
|
|
| 142 |
|
|
HTTP { |
| 143 |
|
|
yylval.number = OPM_TYPE_HTTP; |
| 144 |
|
|
return PROTOCOLTYPE; |
| 145 |
|
|
} |
| 146 |
|
|
|
| 147 |
|
|
HTTPPOST { |
| 148 |
|
|
yylval.number = OPM_TYPE_HTTPPOST; |
| 149 |
|
|
return PROTOCOLTYPE; |
| 150 |
|
|
} |
| 151 |
|
|
|
| 152 |
|
|
SOCKS4 { |
| 153 |
|
|
yylval.number = OPM_TYPE_SOCKS4; |
| 154 |
|
|
return PROTOCOLTYPE; |
| 155 |
|
|
} |
| 156 |
|
|
|
| 157 |
|
|
SOCKS5 { |
| 158 |
|
|
yylval.number = OPM_TYPE_SOCKS5; |
| 159 |
|
|
return PROTOCOLTYPE; |
| 160 |
|
|
} |
| 161 |
|
|
|
| 162 |
|
|
WINGATE { |
| 163 |
|
|
yylval.number = OPM_TYPE_WINGATE; |
| 164 |
|
|
return PROTOCOLTYPE; |
| 165 |
|
|
} |
| 166 |
|
|
|
| 167 |
|
|
ROUTER { |
| 168 |
|
|
yylval.number = OPM_TYPE_ROUTER; |
| 169 |
|
|
return PROTOCOLTYPE; |
| 170 |
|
|
} |
| 171 |
|
|
|
| 172 |
|
|
|
| 173 |
|
|
[0-9]+ { |
| 174 |
|
|
yylval.number=atoi(yytext); |
| 175 |
|
|
return NUMBER; |
| 176 |
|
|
} |
| 177 |
|
|
|
| 178 |
|
|
|
| 179 |
|
|
|
| 180 |
|
|
|
| 181 |
|
|
|
| 182 |
|
|
TRUE { |
| 183 |
|
|
yylval.number=1; |
| 184 |
|
|
return NUMBER; |
| 185 |
|
|
} |
| 186 |
|
|
YES { |
| 187 |
|
|
yylval.number=1; |
| 188 |
|
|
return NUMBER; |
| 189 |
|
|
} |
| 190 |
|
|
ON { |
| 191 |
|
|
yylval.number=1; |
| 192 |
|
|
return NUMBER; |
| 193 |
|
|
} |
| 194 |
|
|
|
| 195 |
|
|
|
| 196 |
|
|
|
| 197 |
|
|
FALSE { |
| 198 |
|
|
yylval.number=0; |
| 199 |
|
|
return NUMBER; |
| 200 |
|
|
} |
| 201 |
|
|
|
| 202 |
|
|
NO { |
| 203 |
|
|
yylval.number=0; |
| 204 |
|
|
return NUMBER; |
| 205 |
|
|
} |
| 206 |
|
|
|
| 207 |
|
|
OFF { |
| 208 |
|
|
yylval.number=0; |
| 209 |
|
|
return NUMBER; |
| 210 |
|
|
} |
| 211 |
|
|
|
| 212 |
|
|
|
| 213 |
michael |
5078 |
\n.* { |
| 214 |
|
|
strlcpy(linebuf, yytext + 1, sizeof(linebuf)); |
| 215 |
|
|
++linenum; |
| 216 |
|
|
yyless(1); |
| 217 |
|
|
} |
| 218 |
michael |
5052 |
|
| 219 |
|
|
{whitespace} /* ignore whitespace */; |
| 220 |
|
|
|
| 221 |
|
|
. return yytext[0]; |
| 222 |
|
|
|
| 223 |
|
|
%% |
| 224 |
|
|
|
| 225 |
|
|
|
| 226 |
|
|
/* C-comment ignoring routine -kre*/ |
| 227 |
|
|
void ccomment(void) |
| 228 |
|
|
{ |
| 229 |
|
|
int c; |
| 230 |
|
|
|
| 231 |
|
|
/* log(L_NOTICE, "got comment"); */ |
| 232 |
|
|
while (1) |
| 233 |
|
|
{ |
| 234 |
|
|
while ((c = input()) != '*' && c != EOF) |
| 235 |
|
|
if (c == '\n') ++linenum; |
| 236 |
|
|
if (c == '*') |
| 237 |
|
|
{ |
| 238 |
|
|
while ((c = input()) == '*'); |
| 239 |
|
|
if (c == '/') break; |
| 240 |
|
|
} |
| 241 |
|
|
if (c == EOF) |
| 242 |
|
|
{ |
| 243 |
|
|
YY_FATAL_ERROR("EOF in comment"); |
| 244 |
|
|
/* XXX hack alert this disables |
| 245 |
|
|
* the stupid unused function warning |
| 246 |
|
|
* gcc generates |
| 247 |
|
|
*/ |
| 248 |
|
|
if(1 == 0) |
| 249 |
|
|
yy_fatal_error("EOF in comment"); |
| 250 |
|
|
break; |
| 251 |
|
|
} |
| 252 |
|
|
} |
| 253 |
|
|
} |
| 254 |
|
|
|