Blame compat/derefctrl.c

Packit 6bd9ab
/*
Packit 6bd9ab
   derefctrl.c - replacement function
Packit 6bd9ab
Packit 6bd9ab
   Copyright (C) 2013 Arthur de Jong
Packit 6bd9ab
Packit 6bd9ab
   This library is free software; you can redistribute it and/or
Packit 6bd9ab
   modify it under the terms of the GNU Lesser General Public
Packit 6bd9ab
   License as published by the Free Software Foundation; either
Packit 6bd9ab
   version 2.1 of the License, or (at your option) any later version.
Packit 6bd9ab
Packit 6bd9ab
   This library is distributed in the hope that it will be useful,
Packit 6bd9ab
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6bd9ab
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6bd9ab
   Lesser General Public License for more details.
Packit 6bd9ab
Packit 6bd9ab
   You should have received a copy of the GNU Lesser General Public
Packit 6bd9ab
   License along with this library; if not, write to the Free Software
Packit 6bd9ab
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 6bd9ab
   02110-1301 USA
Packit 6bd9ab
*/
Packit 6bd9ab
Packit 6bd9ab
#include "config.h"
Packit 6bd9ab
Packit 6bd9ab
#include <stdlib.h>
Packit 6bd9ab
#include <lber.h>
Packit 6bd9ab
#include <ldap.h>
Packit 6bd9ab
#include <string.h>
Packit 6bd9ab
Packit 6bd9ab
#include "compat/ldap_compat.h"
Packit 6bd9ab
#include "compat/attrs.h"
Packit 6bd9ab
Packit 6bd9ab
#ifdef REPLACE_LDAP_CREATE_DEREF_CONTROL
Packit 6bd9ab
int replacement_ldap_create_deref_control(LDAP *ld, LDAPDerefSpec *ds,
Packit 6bd9ab
      int iscritical, LDAPControl **ctrlp)
Packit 6bd9ab
{
Packit 6bd9ab
  int rc;
Packit 6bd9ab
  struct berval value;
Packit 6bd9ab
  if (ctrlp == NULL)
Packit 6bd9ab
    return LDAP_PARAM_ERROR;
Packit 6bd9ab
  rc = ldap_create_deref_control_value(ld, ds, &value);
Packit 6bd9ab
  if (rc != LDAP_SUCCESS)
Packit 6bd9ab
    return rc;
Packit 6bd9ab
  rc = ldap_control_create(LDAP_CONTROL_X_DEREF, iscritical, &value, 0, ctrlp);
Packit 6bd9ab
  if (rc != LDAP_SUCCESS)
Packit 6bd9ab
  {
Packit 6bd9ab
    ber_memfree(value.bv_val);
Packit 6bd9ab
  }
Packit 6bd9ab
  return rc;
Packit 6bd9ab
}
Packit 6bd9ab
#endif /* REPLACE_LDAP_CREATE_DEREF_CONTROL */