X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fircd_lexer.l;h=eee4c75061b2d052c808126fbc5c6132976d3839;hb=d13c7b5efd15eec19cbd08d00a3f65da03049868;hp=458e571cdd867cd1a4052c7725514d3524e2e7f0;hpb=9b1f5beca29ec78141f19a19d689f0f7cc3fe3ac;p=ircu2.10.12-pk.git diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 458e571..eee4c75 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -24,8 +24,11 @@ #include #include #include +#include #include "config.h" +#include "fileio.h" #include "ircd.h" +#include "ircd_alloc.h" #include "ircd_string.h" #include "s_debug.h" #include "y.tab.h" @@ -46,9 +49,12 @@ static struct lexer_token { TOKEN(CONNECT), TOKEN(CONNECTFREQ), TOKEN(MAXLINKS), + TOKEN(MAXHOPS), TOKEN(SENDQ), TOKEN(NAME), TOKEN(HOST), + TOKEN(IP), + TOKEN(USERNAME), TOKEN(PASS), TOKEN(SECONDS), TOKEN(MINUTES), @@ -85,7 +91,6 @@ static struct lexer_token { TOKEN(REASON), TOKEN(RULE), TOKEN(ALL), - TOKEN(IP), TOKEN(CRULE), TOKEN(KILL), TOKEN(QUARANTINE), @@ -96,8 +101,14 @@ static struct lexer_token { TOKEN(PSEUDO), TOKEN(PREPEND), TOKEN(USERMODE), + TOKEN(FAST), + TOKEN(AUTOCONNECT), + TOKEN(PROGRAM), + TOKEN(DNS), #undef TOKEN { "administrator", ADMIN }, + { "apass_opmode", TPRIV_APASS_OPMODE }, + { "auto", AUTOCONNECT }, { "b", BYTES }, { "badchan", TPRIV_BADCHAN }, { "chan_limit", TPRIV_CHAN_LIMIT }, @@ -107,18 +118,22 @@ static struct lexer_token { { "file", TFILE }, { "force_local_opmode", TPRIV_FORCE_LOCAL_OPMODE }, { "force_opmode", TPRIV_FORCE_OPMODE }, + { "gb", GBYTES }, + { "gigabytes", GBYTES }, { "gline", TPRIV_GLINE }, + { "ipv4", TOK_IPV4 }, + { "ipv6", TOK_IPV6 }, { "kb", KBYTES }, { "kilobytes", KBYTES }, + { "list_chan", TPRIV_LIST_CHAN }, { "local_badchan", TPRIV_LOCAL_BADCHAN }, { "local_gline", TPRIV_LOCAL_GLINE }, { "local_jupe", TPRIV_LOCAL_JUPE }, { "local_kill", TPRIV_LOCAL_KILL }, + { "local_opmode", TPRIV_LOCAL_OPMODE }, { "mb", MBYTES }, { "megabytes", MBYTES }, { "mode_lchan", TPRIV_MODE_LCHAN }, - { "gb", GBYTES }, - { "gigabytes", GBYTES }, { "operator", OPER }, { "opmode", TPRIV_OPMODE }, { "password", PASS }, @@ -134,6 +149,7 @@ static struct lexer_token { { "tb", TBYTES }, { "terabytes", TBYTES }, { "unlimit_query", TPRIV_UNLIMIT_QUERY }, + { "unlimit_flood", TPRIV_UNLIMIT_FLOOD }, { "walk_lchan", TPRIV_WALK_LCHAN }, { "wide_gline", TPRIV_WIDE_GLINE }, { "whox", TPRIV_WHOX }, @@ -171,22 +187,44 @@ find_token(char *token) return tok ? tok->value : 0; } -void +static FBFILE *lexer_input; + +#undef YY_INPUT +#define YY_INPUT(buf, res, size) res = (fbgets(buf, size, lexer_input) ? strlen(buf) : 0) + +int init_lexer(void) { - yyin = fopen(configfile, "r"); - if (yyin == NULL) + lexer_input = fbopen(configfile, "r"); + if (lexer_input == NULL) { #ifdef YY_FATAL_ERROR YY_FATAL_ERROR("Could not open the configuration file."); #else fprintf(stderr, "Could not open the configuration file."); #endif + return 0; } #ifdef YY_NEW_FILE YY_NEW_FILE; #endif lineno = 1; + return 1; +} + +void deinit_lexer(void) +{ + if (lexer_input != NULL) + { + fbclose(lexer_input); + lexer_input = NULL; + } +} + +int +yywrap(void) +{ + return 1; } %} @@ -197,11 +235,11 @@ NUMBER [0-9]+ QSTRING \"[^"\n]+[\"\n] %% -{QSTRING} {yytext[yyleng-1] = 0; yylval.text = yytext+1; return QSTRING;} +{QSTRING} {yytext[yyleng-1] = 0; DupString(yylval.text, yytext+1); return QSTRING;} {NUMBER} {yylval.num = strtoul(yytext, NULL, 10); return NUMBER;} {WHITE} ; {SHCOMMENT} ; -[a-zA-Z_]+ { int res = find_token(yytext); if (res) return res; else REJECT; } +[a-zA-Z_][a-zA-Z_0-9]* { int res = find_token(yytext); if (res) return res; else REJECT; } \n lineno++; . return yytext[0];