From bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sat, 15 Mar 2014 01:49:50 +0100 Subject: Lean and mean initial commit Not much functionality yet --- fmt_ldapadl.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 fmt_ldapadl.c (limited to 'fmt_ldapadl.c') diff --git a/fmt_ldapadl.c b/fmt_ldapadl.c new file mode 100644 index 0000000..c8ba076 --- /dev/null +++ b/fmt_ldapadl.c @@ -0,0 +1,32 @@ +#include "ldap.h" + +static size_t doit(char* dest,const struct AttributeDescriptionList* adl,int seq) { + const struct AttributeDescriptionList* x=adl; + size_t sum=0,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; +} + +size_t fmt_ldapadl(char* dest,const struct AttributeDescriptionList* adl) { + return doit(dest,adl,1); +} + +size_t fmt_ldapavl(char* dest,const struct AttributeDescriptionList* adl) { + return doit(dest,adl,0); +} -- cgit v1.2.3-55-g7522