1 #include <string.h> 2 #include "case.h" 3 #include "ldif.h" 4 #include "str.h" 5 6 /* behave like strcmp, but also return 0 if s is a prefix of c. */ matchcaseprefix(struct string * s,const char * c)7int matchcaseprefix(struct string* s,const char* c) { 8 unsigned int l,l1,i; 9 if (!c) return -1; 10 l1=l=str_len(c); 11 if (s->l<l1) l1=s->l; 12 i=case_diffb(s->s,l1,c); 13 if (i) return i; 14 /* one is a prefix of the other */ 15 if (l==s->l) return 0; 16 if (c[l1]) /* is c the longer string? */ 17 return 0; 18 return -(int)(s->s[l1]); 19 } 20 21