summaryrefslogtreecommitdiffstats
path: root/blob.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-08-11 14:28:06 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-08-11 14:28:06 +0300
commite0a013397a51963039c43877be3afe954e519be0 (patch)
tree77cbd4db435ec62d679920596ffbd07166fdc902 /blob.c
parentcf7e91d59880424ff6c643a848938619b7968ad8 (diff)
downloadsquark-e0a013397a51963039c43877be3afe954e519be0.tar.bz2
squark-e0a013397a51963039c43877be3afe954e519be0.tar.xz
filter: implement basic analysis of urls
Analysing of the url host part, some simple tests. Not usable as squid filter yet.
Diffstat (limited to 'blob.c')
-rw-r--r--blob.c20
1 files changed, 20 insertions, 0 deletions
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;
+}