wldap32: Don't depend on libldap for the value functions.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
91355dae93
commit
5a236e55c3
|
@ -18,21 +18,14 @@
|
||||||
* 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 "wine/heap.h"
|
||||||
|
#include "winldap_private.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
||||||
|
|
||||||
|
@ -42,7 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
||||||
* Count the number of values in an array of berval structures.
|
* Count the number of values in an array of berval structures.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* vals [I] Pointer to an array of berval structures.
|
* values [I] Pointer to an array of berval structures.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: The number of values counted.
|
* Success: The number of values counted.
|
||||||
|
@ -52,15 +45,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
||||||
* Call ldap_count_values_len with the result of a call to
|
* Call ldap_count_values_len with the result of a call to
|
||||||
* ldap_get_values_len.
|
* ldap_get_values_len.
|
||||||
*/
|
*/
|
||||||
ULONG CDECL WLDAP32_ldap_count_values_len( struct WLDAP32_berval **vals )
|
ULONG CDECL WLDAP32_ldap_count_values_len( struct WLDAP32_berval **values )
|
||||||
{
|
{
|
||||||
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
ULONG ret = 0;
|
||||||
#ifdef HAVE_LDAP
|
struct WLDAP32_berval **ptr = values;
|
||||||
|
|
||||||
TRACE( "(%p)\n", vals );
|
TRACE( "(%p)\n", values );
|
||||||
ret = ldap_count_values_len( (struct berval **)vals );
|
|
||||||
|
|
||||||
#endif
|
if (!values) return 0;
|
||||||
|
while (*ptr++) ret++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,23 +62,15 @@ ULONG CDECL WLDAP32_ldap_count_values_len( struct WLDAP32_berval **vals )
|
||||||
*
|
*
|
||||||
* See ldap_count_valuesW.
|
* See ldap_count_valuesW.
|
||||||
*/
|
*/
|
||||||
ULONG CDECL ldap_count_valuesA( PCHAR *vals )
|
ULONG CDECL ldap_count_valuesA( char **values )
|
||||||
{
|
{
|
||||||
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
ULONG ret = 0;
|
||||||
#ifdef HAVE_LDAP
|
char **ptr = values;
|
||||||
WCHAR **valsW = NULL;
|
|
||||||
|
|
||||||
TRACE( "(%p)\n", vals );
|
TRACE( "(%p)\n", values );
|
||||||
|
|
||||||
if (!vals) return 0;
|
if (!values) return 0;
|
||||||
|
while (*ptr++) ret++;
|
||||||
valsW = strarrayAtoW( vals );
|
|
||||||
if (!valsW) return WLDAP32_LDAP_NO_MEMORY;
|
|
||||||
|
|
||||||
ret = ldap_count_valuesW( valsW );
|
|
||||||
strarrayfreeW( valsW );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +80,7 @@ ULONG CDECL ldap_count_valuesA( PCHAR *vals )
|
||||||
* Count the number of values in a string array.
|
* Count the number of values in a string array.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* vals [I] Pointer to an array of strings.
|
* values [I] Pointer to an array of strings.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: The number of values counted.
|
* Success: The number of values counted.
|
||||||
|
@ -105,20 +90,15 @@ ULONG CDECL ldap_count_valuesA( PCHAR *vals )
|
||||||
* Call ldap_count_valuesW with the result of a call to
|
* Call ldap_count_valuesW with the result of a call to
|
||||||
* ldap_get_valuesW.
|
* ldap_get_valuesW.
|
||||||
*/
|
*/
|
||||||
ULONG CDECL ldap_count_valuesW( PWCHAR *vals )
|
ULONG CDECL ldap_count_valuesW( WCHAR **values )
|
||||||
{
|
{
|
||||||
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
|
ULONG ret = 0;
|
||||||
#ifdef HAVE_LDAP
|
WCHAR **p = values;
|
||||||
WCHAR **p = vals;
|
|
||||||
|
|
||||||
TRACE( "(%p)\n", vals );
|
TRACE( "(%p)\n", values );
|
||||||
|
|
||||||
if (!vals) return 0;
|
if (!values) return 0;
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
while (*p++) ret++;
|
while (*p++) ret++;
|
||||||
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,31 +107,24 @@ ULONG CDECL ldap_count_valuesW( PWCHAR *vals )
|
||||||
*
|
*
|
||||||
* See ldap_get_valuesW.
|
* See ldap_get_valuesW.
|
||||||
*/
|
*/
|
||||||
PCHAR * CDECL ldap_get_valuesA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PCHAR attr )
|
char ** CDECL ldap_get_valuesA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, char *attr )
|
||||||
{
|
{
|
||||||
PCHAR *ret = NULL;
|
char **ret;
|
||||||
#ifdef HAVE_LDAP
|
|
||||||
WCHAR *attrW = NULL, **retW;
|
WCHAR *attrW = NULL, **retW;
|
||||||
|
|
||||||
TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_a(attr) );
|
TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_a(attr) );
|
||||||
|
|
||||||
if (!ld || !entry || !attr) return NULL;
|
if (!ld || !entry || !attr || !(attrW = strAtoW( attr ))) return NULL;
|
||||||
|
|
||||||
attrW = strAtoW( attr );
|
|
||||||
if (!attrW) return NULL;
|
|
||||||
|
|
||||||
retW = ldap_get_valuesW( ld, entry, attrW );
|
retW = ldap_get_valuesW( ld, entry, attrW );
|
||||||
|
|
||||||
ret = strarrayWtoA( retW );
|
ret = strarrayWtoA( retW );
|
||||||
|
|
||||||
ldap_value_freeW( retW );
|
ldap_value_freeW( retW );
|
||||||
strfreeW( attrW );
|
strfreeW( attrW );
|
||||||
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LDAP
|
static char *bv2str( struct bervalU *bv )
|
||||||
static char *bv2str( struct berval *bv )
|
|
||||||
{
|
{
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
unsigned int len = bv->bv_len;
|
unsigned int len = bv->bv_len;
|
||||||
|
@ -164,10 +137,10 @@ static char *bv2str( struct berval *bv )
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **bv2str_array( struct berval **bv )
|
static char **bv2str_array( struct bervalU **bv )
|
||||||
{
|
{
|
||||||
unsigned int len = 0, i = 0;
|
unsigned int len = 0, i = 0;
|
||||||
struct berval **p = bv;
|
struct bervalU **p = bv;
|
||||||
char **str;
|
char **str;
|
||||||
|
|
||||||
while (*p)
|
while (*p)
|
||||||
|
@ -186,14 +159,13 @@ static char **bv2str_array( struct berval **bv )
|
||||||
while (i > 0) heap_free( str[--i] );
|
while (i > 0) heap_free( str[--i] );
|
||||||
heap_free( str );
|
heap_free( str );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
str[i] = NULL;
|
str[i] = NULL;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* ldap_get_valuesW (WLDAP32.@)
|
* ldap_get_valuesW (WLDAP32.@)
|
||||||
|
@ -214,32 +186,26 @@ static char **bv2str_array( struct berval **bv )
|
||||||
* ldap_first_entry or ldap_next_entry. Free the returned
|
* ldap_first_entry or ldap_next_entry. Free the returned
|
||||||
* array with a call to ldap_value_freeW.
|
* array with a call to ldap_value_freeW.
|
||||||
*/
|
*/
|
||||||
PWCHAR * CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PWCHAR attr )
|
WCHAR ** CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WCHAR *attr )
|
||||||
{
|
{
|
||||||
PWCHAR *ret = NULL;
|
WCHAR **ret = NULL;
|
||||||
#ifdef HAVE_LDAP
|
char *attrU, **retU;
|
||||||
char *attrU = NULL, **retU;
|
struct bervalU **bv;
|
||||||
struct berval **bv;
|
|
||||||
|
|
||||||
TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) );
|
TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) );
|
||||||
|
|
||||||
if (!ld || !entry || !attr) return NULL;
|
if (!ld || !entry || !attr || !(attrU = strWtoU( attr ))) return NULL;
|
||||||
|
|
||||||
attrU = strWtoU( attr );
|
if ((bv = ldap_funcs->ldap_get_values_len( ld->ld, entry->Request, attrU )))
|
||||||
if (!attrU) return NULL;
|
|
||||||
|
|
||||||
bv = ldap_get_values_len( ld->ld, entry->Request, attrU );
|
|
||||||
if (bv)
|
|
||||||
{
|
{
|
||||||
retU = bv2str_array( bv );
|
retU = bv2str_array( bv );
|
||||||
ret = strarrayUtoW( retU );
|
ret = strarrayUtoW( retU );
|
||||||
|
|
||||||
ldap_value_free_len( bv );
|
ldap_funcs->ldap_value_free_len( bv );
|
||||||
strarrayfreeU( retU );
|
strarrayfreeU( retU );
|
||||||
}
|
}
|
||||||
strfreeU( attrU );
|
|
||||||
|
|
||||||
#endif
|
strfreeU( attrU );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,28 +214,19 @@ PWCHAR * CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, P
|
||||||
*
|
*
|
||||||
* See ldap_get_values_lenW.
|
* See ldap_get_values_lenW.
|
||||||
*/
|
*/
|
||||||
struct WLDAP32_berval ** CDECL ldap_get_values_lenA( WLDAP32_LDAP *ld,
|
struct WLDAP32_berval ** CDECL ldap_get_values_lenA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message, char *attr )
|
||||||
WLDAP32_LDAPMessage *message, PCHAR attr )
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LDAP
|
WCHAR *attrW;
|
||||||
WCHAR *attrW = NULL;
|
|
||||||
struct WLDAP32_berval **ret;
|
struct WLDAP32_berval **ret;
|
||||||
|
|
||||||
TRACE( "(%p, %p, %s)\n", ld, message, debugstr_a(attr) );
|
TRACE( "(%p, %p, %s)\n", ld, message, debugstr_a(attr) );
|
||||||
|
|
||||||
if (!ld || !message || !attr) return NULL;
|
if (!ld || !message || !attr || !(attrW = strAtoW( attr ))) return NULL;
|
||||||
|
|
||||||
attrW = strAtoW( attr );
|
|
||||||
if (!attrW) return NULL;
|
|
||||||
|
|
||||||
ret = ldap_get_values_lenW( ld, message, attrW );
|
ret = ldap_get_values_lenW( ld, message, attrW );
|
||||||
|
|
||||||
strfreeW( attrW );
|
strfreeW( attrW );
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -291,28 +248,24 @@ struct WLDAP32_berval ** CDECL ldap_get_values_lenA( WLDAP32_LDAP *ld,
|
||||||
* ldap_first_entry or ldap_next_entry. Free the returned
|
* ldap_first_entry or ldap_next_entry. Free the returned
|
||||||
* array with a call to ldap_value_free_len.
|
* array with a call to ldap_value_free_len.
|
||||||
*/
|
*/
|
||||||
struct WLDAP32_berval ** CDECL ldap_get_values_lenW( WLDAP32_LDAP *ld,
|
struct WLDAP32_berval ** CDECL ldap_get_values_lenW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message, WCHAR *attr )
|
||||||
WLDAP32_LDAPMessage *message, PWCHAR attr )
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LDAP
|
|
||||||
char *attrU = NULL;
|
char *attrU = NULL;
|
||||||
struct berval **ret;
|
struct bervalU **retU;
|
||||||
|
struct WLDAP32_berval **ret = NULL;
|
||||||
|
|
||||||
TRACE( "(%p, %p, %s)\n", ld, message, debugstr_w(attr) );
|
TRACE( "(%p, %p, %s)\n", ld, message, debugstr_w(attr) );
|
||||||
|
|
||||||
if (!ld || !message || !attr) return NULL;
|
if (!ld || !message || !attr || !(attrU = strWtoU( attr ))) return NULL;
|
||||||
|
|
||||||
attrU = strWtoU( attr );
|
if ((retU = ldap_funcs->ldap_get_values_len( ld->ld, message->Request, attrU )))
|
||||||
if (!attrU) return NULL;
|
{
|
||||||
|
ret = bvarrayUtoW( retU );
|
||||||
ret = ldap_get_values_len( ld->ld, message->Request, attrU );
|
bvarrayfreeU( retU );
|
||||||
|
}
|
||||||
|
|
||||||
strfreeU( attrU );
|
strfreeU( attrU );
|
||||||
return (struct WLDAP32_berval **)ret;
|
return ret;
|
||||||
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -321,20 +274,17 @@ struct WLDAP32_berval ** CDECL ldap_get_values_lenW( WLDAP32_LDAP *ld,
|
||||||
* Free an array of berval structures.
|
* Free an array of berval structures.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* vals [I] Array of berval structures.
|
* values [I] Array of berval structures.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: LDAP_SUCCESS
|
* Success: LDAP_SUCCESS
|
||||||
* Failure: An LDAP error code.
|
* Failure: An LDAP error code.
|
||||||
*/
|
*/
|
||||||
ULONG CDECL WLDAP32_ldap_value_free_len( struct WLDAP32_berval **vals )
|
ULONG CDECL WLDAP32_ldap_value_free_len( struct WLDAP32_berval **values )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LDAP
|
TRACE( "(%p)\n", values );
|
||||||
|
|
||||||
TRACE( "(%p)\n", vals );
|
bvarrayfreeW( values );
|
||||||
ldap_value_free_len( (struct berval **)vals );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return WLDAP32_LDAP_SUCCESS;
|
return WLDAP32_LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,11 +293,11 @@ ULONG CDECL WLDAP32_ldap_value_free_len( struct WLDAP32_berval **vals )
|
||||||
*
|
*
|
||||||
* See ldap_value_freeW.
|
* See ldap_value_freeW.
|
||||||
*/
|
*/
|
||||||
ULONG CDECL ldap_value_freeA( PCHAR *vals )
|
ULONG CDECL ldap_value_freeA( char **values )
|
||||||
{
|
{
|
||||||
TRACE( "(%p)\n", vals );
|
TRACE( "(%p)\n", values );
|
||||||
|
|
||||||
strarrayfreeA( vals );
|
strarrayfreeA( values );
|
||||||
return WLDAP32_LDAP_SUCCESS;
|
return WLDAP32_LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,16 +307,16 @@ ULONG CDECL ldap_value_freeA( PCHAR *vals )
|
||||||
* Free an array of string values.
|
* Free an array of string values.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* vals [I] Array of string values.
|
* values [I] Array of string values.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: LDAP_SUCCESS
|
* Success: LDAP_SUCCESS
|
||||||
* Failure: An LDAP error code.
|
* Failure: An LDAP error code.
|
||||||
*/
|
*/
|
||||||
ULONG CDECL ldap_value_freeW( PWCHAR *vals )
|
ULONG CDECL ldap_value_freeW( WCHAR **values )
|
||||||
{
|
{
|
||||||
TRACE( "(%p)\n", vals );
|
TRACE( "(%p)\n", values );
|
||||||
|
|
||||||
strarrayfreeW( vals );
|
strarrayfreeW( values );
|
||||||
return WLDAP32_LDAP_SUCCESS;
|
return WLDAP32_LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1098,6 +1098,16 @@ static inline void strfreeA( char *str )
|
||||||
RtlFreeHeap( GetProcessHeap(), 0, str );
|
RtlFreeHeap( GetProcessHeap(), 0, str );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void strarrayfreeA( char **strarray )
|
||||||
|
{
|
||||||
|
if (strarray)
|
||||||
|
{
|
||||||
|
char **p = strarray;
|
||||||
|
while (*p) strfreeA( *p++ );
|
||||||
|
RtlFreeHeap( GetProcessHeap(), 0, strarray );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void controlfreeA( LDAPControlA *control )
|
static inline void controlfreeA( LDAPControlA *control )
|
||||||
{
|
{
|
||||||
if (control)
|
if (control)
|
||||||
|
|
Loading…
Reference in New Issue