summaryrefslogtreecommitdiffstats
path: root/fmt_ldapbindrequest.c
blob: b95c5f45f6a74db298991a5ac4b26a8c2eec2925 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <string.h>
#include "ldap.h"
#include <str.h>
#include "rangecheck.h"

size_t fmt_ldapbindrequest(char* dest,long version,const char* name,const char* simple) {
  size_t l,sum;
  size_t nlen=str_len(name);
  sum=l=fmt_asn1INTEGER(dest,version);
  if (dest) dest+=l;
  l=fmt_asn1OCTETSTRING(dest,name,nlen);
  if (add_of(sum,sum,l)) return (size_t)-1; if (dest) dest+=l;
//  sum+=l; if (dest) dest+=l;
  nlen=str_len(simple);
  l=fmt_asn1string(dest,PRIVATE,PRIMITIVE,0,simple,nlen);
  if (add_of(sum,sum,l)) return (size_t)-1; if (dest) dest+=l;
  return sum;
}

size_t fmt_ldapbindrequeststring(char* dest,long version,const struct string* name,const struct string* simple) {
  size_t l,sum;
  sum=l=fmt_asn1INTEGER(dest,version);
  if (dest) dest+=l;
  l=fmt_asn1OCTETSTRING(dest,name->s,name->l);
  if (add_of(sum,sum,l)) return (size_t)-1; if (dest) dest+=l;
//  sum+=l; if (dest) dest+=l;
  l=fmt_asn1string(dest,PRIVATE,PRIMITIVE,0,simple->s,simple->l);
  if (add_of(sum,sum,l)) return (size_t)-1; if (dest) dest+=l;
  return sum;
}