now the generated "data" file matches the old one
strlen -> str_len
This commit is contained in:
@@ -8,8 +8,8 @@ int bstr_diff(const char* a,const char* b) {
|
||||
/* like str_diff, just for bstrs */
|
||||
if (*a && *b)
|
||||
return str_diff(a,b);
|
||||
if (*a) A=a+strlen(a); else { A=a+5+uint32_read(a+1); a+=5; }
|
||||
if (*b) B=b+strlen(b); else { B=b+5+uint32_read(b+1); b+=5; }
|
||||
if (*a) A=a+str_len(a); else { A=a+5+uint32_read(a+1); a+=5; }
|
||||
if (*b) B=b+str_len(b); else { B=b+5+uint32_read(b+1); b+=5; }
|
||||
for (;;) {
|
||||
if (a==A) {
|
||||
if (b==B)
|
||||
|
||||
@@ -7,7 +7,7 @@ int bstr_diff2(const char* a,const char* b,unsigned int blen) {
|
||||
const char* A,* B;
|
||||
int j;
|
||||
/* like str_diff, just for bstrs */
|
||||
if (*a) A=a+strlen(a); else { A=a+5+uint32_read(a+1); a+=5; }
|
||||
if (*a) A=a+str_len(a); else { A=a+5+uint32_read(a+1); a+=5; }
|
||||
B=b+blen;
|
||||
for (;;) {
|
||||
if (a==A) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <string.h>
|
||||
#include "bstr.h"
|
||||
#include "uint32.h"
|
||||
#include "str.h"
|
||||
|
||||
int bstrlen(const char* a) {
|
||||
if (*a) return strlen(a); else return uint32_read(a+1);
|
||||
if (*a) return str_len(a); else return uint32_read(a+1);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include <string.h>
|
||||
#include "asn1.h"
|
||||
#include "ldap.h"
|
||||
#include "str.h"
|
||||
|
||||
int fmt_ldapbindrequest(char* dest,long version,char* name,char* simple) {
|
||||
int l,sum;
|
||||
int nlen=strlen(name);
|
||||
int nlen=str_len(name);
|
||||
sum=l=fmt_asn1INTEGER(dest,version);
|
||||
if (dest) dest+=l;
|
||||
l=fmt_asn1OCTETSTRING(dest,name,nlen);
|
||||
sum+=l; if (dest) dest+=l;
|
||||
nlen=strlen(simple);
|
||||
nlen=str_len(simple);
|
||||
l=fmt_asn1string(dest,PRIVATE,PRIMITIVE,0,simple,nlen);
|
||||
if (dest) dest+=l+nlen;
|
||||
return sum+l+nlen;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#include "asn1.h"
|
||||
#include "ldap.h"
|
||||
#include "str.h"
|
||||
|
||||
int fmt_ldapresult(char* dest,long result,char* matcheddn,char* errormessage,char* referral) {
|
||||
int l,sum=0;
|
||||
int nlen;
|
||||
sum=l=fmt_asn1ENUMERATED(dest,result);
|
||||
if (dest) dest+=l;
|
||||
nlen=strlen(matcheddn);
|
||||
nlen=str_len(matcheddn);
|
||||
l=fmt_asn1OCTETSTRING(dest,matcheddn,nlen);
|
||||
sum+=l; if (dest) dest+=l;
|
||||
nlen=strlen(errormessage);
|
||||
nlen=str_len(errormessage);
|
||||
l=fmt_asn1OCTETSTRING(dest,errormessage,nlen);
|
||||
sum+=l; if (dest) dest+=l;
|
||||
if (referral && *referral) {
|
||||
nlen=strlen(referral);
|
||||
nlen=str_len(referral);
|
||||
l=fmt_asn1OCTETSTRING(dest,referral,nlen);
|
||||
sum+=l; if (dest) dest+=l;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ static int substringmatch(struct Substring* x,const char* attr,int ignorecase) {
|
||||
diff=byte_diff;
|
||||
while (x) {
|
||||
unsigned long i;
|
||||
if (x->s.l>strlen(attr)) return 0;
|
||||
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;
|
||||
@@ -30,7 +30,7 @@ found:
|
||||
break;
|
||||
case any:
|
||||
{
|
||||
unsigned long len=strlen(attr);
|
||||
unsigned long len=str_len(attr);
|
||||
if (len>x->s.l) return 0;
|
||||
for (i=0; i<x->s.l-len; ++i)
|
||||
if (!diff(x->s.s,x->s.l,attr+i))
|
||||
@@ -38,7 +38,7 @@ found:
|
||||
}
|
||||
return 0;
|
||||
case suffix:
|
||||
if (diff(x->s.s,x->s.l,attr+strlen(attr)-x->s.l)) return 0;
|
||||
if (diff(x->s.s,x->s.l,attr+str_len(attr)-x->s.l)) return 0;
|
||||
}
|
||||
x=x->next;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ int ldap_matchfilter_mapped(uint32 ofs,struct Filter* f) {
|
||||
/* 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+strlen(b);
|
||||
const char* B=b+str_len(b);
|
||||
while (len>0 && A>a && B>b) {
|
||||
--A; --B; --len;
|
||||
while (*A==' ' && A>a) { --A; --len; }
|
||||
@@ -166,7 +166,7 @@ static int match(const char* a,int len,const char* b) {
|
||||
if (tolower(*A) != tolower(*B))
|
||||
return 0;
|
||||
}
|
||||
return strlen(B);
|
||||
return str_len(B);
|
||||
}
|
||||
|
||||
/* return non-zero if the record matches the search request */
|
||||
@@ -174,7 +174,7 @@ int ldap_match_mapped(uint32 ofs,struct SearchRequest* sr) {
|
||||
unsigned int l,i;
|
||||
uint32 k;
|
||||
uint32_unpack(map+ofs+8,&k);
|
||||
l=strlen(map+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");
|
||||
|
||||
@@ -68,13 +68,13 @@ usage:
|
||||
}
|
||||
i=4; /* This should be the first index to an attribute argument in argv[] */
|
||||
adl.a.s=argv[i];
|
||||
adl.a.l=strlen(argv[i]);
|
||||
adl.a.l=str_len(argv[i]);
|
||||
next=&adl;
|
||||
++i;
|
||||
while (i<argc) {
|
||||
struct AttributeDescriptionList *n;
|
||||
n=malloc(sizeof(struct AttributeDescriptionList));
|
||||
n->a.s=argv[i]; n->a.l=strlen(argv[i]);
|
||||
n->a.s=argv[i]; n->a.l=str_len(argv[i]);
|
||||
n->next=0;
|
||||
next->next=n;
|
||||
next=n;
|
||||
@@ -85,7 +85,7 @@ usage:
|
||||
|
||||
i++;
|
||||
}
|
||||
sr.baseObject.s=argv[2]; sr.baseObject.l=strlen(sr.baseObject.s);
|
||||
sr.baseObject.s=argv[2]; sr.baseObject.l=str_len(sr.baseObject.s);
|
||||
sr.scope=wholeSubtree; sr.derefAliases=neverDerefAliases;
|
||||
sr.sizeLimit=sr.timeLimit=sr.typesOnly=0;
|
||||
sr.filter=f;
|
||||
|
||||
@@ -74,7 +74,7 @@ usage:
|
||||
f.substrings=&ssr;
|
||||
adl.a.s="mail"; adl.a.l=4;
|
||||
adl.next=0;
|
||||
sr.baseObject.s=argv[2]; sr.baseObject.l=strlen(sr.baseObject.s);
|
||||
sr.baseObject.s=argv[2]; sr.baseObject.l=str_len(sr.baseObject.s);
|
||||
sr.scope=wholeSubtree; sr.derefAliases=neverDerefAliases;
|
||||
sr.sizeLimit=sr.timeLimit=sr.typesOnly=0;
|
||||
sr.filter=&f;
|
||||
|
||||
@@ -57,7 +57,7 @@ static int normalize_dn(char* dest,const char* src,int len) {
|
||||
}
|
||||
|
||||
static int unbase64(char* buf) {
|
||||
unsigned int destlen;
|
||||
unsigned long destlen;
|
||||
char temp[8192];
|
||||
long l=scan_base64(buf,temp,&destlen);
|
||||
if (buf[l] && buf[l]!='\n') return 0;
|
||||
@@ -200,8 +200,9 @@ struct ldaprec *first=0;
|
||||
|
||||
int ldif_parse(const char* filename) {
|
||||
char buf[4096];
|
||||
int fd=open_read(filename);
|
||||
int fd;
|
||||
buffer in;
|
||||
if (str_equal(filename,"-")) fd=0; else fd=open_read(filename);
|
||||
if (fd<0) return 1;
|
||||
buffer_init(&in,read,fd,buf,sizeof buf);
|
||||
dn=mduptab_adds(&attributes,"dn");
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include <string.h>
|
||||
#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=strlen(c);
|
||||
l1=l=str_len(c);
|
||||
if (s->l<l1) l1=s->l;
|
||||
i=case_diffb(s->s,l1,c);
|
||||
if (i) return i;
|
||||
|
||||
@@ -11,7 +11,7 @@ int main(int argc,char* argv[]) {
|
||||
for (i=1; i<argc; ++i) {
|
||||
MD5_CTX c;
|
||||
MD5Init(&c);
|
||||
MD5Update(&c,argv[i],strlen(argv[i]));
|
||||
MD5Update(&c,argv[i],str_len(argv[i]));
|
||||
MD5Final(digest,&c);
|
||||
digest[16]=0;
|
||||
md5[fmt_base64(md5,digest,16)]=0;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "mstorage.h"
|
||||
#include "mduptab.h"
|
||||
#include "str.h"
|
||||
|
||||
long mduptab_adds(mduptab_t* t,const char* s) {
|
||||
return mduptab_add(t,s,strlen(s));
|
||||
return mduptab_add(t,s,str_len(s));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "str.h"
|
||||
#include "strduptab.h"
|
||||
#include "strstorage.h"
|
||||
#include <string.h>
|
||||
#include "str.h"
|
||||
|
||||
#define PAGESIZE 4096
|
||||
|
||||
@@ -21,7 +21,7 @@ const char* strduptab_add(struct stringduptable* t,const char* s) {
|
||||
t->s=x;
|
||||
}
|
||||
{
|
||||
const char* x=strstorage_add(s,strlen(s)+1);
|
||||
const char* x=strstorage_add(s,str_len(s)+1);
|
||||
if (!x) return 0;
|
||||
s=x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user