/*
 * This file was generated automatically by ExtUtils::ParseXS version 2.18 from the
 * contents of API.xs. Do not edit this file, edit API.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST! 
 *
 */

/******************************************************************************
 * $Id: API.xs,v 1.18 2000/10/05 19:47:27 leif%netscape.com Exp $
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is PerLDAP. The Initial Developer of the Original
 * Code is Netscape Communications Corp. and Clayton Donley. Portions
 * created by Netscape are Copyright (C) Netscape Communications
 * Corp., portions created by Clayton Donley are Copyright (C) Clayton
 * Donley. All Rights Reserved.
 *
 * Contributor(s):
 *
 * DESCRIPTION
 *    This is the XSUB interface for the API.
 *
 *****************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

/* Perl Include Files */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif

/* LDAP C SDK Include Files */
#include <mozlber.h>
#include <mozldap.h>

/* SSL is only available in Binary */
#ifdef USE_SSL
# include <ldap_ssl.h>
#endif

/* AUTOLOAD methods for LDAP constants */
#include "constant.h"

/* Prototypes */
static int perldap_init();

static void * perldap_malloc(size_t size);

static void * perldap_calloc(size_t number, size_t size);

static void * perldap_realloc(void *ptr, size_t size);

static void perldap_free(void *ptr);

static char ** avref2charptrptr(SV *avref);

static struct berval ** avref2berptrptr(SV *avref);

static SV* charptrptr2avref(char **cppval);

static SV* berptrptr2avref(struct berval **bval);

static LDAPMod *parse1mod(SV *ldap_value_ref,char *ldap_current_attribute,
                int ldap_add_func,int cont);

static int calc_mod_size(HV *ldap_change);

static LDAPMod **hash2mod(SV *ldap_change_ref,int ldap_add_func,const char *func);

static int StrCaseCmp(const char *s, const char *t);

static char * StrDup(const char *source);

static int LDAP_CALL internal_rebind_proc(LDAP *ld,char **dnp,char **pwp,
            int *authmethodp,int freeit,void *arg);

static int LDAP_CALL ldap_default_rebind_proc(LDAP *ld, char **dn, char **pswd,
            int *auth, int freeit, void *arg);


/* Global Definitions and Variables */
SV *ldap_perl_rebindproc = NULL;
static char *ldap_default_rebind_dn = NULL;
static char *ldap_default_rebind_pwd = NULL;
static int ldap_default_rebind_auth = LDAP_AUTH_SIMPLE;

/* Return a Perl List from a char ** in PPCODE */
#define RET_CPP(cppvar) \
	   int cppindex; \
	   if (cppvar) { \
	   for (cppindex = 0; cppvar[cppindex] != NULL; cppindex++) \
	   { \
	      EXTEND(sp,1); \
	      PUSHs(sv_2mortal(newSVpv(cppvar[cppindex],strlen(cppvar[cppindex])))); \
	   } \
	   ldap_value_free(cppvar); }

/* Return a Perl List from a berval ** in PPCODE */
#define RET_BVPP(bvppvar) \
	   int bvppindex; \
	   if (bvppvar) { \
	   for (bvppindex = 0; bvppvar[bvppindex] != NULL; bvppindex++) \
	   { \
	      EXTEND(sp,1); \
	      PUSHs(sv_2mortal(newSVpv(bvppvar[bvppindex]->bv_val,bvppvar[bvppindex]->bv_len))); \
	   } \
	   ldap_value_free_len(bvppvar); }


/*
 * Function Definition
 */

static
int
perldap_init()
{
   struct ldap_memalloc_fns memalloc_fns;

   memalloc_fns.ldapmem_malloc = perldap_malloc;
   memalloc_fns.ldapmem_calloc = perldap_calloc;
   memalloc_fns.ldapmem_realloc = perldap_realloc;
   memalloc_fns.ldapmem_free = perldap_free;

   return (ldap_set_option(NULL,
                           LDAP_OPT_MEMALLOC_FN_PTRS,
                           &memalloc_fns));
}


static
void *
perldap_malloc(size_t size)
{
   void *new_ptr;

   New(1, new_ptr, size, char);

   return (new_ptr);
}

static
void *
perldap_calloc(size_t number, size_t size)
{
   void *new_ptr;

   Newz(1, new_ptr, (number*size), char);

   return (new_ptr);
}

static
void *
perldap_realloc(void *ptr, size_t size)
{
   Renew(ptr, size, char);

   return (ptr);
}

static
void
perldap_free(void *ptr)
{
   Safefree(ptr);
}


/* Return a char ** when passed a reference to an AV */
static
char **
avref2charptrptr(SV *avref)
{
   I32 avref_arraylen;
   int ix_av;
   SV **current_val;
   char **tmp_cpp;

   if ((! SvROK(avref)) ||
       (SvTYPE(SvRV(avref)) != SVt_PVAV) ||
       ((avref_arraylen = av_len((AV *)SvRV(avref))) < 0))
   {
      return NULL;
   }

   Newz(1,tmp_cpp,avref_arraylen+2,char *);
   for (ix_av = 0;ix_av <= avref_arraylen;ix_av++)
   {
      current_val = av_fetch((AV *)SvRV(avref),ix_av,0);
      tmp_cpp[ix_av] = StrDup(SvPV(*current_val,na));
   }
   tmp_cpp[ix_av] = NULL;

   return (tmp_cpp);
}

/* Return a struct berval ** when passed a reference to an AV */
static
struct berval **
avref2berptrptr(SV *avref)
{
   I32 avref_arraylen;
   int ix_av,val_len;
   SV **current_val;
   char *tmp_char,*tmp2;
   struct berval **tmp_ber;

   if ((! SvROK(avref)) ||
       (SvTYPE(SvRV(avref)) != SVt_PVAV) || 
       ((avref_arraylen = av_len((AV *)SvRV(avref))) < 0))
   {
      return NULL;
   }

   Newz(1,tmp_ber,avref_arraylen+2,struct berval *);
   for (ix_av = 0;ix_av <= avref_arraylen;ix_av++)
   {
      New(1,tmp_ber[ix_av],1,struct berval);
      current_val = av_fetch((AV *)SvRV(avref),ix_av,0);

      tmp_char = SvPV(*current_val,na);
      val_len = SvCUR(*current_val);

      Newz(1,tmp2,val_len+1,char);
      Copy(tmp_char,tmp2,val_len,char);

      tmp_ber[ix_av]->bv_val = tmp2;
      tmp_ber[ix_av]->bv_len = val_len;
   }
   tmp_ber[ix_av] = NULL;

   return(tmp_ber);
}

/* Return an AV reference when given a char ** */

static
SV*
charptrptr2avref(char **cppval)
{
   AV* tmp_av = newAV();
   SV* tmp_ref = newRV((SV*)tmp_av);
   int ix;

   if (cppval != NULL)
   {
      for (ix = 0; cppval[ix] != NULL; ix++)
      {
         SV* SVval = newSVpv(cppval[ix],0);
         av_push(tmp_av,SVval);
      }
      ldap_value_free(cppval);
   }
   return(tmp_ref);
}

/* Return an AV Reference when given a struct berval ** */

static
SV*
berptrptr2avref(struct berval **bval)
{
   AV* tmp_av = newAV();
   SV* tmp_ref = newRV((SV*)tmp_av);
   int ix;

   if (bval != NULL)
   {
      for(ix = 0; bval[ix] != NULL; ix++)
      {
         SV *SVval = newSVpv(bval[ix]->bv_val,bval[ix]->bv_len);
         av_push(tmp_av,SVval);
      }
      ldap_value_free_len(bval);
   }
   return(tmp_ref);
}


/* parse1mod - Take a single reference, figure out if it is a HASH, */
/*   ARRAY, or SCALAR, then extract the values and attributes and   */
/*   return a single LDAPMod pointer to this data.                  */

static
LDAPMod *
parse1mod(SV *ldap_value_ref,char *ldap_current_attribute,
          int ldap_add_func,int cont)
{
   LDAPMod *ldap_current_mod;
   static HV *ldap_current_values_hv;
   HE *ldap_change_element;
   char *ldap_current_modop;
   SV *ldap_current_value_sv;
   I32 keylen;
   int ldap_isa_ber = 0;

   if (ldap_current_attribute == NULL)
      return(NULL);
   Newz(1,ldap_current_mod,1,LDAPMod);
   ldap_current_mod->mod_type = StrDup(ldap_current_attribute);
   if (SvROK(ldap_value_ref))
   {
     if (SvTYPE(SvRV(ldap_value_ref)) == SVt_PVHV)
     {
      if (!cont)
      {
         ldap_current_values_hv = (HV *) SvRV(ldap_value_ref);
         hv_iterinit(ldap_current_values_hv);
      }
      if ((ldap_change_element = hv_iternext(ldap_current_values_hv)) == NULL)
         return(NULL);
      ldap_current_modop = hv_iterkey(ldap_change_element,&keylen);
      ldap_current_value_sv = hv_iterval(ldap_current_values_hv,
        ldap_change_element);
      if (ldap_add_func == 1)
      {
         ldap_current_mod->mod_op = 0;
      } else {
         if (strchr(ldap_current_modop,'a') != NULL)
         {
            ldap_current_mod->mod_op = LDAP_MOD_ADD;
         } else if (strchr(ldap_current_modop,'r') != NULL)
         {
            ldap_current_mod->mod_op = LDAP_MOD_REPLACE;
         } else if (strchr(ldap_current_modop,'d') != NULL) {
            ldap_current_mod->mod_op = LDAP_MOD_DELETE;
         } else {
            return(NULL);
         }
      }
      if (strchr(ldap_current_modop,'b') != NULL)
      {
         ldap_isa_ber = 1;
         ldap_current_mod->mod_op = ldap_current_mod->mod_op | LDAP_MOD_BVALUES;
      }
      if (SvTYPE(SvRV(ldap_current_value_sv)) == SVt_PVAV)
      {
         if (ldap_isa_ber == 1)
         {
            ldap_current_mod->mod_bvalues =
		avref2berptrptr(ldap_current_value_sv);
         } else {
            ldap_current_mod->mod_values =
		avref2charptrptr(ldap_current_value_sv);
         }
      }
     } else if (SvTYPE(SvRV(ldap_value_ref)) == SVt_PVAV) {
      if (cont)
         return NULL;
      if (ldap_add_func == 1)
         ldap_current_mod->mod_op = 0;
      else
         ldap_current_mod->mod_op = LDAP_MOD_REPLACE;
      ldap_current_mod->mod_values = avref2charptrptr(ldap_value_ref);
      if (ldap_current_mod->mod_values == NULL)
      {
         ldap_current_mod->mod_op = LDAP_MOD_DELETE;
      }
     }
   } else {
      if (cont)
         return NULL;
      if (strcmp(SvPV(ldap_value_ref,na),"") == 0)
      {
         if (ldap_add_func != 1)
         {
            ldap_current_mod->mod_op = LDAP_MOD_DELETE;
            ldap_current_mod->mod_values = NULL;
         } else {
            return(NULL);
         }
      } else {
         if (ldap_add_func == 1)
         {
            ldap_current_mod->mod_op = 0;
         } else {
            ldap_current_mod->mod_op = LDAP_MOD_REPLACE;
         }
         New(1,ldap_current_mod->mod_values,2,char *);
         ldap_current_mod->mod_values[0] = StrDup(SvPV(ldap_value_ref,na));
         ldap_current_mod->mod_values[1] = NULL;
      }
   }
   return(ldap_current_mod);
}

