Commit 5bf1900d authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wldap32: Move support for control functions to the Unix library.

parent e32a6026
...@@ -18,25 +18,15 @@ ...@@ -18,25 +18,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_LDAP_H
#include <ldap.h>
#endif
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winnls.h" #include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "winldap_private.h"
#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32); WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
#endif
/*********************************************************************** /***********************************************************************
* ldap_control_freeA (WLDAP32.@) * ldap_control_freeA (WLDAP32.@)
...@@ -45,14 +35,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32); ...@@ -45,14 +35,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
*/ */
ULONG CDECL ldap_control_freeA( LDAPControlA *control ) ULONG CDECL ldap_control_freeA( LDAPControlA *control )
{ {
ULONG ret = WLDAP32_LDAP_SUCCESS;
#ifdef HAVE_LDAP
TRACE( "(%p)\n", control ); TRACE( "(%p)\n", control );
controlfreeA( control ); controlfreeA( control );
return WLDAP32_LDAP_SUCCESS;
#endif
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -68,14 +53,9 @@ ULONG CDECL ldap_control_freeA( LDAPControlA *control ) ...@@ -68,14 +53,9 @@ ULONG CDECL ldap_control_freeA( LDAPControlA *control )
*/ */
ULONG CDECL ldap_control_freeW( LDAPControlW *control ) ULONG CDECL ldap_control_freeW( LDAPControlW *control )
{ {
ULONG ret = WLDAP32_LDAP_SUCCESS;
#ifdef HAVE_LDAP
TRACE( "(%p)\n", control ); TRACE( "(%p)\n", control );
controlfreeW( control ); controlfreeW( control );
return WLDAP32_LDAP_SUCCESS;
#endif
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -85,14 +65,9 @@ ULONG CDECL ldap_control_freeW( LDAPControlW *control ) ...@@ -85,14 +65,9 @@ ULONG CDECL ldap_control_freeW( LDAPControlW *control )
*/ */
ULONG CDECL ldap_controls_freeA( LDAPControlA **controls ) ULONG CDECL ldap_controls_freeA( LDAPControlA **controls )
{ {
ULONG ret = WLDAP32_LDAP_SUCCESS;
#ifdef HAVE_LDAP
TRACE( "(%p)\n", controls ); TRACE( "(%p)\n", controls );
controlarrayfreeA( controls ); controlarrayfreeA( controls );
return WLDAP32_LDAP_SUCCESS;
#endif
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -108,14 +83,9 @@ ULONG CDECL ldap_controls_freeA( LDAPControlA **controls ) ...@@ -108,14 +83,9 @@ ULONG CDECL ldap_controls_freeA( LDAPControlA **controls )
*/ */
ULONG CDECL ldap_controls_freeW( LDAPControlW **controls ) ULONG CDECL ldap_controls_freeW( LDAPControlW **controls )
{ {
ULONG ret = WLDAP32_LDAP_SUCCESS;
#ifdef HAVE_LDAP
TRACE( "(%p)\n", controls ); TRACE( "(%p)\n", controls );
controlarrayfreeW( controls ); controlarrayfreeW( controls );
return WLDAP32_LDAP_SUCCESS;
#endif
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -123,31 +93,29 @@ ULONG CDECL ldap_controls_freeW( LDAPControlW **controls ) ...@@ -123,31 +93,29 @@ ULONG CDECL ldap_controls_freeW( LDAPControlW **controls )
* *
* See ldap_create_sort_controlW. * See ldap_create_sort_controlW.
*/ */
ULONG CDECL ldap_create_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkey, ULONG CDECL ldap_create_sort_controlA( WLDAP32_LDAP *ld, LDAPSortKeyA **sortkey, UCHAR critical,
UCHAR critical, PLDAPControlA *control ) LDAPControlA **control )
{ {
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; ULONG ret;
#ifdef HAVE_LDAP LDAPSortKeyW **sortkeyW;
LDAPSortKeyW **sortkeyW = NULL; LDAPControlW *controlW;
LDAPControlW *controlW = NULL;
TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control ); TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
if (!ld || !sortkey || !control) if (!ld || !sortkey || !control) return WLDAP32_LDAP_PARAM_ERROR;
return WLDAP32_LDAP_PARAM_ERROR;
sortkeyW = sortkeyarrayAtoW( sortkey ); if (!(sortkeyW = sortkeyarrayAtoW( sortkey ))) return WLDAP32_LDAP_NO_MEMORY;
if (!sortkeyW) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_create_sort_controlW( ld, sortkeyW, critical, &controlW ); ret = ldap_create_sort_controlW( ld, sortkeyW, critical, &controlW );
if (ret == WLDAP32_LDAP_SUCCESS)
*control = controlWtoA( controlW ); {
if (!*control) ret = WLDAP32_LDAP_NO_MEMORY; LDAPControlA *controlA = controlWtoA( controlW );
if (controlA) *control = controlA;
else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_control_freeW( controlW ); ldap_control_freeW( controlW );
sortkeyarrayfreeW( sortkeyW ); }
#endif sortkeyarrayfreeW( sortkeyW );
return ret; return ret;
} }
...@@ -173,31 +141,29 @@ ULONG CDECL ldap_create_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkey, ...@@ -173,31 +141,29 @@ ULONG CDECL ldap_create_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkey,
* Pass the created control as a server control in subsequent calls * Pass the created control as a server control in subsequent calls
* to ldap_search_ext(_s) to obtain sorted search results. * to ldap_search_ext(_s) to obtain sorted search results.
*/ */
ULONG CDECL ldap_create_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkey, ULONG CDECL ldap_create_sort_controlW( WLDAP32_LDAP *ld, LDAPSortKeyW **sortkey, UCHAR critical,
UCHAR critical, PLDAPControlW *control ) LDAPControlW **control )
{ {
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; ULONG ret;
#ifdef HAVE_LDAP LDAPSortKeyU **sortkeyU;
LDAPSortKey **sortkeyU = NULL; LDAPControlU *controlU;
LDAPControl *controlU = NULL;
TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control ); TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
if (!ld || !sortkey || !control) if (!ld || !sortkey || !control) return WLDAP32_LDAP_PARAM_ERROR;
return WLDAP32_LDAP_PARAM_ERROR;
sortkeyU = sortkeyarrayWtoU( sortkey );
if (!sortkeyU) return WLDAP32_LDAP_NO_MEMORY;
ret = map_error( ldap_create_sort_control( ld->ld, sortkeyU, critical, &controlU )); if (sortkey && !(sortkeyU = sortkeyarrayWtoU( sortkey ))) return WLDAP32_LDAP_NO_MEMORY;
*control = controlUtoW( controlU ); ret = map_error( ldap_funcs->ldap_create_sort_control( ld->ld, sortkeyU, critical, &controlU ) );
if (!*control) ret = WLDAP32_LDAP_NO_MEMORY; if (ret == WLDAP32_LDAP_SUCCESS)
{
LDAPControlW *controlW = controlUtoW( controlU );
if (controlW) *control = controlW;
else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_funcs->ldap_control_free( controlU );
}
ldap_control_free( controlU );
sortkeyarrayfreeU( sortkeyU ); sortkeyarrayfreeU( sortkeyU );
#endif
return ret; return ret;
} }
...@@ -206,27 +172,25 @@ ULONG CDECL ldap_create_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkey, ...@@ -206,27 +172,25 @@ ULONG CDECL ldap_create_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkey,
* *
* See ldap_create_vlv_controlW. * See ldap_create_vlv_controlW.
*/ */
INT CDECL ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info, INT CDECL ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info, UCHAR critical,
UCHAR critical, LDAPControlA **control ) LDAPControlA **control )
{ {
INT ret = WLDAP32_LDAP_NOT_SUPPORTED; INT ret;
#ifdef HAVE_LDAP LDAPControlW *controlW;
LDAPControlW *controlW = NULL;
TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control ); TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
if (!ld || !control) return ~0u; if (!ld || !control) return ~0u;
ret = ldap_create_vlv_controlW( ld, info, critical, &controlW ); ret = ldap_create_vlv_controlW( ld, info, critical, &controlW );
if (ret == WLDAP32_LDAP_SUCCESS) if (ret == WLDAP32_LDAP_SUCCESS)
{ {
*control = controlWtoA( controlW ); LDAPControlA *controlA = controlWtoA( controlW );
if (!*control) ret = WLDAP32_LDAP_NO_MEMORY; if (controlA) *control = controlA;
else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_control_freeW( controlW ); ldap_control_freeW( controlW );
} }
#endif
return ret; return ret;
} }
...@@ -252,33 +216,35 @@ INT CDECL ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info, ...@@ -252,33 +216,35 @@ INT CDECL ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
* server will then return a sorted, contiguous subset of results * server will then return a sorted, contiguous subset of results
* that meets the criteria specified in the LDAPVLVInfo structure. * that meets the criteria specified in the LDAPVLVInfo structure.
*/ */
INT CDECL ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info, INT CDECL ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info, UCHAR critical,
UCHAR critical, LDAPControlW **control ) LDAPControlW **control )
{ {
INT ret = WLDAP32_LDAP_NOT_SUPPORTED; ULONG ret;
#ifdef HAVE_LDAP LDAPVLVInfoU *infoU = NULL;
LDAPControl *controlU = NULL; LDAPControlU *controlU;
TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control ); TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
if (!ld || !control) return ~0u; if (!ld || !control) return ~0u;
ret = map_error( ldap_create_vlv_control( ld->ld, (LDAPVLVInfo *)info, &controlU )); if (info && !(infoU = vlvinfoWtoU( info ))) return WLDAP32_LDAP_NO_MEMORY;
ret = map_error( ldap_funcs->ldap_create_vlv_control( ld->ld, infoU, &controlU ) );
if (ret == WLDAP32_LDAP_SUCCESS) if (ret == WLDAP32_LDAP_SUCCESS)
{ {
*control = controlUtoW( controlU ); LDAPControlW *controlW = controlUtoW( controlU );
if (!*control) ret = WLDAP32_LDAP_NO_MEMORY; if (controlW) *control = controlW;
ldap_control_free( controlU ); else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_funcs->ldap_control_free( controlU );
} }
#endif vlvinfofreeU( infoU );
return ret; return ret;
} }
static inline void bv_val_dup( const struct WLDAP32_berval *src, struct WLDAP32_berval *dst ) static inline void bv_val_dup( const struct WLDAP32_berval *src, struct WLDAP32_berval *dst )
{ {
if ((dst->bv_val = heap_alloc( src->bv_len ))) if ((dst->bv_val = RtlAllocateHeap( GetProcessHeap(), 0 , src->bv_len )))
{ {
memcpy( dst->bv_val, src->bv_val, src->bv_len ); memcpy( dst->bv_val, src->bv_val, src->bv_len );
dst->bv_len = src->bv_len; dst->bv_len = src->bv_len;
...@@ -292,8 +258,7 @@ static inline void bv_val_dup( const struct WLDAP32_berval *src, struct WLDAP32_ ...@@ -292,8 +258,7 @@ static inline void bv_val_dup( const struct WLDAP32_berval *src, struct WLDAP32_
* *
* See ldap_encode_sort_controlW. * See ldap_encode_sort_controlW.
*/ */
ULONG CDECL ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys, ULONG CDECL ldap_encode_sort_controlA( WLDAP32_LDAP *ld, LDAPSortKeyA **sortkeys, LDAPControlA *ret, BOOLEAN critical )
PLDAPControlA ret, BOOLEAN critical )
{ {
LDAPControlA *control; LDAPControlA *control;
ULONG result; ULONG result;
...@@ -330,8 +295,7 @@ ULONG CDECL ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys ...@@ -330,8 +295,7 @@ ULONG CDECL ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys
* This function is obsolete. Use its equivalent * This function is obsolete. Use its equivalent
* ldap_create_sort_control instead. * ldap_create_sort_control instead.
*/ */
ULONG CDECL ldap_encode_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkeys, ULONG CDECL ldap_encode_sort_controlW( WLDAP32_LDAP *ld, LDAPSortKeyW **sortkeys, LDAPControlW *ret, BOOLEAN critical )
PLDAPControlW ret, BOOLEAN critical )
{ {
LDAPControlW *control; LDAPControlW *control;
ULONG result; ULONG result;
......
...@@ -309,6 +309,11 @@ int CDECL wrap_ldap_add_ext_s( void *ld, const char *dn, LDAPModU **attrs, LDAPC ...@@ -309,6 +309,11 @@ int CDECL wrap_ldap_add_ext_s( void *ld, const char *dn, LDAPModU **attrs, LDAPC
(LDAPControl **)clientctrls ); (LDAPControl **)clientctrls );
} }
void CDECL wrap_ldap_control_free( LDAPControlU *control )
{
ldap_control_free( (LDAPControl *)control );
}
int CDECL wrap_ldap_compare_ext( void *ld, const char *dn, const char *attrs, struct bervalU *value, int CDECL wrap_ldap_compare_ext( void *ld, const char *dn, const char *attrs, struct bervalU *value,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, ULONG *msg ) LDAPControlU **serverctrls, LDAPControlU **clientctrls, ULONG *msg )
{ {
...@@ -324,6 +329,16 @@ int CDECL wrap_ldap_compare_ext_s( void *ld, const char *dn, const char *attrs, ...@@ -324,6 +329,16 @@ int CDECL wrap_ldap_compare_ext_s( void *ld, const char *dn, const char *attrs,
(LDAPControl **)serverctrls, (LDAPControl **)clientctrls ); (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
} }
int CDECL wrap_ldap_create_sort_control( void *ld, LDAPSortKeyU **keylist, int critical, LDAPControlU **control )
{
return ldap_create_sort_control( ld, (LDAPSortKey **)keylist, critical, (LDAPControl **)control );
}
int CDECL wrap_ldap_create_vlv_control( void *ld, LDAPVLVInfoU *info, LDAPControlU **control )
{
return ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, (LDAPControl **)control );
}
void CDECL wrap_ldap_memfree( void *ptr ) void CDECL wrap_ldap_memfree( void *ptr )
{ {
return ldap_memfree( ptr ); return ldap_memfree( ptr );
...@@ -392,6 +407,9 @@ static const struct ldap_funcs funcs = ...@@ -392,6 +407,9 @@ static const struct ldap_funcs funcs =
wrap_ldap_add_ext_s, wrap_ldap_add_ext_s,
wrap_ldap_compare_ext, wrap_ldap_compare_ext,
wrap_ldap_compare_ext_s, wrap_ldap_compare_ext_s,
wrap_ldap_control_free,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
wrap_ldap_memfree, wrap_ldap_memfree,
wrap_ldap_sasl_bind, wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s, wrap_ldap_sasl_bind_s,
......
...@@ -98,6 +98,9 @@ extern int CDECL wrap_ldap_compare_ext(void *, const char *, const char *, struc ...@@ -98,6 +98,9 @@ extern int CDECL wrap_ldap_compare_ext(void *, const char *, const char *, struc
LDAPControlU **, ULONG *) DECLSPEC_HIDDEN; LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **, extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **) DECLSPEC_HIDDEN; LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_control_free(LDAPControlU *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN; extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **, extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN; LDAPControlU **, int *) DECLSPEC_HIDDEN;
...@@ -130,6 +133,9 @@ struct ldap_funcs ...@@ -130,6 +133,9 @@ struct ldap_funcs
LDAPControlU **, ULONG *); LDAPControlU **, ULONG *);
int (CDECL *ldap_compare_ext_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, int (CDECL *ldap_compare_ext_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **); LDAPControlU **);
void (CDECL *ldap_control_free)(LDAPControlU *);
int (CDECL *ldap_create_sort_control)(void *, LDAPSortKeyU **, int, LDAPControlU **);
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
void (CDECL *ldap_memfree)(void *); void (CDECL *ldap_memfree)(void *);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **, int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *); int *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment