diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-08-11 14:28:06 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-08-11 14:28:06 +0300 |
commit | e0a013397a51963039c43877be3afe954e519be0 (patch) | |
tree | 77cbd4db435ec62d679920596ffbd07166fdc902 /blob.c | |
parent | cf7e91d59880424ff6c643a848938619b7968ad8 (diff) | |
download | squark-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.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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; +} |