/* calc_mod_size                                                           */
/* Calculates the number of LDAPMod's buried inside the ldap_change passed */
/* in.  This is used by hash2mod to calculate the size to allocate in Newz */
static
int
calc_mod_size(HV *ldap_change)
{
   int mod_size = 0;
   HE *ldap_change_element;
   SV *ldap_change_element_value_ref;
   HV *ldap_change_element_value;

   hv_iterinit(ldap_change);

   while((ldap_change_element = hv_iternext(ldap_change)) != NULL)
   {
      ldap_change_element_value_ref = hv_iterval(ldap_change,ldap_change_element);
      /* Hashes can take up multiple mod slots. */
      if ( (SvROK(ldap_change_element_value_ref)) &&
           (SvTYPE(SvRV(ldap_change_element_value_ref)) == SVt_PVHV) )
      {
         ldap_change_element_value = (HV *)SvRV(ldap_change_element_value_ref);
         hv_iterinit(ldap_change_element_value);
         while ( hv_iternext(ldap_change_element_value) != NULL )
         {
            mod_size++;
         }
      }
      /* scalars and array references only take up one mod slot */
      else
      {
         mod_size++;
      }
   }

   return(mod_size);
}


/* hash2mod - Cycle through all the keys in the hash and properly call */
/*    the appropriate functions to build a NULL terminated list of     */
/*    LDAPMod pointers.                                                */

static
LDAPMod **
hash2mod(SV *ldap_change_ref,int ldap_add_func,const char *func)
{
   LDAPMod **ldapmod = NULL;
   LDAPMod *ldap_current_mod;
   int ldap_attribute_count = 0;
   HE *ldap_change_element;
   char *ldap_current_attribute;
   SV *ldap_current_value_sv;
   I32 keylen;
   HV *ldap_change;

   if (!SvROK(ldap_change_ref) || SvTYPE(SvRV(ldap_change_ref)) != SVt_PVHV)
      croak("Mozilla::LDAP::API::%s needs Hash reference as argument 3.",func);

   ldap_change = (HV *)SvRV(ldap_change_ref);

   Newz(1,ldapmod,1+calc_mod_size(ldap_change),LDAPMod *);
   hv_iterinit(ldap_change);
   while((ldap_change_element = hv_iternext(ldap_change)) != NULL)
   {
      ldap_current_attribute = hv_iterkey(ldap_change_element,&keylen);
      ldap_current_value_sv = hv_iterval(ldap_change,ldap_change_element);
      ldap_current_mod = parse1mod(ldap_current_value_sv,
        ldap_current_attribute,ldap_add_func,0);
      while (ldap_current_mod != NULL)
      {
         ldap_attribute_count++;
         ldapmod[ldap_attribute_count-1] = (LDAPMod *)ldap_current_mod;
         ldap_current_mod = parse1mod(ldap_current_value_sv,
           ldap_current_attribute,ldap_add_func,1);

      }
   }
   ldapmod[ldap_attribute_count] = NULL;
   return ldapmod;
}

/* StrCaseCmp - Replacement for strcasecmp, since it doesn't exist on many
   systems, including NT...  */

static
int
StrCaseCmp(const char *s, const char *t)
{
   while (*s && *t && toupper(*s) == toupper(*t))
   {
      s++; t++;
   }
   return(toupper(*s) - toupper(*t));
}

/*
 * StrDup
 *
 * Duplicates a string, but uses the Perl memory allocation
 * routines (so it can be free by the internal routines
 */
static
char *
StrDup(const char *source)
{
   char *dest;
   STRLEN length;

   if ( source == NULL )
      return(NULL);
   length = strlen(source);
   Newz(1,dest,length+1,char);
   Copy(source,dest,length+1,char);

   return(dest);
}

/* internal_rebind_proc - Wrapper to call a PERL rebind process             */

static
int
LDAP_CALL
internal_rebind_proc(LDAP *ld, char **dnp, char **pwp,
                     int *authmethodp, int freeit, void *arg)
{
   if (freeit == 0)
   {
      int count = 0;
      dSP;

      ENTER ;
      SAVETMPS ;
      count = perl_call_sv(ldap_perl_rebindproc,G_ARRAY|G_NOARGS);

      SPAGAIN;

      if (count != 3)
         croak("ldap_perl_rebindproc: Expected DN, PASSWORD, and AUTHTYPE returned.\n");

      *authmethodp = POPi;
      *pwp = StrDup(POPp);
      *dnp = StrDup(POPp);

      FREETMPS ;
      LEAVE ;
   } else {
      if (dnp && *dnp)
      {
         Safefree(*dnp);
      }
      if (pwp && *pwp)
      {
         Safefree(*pwp);
      }
   }
   return(LDAP_SUCCESS);
}

/* NT and internal_rebind_proc hate each other, so they need this... */

static
int
LDAP_CALL
ldap_default_rebind_proc(LDAP *ld, char **dn, char **pwd,
                         int *auth, int freeit, void *arg)
{
  if (!ldap_default_rebind_dn || !ldap_default_rebind_pwd)
    {
      *dn = NULL;
      *pwd = NULL;
      *auth = 0;

      return LDAP_OPERATIONS_ERROR;
    }

  *dn = ldap_default_rebind_dn;
  *pwd = ldap_default_rebind_pwd;
  *auth = ldap_default_rebind_auth;

  return LDAP_SUCCESS;
}


#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif


XS(XS_Mozilla__LDAP__API_constant); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_constant)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::constant", "name, arg");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	name = (char *)SvPV_nolen(ST(0));
	int	arg = (int)SvIV(ST(1));
	double	RETVAL;
	dXSTARG;

	RETVAL = constant(name, arg);
	XSprePUSH; PUSHn((double)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_abandon); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_abandon)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_abandon", "ld, msgid");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	msgid = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_abandon(ld, msgid);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAA 1


XS(XS_Mozilla__LDAP__API_ldap_abandon_ext); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_abandon_ext)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_abandon_ext", "ld, msgid, serverctrls, clientctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	msgid = (int)SvIV(ST(1));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(2)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_abandon_ext(ld, msgid, serverctrls, clientctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_add); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_add)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_add", "ld, dn, attrs");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	attrs = hash2mod(ST(2),1,"ldap_add");
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_add(ld, dn, attrs);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_mods_free(attrs, 1);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAB 1


XS(XS_Mozilla__LDAP__API_ldap_add_ext); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_add_ext)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_add_ext", "ld, dn, attrs, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	attrs = hash2mod(ST(2),1,"ldap_add_ext");
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_add_ext(ld, dn, attrs, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(5), (IV)msgidp);
	SvSETMAGIC(ST(5));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_mods_free(attrs, 1);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_add_ext_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_add_ext_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_add_ext_s", "ld, dn, attrs, serverctrls, clientctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	attrs = hash2mod(ST(2),1,"ldap_add_ext_s");
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_add_ext_s(ld, dn, attrs, serverctrls, clientctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_mods_free(attrs, 1);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_add_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_add_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_add_s", "ld, dn, attrs");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	attrs = hash2mod(ST(2),1,"ldap_add_s");
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_add_s(ld, dn, attrs);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_mods_free(attrs, 1);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_ber_free); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_ber_free)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_ber_free", "ber, freebuf");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	BerElement *	ber = INT2PTR(BerElement *,SvIV(ST(0)));
	int	freebuf = (int)SvIV(ST(1));
	{
	   if (ber)
	   {
	      ldap_ber_free(ber, freebuf);
	   }
	}
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_bind); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_bind)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_bind", "ld, dn, passwd, authmethod");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	passwd = (const char *)SvPV_nolen(ST(2));
	int	authmethod = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_bind(ld, dn, passwd, authmethod);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_bind_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_bind_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_bind_s", "ld, dn, passwd, authmethod");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	passwd = (const char *)SvPV_nolen(ST(2));
	int	authmethod = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_bind_s(ld, dn, passwd, authmethod);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_compare); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_compare)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_compare", "ld, dn, attr, value");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	attr = (const char *)SvPV_nolen(ST(2));
	const char *	value = (const char *)SvPV_nolen(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_compare(ld, dn, attr, value);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAC 1


XS(XS_Mozilla__LDAP__API_ldap_compare_ext); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_compare_ext)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_compare_ext", "ld, dn, attr, bvalue, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	attr = (const char *)SvPV_nolen(ST(2));
	struct berval	bvalue;
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(5)));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	bvalue.bv_val = (char *)SvPV(ST(3),na);
	bvalue.bv_len = na;

	RETVAL = ldap_compare_ext(ld, dn, attr, &bvalue, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(6), (IV)msgidp);
	SvSETMAGIC(ST(6));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_compare_ext_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_compare_ext_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_compare_ext_s", "ld, dn, attr, bvalue, serverctrls, clientctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	attr = (const char *)SvPV_nolen(ST(2));
	struct berval	bvalue;
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(5)));
	int	RETVAL;
	dXSTARG;

	bvalue.bv_val = (char *)SvPV(ST(3),na);
	bvalue.bv_len = na;

	RETVAL = ldap_compare_ext_s(ld, dn, attr, &bvalue, serverctrls, clientctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_compare_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_compare_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_compare_s", "ld, dn, attr, value");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	attr = (const char *)SvPV_nolen(ST(2));
	const char *	value = (const char *)SvPV_nolen(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_compare_s(ld, dn, attr, value);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAD 1


XS(XS_Mozilla__LDAP__API_ldap_control_free); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_control_free)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_control_free", "ctrl");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPControl *	ctrl = INT2PTR(LDAPControl *,SvIV(ST(0)));

	ldap_control_free(ctrl);
    }
    XSRETURN_EMPTY;
}

