Files
mars-tinyldap/fmt_ldapadl.c
leitner 8f9cd366f0 split fmt_ldapadl into fmt_ldapadl and fmt_ldapavl (the former is a
SEQUENCE used in search requests, the latter is a SET used in search
results)
2002-03-14 21:05:36 +00:00

35 lines
684 B
C

#include "asn1.h"
#include "ldap.h"
static int doit(char* dest,struct AttributeDescriptionList* adl,int seq) {
struct AttributeDescriptionList* x=adl;
long sum=0;
int tmp;
while (x) {
sum+=fmt_asn1OCTETSTRING(0,0,x->a.l);
x=x->next;
}
if (seq)
tmp=fmt_asn1SEQUENCE(dest,sum);
else
tmp=fmt_asn1SET(dest,sum);
sum+=tmp;
if (dest) {
dest+=tmp;
x=adl;
while (x) {
dest+=fmt_ldapstring(dest,&x->a);
x=x->next;
}
}
return sum;
}
int fmt_ldapadl(char* dest,struct AttributeDescriptionList* adl) {
return doit(dest,adl,1);
}
int fmt_ldapavl(char* dest,struct AttributeDescriptionList* adl) {
return doit(dest,adl,0);
}