20 lines
447 B
C
20 lines
447 B
C
#include <string.h>
|
|
#include "case.h"
|
|
#include "ldif.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=strlen(c);
|
|
if (s->l<l1) l1=s->l;
|
|
i=byte_case_diff(s->s,l1,c);
|
|
if (i) return i;
|
|
/* one is a prefix of the other */
|
|
if (l==s->l) return 0;
|
|
if (c[l1]) /* is c the longer string? */
|
|
return c[l1];
|
|
return -(int)(s->s[l1]);
|
|
}
|
|
|