#endif
#ifdef CONTROLS_COUNT_WORKS
#define XSubPPtmpAAAE 1


XS(XS_Mozilla__LDAP__API_ldap_controls_count); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_controls_count)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_controls_count", "ctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPControl **	ctrls = INT2PTR(LDAPControl **,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_controls_count(ctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif
#ifdef LDAPV3
#define XSubPPtmpAAAF 1


XS(XS_Mozilla__LDAP__API_ldap_controls_free); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_controls_free)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_controls_free", "ctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPControl **	ctrls = INT2PTR(LDAPControl **,SvIV(ST(0)));

	ldap_controls_free(ctrls);
    }
    XSRETURN_EMPTY;
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_count_entries); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_count_entries)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_count_entries", "ld, result");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	result = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_count_entries(ld, result);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAG 1


XS(XS_Mozilla__LDAP__API_ldap_count_messages); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_count_messages)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_count_messages", "ld, result");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	result = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_count_messages(ld, result);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_count_references); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_count_references)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_count_references", "ld, result");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	result = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_count_references(ld, result);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_create_filter); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_create_filter)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 8)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_create_filter", "buf, buflen, pattern, prefix, suffix, attr, value, valwords");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	buf = (char *)SvPV_nolen(ST(0));
	unsigned long	buflen = (unsigned long)SvUV(ST(1));
	char *	pattern = (char *)SvPV_nolen(ST(2));
	char *	prefix = (char *)SvPV_nolen(ST(3));
	char *	suffix = (char *)SvPV_nolen(ST(4));
	char *	attr = (char *)SvPV_nolen(ST(5));
	char *	value = (char *)SvPV_nolen(ST(6));
	char **        valwords = (char **)avref2charptrptr(ST(7));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_create_filter(buf, buflen, pattern, prefix, suffix, attr, value, valwords);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (valwords)
	  ldap_value_free(valwords);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAH 1


XS(XS_Mozilla__LDAP__API_ldap_create_persistentsearch_control); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_create_persistentsearch_control)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_create_persistentsearch_control", "ld, changetypes, changesonly, return_echg_ctrls, ctrl_iscritical, ctrlp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	changetypes = (int)SvIV(ST(1));
	int	changesonly = (int)SvIV(ST(2));
	int	return_echg_ctrls = (int)SvIV(ST(3));
	char	ctrl_iscritical = (char)*SvPV_nolen(ST(4));
	LDAPControl **	ctrlp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_create_persistentsearch_control(ld, changetypes, changesonly, return_echg_ctrls, ctrl_iscritical, ctrlp);
	sv_setiv(ST(5), PTR2IV(ctrlp));
	SvSETMAGIC(ST(5));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_create_sort_control); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_create_sort_control)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_create_sort_control", "ld, sortKeyList, ctrl_iscritical, ctrlp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPsortkey **	sortKeyList = INT2PTR(LDAPsortkey **,SvIV(ST(1)));
	char	ctrl_iscritical = (char)*SvPV_nolen(ST(2));
	LDAPControl **	ctrlp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_create_sort_control(ld, sortKeyList, ctrl_iscritical, ctrlp);
	sv_setiv(ST(3), PTR2IV(ctrlp));
	SvSETMAGIC(ST(3));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_create_sort_keylist); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_create_sort_keylist)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_create_sort_keylist", "sortKeyList, string_rep");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPsortkey **	sortKeyList;
	char *	string_rep = (char *)SvPV_nolen(ST(1));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_create_sort_keylist(&sortKeyList, string_rep);
	sv_setiv(ST(0), PTR2IV(sortKeyList));
	SvSETMAGIC(ST(0));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_create_virtuallist_control); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_create_virtuallist_control)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_create_virtuallist_control", "ld, ldvlistp, ctrlp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPVirtualList *	ldvlistp = INT2PTR(LDAPVirtualList *,SvIV(ST(1)));
	LDAPControl **	ctrlp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_create_virtuallist_control(ld, ldvlistp, ctrlp);
	sv_setiv(ST(2), PTR2IV(ctrlp));
	SvSETMAGIC(ST(2));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_delete); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_delete)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_delete", "ld, dn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_delete(ld, dn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAI 1


XS(XS_Mozilla__LDAP__API_ldap_delete_ext); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_delete_ext)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_delete_ext", "ld, dn, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(2)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_delete_ext(ld, dn, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(4), (IV)msgidp);
	SvSETMAGIC(ST(4));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_delete_ext_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_delete_ext_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_delete_ext_s", "ld, dn, serverctrls, clientctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(2)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_delete_ext_s(ld, dn, serverctrls, clientctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_delete_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_delete_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_delete_s", "ld, dn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_delete_s(ld, dn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_dn2ufn); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_dn2ufn)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_dn2ufn", "dn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	dn = (const char *)SvPV_nolen(ST(0));
	char *	RETVAL;
	dXSTARG;

	RETVAL = ldap_dn2ufn(dn);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_err2string); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_err2string)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_err2string", "err");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	int	err = (int)SvIV(ST(0));
	char *	RETVAL;
	dXSTARG;

	RETVAL = ldap_err2string(err);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_explode_dn); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_explode_dn)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_explode_dn", "dn, notypes");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	const char *	dn = (const char *)SvPV_nolen(ST(0));
	const int	notypes = (const int)SvIV(ST(1));
	{
	   char **MOZLDAP_VAL = ldap_explode_dn(dn,notypes);
	   RET_CPP(MOZLDAP_VAL);
	}
	PUTBACK;
	return;
    }
}


XS(XS_Mozilla__LDAP__API_ldap_explode_rdn); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_explode_rdn)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_explode_rdn", "dn, notypes");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	const char *	dn = (const char *)SvPV_nolen(ST(0));
	int	notypes = (int)SvIV(ST(1));
	{
	   char **MOZLDAP_VAL = ldap_explode_rdn(dn,notypes);
	   RET_CPP(MOZLDAP_VAL);
	}
	PUTBACK;
	return;
    }
}

#ifdef LDAPV3
#define XSubPPtmpAAAJ 1


XS(XS_Mozilla__LDAP__API_ldap_extended_operation); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_extended_operation)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_extended_operation", "ld, requestoid, requestdata, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	requestoid = (const char *)SvPV_nolen(ST(1));
	struct berval	requestdata;
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	requestdata.bv_val = (char *)SvPV(ST(2),na);
	requestdata.bv_len = na;

	RETVAL = ldap_extended_operation(ld, requestoid, &requestdata, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(5), (IV)msgidp);
	SvSETMAGIC(ST(5));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_extended_operation_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_extended_operation_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_extended_operation_s", "ld, requestoid, requestdata, serverctrls, clientctrls, retoidp, retdatap");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	requestoid = (const char *)SvPV_nolen(ST(1));
	struct berval	requestdata;
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	char *	retoidp;
	struct berval **	retdatap;
	int	RETVAL;
	dXSTARG;

	requestdata.bv_val = (char *)SvPV(ST(2),na);
	requestdata.bv_len = na;

	RETVAL = ldap_extended_operation_s(ld, requestoid, &requestdata, serverctrls, clientctrls, &retoidp, retdatap);
	sv_setpv((SV*)ST(5), retoidp);
	SvSETMAGIC(ST(5));
	ST(6) = berptrptr2avref((struct berval **)retdatap);
	SvSETMAGIC(ST(6));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (retdatap)
	  ldap_value_free_len(retdatap);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_first_attribute); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_first_attribute)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_first_attribute", "ld, entry, ber");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	BerElement *	ber;
	char *	RETVAL;
	dXSTARG;

	RETVAL = ldap_first_attribute(ld, entry, &ber);
	sv_setiv(ST(2), PTR2IV(ber));
	SvSETMAGIC(ST(2));
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
	ldap_memfree(RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_first_entry); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_first_entry)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_first_entry", "ld, chain");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	chain = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPMessage *	RETVAL;
	dXSTARG;

	RETVAL = ldap_first_entry(ld, chain);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAK 1


XS(XS_Mozilla__LDAP__API_ldap_first_message); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_first_message)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_first_message", "ld, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPMessage *	RETVAL;
	dXSTARG;

	RETVAL = ldap_first_message(ld, res);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_first_reference); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_first_reference)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_first_reference", "ld, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPMessage *	RETVAL;
	dXSTARG;

	RETVAL = ldap_first_reference(ld, res);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_free_friendlymap); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_free_friendlymap)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_free_friendlymap", "map");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	FriendlyMap *	map = INT2PTR(FriendlyMap *,SvIV(ST(0)));

	ldap_free_friendlymap(map);
    }
    XSRETURN_EMPTY;
}

#ifdef LDAPV3
#define XSubPPtmpAAAL 1


