summaryrefslogblamecommitdiffstats
path: root/fmt_ldapbindrequest.c
blob: 0d0c361572eb433217da6b1f165f207618e5549c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                   
                       






                                                                                         

                                           

                              
                                                                  
                                           

             





                                                                                                                 

                                           
                              
                                                                          
                                           

             
#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,CONTEXT_SPECIFIC,PRIMITIVE,0,simple,nlen);
  if (add_of(sum,sum,l)) return (size_t)-1;
  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,CONTEXT_SPECIFIC,PRIMITIVE,0,simple->s,simple->l);
  if (add_of(sum,sum,l)) return (size_t)-1;
  return sum;
}