Commit e21c9596 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

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

parent 22b26a20
......@@ -18,49 +18,35 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#ifdef HAVE_LDAP_H
#include <ldap.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h"
#include "winldap_private.h"
#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
#endif
/***********************************************************************
* ldap_dn2ufnA (WLDAP32.@)
*
* See ldap_dn2ufnW.
*/
PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
char * CDECL ldap_dn2ufnA( char *dn )
{
PCHAR ret = NULL;
#ifdef HAVE_LDAP
char *ret;
WCHAR *dnW, *retW;
TRACE( "(%s)\n", debugstr_a(dn) );
dnW = strAtoW( dn );
if (!dnW) return NULL;
if (!(dnW = strAtoW( dn ))) return NULL;
retW = ldap_dn2ufnW( dnW );
ret = strWtoA( retW );
strfreeW( dnW );
ldap_memfreeW( retW );
#endif
return ret;
}
......@@ -73,30 +59,26 @@ PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
* dn [I] DN to convert.
*
* RETURNS
* Success: Pointer to a string containing the user-friendly name.
* Success: Pointer to a string containing the user-friendly name.
* Failure: NULL
*
* NOTES
* Free the string with ldap_memfree.
*/
PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
WCHAR * CDECL ldap_dn2ufnW( WCHAR *dn )
{
PWCHAR ret = NULL;
#ifdef HAVE_LDAP
WCHAR *ret;
char *dnU, *retU;
TRACE( "(%s)\n", debugstr_w(dn) );
dnU = strWtoU( dn );
if (!dnU) return NULL;
if (!(dnU = strWtoU( dn ))) return NULL;
retU = ldap_dn2ufn( dnU );
retU = ldap_funcs->ldap_dn2ufn( dnU );
ret = strUtoW( retU );
strfreeU( dnU );
ldap_memfree( retU );
#endif
ldap_funcs->ldap_memfree( retU );
return ret;
}
......@@ -105,24 +87,20 @@ PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
*
* See ldap_explode_dnW.
*/
PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
char ** CDECL ldap_explode_dnA( char *dn, ULONG notypes )
{
PCHAR *ret = NULL;
#ifdef HAVE_LDAP
char **ret;
WCHAR *dnW, **retW;
TRACE( "(%s, 0x%08x)\n", debugstr_a(dn), notypes );
dnW = strAtoW( dn );
if (!dnW) return NULL;
if (!(dnW = strAtoW( dn ))) return NULL;
retW = ldap_explode_dnW( dnW, notypes );
ret = strarrayWtoA( retW );
strfreeW( dnW );
ldap_value_freeW( retW );
#endif
return ret;
}
......@@ -137,30 +115,26 @@ PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
*
* RETURNS
* Success: Pointer to a NULL-terminated array that contains the DN
* components.
* components.
* Failure: NULL
*
* NOTES
* Free the string array with ldap_value_free.
*/
PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
WCHAR ** CDECL ldap_explode_dnW( WCHAR *dn, ULONG notypes )
{
PWCHAR *ret = NULL;
#ifdef HAVE_LDAP
WCHAR **ret;
char *dnU, **retU;
TRACE( "(%s, 0x%08x)\n", debugstr_w(dn), notypes );
dnU = strWtoU( dn );
if (!dnU) return NULL;
if (!(dnU = strWtoU( dn ))) return NULL;
retU = ldap_explode_dn( dnU, notypes );
retU = ldap_funcs->ldap_explode_dn( dnU, notypes );
ret = strarrayUtoW( retU );
strfreeU( dnU );
ldap_memvfree( (void **)retU );
#endif
ldap_funcs->ldap_memvfree( (void **)retU );
return ret;
}
......@@ -169,11 +143,10 @@ PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
*
* See ldap_get_dnW.
*/
PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
char * CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
PCHAR ret = NULL;
#ifdef HAVE_LDAP
PWCHAR retW;
char *ret;
WCHAR *retW;
TRACE( "(%p, %p)\n", ld, entry );
......@@ -183,8 +156,6 @@ PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
ret = strWtoA( retW );
ldap_memfreeW( retW );
#endif
return ret;
}
......@@ -204,22 +175,19 @@ PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
* NOTES
* Free the string with ldap_memfree.
*/
PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
WCHAR * CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
PWCHAR ret = NULL;
#ifdef HAVE_LDAP
WCHAR *ret;
char *retU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
retU = ldap_get_dn( ld->ld, entry->Request );
retU = ldap_funcs->ldap_get_dn( ld->ld, entry->Request );
ret = strUtoW( retU );
ldap_memfree( retU );
#endif
ldap_funcs->ldap_memfree( retU );
return ret;
}
......@@ -228,34 +196,28 @@ PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
*
* See ldap_ufn2dnW.
*/
ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
ULONG CDECL ldap_ufn2dnA( char *ufn, char **dn )
{
ULONG ret = WLDAP32_LDAP_SUCCESS;
#ifdef HAVE_LDAP
PWCHAR ufnW = NULL, dnW = NULL;
ULONG ret;
WCHAR *ufnW = NULL, *dnW = NULL;
TRACE( "(%s, %p)\n", debugstr_a(ufn), dn );
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
if (ufn) {
ufnW = strAtoW( ufn );
if (!ufnW) return WLDAP32_LDAP_NO_MEMORY;
}
if (ufn && !(ufnW = strAtoW( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_ufn2dnW( ufnW, &dnW );
if (dnW) {
*dn = strWtoA( dnW );
if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
if (dnW)
{
char *str;
if (!(str = strWtoA( dnW ))) ret = WLDAP32_LDAP_NO_MEMORY;
else *dn = str;
}
strfreeW( ufnW );
ldap_memfreeW( dnW );
#endif
return ret;
}
......@@ -266,7 +228,7 @@ ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
*
* PARAMS
* ufn [I] User-friendly name to convert.
* dn [O] Receives a pointer to a string containing the DN.
* dn [O] Receives a pointer to a string containing the DN.
*
* RETURNS
* Success: LDAP_SUCCESS
......@@ -275,10 +237,9 @@ ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
* NOTES
* Free the string with ldap_memfree.
*/
ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
ULONG CDECL ldap_ufn2dnW( WCHAR *ufn, WCHAR **dn )
{
ULONG ret = WLDAP32_LDAP_SUCCESS;
#ifdef HAVE_LDAP
char *ufnU = NULL;
TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
......@@ -286,18 +247,16 @@ ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
if (ufn) {
ufnU = strWtoU( ufn );
if (!ufnU) return WLDAP32_LDAP_NO_MEMORY;
if (ufn)
{
WCHAR *str;
if (!(ufnU = strWtoU( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
/* FIXME: do more than just a copy */
*dn = strUtoW( ufnU );
if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
if (!(str = strUtoW( ufnU ))) ret = WLDAP32_LDAP_NO_MEMORY;
else *dn = str;
}
strfreeU( ufnU );
#endif
return ret;
}
......@@ -369,6 +369,21 @@ int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serve
return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
char * CDECL wrap_ldap_dn2ufn( const char *dn )
{
return ldap_dn2ufn( dn );
}
char ** CDECL wrap_ldap_explode_dn( const char *dn, int notypes )
{
return ldap_explode_dn( dn, notypes );
}
char * CDECL wrap_ldap_get_dn( void *ld, void *entry )
{
return ldap_get_dn( ld, entry );
}
char * CDECL wrap_ldap_first_attribute( void *ld, void *entry, void **ber )
{
return ldap_first_attribute( ld, entry, (BerElement **)ber );
......@@ -389,6 +404,11 @@ void CDECL wrap_ldap_memfree( void *ptr )
return ldap_memfree( ptr );
}
void CDECL wrap_ldap_memvfree( void **ptr )
{
ldap_memvfree( ptr );
}
int CDECL wrap_ldap_msgfree( void *msg )
{
return ldap_msgfree( msg );
......@@ -508,10 +528,14 @@ static const struct ldap_funcs funcs =
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
wrap_ldap_dn2ufn,
wrap_ldap_explode_dn,
wrap_ldap_get_dn,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
wrap_ldap_first_reference,
wrap_ldap_memfree,
wrap_ldap_memvfree,
wrap_ldap_msgfree,
wrap_ldap_next_attribute,
wrap_ldap_next_entry,
......
......@@ -112,10 +112,14 @@ extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDA
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_dn2ufn(const char *) DECLSPEC_HIDDEN;
extern char ** CDECL wrap_ldap_explode_dn(const char *, int) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_get_dn(void *, void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_reference(void *, void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memvfree(void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_msgfree(void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_next_attribute(void *, void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
......@@ -166,10 +170,14 @@ struct ldap_funcs
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
char * (CDECL *ldap_dn2ufn)(const char *);
char ** (CDECL *ldap_explode_dn)(const char *, int);
char * (CDECL *ldap_get_dn)(void *, void *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
void (CDECL *ldap_memvfree)(void **);
int (CDECL *ldap_msgfree)(void *);
char * (CDECL *ldap_next_attribute)(void *, void *, void *);
void * (CDECL *ldap_next_entry)(void *, void *);
......
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