XS(XS_Mozilla__LDAP__API_ldap_free_sort_keylist); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_free_sort_keylist)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_free_sort_keylist", "sortKeyList");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPsortkey **	sortKeyList = INT2PTR(LDAPsortkey **,SvIV(ST(0)));

	ldap_free_sort_keylist(sortKeyList);
    }
    XSRETURN_EMPTY;
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_free_urldesc); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_free_urldesc)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_free_urldesc", "ludp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPURLDesc *	ludp = INT2PTR(LDAPURLDesc *,SvIV(ST(0)));

	ldap_free_urldesc(ludp);
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_friendly_name); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_friendly_name)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_friendly_name", "filename, name, map");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	filename = (char *)SvPV_nolen(ST(0));
	char *	name = (char *)SvPV_nolen(ST(1));
	FriendlyMap *	map = INT2PTR(FriendlyMap *,SvIV(ST(2)));
	char *	RETVAL;
	dXSTARG;

	RETVAL = ldap_friendly_name(filename, name, map);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_get_dn); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_dn)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_dn", "ld, entry");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	char *	RETVAL;
	dXSTARG;

	RETVAL = ldap_get_dn(ld, entry);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
	ldap_memfree(RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAM 1


XS(XS_Mozilla__LDAP__API_ldap_get_entry_controls); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_entry_controls)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_entry_controls", "ld, entry, serverctrlsp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPControl **	serverctrlsp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_get_entry_controls(ld, entry, &serverctrlsp);
	sv_setiv(ST(2), PTR2IV(serverctrlsp));
	SvSETMAGIC(ST(2));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_getfilter_free); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_getfilter_free)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_getfilter_free", "lfdp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPFiltDesc *	lfdp = INT2PTR(LDAPFiltDesc *,SvIV(ST(0)));

	ldap_getfilter_free(lfdp);
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_getfirstfilter); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_getfirstfilter)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_getfirstfilter", "lfdp, tagpat, value");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPFiltDesc *	lfdp = INT2PTR(LDAPFiltDesc *,SvIV(ST(0)));
	char *	tagpat = (char *)SvPV_nolen(ST(1));
	char *	value = (char *)SvPV_nolen(ST(2));
	LDAPFiltInfo *	RETVAL;
	dXSTARG;

	RETVAL = ldap_getfirstfilter(lfdp, tagpat, value);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAN 1


XS(XS_Mozilla__LDAP__API_ldap_get_lang_values); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_lang_values)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_lang_values", "ld, entry, target, type");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	const char *	target = (const char *)SvPV_nolen(ST(2));
	char *	type = (char *)SvPV_nolen(ST(3));
	{
	   char ** MOZLDAP_VAL = ldap_get_lang_values(ld,entry,target,&type);
	   RET_CPP(MOZLDAP_VAL);
	}
	PUTBACK;
	return;
    }
}


XS(XS_Mozilla__LDAP__API_ldap_get_lang_values_len); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_lang_values_len)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_lang_values_len", "ld, entry, target, type");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	const char *	target = (const char *)SvPV_nolen(ST(2));
	char *	type = (char *)SvPV_nolen(ST(3));
	{
	   struct berval ** MOZLDAP_VAL = 
	       ldap_get_lang_values_len(ld,entry,target,&type);
	   RET_BVPP(MOZLDAP_VAL);
	}
	PUTBACK;
	return;
    }
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_get_lderrno); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_lderrno)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_lderrno", "ld, ...");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;
	{
	   char *match = (char *)NULL, *msg = (char *)NULL;
           SV *tmp, *m = (SV *)NULL, *s = (SV *)NULL;

	   if (items > 1)
	   {
	      m = ST(1);
	      if (items > 2)
	         s = ST(2);
           }

	   RETVAL = ldap_get_lderrno(ld, (m && SvROK(m)) ? &match : (char **)NULL,
	                                 (s && SvROK(s)) ? &msg : (char **)NULL);

	   if (match)
	   {
	      tmp = SvRV(m);
	      if (SvTYPE(tmp) <= SVt_PV)
	         sv_setpv(tmp, match);
	   }
	   if (msg)
	   {
	      tmp = SvRV(s);
	      if (SvTYPE(tmp) <= SVt_PV)
	         sv_setpv(tmp, msg);
	   }

	}
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_getnextfilter); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_getnextfilter)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_getnextfilter", "lfdp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPFiltDesc *	lfdp = INT2PTR(LDAPFiltDesc *,SvIV(ST(0)));
	LDAPFiltInfo *	RETVAL;
	dXSTARG;

	RETVAL = ldap_getnextfilter(lfdp);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_get_option); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_option)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_option", "ld, option, optdata");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	option = (int)SvIV(ST(1));
	int	optdata;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_get_option(ld, option, &optdata);
	sv_setiv(ST(2), (IV)optdata);
	SvSETMAGIC(ST(2));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_get_values); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_values)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_values", "ld, entry, target");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	const char *	target = (const char *)SvPV_nolen(ST(2));
	{
	   char **MOZLDAP_VAL = ldap_get_values(ld,entry,target);
	   RET_CPP(MOZLDAP_VAL);
	}
	PUTBACK;
	return;
    }
}


XS(XS_Mozilla__LDAP__API_ldap_get_values_len); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_get_values_len)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_get_values_len", "ld, entry, target");
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	const char *	target = (const char *)SvPV_nolen(ST(2));
	{
	   struct berval **MOZLDAP_VAL = ldap_get_values_len(ld,entry,target);
	   RET_BVPP(MOZLDAP_VAL);
	}
	PUTBACK;
	return;
    }
}


XS(XS_Mozilla__LDAP__API_ldap_init); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_init)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_init", "host, port");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	host = (const char *)SvPV_nolen(ST(0));
	int	port = (int)SvIV(ST(1));
	LDAP *	RETVAL;
	dXSTARG;

	RETVAL = ldap_init(host, port);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_init_getfilter); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_init_getfilter)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_init_getfilter", "fname");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	fname = (char *)SvPV_nolen(ST(0));
	LDAPFiltDesc *	RETVAL;
	dXSTARG;

	RETVAL = ldap_init_getfilter(fname);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_init_getfilter_buf); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_init_getfilter_buf)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_init_getfilter_buf", "buf, buflen");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	buf = (char *)SvPV_nolen(ST(0));
	long	buflen = (long)SvIV(ST(1));
	LDAPFiltDesc *	RETVAL;
	dXSTARG;

	RETVAL = ldap_init_getfilter_buf(buf, buflen);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_is_ldap_url); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_is_ldap_url)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_is_ldap_url", "url");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	url = (char *)SvPV_nolen(ST(0));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_is_ldap_url(url);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAO 1


XS(XS_Mozilla__LDAP__API_ldap_memcache_destroy); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memcache_destroy)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memcache_destroy", "cache");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMemCache *	cache = INT2PTR(LDAPMemCache *,SvIV(ST(0)));

	ldap_memcache_destroy(cache);
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_memcache_flush); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memcache_flush)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memcache_flush", "cache, dn, scope");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMemCache *	cache = INT2PTR(LDAPMemCache *,SvIV(ST(0)));
	char *	dn = (char *)SvPV_nolen(ST(1));
	int	scope = (int)SvIV(ST(2));

	ldap_memcache_flush(cache, dn, scope);
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_memcache_get); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memcache_get)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memcache_get", "ld, cachep");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMemCache **	cachep;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_memcache_get(ld, cachep);
	sv_setiv(ST(1), PTR2IV(cachep));
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_memcache_init); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memcache_init)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memcache_init", "ttl, size, baseDNs, cachep");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	unsigned long	ttl = (unsigned long)SvUV(ST(0));
	unsigned long	size = (unsigned long)SvUV(ST(1));
	char **        baseDNs = (char **)avref2charptrptr(ST(2));
	LDAPMemCache **	cachep;
	int	RETVAL;
	dXSTARG;
	RETVAL = ldap_memcache_init(ttl,size,baseDNs,NULL,cachep);
	sv_setiv(ST(3), PTR2IV(cachep));
	SvSETMAGIC(ST(3));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (baseDNs)
	  ldap_value_free(baseDNs);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_memcache_set); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memcache_set)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memcache_set", "ld, cache");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMemCache *	cache = INT2PTR(LDAPMemCache *,SvIV(ST(1)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_memcache_set(ld, cache);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_memcache_update); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memcache_update)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memcache_update", "cache");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMemCache *	cache = INT2PTR(LDAPMemCache *,SvIV(ST(0)));

	ldap_memcache_update(cache);
    }
    XSRETURN_EMPTY;
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_memfree); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_memfree)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_memfree", "p");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	void *	p = INT2PTR(void *,SvIV(ST(0)));

	ldap_memfree(p);
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_modify); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modify)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modify", "ld, dn, mods");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	mods = hash2mod(ST(2),0,"ldap_modify");
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modify(ld, dn, mods);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (mods)
	  ldap_mods_free(mods, 1);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAP 1


