diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-08-26 21:07:27 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-08-26 21:07:27 +0000 |
commit | 849345e88bd3bdb2bde1e531a3815308dc3e7bf0 (patch) | |
tree | 48adee5b6ab80f758c457aaf14eb7fcf887d1d20 /src/anonymous.c | |
parent | 99dfce8f494300de982997214a1ad1b1f956ff7b (diff) |
Removed the anon_new() function and moved it's functionality into
anonymous_insert(). Also renamed all the anon_* functions to anonymous_*
function.
Diffstat (limited to 'src/anonymous.c')
-rw-r--r-- | src/anonymous.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/anonymous.c b/src/anonymous.c index a03347d..4463080 100644 --- a/src/anonymous.c +++ b/src/anonymous.c @@ -1,4 +1,4 @@ -/* $Id: anonymous.c,v 1.5 2001-05-27 02:21:37 rjkaes Exp $ +/* $Id: anonymous.c,v 1.6 2001-08-26 21:07:27 rjkaes Exp $ * * Handles insertion and searches for headers which should be let through when * the anonymous feature is turned on. The headers are stored in a Ternary @@ -29,26 +29,48 @@ #include <unistd.h> #include "anonymous.h" +#include "log.h" #include "ternary.h" +#include "tinyproxy.h" -static TERNARY anonymous_tree; +static TERNARY anonymous_tree = 0; +/* + * Keep track of whether the Anonymous filtering is enabled. Off by + * default. + */ +static short int anonymous_is_enabled = 0; -TERNARY new_anonymous(void) +short int is_anonymous_enabled(void) { - anonymous_tree = ternary_new(); - return anonymous_tree; + return anonymous_is_enabled; } -int anon_search(char *s) +int anonymous_search(char *s) { assert(s != NULL); + assert(anonymous_is_enabled == 1); + assert(anonymous_tree > 0); return ternary_search(anonymous_tree, s, NULL); } -void anon_insert(char *s) +int anonymous_insert(char *s) { assert(s != NULL); - ternary_insert(anonymous_tree, s, NULL); + /* + * If this is the first time we're inserting a word, create the + * search tree. + */ + if (!anonymous_is_enabled) { + anonymous_tree = ternary_new(); + if (anonymous_tree < 0) + return -1; + + anonymous_is_enabled = 1; + + DEBUG1("Starting the Anonymous header subsytem."); + } + + return ternary_insert(anonymous_tree, s, NULL); } |