diff options
author | Simon Rettberg | 2014-03-15 01:49:50 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-03-15 01:49:50 +0100 |
commit | bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad (patch) | |
tree | c7d1995a09f6ed0c4e6873252e957d72f5d07d07 /matchcasestring.c | |
download | ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.gz ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.xz ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.zip |
Lean and mean initial commit
Not much functionality yet
Diffstat (limited to 'matchcasestring.c')
-rw-r--r-- | matchcasestring.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/matchcasestring.c b/matchcasestring.c new file mode 100644 index 0000000..5e75e51 --- /dev/null +++ b/matchcasestring.c @@ -0,0 +1,21 @@ +#include "case.h" +#include "bstr.h" +#include "asn1.h" + +/* like matchstring, but case insensitively */ +int matchcasestring(struct string* s,const char* c) { + unsigned int l,l1,i; + if (!c) return -1; + l1=l=bstrlen(c); + if (s->l<l1) l1=s->l; + c=bstrfirst(c); + i=case_diffb(s->s,l1,c); + if (i) return i; + /* same length? */ + if (l==s->l) return 0; + /* one is a prefix of the other */ + if (l1<l) /* we cut off c */ + return -c[l1]; + return (int)(s->s[l1]); +} + |