diff options
author | Simon Rettberg | 2014-03-15 01:49:50 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-03-15 01:49:50 +0100 |
commit | bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad (patch) | |
tree | c7d1995a09f6ed0c4e6873252e957d72f5d07d07 /scan_ldapsearchresultentry.c | |
download | ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.gz ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.tar.xz ldadp-bedd2e7ccb1595c23e159eaa952ae1b0b5a3d2ad.zip |
Lean and mean initial commit
Not much functionality yet
Diffstat (limited to 'scan_ldapsearchresultentry.c')
-rw-r--r-- | scan_ldapsearchresultentry.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/scan_ldapsearchresultentry.c b/scan_ldapsearchresultentry.c new file mode 100644 index 0000000..50e8654 --- /dev/null +++ b/scan_ldapsearchresultentry.c @@ -0,0 +1,42 @@ +#include <stdlib.h> +#include "ldap.h" + +size_t scan_ldapsearchresultentry(const char* src,const char* max,struct SearchResultEntry* sre) { + size_t res,tmp,oslen; /* outer sequence length */ + struct PartialAttributeList** a=&sre->attributes; + *a=0; + if (!(res=scan_ldapstring(src,max,&sre->objectName))) goto error; + if (!(tmp=scan_asn1SEQUENCE(src+res,max,&oslen))) goto error; + res+=tmp; + if (src+res+oslen>max) goto error; + max=src+res+oslen; /* we now may have a stronger limit */ + while (src+res<max) { + struct string s; + struct AttributeDescriptionList* x; + size_t islen; + const char* nmax; + if (!(tmp=scan_asn1SEQUENCE(src+res,max,&islen))) goto error; + res+=tmp; nmax=src+res+islen; if (nmax>max) goto error; + if (!(tmp=scan_ldapstring(src+res,nmax,&s))) goto error; + if (!(*a=malloc(sizeof(struct PartialAttributeList)))) goto error; + (*a)->next=0; (*a)->values=0; (*a)->type=s; + res+=tmp; + if (!(tmp=scan_asn1SET(src+res,max,&islen))) goto error; + res+=tmp; if (src+res+islen!=nmax) goto error; + while (src+res<nmax) { + if (!(tmp=scan_ldapstring(src+res,max,&s))) goto error; + if (!(x=malloc(sizeof(struct AttributeDescriptionList)))) goto error; + x->a=s; + x->next=(*a)->values; + (*a)->values=x; + res+=tmp; + } + a=&(*a)->next; + } + *a=0; + return res; +error: + freepal(sre->attributes); + return 0; +} + |