XS(XS_Mozilla__LDAP__API_ldap_modify_ext); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modify_ext)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modify_ext", "ld, dn, mods, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	mods = hash2mod(ST(2),0,"ldap_modify_ext");
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	int	msgidp = (int)SvIV(ST(5));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modify_ext(ld, dn, mods, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(5), (IV)msgidp);
	SvSETMAGIC(ST(5));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (mods)
	  ldap_mods_free(mods, 1);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_modify_ext_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modify_ext_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modify_ext_s", "ld, dn, mods, serverctrls, clientctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	mods = hash2mod(ST(2),0,"ldap_modify_ext_s");
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(3)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modify_ext_s(ld, dn, mods, serverctrls, clientctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (mods)
	  ldap_mods_free(mods, 1);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_modify_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modify_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modify_s", "ld, dn, mods");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	LDAPMod **	mods = hash2mod(ST(2), 0, "ldap_modify_s");
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modify_s(ld, dn, mods);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (mods)
	  ldap_mods_free(mods, 1);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_modrdn); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modrdn)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modrdn", "ld, dn, newrdn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	newrdn = (const char *)SvPV_nolen(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modrdn(ld, dn, newrdn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_modrdn_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modrdn_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modrdn_s", "ld, dn, newrdn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	newrdn = (const char *)SvPV_nolen(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modrdn_s(ld, dn, newrdn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_modrdn2); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modrdn2)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modrdn2", "ld, dn, newrdn, deleteoldrdn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	newrdn = (const char *)SvPV_nolen(ST(2));
	int	deleteoldrdn = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modrdn2(ld, dn, newrdn, deleteoldrdn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_modrdn2_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_modrdn2_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_modrdn2_s", "ld, dn, newrdn, deleteoldrdn");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	newrdn = (const char *)SvPV_nolen(ST(2));
	int	deleteoldrdn = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_modrdn2_s(ld, dn, newrdn, deleteoldrdn);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_mods_free); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_mods_free)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_mods_free", "mods, freemods");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMod **	mods = INT2PTR(LDAPMod **,SvIV(ST(0)));
	int	freemods = (int)SvIV(ST(1));

	ldap_mods_free(mods, freemods);
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_msgfree); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_msgfree)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_msgfree", "lm");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMessage *	lm = INT2PTR(LDAPMessage *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;
	{
	   if (lm)
	   {
	      RETVAL = ldap_msgfree(lm);
	   }
	}
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_msgid); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_msgid)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_msgid", "lm");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMessage *	lm = INT2PTR(LDAPMessage *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_msgid(lm);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_msgtype); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_msgtype)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_msgtype", "lm");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPMessage *	lm = INT2PTR(LDAPMessage *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_msgtype(lm);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_multisort_entries); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_multisort_entries)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_multisort_entries", "ld, chain, attr");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	chain = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	char **        attr = (char **)avref2charptrptr(ST(2));
	int	RETVAL;
	dXSTARG;
	{
	   RETVAL = ldap_multisort_entries(ld,&chain,attr,StrCaseCmp);
	}
	sv_setiv(ST(1), PTR2IV(chain));
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attr)
	  ldap_value_free(attr);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_next_attribute); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_next_attribute)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_next_attribute", "ld, entry, ber");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	BerElement *	ber = INT2PTR(BerElement *,SvIV(ST(2)));
	char *	RETVAL;
	dXSTARG;

	RETVAL = ldap_next_attribute(ld, entry, ber);
	sv_setiv(ST(2), PTR2IV(ber));
	SvSETMAGIC(ST(2));
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
	ldap_memfree(RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_next_entry); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_next_entry)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_next_entry", "ld, entry");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	entry = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPMessage *	RETVAL;
	dXSTARG;

	RETVAL = ldap_next_entry(ld, entry);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAQ 1


XS(XS_Mozilla__LDAP__API_ldap_next_message); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_next_message)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_next_message", "ld, msg");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	msg = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPMessage *	RETVAL;
	dXSTARG;

	RETVAL = ldap_next_message(ld, msg);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_next_reference); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_next_reference)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_next_reference", "ld, ref");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	ref = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	LDAPMessage *	RETVAL;
	dXSTARG;

	RETVAL = ldap_next_reference(ld, ref);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_entrychange_control); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_entrychange_control)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_entrychange_control", "ld, ctrls, chgtypep, prevdnp, chgnumpresentp, chgnump");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPControl **	ctrls = INT2PTR(LDAPControl **,SvIV(ST(1)));
	int	chgtypep;
	char *	prevdnp;
	int	chgnumpresentp;
	long	chgnump;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_entrychange_control(ld, ctrls, &chgtypep, &prevdnp, &chgnumpresentp, &chgnump);
	sv_setiv(ST(2), (IV)chgtypep);
	SvSETMAGIC(ST(2));
	sv_setpv((SV*)ST(3), prevdnp);
	SvSETMAGIC(ST(3));
	sv_setiv(ST(4), (IV)chgnumpresentp);
	SvSETMAGIC(ST(4));
	sv_setiv(ST(5), (IV)chgnump);
	SvSETMAGIC(ST(5));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_extended_result); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_extended_result)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_extended_result", "ld, res, retoidp, retdatap, freeit");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	char *	retoidp;
	struct berval **	retdatap;
	int	freeit = (int)SvIV(ST(4));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_extended_result(ld, res, &retoidp, retdatap, freeit);
	sv_setpv((SV*)ST(2), retoidp);
	SvSETMAGIC(ST(2));
	ST(3) = berptrptr2avref((struct berval **)retdatap);
	SvSETMAGIC(ST(3));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_reference); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_reference)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_reference", "ld, ref, referalsp, serverctrlsp, freeit");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	ref = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	char **	referalsp;
	LDAPControl **	serverctrlsp;
	int	freeit = (int)SvIV(ST(4));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_reference(ld, ref, &referalsp, &serverctrlsp, freeit);
	ST(2) = charptrptr2avref(referalsp);
	SvSETMAGIC(ST(2));
	sv_setiv(ST(3), PTR2IV(serverctrlsp));
	SvSETMAGIC(ST(3));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_result); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_result)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 8)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_result", "ld, res, errcodep, matcheddnp, errmsgp, referralsp, serverctrlsp, freeit");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	int	errcodep;
	char *	matcheddnp;
	char *	errmsgp;
	char **	referralsp;
	LDAPControl **	serverctrlsp;
	int	freeit = (int)SvIV(ST(7));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_result(ld, res, &errcodep, &matcheddnp, &errmsgp, &referralsp, &serverctrlsp, freeit);
	sv_setiv(ST(2), (IV)errcodep);
	SvSETMAGIC(ST(2));
	sv_setpv((SV*)ST(3), matcheddnp);
	SvSETMAGIC(ST(3));
	sv_setpv((SV*)ST(4), errmsgp);
	SvSETMAGIC(ST(4));
	ST(5) = charptrptr2avref(referralsp);
	SvSETMAGIC(ST(5));
	sv_setiv(ST(6), PTR2IV(serverctrlsp));
	SvSETMAGIC(ST(6));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_sasl_bind_result); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_sasl_bind_result)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_sasl_bind_result", "ld, res, servercredp, freeit");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	struct berval **	servercredp;
	int	freeit = (int)SvIV(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_sasl_bind_result(ld, res, servercredp, freeit);
	ST(2) = berptrptr2avref((struct berval **)servercredp);
	SvSETMAGIC(ST(2));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_sort_control); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_sort_control)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_sort_control", "ld, ctrls, result, attribute");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPControl **	ctrls = INT2PTR(LDAPControl **,SvIV(ST(1)));
	unsigned long	result;
	char *	attribute;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_sort_control(ld, ctrls, &result, &attribute);
	sv_setuv(ST(2), (UV)result);
	SvSETMAGIC(ST(2));
	sv_setpv((SV*)ST(3), attribute);
	SvSETMAGIC(ST(3));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_parse_virtuallist_control); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_parse_virtuallist_control)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_parse_virtuallist_control", "ld, ctrls, target_posp, list_sizep, errcodep");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPControl **	ctrls = INT2PTR(LDAPControl **,SvIV(ST(1)));
	unsigned long	target_posp;
	unsigned long	list_sizep;
	int	errcodep;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_parse_virtuallist_control(ld, ctrls, &target_posp, &list_sizep, &errcodep);
	sv_setuv(ST(2), (UV)target_posp);
	SvSETMAGIC(ST(2));
	sv_setuv(ST(3), (UV)list_sizep);
	SvSETMAGIC(ST(3));
	sv_setiv(ST(4), (IV)errcodep);
	SvSETMAGIC(ST(4));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_perror); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_perror)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_perror", "ld, s");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	s = (const char *)SvPV_nolen(ST(1));

	ldap_perror(ld, s);
    }
    XSRETURN_EMPTY;
}

#ifdef LDAPV3
#define XSubPPtmpAAAR 1


XS(XS_Mozilla__LDAP__API_ldap_rename); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_rename)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 8)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_rename", "ld, dn, newrdn, newparent, deleteoldrdn, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	newrdn = (const char *)SvPV_nolen(ST(2));
	const char *	newparent = (const char *)SvPV_nolen(ST(3));
	int	deleteoldrdn = (int)SvIV(ST(4));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(5)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(6)));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_rename(ld, dn, newrdn, newparent, deleteoldrdn, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(7), (IV)msgidp);
	SvSETMAGIC(ST(7));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_rename_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_rename_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_rename_s", "ld, dn, newrdn, newparent, deleteoldrdn, serverctrls, clientctrls");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	newrdn = (const char *)SvPV_nolen(ST(2));
	const char *	newparent = (const char *)SvPV_nolen(ST(3));
	int	deleteoldrdn = (int)SvIV(ST(4));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(5)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(6)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_rename_s(ld, dn, newrdn, newparent, deleteoldrdn, serverctrls, clientctrls);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_result); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_result)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_result", "ld, msgid, all, timeout, result");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	msgid = (int)SvIV(ST(1));
	int	all = (int)SvIV(ST(2));
	struct timeval	timeout;
	LDAPMessage *	result;
	int	RETVAL;
	dXSTARG;

	timeout.tv_sec = atof((char *)SvPV(ST(3),na));
	timeout.tv_usec = 0;

	RETVAL = ldap_result(ld, msgid, all, &timeout, &result);
	sv_setiv(ST(4), PTR2IV(result));
	SvSETMAGIC(ST(4));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_result2error); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_result2error)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_result2error", "ld, r, freeit");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	r = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	int	freeit = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_result2error(ld, r, freeit);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAS 1


XS(XS_Mozilla__LDAP__API_ldap_sasl_bind); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_sasl_bind)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_sasl_bind", "ld, dn, mechanism, cred, serverctrls, clientctrls, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	mechanism = (const char *)SvPV_nolen(ST(2));
	struct berval	cred;
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(5)));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	cred.bv_val = (char *)SvPV(ST(3),na);
	cred.bv_len = na;

	RETVAL = ldap_sasl_bind(ld, dn, mechanism, &cred, serverctrls, clientctrls, &msgidp);
	sv_setiv(ST(6), (IV)msgidp);
	SvSETMAGIC(ST(6));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_sasl_bind_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_sasl_bind_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_sasl_bind_s", "ld, dn, mechanism, cred, serverctrls, clientctrls, servercredp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	dn = (const char *)SvPV_nolen(ST(1));
	const char *	mechanism = (const char *)SvPV_nolen(ST(2));
	struct berval	cred;
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(4)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(5)));
	struct berval **	servercredp;
	int	RETVAL;
	dXSTARG;

	cred.bv_val = (char *)SvPV(ST(3),na);
	cred.bv_len = na;

	RETVAL = ldap_sasl_bind_s(ld, dn, mechanism, &cred, serverctrls, clientctrls, servercredp);
	ST(6) = berptrptr2avref((struct berval **)servercredp);
	SvSETMAGIC(ST(6));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_search); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_search)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 6)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_search", "ld, base, scope, filter, attrs, attrsonly");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	base = (const char *)SvPV_nolen(ST(1));
	int	scope = (int)SvIV(ST(2));
	const char *	filter = (const char *)SvPV_nolen(ST(3));
	char **        attrs = (char **)avref2charptrptr(ST(4));
	int	attrsonly = (int)SvIV(ST(5));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_search(ld, base, scope, filter, attrs, attrsonly);
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_value_free(attrs);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAT 1


