diff options
author | Ian C <ianc@noddybox.co.uk> | 2003-12-09 01:25:08 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2003-12-09 01:25:08 +0000 |
commit | b0feacc0fe2d006ac4536f5069c9373beffe2cf5 (patch) | |
tree | a8f78032fe66f9be35383c27851bd65189b693f9 /src/config.c | |
parent | 1c161a8cbe16aa59cc8bf4d60d5fa64fdcbc6aa5 (diff) |
Added blacklist command; fixed a few dodgy frees (oops)
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index 268198d..4e369f7 100644 --- a/src/config.c +++ b/src/config.c @@ -54,6 +54,7 @@ typedef enum { TOK_AllowSubject, TOK_BlockSubject, TOK_SubjectMacro, + TOK_Blacklist, TOK_VarHostname, TOK_VarPort, TOK_VarUsername, @@ -122,6 +123,7 @@ static const Command cmd_table[]= {"allow_subject", TOK_AllowSubject}, {"block_subject", TOK_BlockSubject}, {"subject_macro", TOK_SubjectMacro}, + {"blacklist", TOK_Blacklist}, /* Variables */ @@ -524,6 +526,50 @@ static int DoSubjectMacro(FILE *fp) } +static int DoBlacklist(FILE *fp) +{ + DString ds; + Token tok; + + ds=DSInit(); + + tok=GetToken(fp,&ds); + + if (tok!=TOK_OpenBracket) + { + DSAddCP(error,"Missing opening bracket in blacklist"); + DSFree(ds); + return FALSE; + } + + while((tok=GetToken(fp,&ds))!=TOK_CloseBracket) + { + RE_Expression re; + + if (tok==TOK_EOF) + { + DSAddCP(error,"Missing close bracket in blacklist"); + DSFree(ds); + return FALSE; + } + + if (!(re=RECompile(ds->text))) + { + DSAddCP(error,"Bad regular expression: "); + DSAddDS(error,ds); + DSFree(ds); + return FALSE; + } + + DBBlacklist(re); + } + + DSFree(ds); + + return TRUE; +} + + /* ---------------------------------------- PRVIVATE FUNCTIONS */ static int Getc(FILE *fp) @@ -695,6 +741,11 @@ static int Parse(FILE *fp) ok=FALSE; break; + case TOK_Blacklist: + if (!DoBlacklist(fp)) + ok=FALSE; + break; + case TOK_Expression: DSAddCP(error,"Unknown command in config file: "); DSAddDS(error,txt); |