From e0a013397a51963039c43877be3afe954e519be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Wed, 11 Aug 2010 14:28:06 +0300 Subject: filter: implement basic analysis of urls Analysing of the url host part, some simple tests. Not usable as squid filter yet. --- blob.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'blob.c') diff --git a/blob.c b/blob.c index 377ec62..a417a0b 100644 --- a/blob.c +++ b/blob.c @@ -180,3 +180,23 @@ blob_t blob_pull_cspn(blob_t *b, const blob_t reject) *b = BLOB_NULL; return t; } + +blob_t blob_expand_head(blob_t *b, blob_t limits, unsigned char sep) +{ + blob_t t = *b; + blob_t r; + + if (t.ptr <= limits.ptr || t.ptr+t.len > limits.ptr+limits.len) + return BLOB_NULL; + while (t.ptr > limits.ptr && t.ptr[-1] == sep) + t.ptr--, t.len++; + + r.ptr = t.ptr; + r.len = 0; + while (t.ptr > limits.ptr && t.ptr[-1] != sep) { + t.ptr--, t.len++; + r.ptr--, r.len++; + } + *b = t; + return r; +} -- cgit v1.2.3