XS(XS_Mozilla__LDAP__API_ldap_search_ext); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_search_ext)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 11)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_search_ext", "ld, base, scope, filter, attrs, attrsonly, serverctrls, clientctrls, timeoutp, sizelimit, msgidp");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	base = (const char *)SvPV_nolen(ST(1));
	int	scope = (int)SvIV(ST(2));
	const char *	filter = (const char *)SvPV_nolen(ST(3));
	char **        attrs = (char **)avref2charptrptr(ST(4));
	int	attrsonly = (int)SvIV(ST(5));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(6)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(7)));
	struct timeval	timeoutp;
	int	sizelimit = (int)SvIV(ST(9));
	int	msgidp;
	int	RETVAL;
	dXSTARG;

	timeoutp.tv_sec = atof((char *)SvPV(ST(8),na));
	timeoutp.tv_usec = 0;

	RETVAL = ldap_search_ext(ld, base, scope, filter, attrs, attrsonly, serverctrls, clientctrls, &timeoutp, sizelimit, &msgidp);
	sv_setiv(ST(10), (IV)msgidp);
	SvSETMAGIC(ST(10));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_value_free(attrs);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_search_ext_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_search_ext_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 11)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_search_ext_s", "ld, base, scope, filter, attrs, attrsonly, serverctrls, clientctrls, timeoutp, sizelimit, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	base = (const char *)SvPV_nolen(ST(1));
	int	scope = (int)SvIV(ST(2));
	const char *	filter = (const char *)SvPV_nolen(ST(3));
	char **        attrs = (char **)avref2charptrptr(ST(4));
	int	attrsonly = (int)SvIV(ST(5));
	LDAPControl **	serverctrls = INT2PTR(LDAPControl **,SvIV(ST(6)));
	LDAPControl **	clientctrls = INT2PTR(LDAPControl **,SvIV(ST(7)));
	struct timeval	timeoutp;
	int	sizelimit = (int)SvIV(ST(9));
	LDAPMessage *	res;
	int	RETVAL;
	dXSTARG;

	timeoutp.tv_sec = atof((char *)SvPV(ST(8),na));
	timeoutp.tv_usec = 0;

	RETVAL = ldap_search_ext_s(ld, base, scope, filter, attrs, attrsonly, serverctrls, clientctrls, &timeoutp, sizelimit, &res);
	sv_setiv(ST(10), PTR2IV(res));
	SvSETMAGIC(ST(10));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_value_free(attrs);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldap_search_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_search_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 7)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_search_s", "ld, base, scope, filter, attrs, attrsonly, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	base = (const char *)SvPV_nolen(ST(1));
	int	scope = (int)SvIV(ST(2));
	const char *	filter = (const char *)SvPV_nolen(ST(3));
	char **        attrs = (char **)avref2charptrptr(ST(4));
	int	attrsonly = (int)SvIV(ST(5));
	LDAPMessage *	res;
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_search_s(ld, base, scope, filter, attrs, attrsonly, &res);
	sv_setiv(ST(6), PTR2IV(res));
	SvSETMAGIC(ST(6));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_value_free(attrs);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_search_st); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_search_st)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 8)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_search_st", "ld, base, scope, filter, attrs, attrsonly, timeout, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	base = (const char *)SvPV_nolen(ST(1));
	int	scope = (int)SvIV(ST(2));
	const char *	filter = (const char *)SvPV_nolen(ST(3));
	char **        attrs = (char **)avref2charptrptr(ST(4));
	int	attrsonly = (int)SvIV(ST(5));
	struct timeval	timeout;
	LDAPMessage *	res;
	int	RETVAL;
	dXSTARG;

	timeout.tv_sec = atof((char *)SvPV(ST(6),na));
	timeout.tv_usec = 0;

	RETVAL = ldap_search_st(ld, base, scope, filter, attrs, attrsonly, &timeout, &res);
	sv_setiv(ST(7), PTR2IV(res));
	SvSETMAGIC(ST(7));
	XSprePUSH; PUSHi((IV)RETVAL);
	if (attrs)
	  ldap_value_free(attrs);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_set_filter_additions); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_set_filter_additions)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_set_filter_additions", "lfdp, prefix, suffix");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPFiltDesc *	lfdp = INT2PTR(LDAPFiltDesc *,SvIV(ST(0)));
	char *	prefix = (char *)SvPV_nolen(ST(1));
	char *	suffix = (char *)SvPV_nolen(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_set_filter_additions(lfdp, prefix, suffix);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_set_lderrno); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_set_lderrno)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_set_lderrno", "ld, e, m, s");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	e = (int)SvIV(ST(1));
	char *	m = (char *)SvPV_nolen(ST(2));
	char *	s = (char *)SvPV_nolen(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_set_lderrno(ld, e, m, s);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_set_option); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_set_option)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_set_option", "ld, option, optdata");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	option = (int)SvIV(ST(1));
	int	optdata = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_set_option(ld, option, &optdata);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_set_rebind_proc); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_set_rebind_proc)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_set_rebind_proc", "ld, rebindproc");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	SV *	rebindproc = ST(1);
	{
	   if (SvTYPE(SvRV(rebindproc)) != SVt_PVCV)
	   {
	      ldap_set_rebind_proc(ld,NULL,NULL);
	   } else {
	      if (ldap_perl_rebindproc == (SV*)NULL)
	         ldap_perl_rebindproc = newSVsv(rebindproc);
	      else
	         SvSetSV(ldap_perl_rebindproc,rebindproc);
	      ldap_set_rebind_proc(ld,internal_rebind_proc,NULL);
	   }
	}
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_set_default_rebind_proc); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_set_default_rebind_proc)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_set_default_rebind_proc", "ld, dn, pwd, auth");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	char *	dn = (char *)SvPV_nolen(ST(1));
	char *	pwd = (char *)SvPV_nolen(ST(2));
	int	auth = (int)SvIV(ST(3));
        {
          if ( ldap_default_rebind_dn != NULL )
          {
             Safefree(ldap_default_rebind_dn);
             ldap_default_rebind_dn = NULL;
          }
          if ( ldap_default_rebind_pwd != NULL )
          {
             Safefree(ldap_default_rebind_pwd);
             ldap_default_rebind_pwd = NULL;
          }
          ldap_default_rebind_dn = StrDup(dn);
          ldap_default_rebind_pwd = StrDup(pwd);
          ldap_default_rebind_auth = auth;

          ldap_set_rebind_proc(ld,
           (LDAP_REBINDPROC_CALLBACK *)&ldap_default_rebind_proc,NULL);
        }
    }
    XSRETURN_EMPTY;
}


XS(XS_Mozilla__LDAP__API_ldap_simple_bind); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_simple_bind)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_simple_bind", "ld, who, passwd");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	who = (const char *)SvPV_nolen(ST(1));
	const char *	passwd = (const char *)SvPV_nolen(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_simple_bind(ld, who, passwd);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_simple_bind_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_simple_bind_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_simple_bind_s", "ld, who, passwd");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	const char *	who = (const char *)SvPV_nolen(ST(1));
	const char *	passwd = (const char *)SvPV_nolen(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_simple_bind_s(ld, who, passwd);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_sort_entries); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_sort_entries)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_sort_entries", "ld, chain, attr");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	LDAPMessage *	chain = INT2PTR(LDAPMessage *,SvIV(ST(1)));
	char *	attr = (char *)SvPV_nolen(ST(2));
	int	RETVAL;
	dXSTARG;
	{
	   RETVAL = ldap_sort_entries(ld,&chain,attr,StrCaseCmp);
	}
	sv_setiv(ST(1), PTR2IV(chain));
	SvSETMAGIC(ST(1));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_unbind); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_unbind)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_unbind", "ld");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_unbind(ld);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_unbind_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_unbind_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_unbind_s", "ld");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_unbind_s(ld);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_url_parse); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_url_parse)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_url_parse", "url");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	url = (char *)SvPV_nolen(ST(0));
	SV *	RETVAL;
        {
	   LDAPURLDesc *realcomp;
	   int count,ret;

	   HV*   FullHash = newHV();
	   RETVAL = newRV((SV*)FullHash);

	   ret = ldap_url_parse(url,&realcomp);
	   if (ret == 0)
	   {
	      static char *host_key = "host";
	      static char *port_key = "port";
	      static char *dn_key = "dn";
	      static char *attr_key = "attr";
	      static char *scope_key = "scope";
	      static char *filter_key = "filter";
	      static char *options_key = "options";
	      SV* options = newSViv(realcomp->lud_options);
	      SV* host = newSVpv(realcomp->lud_host,0);
	      SV* port = newSViv(realcomp->lud_port);
	      SV* dn; /* = newSVpv(realcomp->lud_dn,0); */
	      SV* scope = newSViv(realcomp->lud_scope);
	      SV* filter = newSVpv(realcomp->lud_filter,0);
	      AV* attrarray = newAV();
	      SV* attribref = newRV((SV*) attrarray);

	      if (realcomp->lud_dn)
	         dn = newSVpv(realcomp->lud_dn,0);
	      else
	         dn = newSVpv("",0);

	      if (realcomp->lud_attrs != NULL)
	      {
	         for (count=0; realcomp->lud_attrs[count] != NULL; count++)
	         {
	            SV* SVval = newSVpv(realcomp->lud_attrs[count],0);
	            av_push(attrarray, SVval);
	         }
	      }
	      hv_store(FullHash,host_key,strlen(host_key),host,0);
	      hv_store(FullHash,port_key,strlen(port_key),port,0);
	      hv_store(FullHash,dn_key,strlen(dn_key),dn,0);
	      hv_store(FullHash,attr_key,strlen(attr_key),attribref,0);
	      hv_store(FullHash,scope_key,strlen(scope_key),scope,0);
	      hv_store(FullHash,filter_key,strlen(filter_key),filter,0);
	      hv_store(FullHash,options_key,strlen(options_key),options,0);
	      ldap_free_urldesc(realcomp);
	   } else {
	      RETVAL = &sv_undef;
	   }
	}
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_url_search); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_url_search)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_url_search", "ld, url, attrsonly");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	char *	url = (char *)SvPV_nolen(ST(1));
	int	attrsonly = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_url_search(ld, url, attrsonly);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_url_search_s); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_url_search_s)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_url_search_s", "ld, url, attrsonly, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	char *	url = (char *)SvPV_nolen(ST(1));
	int	attrsonly = (int)SvIV(ST(2));
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(3)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_url_search_s(ld, url, attrsonly, &res);
	sv_setiv(ST(3), PTR2IV(res));
	SvSETMAGIC(ST(3));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_url_search_st); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_url_search_st)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_url_search_st", "ld, url, attrsonly, timeout, res");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	char *	url = (char *)SvPV_nolen(ST(1));
	int	attrsonly = (int)SvIV(ST(2));
	struct timeval	timeout;
	LDAPMessage *	res = INT2PTR(LDAPMessage *,SvIV(ST(4)));
	int	RETVAL;
	dXSTARG;

	timeout.tv_sec = atof((char *)SvPV(ST(3),na));
	timeout.tv_usec = 0;

	RETVAL = ldap_url_search_st(ld, url, attrsonly, &timeout, &res);
	sv_setiv(ST(4), PTR2IV(res));
	SvSETMAGIC(ST(4));
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldap_version); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldap_version)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldap_version", "ver");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAPVersion *	ver = INT2PTR(LDAPVersion *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldap_version(ver);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef USE_SSL
#define XSubPPtmpAAAU 1


