summaryrefslogtreecommitdiffstats
path: root/blob.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-08-14 20:21:59 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-08-14 20:21:59 +0300
commit54581ca7fe116ab20d6fa7f15013efe1777e1380 (patch)
treedc22731105eaa0ff39920e461f6b4831dad46f47 /blob.c
parent7daf2874969fb6773d480e9776cd8418eeb6353f (diff)
downloadsquark-54581ca7fe116ab20d6fa7f15013efe1777e1380.tar.bz2
squark-54581ca7fe116ab20d6fa7f15013efe1777e1380.tar.xz
filter: squid interfacing code, basic minimum configuration
Implement squid redirect protocol. It implements the "concurrent" version even though the algorithm is non-blocking. Doing this can reduce the amount of read system calls on busy system. Minimum command line based configuration for banning specific categories and specifying the redirect site. Will probably have to add some sort of config file system later.
Diffstat (limited to 'blob.c')
-rw-r--r--blob.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/blob.c b/blob.c
index 0c28877..5a3b226 100644
--- a/blob.c
+++ b/blob.c
@@ -189,6 +189,22 @@ unsigned int blob_pull_uint(blob_t *b, int radix)
return val;
}
+blob_t blob_pull_spn(blob_t *b, const blob_t reject)
+{
+ blob_t t = *b;
+ int i;
+
+ for (i = 0; i < t.len; i++) {
+ if (memchr(reject.ptr, t.ptr[i], reject.len) == NULL) {
+ *b = BLOB_PTR_LEN(t.ptr + i, t.len - i);
+ return BLOB_PTR_LEN(t.ptr, i);
+ }
+ }
+
+ *b = BLOB_NULL;
+ return t;
+}
+
blob_t blob_pull_cspn(blob_t *b, const blob_t reject)
{
blob_t t = *b;