From 332ff7a104d978a607aae7239c70073c4e88fa22 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 21 Apr 2017 16:39:24 +0200 Subject: Remove unused string matching helpers --- Makefile | 13 +- ldap_match_mapped.c | 200 ---------------------------- ldap_match_sre.c | 166 ----------------------- ldif.h | 32 ----- ldif_parse.c | 371 ---------------------------------------------------- matchcaseprefix.c | 20 --- matchcasestring.c | 21 --- matchprefix.c | 20 --- matchstring.c | 21 --- 9 files changed, 3 insertions(+), 861 deletions(-) delete mode 100644 ldap_match_mapped.c delete mode 100644 ldap_match_sre.c delete mode 100644 ldif.h delete mode 100644 ldif_parse.c delete mode 100644 matchcaseprefix.c delete mode 100644 matchcasestring.c delete mode 100644 matchprefix.c delete mode 100644 matchstring.c diff --git a/Makefile b/Makefile index 111baaa..05af089 100644 --- a/Makefile +++ b/Makefile @@ -18,16 +18,13 @@ scan_ldapstring.o scan_ldapsearchfilter.o scan_ldapsearchrequest.o \ freefilter.o freeava.o scan_ldapava.o fmt_ldapsearchresultentry.o \ fmt_ldapstring.o freepal.o scan_ldapsearchresultentry.o \ fmt_ldapresult.o fmt_ldappal.o fmt_ldapadl.o fmt_ldapava.o \ -fmt_ldapsearchfilter.o fmt_ldapsearchrequest.o matchstring.o \ -matchprefix.o matchcasestring.o matchcaseprefix.o \ +fmt_ldapsearchfilter.o fmt_ldapsearchrequest.o \ scan_ldapmodifyrequest.o scan_ldapaddrequest.o bstrlen.o bstrfirst.o \ bstrstart.o free_ldapadl.o free_ldappal.o free_ldapsearchfilter.o \ scan_ldapsearchfilterstring.o free_ldapsearchresultentry.o \ -fmt_ldapsearchfilterstring.o ldap_match_sre.o \ +fmt_ldapsearchfilterstring.o \ fmt_ldapdeleterequest.o scan_ldapdeleterequest.o normalize_dn.o -ldif.a: ldif_parse.o ldap_match_mapped.o - CC?=gcc CFLAGS+=-g -pipe -W -Wall -Wextra -std=gnu99 -Wno-unused-parameter #CC=clang @@ -44,7 +41,7 @@ LIBS+=-g -lowfat -lssl -lcrypto %: %.c $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) ${LIBS} -ldadp: tmpbuffer.o ini.o client.o server.o helper.o proxy.o epoll.o openssl.o ldap.a asn1.a ldif.a +ldadp: tmpbuffer.o ini.o client.o server.o helper.o proxy.o epoll.o openssl.o ldap.a asn1.a .PHONY: clean tar clean: @@ -53,8 +50,6 @@ clean: tar: clean cd ..; tar cvvf ldadp.tar.bz2 ldadp --use=bzip2 --exclude capture --exclude .git -ldif_parse.o: ldif_parse.c strduptab.h strstorage.h ldif.h - bindrequest.o: bindrequest.c ldap.h tmpbuffer.o: tmpbuffer.c tmpbuffer.h @@ -121,5 +116,3 @@ scan_asn1generic.o: scan_asn1generic.c asn1.h asn1oid.o: asn1oid.c asn1.h -ldap_match_sre.o: ldap_match_sre.c ldap.h - diff --git a/ldap_match_mapped.c b/ldap_match_mapped.c deleted file mode 100644 index d457a1a..0000000 --- a/ldap_match_mapped.c +++ /dev/null @@ -1,200 +0,0 @@ -#include "ldif.h" -#include "byte.h" -#include -#include "uint32.h" -#include "case.h" -#include -#include -#include -#include - -extern char* map; -extern long filelen; -extern uint32 magic,attribute_count,record_count,indices_offset,size_of_string_table; -extern uint32 dn_ofs,objectClass_ofs; - -int substringmatch(struct Substring* x,const char* attr,int ignorecase) { - int (*diff)(const void* a, unsigned long len, const void* b); - if (ignorecase) - diff=case_diffb; - else - diff=byte_diff; - while (x) { - unsigned long i; - if (x->s.l>str_len(attr)) return 0; - switch (x->substrtype) { - case prefix: - if (diff(x->s.s,x->s.l,attr)) return 0; -found: - break; - case any: - { - unsigned long len=str_len(attr); - if (lens.l) return 0; - for (i=0; i<=len-x->s.l; ++i) - if (!diff(x->s.s,x->s.l,attr+i)) - goto found; - } - return 0; - case suffix: - if (diff(x->s.s,x->s.l,attr+str_len(attr)-x->s.l)) return 0; - } - x=x->next; - } - return 1; -} - -int ldap_match_present(uint32 ofs,uint32 attrofs) { - uint32 j,k; - if (attrofs==dn_ofs || attrofs==objectClass_ofs) return 1; - uint32_unpack(map+ofs,&j); - for (k=2; kattrflag&1) - r=matchcasestring(&f->ava.value,t); - else - r=matchstring(&f->ava.value,t); - if (f->type==EQUAL) return (r==0); - if (f->type==LESSEQUAL) return (r>0); - return (r<0); -} - -/* return non-zero if the record matches the search filter */ -int ldap_matchfilter_mapped(uint32 ofs,struct Filter* f) { - struct Filter* y=f->x; - if (!f) return 1; - switch (f->type) { - case AND: - while (y) { - if (!ldap_matchfilter_mapped(ofs,y)) return 0; - y=y->next; - } - return 1; - case OR: - while (y) { - if (ldap_matchfilter_mapped(ofs,y)) return 1; - y=y->next; - } - return 0; - case NOT: - return !ldap_matchfilter_mapped(ofs,y); - case PRESENT: - return ldap_match_present(ofs,f->attrofs); - case EQUAL: - case LESSEQUAL: - case GREATEQUAL: - { - uint32 i,j,k; - uint32_unpack(map+ofs,&j); -// if (!matchstring(&f->ava.desc,"dn")) { - if (f->attrofs==dn_ofs) { - uint32_unpack(map+ofs+8,&k); - return matchint(f,map+k); -// } else if (!matchstring(&f->ava.desc,"objectName")) { - } else if (f->attrofs==objectClass_ofs) { - uint32_unpack(map+ofs+12,&k); - if (matchint(f,map+k)) return 1; - } - for (i=2; iava.desc,map+k)) { - if (f->attrofs==k) { - uint32_unpack(map+ofs+i*8+4,&k); - if (matchint(f,map+k)) return 1; - } - } - return 0; - } - break; - case SUBSTRING: - { - uint32 i,j,k; - uint32_unpack(map+ofs,&j); -// if (matchstring(&f->ava.desc,"dn")) { - if (f->attrofs==dn_ofs) { - uint32_unpack(map+ofs+8,&k); - if (substringmatch(f->substrings,map+k,f->attrflag&1)) return 1; - return 0; -// } else if (matchstring(&f->ava.desc,"objectName")) { - } else if (f->attrofs==objectClass_ofs) { - uint32_unpack(map+ofs+12,&k); - if (substringmatch(f->substrings,map+k,f->attrflag&1)) return 1; - } - for (i=2; iava.desc,map+k)) { - if (f->attrofs==k) { - uint32_unpack(map+ofs+i*8+4,&k); - if (substringmatch(f->substrings,map+k,f->attrflag&1)) - return 1; - } - } - return 0; - } - break; - default: - write(2,"unsupported query type\n",23); - return 0; - } - return 1; -} - -/* return 0 if they didn't match, otherwise return length in b */ -static int match(const char* a,int len,const char* b) { - const char* A=a+len; - const char* B=b+str_len(b); - while (len>0 && A>a && B>b) { - --A; --B; --len; - while (*A==' ' && A>a) { --A; --len; } - while (*B==' ' && B>b) --B; - if (tolower(*A) != tolower(*B)) - return 0; - } - return str_len(B); -} - -/* return non-zero if the record matches the search request */ -int ldap_match_mapped(uint32 ofs,struct SearchRequest* sr) { - unsigned int l,i; - uint32 k; - uint32_unpack(map+ofs+8,&k); - l=str_len(map+k); - /* first see if baseObject is a suffix of dn */ - if (sr->baseObject.l>l) { -// puts("fail: baseObject longer than dn"); - return 0; - } - /* we want "o=foo, o=bar" and "o=FOO,o=baR" to be equal */ - if (sr->baseObject.l && !match(sr->baseObject.s,sr->baseObject.l,map+k)) { -// puts("fail: not suffix"); - return 0; - } - /* it is. If scope==wholeSubtree, the scope check is also done */ - switch (sr->scope) { - case wholeSubtree: break; - case baseObject: if (l==sr->baseObject.l) break; return 0; - default: - i=str_chr(map+k,','); - if (i+2>=l-sr->baseObject.l) break; - return 0; - } - return ldap_matchfilter_mapped(ofs,sr->filter); -} diff --git a/ldap_match_sre.c b/ldap_match_sre.c deleted file mode 100644 index b0e69c1..0000000 --- a/ldap_match_sre.c +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include "ldap.h" -#include "byte.h" -#include "case.h" -#include - -static int matchcasestr(struct string* a,struct string* b) { - unsigned long l=a->l; - unsigned long r; - if (b->ll; - if ((r=case_diffb(a->s,l,b->s))) return r; - if (a->l>l) return 1; - if (b->l>l) return -1; - return 0; -} - -static int matchstr(struct string* a,struct string* b) { - unsigned long l=a->l; - unsigned long r; - if (b->ll; - if ((r=byte_diff(a->s,l,b->s))) return r; - if (a->l>l) return 1; - if (b->l>l) return -1; - return 0; -} - -static int matchstr_sre(struct Filter* f,struct string* s) { - int r; - if (f->attrflag&1) - r=matchcasestr(&f->ava.value,s); - else - r=matchstr(&f->ava.value,s); - if (f->type==EQUAL) return (r==0); - if (f->type==LESSEQUAL) return (r>0); - return (r<0); -} - -static int ldap_match_present_sre(struct SearchResultEntry* sre,struct string* s) { - struct PartialAttributeList* p; - for (p=sre->attributes; p; p=p->next) { - int r; - if ((r=matchstr(&p->type,s))) return r; - } - return 0; -} - -static int substrmatch(struct Substring* x,struct string* s,int ignorecase) { - int (*diff)(const void* a, unsigned long len, const void* b); - if (ignorecase) - diff=case_diffb; - else - diff=byte_diff; - while (x) { - unsigned long i; - if (x->s.l>s->l) return 0; - switch (x->substrtype) { - case prefix: - if (diff(x->s.s,x->s.l,s->s)) return 0; -found: - break; - case any: - if (s->ls.l) return 0; - for (i=0; i<=s->l-x->s.l; ++i) - if (!diff(x->s.s,x->s.l,s->s+i)) - goto found; - return 0; - case suffix: - if (diff(x->s.s,x->s.l,s->s+s->l-x->s.l)) return 0; - } - x=x->next; - } - return 1; -} - -extern uint32_t dn_ofs; - -int ldap_matchfilter_sre(struct SearchResultEntry* sre,struct Filter* f) { - struct PartialAttributeList* p; - struct Filter* y=f->x; - if (!f) return 1; - switch (f->type) { - case AND: - while (y) { - if (!ldap_matchfilter_sre(sre,y)) return 0; - y=y->next; - } - return 1; - case OR: - while (y) { - if (ldap_matchfilter_sre(sre,y)) return 1; - y=y->next; - } - return 0; - case NOT: - return !ldap_matchfilter_sre(sre,y); - case PRESENT: - return ldap_match_present_sre(sre,&f->ava.desc); - case EQUAL: - case LESSEQUAL: - case GREATEQUAL: - if (f->attrofs==dn_ofs) - return matchstr_sre(f,&sre->objectName); - for (p=sre->attributes; p; p=p->next) { - int r; - struct AttributeDescriptionList* a; - if (matchstr(&f->ava.desc,&p->type)) { - for (a=p->values; a; a=a->next) - if ((r=matchstr_sre(f,&a->a))) return r; - return 0; - } - } - return 0; - case SUBSTRING: - if (f->attrofs==dn_ofs) - return substrmatch(f->substrings,&sre->objectName,f->attrflag&1); - for (p=sre->attributes; p; p=p->next) { - if (matchstr(&f->ava.desc,&p->type)) { - struct AttributeDescriptionList* a; - int r; - for (a=p->values; a; a=a->next) - if ((r=substrmatch(f->substrings,&a->a,f->attrflag&1))) return r; - return 0; - } - } - return 0; - default: - write(2,"unsupported query type\n",23); - return 0; - } - return 1; -} - -/* return 0 if they didn't match, otherwise return length in b */ -static int match(const char* a,int len,const char* b,int blen) { - const char* A=a+len; - const char* B=b+blen; - while (len>0 && A>a && B>b) { - --A; --B; --len; - while (*A==' ' && A>a) { --A; --len; } - while (*B==' ' && B>b) --B; - if (tolower(*A) != tolower(*B)) - return 0; - } - return b+blen-B; -} - -int ldap_match_sre(struct SearchResultEntry* sre,struct SearchRequest* sr) { - unsigned long i; - if (sr->baseObject.l>sre->objectName.l) - /* baseObject is longer than dn */ - return 0; - if (sr->baseObject.l && !match(sr->baseObject.s,sr->baseObject.l,sre->objectName.s,sre->objectName.l)) - /* baseObject is not a suffix of dn */ - return 0; - switch (sr->scope) { - case wholeSubtree: break; - case baseObject: if (sre->objectName.l==sr->baseObject.l) break; return 0; - default: - for (i=0; iobjectName.l; ++i) - if (sre->objectName.s[i]==',') - break; - if (i+2>=sre->objectName.l-sr->baseObject.l) break; - return 0; - } - return ldap_matchfilter_sre(sre,sr->filter); -} diff --git a/ldif.h b/ldif.h deleted file mode 100644 index fc6496b..0000000 --- a/ldif.h +++ /dev/null @@ -1,32 +0,0 @@ -#define _FILE_OFFSET_BITS 64 -#include -#include -#include "asn1.h" -#include "ldap.h" - -/* how many attributes do we allow per record? */ -#define ATTRIBS 100 - -struct attribute { - uint32_t name, value; -}; - -struct ldaprec { - uint32_t dn; - unsigned int n; /* number of attributes */ - struct attribute a[ATTRIBS]; - struct ldaprec* next; -}; - -extern uint32_t dn, mail, sn, cn, objectClass; -extern struct ldaprec *first; -extern unsigned long ldifrecords; - -int ldif_parse(const char* filename,off_t fromofs,struct stat* ss); - -/* return non-zero if the record matches the search request */ -int ldap_match(struct ldaprec* r,struct SearchRequest* sr); -int ldap_match_mapped(uint32_t ofs,struct SearchRequest* sr); -int ldap_match_present(uint32_t ofs,uint32_t attrofs); -uint32_t ldap_find_attr_value(uint32_t ofs,uint32_t attrofs); -int ldap_matchfilter_mapped(uint32_t ofs,struct Filter* f); diff --git a/ldif_parse.c b/ldif_parse.c deleted file mode 100644 index a7aa8ec..0000000 --- a/ldif_parse.c +++ /dev/null @@ -1,371 +0,0 @@ -#define _FILE_OFFSET_BITS 64 -#include -#include -#include -#include -#include -#include -#include -#include "mduptab.h" -#include "mstorage.h" -#include -#include "ldif.h" -#include "byte.h" -#include "textcode.h" -#include "stralloc.h" -#include "uint32.h" - -mduptab_t attributes,classes; -mstorage_t stringtable; -uint32_t dn, objectClass; -unsigned long lines; - -/* this is called after each record. - * If it returns -1, ldif_parse will exit immediately. - * If it returns 0, ldif_parse will continue parsing and overwrite the - * current ldaprec. - * If it returns 1, ldif_parse will allocate a new ldaprec and link it - * using the next pointer in the current ldaprec. - * If the callback is NULL, a callback that always returns 1 is assumed. - * */ -int (*ldif_parse_callback)(struct ldaprec* l); -uint32_t (*ldif_addstring_callback)(const char* s,unsigned long len); - -unsigned long ldifrecords; - -static void addattribute(struct ldaprec** l,uint32_t name,uint32_t val) { - if (name==dn) (*l)->dn=val; else - if ((*l)->na[(*l)->n].name=name; - (*l)->a[(*l)->n].value=val; - ++(*l)->n; - } else { - buffer_puts(buffer_2,"\r\n\nLDIF parse error: too many attributes!: "); - buffer_puts(buffer_2,attributes.Strings->root+name); - buffer_puts(buffer_2," in line "); - buffer_putulong(buffer_2,lines); - buffer_putnlflush(buffer_2); - exit(1); - } -} - -static size_t unbase64(char* buf) { - size_t destlen; - char temp[8192]; - size_t l=scan_base64(buf,temp,&destlen); - if (buf[l] && buf[l]!='\n') return 0; - byte_copy(buf,destlen,temp); - return destlen; -} - -uint32_t (*ldif_addstring_callback)(const char* s,unsigned long len); - -static uint32_t addstring(const char* s,unsigned long len) { - return mstorage_add(&stringtable,s,len); -} - -static long commit_string_bin(const char* s,unsigned long n) { - unsigned int i; - static char zero; - uint32_t x; - char intbuf[4]; - if (n==0 || (n==1 && s[0]==0)) goto encodebinary; - for (i=0; idn=-1; - (*l)->next=0; (*l)->n=0; - ldifrecords=0; - do { - uint32_t tmp, val; - base64=binary=0; - buf[ofs]=0; - n=ofs+buffer_get_token(b,buf+ofs,8192-ofs,":\n",2); - if (n==ofs) { - if (buf[ofs]==0) eof=1; - break; - } - if (buf[0]=='#') { /* comment line */ - while (n>=8192-ofs || buf[n]==':') { - /* if we got a partial line or the comment contained a colon, do over */ - ofs=0; - n=buffer_get_token(b,buf,8192,"\n",1); - } - ++lines; - continue; - } - i=scan_whitenskip(buf,n); - if (buf[byte_chr(buf+i,n-i,'\n')]=='\n') { - buffer_putm(buffer_2,"\r\n\n",filename,":"); - buffer_putulong(buffer_2,lines+1); - buffer_putsflush(buffer_2,": error: no key:value found\n"); - exit(1); - } - buf[n]=0; - if ((i2=str_chr(buf,';'))<(unsigned int)n) { - buf[i2]=0; - if (str_equal("binary",buf+i2+1)) binary=1; - } - if ((tmp=mduptab_adds(&attributes,buf+i))==(uint32_t)-1) { -// write(2,"a",1); - goto nomem; - } if (!stralloc_copys(&payload,"")) { -// write(2,"b",1); - goto nomem; - } - { - char dummy; - int res; - /* read line, skipping initial whitespace */ - for (n=0; (res=buffer_getc(b,&dummy))==1; ) { - if (dummy=='\n') { ++lines; break; } - if (!n && dummy==':' && base64==0) { base64=1; continue; } - if (!n && (dummy==' ' || dummy=='\t')) continue; - if (!stralloc_append(&payload,&dummy)) { -// write(2,"c",1); - goto nomem; - } - ++n; - } - if (res==-1) return 1; - } - -lookagain: - { - char c; - switch (buffer_getc(b,&c)) { - case 0: eof=1; break; - case -1: buffer_putsflush(buffer_2,"read error!\n"); return 1; - } - if (c==' ') { /* continuation */ -// puts("continuation!"); - n=buffer_get_token(b,buf,8192,"\n",1); - if (n==-1) return 1; - if (!stralloc_catb(&payload,buf,n)) { -// write(2,"d",1); - goto nomem; - } - goto lookagain; - } else if (c=='\n') { - struct ldaprec* m; - - ++lines; - - if (payload.len) { - if (!stralloc_0(&payload)) { -// write(2,"e",1); - goto nomem; - } - if (base64) { - len=unbase64(payload.s); - if (len==0) { - buffer_putm(buffer_2,"\r\n\n",filename,":"); - buffer_putulong(buffer_2,lines+1); - buffer_putsflush(buffer_2,": error: base64 decoding failed\n"); - exit(1); - } - if (!binary) { payload.s[len]=0; ++len; } - } else { - size_t sl; - len=n; - sl=scan_ldapescape(payload.s,payload.s,&len); - if (sl!=payload.len-1) { - buffer_putm(buffer_2,"\r\n\n",filename,":"); - buffer_putulong(buffer_2,lines+1); - buffer_putsflush(buffer_2,": error: LDIF de-escaping failed\n"); - exit(1); - } - payload.s[len]=0; - ++len; - } - } else - len=0; - -#if 0 - buffer_puts(buffer_2,"feld \""); - buffer_puts(buffer_2,attributes.Strings->root+tmp); - buffer_puts(buffer_2,"\", wert \""); - buffer_put(buffer_2,payload.s,len); - buffer_putsflush(buffer_2,"\".\n"); -#endif - - if (tmp==objectClass) { - if ((val=mduptab_add(&classes,payload.s,len-1))==(uint32_t)-1) { -// write(2,"f",1); - goto nomem; - } - } else if (tmp==dn) { - if ((val=add_normalized(payload.s,len))==(uint32_t)-1) { -// write(2,"g",1); - goto nomem; - } - } else - if ((val=commit_string_bin(payload.s,len))==(uint32_t)-1) { -// write(2,"h",1); - goto nomem; - } - addattribute(l,tmp,val); - - m=0; - if (ldif_parse_callback) { - switch (ldif_parse_callback(*l)) { - case -1: - return -1; - case 0: - m=*l; - break; -#if 0 - case 1: - m=0; - break; -#endif - } - } - if (!m) if (!(m=malloc(sizeof(struct ldaprec)))) return 2; - - (*l)->next=m; - m->n=0; m->dn=-1; m->next=0; - ofs=0; -// dumprec(*l); - if (*l!=m) l=&((*l)->next); - ++ldifrecords; - continue; - } else { - ofs=1; - buf[0]=c; - } - } -// buf[n]=0; -#if 1 - - if (payload.len) { - if (!stralloc_0(&payload)) { -// write(2,"i",1); - goto nomem; - } - if (base64) { - len=unbase64(payload.s); - if (len==0) { - buffer_putm(buffer_2,"\r\n\n",filename,":"); - buffer_putulong(buffer_2,lines+1); - buffer_putsflush(buffer_2,": error: base64 decoding failed\n"); - exit(1); - } - if (!binary) { payload.s[len]=0; ++len; } - } else { - len=n; - scan_ldapescape(payload.s,payload.s,&len); - payload.s[len]=0; - ++len; - } - } else - len=0; - -#if 0 - buffer_puts(buffer_2,"feld \""); - buffer_puts(buffer_2,attributes.Strings->root+tmp); - buffer_puts(buffer_2,"\", wert \""); - buffer_put(buffer_2,payload.s,len); - buffer_putsflush(buffer_2,"\".\n"); -#endif - - if (tmp==objectClass) { - if ((val=mduptab_add(&classes,payload.s,len-1))==(uint32_t)-1) { -// write(2,"j",1); - goto nomem; - } - } else if (tmp==dn) { - if ((val=add_normalized(payload.s,payload.len))==(uint32_t)-1) { -// write(2,"k",1); - goto nomem; - } - } else - if ((val=commit_string_bin(payload.s,len))==(uint32_t)-1) { -// write(2,"l",1); - goto nomem; - } - addattribute(l,tmp,val); -#endif - } while (!eof); - if (!eof) { - buffer_putm(buffer_2,"\r\n\n",filename,":"); - buffer_putulong(buffer_2,lines+1); - buffer_putsflush(buffer_2,": error: parse error (maybe 2nd empty line?)\n"); - exit(1); - } - if ((*l)->dn==(uint32_t)-1) return 0; - if (ldif_parse_callback && ldif_parse_callback(*l)==-1) return -1; - if ((*l)->dn==(uint32_t)-1 && ((*l)->next)) { - struct ldaprec* m=(*l)->next; - free((*l)); - (*l)=m; - } - return 0; -} - -struct ldaprec *first=0; - -int ldif_parse(const char* filename,off_t fromofs,struct stat* ss) { - char buf[4096]; - int fd; - buffer in; - buffer* tmp; - mstorage_init(&stringtable); - if (ldif_addstring_callback==0) ldif_addstring_callback=addstring; - if (filename[0]=='-' && !filename[1]) { - tmp=buffer_0; - fd=-1; - } else { - fd=open_read(filename); - if (fd<0) return 0; // no journal file is permissible - if (fromofs) lseek(fd,fromofs,SEEK_SET); - buffer_init(&in,(void*)read,fd,buf,sizeof buf); - tmp=∈ - } - dn=mduptab_adds(&attributes,"dn"); - objectClass=mduptab_adds(&attributes,"objectClass"); - lines=0; - { - int res=parserec(tmp,&first,filename); - if (ss) { - fstat(fd,ss); - /* the file size may have changed between parserec hitting EOF and - * us calling lstat, we we write the current file pointer position - * to st_size */ - ss->st_size=lseek(fd,0,SEEK_CUR); - } - if (fd!=-1) close(fd); - return res; - } -} - diff --git a/matchcaseprefix.c b/matchcaseprefix.c deleted file mode 100644 index 7ba8335..0000000 --- a/matchcaseprefix.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include "case.h" -#include "ldif.h" -#include "str.h" - -/* behave like strcmp, but also return 0 if s is a prefix of c. */ -int matchcaseprefix(struct string* s,const char* c) { - unsigned int l,l1,i; - if (!c) return -1; - l1=l=str_len(c); - if (s->ll; - i=case_diffb(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 0; - return -(int)(s->s[l1]); -} - diff --git a/matchcasestring.c b/matchcasestring.c deleted file mode 100644 index 4f0aab2..0000000 --- a/matchcasestring.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "case.h" -#include "bstr.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=bstrlen(c); - if (s->ll; - 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 (l1s[l1]); -} - diff --git a/matchprefix.c b/matchprefix.c deleted file mode 100644 index 90d9bc2..0000000 --- a/matchprefix.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "byte.h" -#include "ldif.h" -#include "bstr.h" - -/* behave like strcmp, but also return 0 if s is a prefix of c. */ -int matchprefix(struct string* s,const char* c) { - unsigned int l,l1,i; - if (!c) return -1; - l1=l=bstrlen(c); - if (s->ll; - c=bstrfirst(c); - i=byte_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 0; - return -(int)(s->s[l1]); -} - diff --git a/matchstring.c b/matchstring.c deleted file mode 100644 index fdae726..0000000 --- a/matchstring.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "byte.h" -#include "bstr.h" -#include "ldif.h" - -/* behave like strcmp */ -int matchstring(struct string* s,const char* c) { - unsigned int l,l1,i; - if (!c) return -1; - l1=l=bstrlen(c); - if (s->ll; - c=bstrfirst(c); - i=byte_diff(s->s,l1,c); - if (i) return i; - /* same length? */ - if (l==s->l) return 0; - /* one is a prefix of the other */ - if (l1s[l1]); -} - -- cgit v1.2.3-55-g7522