XS(XS_Mozilla__LDAP__API_ldapssl_client_init); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldapssl_client_init)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldapssl_client_init", "certdbpath, certdbhandle");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	certdbpath = (const char *)SvPV_nolen(ST(0));
	void *	certdbhandle = INT2PTR(void *,SvIV(ST(1)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldapssl_client_init(certdbpath, certdbhandle);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef LDAPV3
#define XSubPPtmpAAAV 1


XS(XS_Mozilla__LDAP__API_ldapssl_clientauth_init); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldapssl_clientauth_init)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 5)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldapssl_clientauth_init", "certdbpath, certdbhandle, needkeydb, keydbpath, keydbhandle");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	char *	certdbpath = (char *)SvPV_nolen(ST(0));
	void *	certdbhandle = INT2PTR(void *,SvIV(ST(1)));
	int	needkeydb = (int)SvIV(ST(2));
	char *	keydbpath = (char *)SvPV_nolen(ST(3));
	void *	keydbhandle = INT2PTR(void *,SvIV(ST(4)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldapssl_clientauth_init(certdbpath, certdbhandle, needkeydb, keydbpath, keydbhandle);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldapssl_enable_clientauth); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldapssl_enable_clientauth)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 4)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldapssl_enable_clientauth", "ld, keynickname, keypasswd, certnickname");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	char *	keynickname = (char *)SvPV_nolen(ST(1));
	char *	keypasswd = (char *)SvPV_nolen(ST(2));
	char *	certnickname = (char *)SvPV_nolen(ST(3));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldapssl_enable_clientauth(ld, keynickname, keypasswd, certnickname);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif

