1 #include "case.h" 2 #include "bstr.h" 3 #include "ldif.h" 4 5 /* like matchstring, but case insensitively */ matchcasestring(struct string * s,const char * c)6int matchcasestring(struct string* s,const char* c) { 7 unsigned int l,l1,i; 8 if (!c) return -1; 9 l1=l=bstrlen(c); 10 if (s->l<l1) l1=s->l; 11 c=bstrfirst(c); 12 i=case_diffb(s->s,l1,c); 13 if (i) return i; 14 /* same length? */ 15 if (l==s->l) return 0; 16 /* one is a prefix of the other */ 17 if (l1<l) /* we cut off c */ 18 return -c[l1]; 19 return (int)(s->s[l1]); 20 } 21 22