From 54581ca7fe116ab20d6fa7f15013efe1777e1380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Sat, 14 Aug 2010 20:21:59 +0300 Subject: 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. --- blob.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'blob.c') 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; -- cgit v1.2.3