XS(XS_Mozilla__LDAP__API_ldapssl_init); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldapssl_init)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 3)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldapssl_init", "host, port, secure");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	const char *	host = (const char *)SvPV_nolen(ST(0));
	int	port = (int)SvIV(ST(1));
	int	secure = (int)SvIV(ST(2));
	LDAP *	RETVAL;
	dXSTARG;

	RETVAL = ldapssl_init(host, port, secure);
	XSprePUSH; PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS(XS_Mozilla__LDAP__API_ldapssl_install_routines); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mozilla__LDAP__API_ldapssl_install_routines)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       Perl_croak(aTHX_ "Usage: %s(%s)", "Mozilla::LDAP::API::ldapssl_install_routines", "ld");
    PERL_UNUSED_VAR(cv); /* -W */
    {
	LDAP *	ld = INT2PTR(LDAP *,SvIV(ST(0)));
	int	RETVAL;
	dXSTARG;

	RETVAL = ldapssl_install_routines(ld);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif
#ifdef __cplusplus
extern "C"
#endif
XS(boot_Mozilla__LDAP__API); /* prototype to pass -Wmissing-prototypes */
XS(boot_Mozilla__LDAP__API)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    char* file = __FILE__;

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
    XS_VERSION_BOOTCHECK ;

        newXSproto("Mozilla::LDAP::API::constant", XS_Mozilla__LDAP__API_constant, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_abandon", XS_Mozilla__LDAP__API_ldap_abandon, file, "$$");
#if XSubPPtmpAAAA
        newXSproto("Mozilla::LDAP::API::ldap_abandon_ext", XS_Mozilla__LDAP__API_ldap_abandon_ext, file, "$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_add", XS_Mozilla__LDAP__API_ldap_add, file, "$$$");
#if XSubPPtmpAAAB
        newXSproto("Mozilla::LDAP::API::ldap_add_ext", XS_Mozilla__LDAP__API_ldap_add_ext, file, "$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_add_ext_s", XS_Mozilla__LDAP__API_ldap_add_ext_s, file, "$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_add_s", XS_Mozilla__LDAP__API_ldap_add_s, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_ber_free", XS_Mozilla__LDAP__API_ldap_ber_free, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_bind", XS_Mozilla__LDAP__API_ldap_bind, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_bind_s", XS_Mozilla__LDAP__API_ldap_bind_s, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_compare", XS_Mozilla__LDAP__API_ldap_compare, file, "$$$$");
#if XSubPPtmpAAAC
        newXSproto("Mozilla::LDAP::API::ldap_compare_ext", XS_Mozilla__LDAP__API_ldap_compare_ext, file, "$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_compare_ext_s", XS_Mozilla__LDAP__API_ldap_compare_ext_s, file, "$$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_compare_s", XS_Mozilla__LDAP__API_ldap_compare_s, file, "$$$$");
#if XSubPPtmpAAAD
        newXSproto("Mozilla::LDAP::API::ldap_control_free", XS_Mozilla__LDAP__API_ldap_control_free, file, "$");
#endif
#if XSubPPtmpAAAE
        newXSproto("Mozilla::LDAP::API::ldap_controls_count", XS_Mozilla__LDAP__API_ldap_controls_count, file, "$");
#endif
#if XSubPPtmpAAAF
        newXSproto("Mozilla::LDAP::API::ldap_controls_free", XS_Mozilla__LDAP__API_ldap_controls_free, file, "$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_count_entries", XS_Mozilla__LDAP__API_ldap_count_entries, file, "$$");
#if XSubPPtmpAAAG
        newXSproto("Mozilla::LDAP::API::ldap_count_messages", XS_Mozilla__LDAP__API_ldap_count_messages, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_count_references", XS_Mozilla__LDAP__API_ldap_count_references, file, "$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_create_filter", XS_Mozilla__LDAP__API_ldap_create_filter, file, "$$$$$$$$");
#if XSubPPtmpAAAH
        newXSproto("Mozilla::LDAP::API::ldap_create_persistentsearch_control", XS_Mozilla__LDAP__API_ldap_create_persistentsearch_control, file, "$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_create_sort_control", XS_Mozilla__LDAP__API_ldap_create_sort_control, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_create_sort_keylist", XS_Mozilla__LDAP__API_ldap_create_sort_keylist, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_create_virtuallist_control", XS_Mozilla__LDAP__API_ldap_create_virtuallist_control, file, "$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_delete", XS_Mozilla__LDAP__API_ldap_delete, file, "$$");
#if XSubPPtmpAAAI
        newXSproto("Mozilla::LDAP::API::ldap_delete_ext", XS_Mozilla__LDAP__API_ldap_delete_ext, file, "$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_delete_ext_s", XS_Mozilla__LDAP__API_ldap_delete_ext_s, file, "$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_delete_s", XS_Mozilla__LDAP__API_ldap_delete_s, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_dn2ufn", XS_Mozilla__LDAP__API_ldap_dn2ufn, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_err2string", XS_Mozilla__LDAP__API_ldap_err2string, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_explode_dn", XS_Mozilla__LDAP__API_ldap_explode_dn, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_explode_rdn", XS_Mozilla__LDAP__API_ldap_explode_rdn, file, "$$");
#if XSubPPtmpAAAJ
        newXSproto("Mozilla::LDAP::API::ldap_extended_operation", XS_Mozilla__LDAP__API_ldap_extended_operation, file, "$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_extended_operation_s", XS_Mozilla__LDAP__API_ldap_extended_operation_s, file, "$$$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_first_attribute", XS_Mozilla__LDAP__API_ldap_first_attribute, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_first_entry", XS_Mozilla__LDAP__API_ldap_first_entry, file, "$$");
#if XSubPPtmpAAAK
        newXSproto("Mozilla::LDAP::API::ldap_first_message", XS_Mozilla__LDAP__API_ldap_first_message, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_first_reference", XS_Mozilla__LDAP__API_ldap_first_reference, file, "$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_free_friendlymap", XS_Mozilla__LDAP__API_ldap_free_friendlymap, file, "$");
#if XSubPPtmpAAAL
        newXSproto("Mozilla::LDAP::API::ldap_free_sort_keylist", XS_Mozilla__LDAP__API_ldap_free_sort_keylist, file, "$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_free_urldesc", XS_Mozilla__LDAP__API_ldap_free_urldesc, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_friendly_name", XS_Mozilla__LDAP__API_ldap_friendly_name, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_get_dn", XS_Mozilla__LDAP__API_ldap_get_dn, file, "$$");
#if XSubPPtmpAAAM
        newXSproto("Mozilla::LDAP::API::ldap_get_entry_controls", XS_Mozilla__LDAP__API_ldap_get_entry_controls, file, "$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_getfilter_free", XS_Mozilla__LDAP__API_ldap_getfilter_free, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_getfirstfilter", XS_Mozilla__LDAP__API_ldap_getfirstfilter, file, "$$$");
#if XSubPPtmpAAAN
        newXSproto("Mozilla::LDAP::API::ldap_get_lang_values", XS_Mozilla__LDAP__API_ldap_get_lang_values, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_get_lang_values_len", XS_Mozilla__LDAP__API_ldap_get_lang_values_len, file, "$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_get_lderrno", XS_Mozilla__LDAP__API_ldap_get_lderrno, file, "$;@");
        newXSproto("Mozilla::LDAP::API::ldap_getnextfilter", XS_Mozilla__LDAP__API_ldap_getnextfilter, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_get_option", XS_Mozilla__LDAP__API_ldap_get_option, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_get_values", XS_Mozilla__LDAP__API_ldap_get_values, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_get_values_len", XS_Mozilla__LDAP__API_ldap_get_values_len, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_init", XS_Mozilla__LDAP__API_ldap_init, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_init_getfilter", XS_Mozilla__LDAP__API_ldap_init_getfilter, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_init_getfilter_buf", XS_Mozilla__LDAP__API_ldap_init_getfilter_buf, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_is_ldap_url", XS_Mozilla__LDAP__API_ldap_is_ldap_url, file, "$");
#if XSubPPtmpAAAO
        newXSproto("Mozilla::LDAP::API::ldap_memcache_destroy", XS_Mozilla__LDAP__API_ldap_memcache_destroy, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_memcache_flush", XS_Mozilla__LDAP__API_ldap_memcache_flush, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_memcache_get", XS_Mozilla__LDAP__API_ldap_memcache_get, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_memcache_init", XS_Mozilla__LDAP__API_ldap_memcache_init, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_memcache_set", XS_Mozilla__LDAP__API_ldap_memcache_set, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_memcache_update", XS_Mozilla__LDAP__API_ldap_memcache_update, file, "$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_memfree", XS_Mozilla__LDAP__API_ldap_memfree, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_modify", XS_Mozilla__LDAP__API_ldap_modify, file, "$$$");
#if XSubPPtmpAAAP
        newXSproto("Mozilla::LDAP::API::ldap_modify_ext", XS_Mozilla__LDAP__API_ldap_modify_ext, file, "$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_modify_ext_s", XS_Mozilla__LDAP__API_ldap_modify_ext_s, file, "$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_modify_s", XS_Mozilla__LDAP__API_ldap_modify_s, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_modrdn", XS_Mozilla__LDAP__API_ldap_modrdn, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_modrdn_s", XS_Mozilla__LDAP__API_ldap_modrdn_s, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_modrdn2", XS_Mozilla__LDAP__API_ldap_modrdn2, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_modrdn2_s", XS_Mozilla__LDAP__API_ldap_modrdn2_s, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_mods_free", XS_Mozilla__LDAP__API_ldap_mods_free, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_msgfree", XS_Mozilla__LDAP__API_ldap_msgfree, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_msgid", XS_Mozilla__LDAP__API_ldap_msgid, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_msgtype", XS_Mozilla__LDAP__API_ldap_msgtype, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_multisort_entries", XS_Mozilla__LDAP__API_ldap_multisort_entries, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_next_attribute", XS_Mozilla__LDAP__API_ldap_next_attribute, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_next_entry", XS_Mozilla__LDAP__API_ldap_next_entry, file, "$$");
#if XSubPPtmpAAAQ
        newXSproto("Mozilla::LDAP::API::ldap_next_message", XS_Mozilla__LDAP__API_ldap_next_message, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_next_reference", XS_Mozilla__LDAP__API_ldap_next_reference, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_entrychange_control", XS_Mozilla__LDAP__API_ldap_parse_entrychange_control, file, "$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_extended_result", XS_Mozilla__LDAP__API_ldap_parse_extended_result, file, "$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_reference", XS_Mozilla__LDAP__API_ldap_parse_reference, file, "$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_result", XS_Mozilla__LDAP__API_ldap_parse_result, file, "$$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_sasl_bind_result", XS_Mozilla__LDAP__API_ldap_parse_sasl_bind_result, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_sort_control", XS_Mozilla__LDAP__API_ldap_parse_sort_control, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_parse_virtuallist_control", XS_Mozilla__LDAP__API_ldap_parse_virtuallist_control, file, "$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_perror", XS_Mozilla__LDAP__API_ldap_perror, file, "$$");
#if XSubPPtmpAAAR
        newXSproto("Mozilla::LDAP::API::ldap_rename", XS_Mozilla__LDAP__API_ldap_rename, file, "$$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_rename_s", XS_Mozilla__LDAP__API_ldap_rename_s, file, "$$$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_result", XS_Mozilla__LDAP__API_ldap_result, file, "$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_result2error", XS_Mozilla__LDAP__API_ldap_result2error, file, "$$$");
#if XSubPPtmpAAAS
        newXSproto("Mozilla::LDAP::API::ldap_sasl_bind", XS_Mozilla__LDAP__API_ldap_sasl_bind, file, "$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_sasl_bind_s", XS_Mozilla__LDAP__API_ldap_sasl_bind_s, file, "$$$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_search", XS_Mozilla__LDAP__API_ldap_search, file, "$$$$$$");
#if XSubPPtmpAAAT
        newXSproto("Mozilla::LDAP::API::ldap_search_ext", XS_Mozilla__LDAP__API_ldap_search_ext, file, "$$$$$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_search_ext_s", XS_Mozilla__LDAP__API_ldap_search_ext_s, file, "$$$$$$$$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldap_search_s", XS_Mozilla__LDAP__API_ldap_search_s, file, "$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_search_st", XS_Mozilla__LDAP__API_ldap_search_st, file, "$$$$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_set_filter_additions", XS_Mozilla__LDAP__API_ldap_set_filter_additions, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_set_lderrno", XS_Mozilla__LDAP__API_ldap_set_lderrno, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_set_option", XS_Mozilla__LDAP__API_ldap_set_option, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_set_rebind_proc", XS_Mozilla__LDAP__API_ldap_set_rebind_proc, file, "$$");
        newXSproto("Mozilla::LDAP::API::ldap_set_default_rebind_proc", XS_Mozilla__LDAP__API_ldap_set_default_rebind_proc, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_simple_bind", XS_Mozilla__LDAP__API_ldap_simple_bind, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_simple_bind_s", XS_Mozilla__LDAP__API_ldap_simple_bind_s, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_sort_entries", XS_Mozilla__LDAP__API_ldap_sort_entries, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_unbind", XS_Mozilla__LDAP__API_ldap_unbind, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_unbind_s", XS_Mozilla__LDAP__API_ldap_unbind_s, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_url_parse", XS_Mozilla__LDAP__API_ldap_url_parse, file, "$");
        newXSproto("Mozilla::LDAP::API::ldap_url_search", XS_Mozilla__LDAP__API_ldap_url_search, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldap_url_search_s", XS_Mozilla__LDAP__API_ldap_url_search_s, file, "$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_url_search_st", XS_Mozilla__LDAP__API_ldap_url_search_st, file, "$$$$$");
        newXSproto("Mozilla::LDAP::API::ldap_version", XS_Mozilla__LDAP__API_ldap_version, file, "$");
#if XSubPPtmpAAAU
        newXSproto("Mozilla::LDAP::API::ldapssl_client_init", XS_Mozilla__LDAP__API_ldapssl_client_init, file, "$$");
#if XSubPPtmpAAAV
        newXSproto("Mozilla::LDAP::API::ldapssl_clientauth_init", XS_Mozilla__LDAP__API_ldapssl_clientauth_init, file, "$$$$$");
        newXSproto("Mozilla::LDAP::API::ldapssl_enable_clientauth", XS_Mozilla__LDAP__API_ldapssl_enable_clientauth, file, "$$$$");
#endif
        newXSproto("Mozilla::LDAP::API::ldapssl_init", XS_Mozilla__LDAP__API_ldapssl_init, file, "$$$");
        newXSproto("Mozilla::LDAP::API::ldapssl_install_routines", XS_Mozilla__LDAP__API_ldapssl_install_routines, file, "$");
#endif

    /* Initialisation Section */

if ( perldap_init() != 0)
{
   fprintf(stderr, "Error loading Mozilla::LDAP::API: perldap_init failed\n");
   exit(1);
}

#if XSubPPtmpAAAA
#endif
#if XSubPPtmpAAAB
#endif
#if XSubPPtmpAAAC
#endif
#if XSubPPtmpAAAD
#endif
#if XSubPPtmpAAAE
#endif
#if XSubPPtmpAAAF
#endif
#if XSubPPtmpAAAG
#endif
#if XSubPPtmpAAAH
#endif
#if XSubPPtmpAAAI
#endif
#if XSubPPtmpAAAJ
#endif
#if XSubPPtmpAAAK
#endif
#if XSubPPtmpAAAL
#endif
#if XSubPPtmpAAAM
#endif
#if XSubPPtmpAAAN
#endif
#if XSubPPtmpAAAO
#endif
#if XSubPPtmpAAAP
#endif
#if XSubPPtmpAAAQ
#endif
#if XSubPPtmpAAAR
#endif
#if XSubPPtmpAAAS
#endif
#if XSubPPtmpAAAT
#endif
#if XSubPPtmpAAAU
#if XSubPPtmpAAAV
#endif
#endif

    /* End of Initialisation Section */

    XSRETURN_YES;
}



syntax highlighted by Code2HTML, v. 0.9.1