Commit 2be395db authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

Implement LdapUnicodeToUTF8, LdapUTF8ToUnicode,

ldap_dn2ufn*, ldap_explode_dn*, ldap_get_dn*, ldap_memfree*, ldap_ufn2dn* and ldap_value_free*.
parent 9332f2bb
...@@ -11,9 +11,11 @@ C_SRCS = \ ...@@ -11,9 +11,11 @@ C_SRCS = \
ber.c \ ber.c \
bind.c \ bind.c \
compare.c \ compare.c \
dn.c \
error.c \ error.c \
init.c \ init.c \
main.c \ main.c \
misc.c \
search.c search.c
RC_SRCS = wldap32.rc RC_SRCS = wldap32.rc
......
/*
* WLDAP32 - LDAP support for Wine
*
* Copyright 2005 Hans Leidekker
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#ifdef HAVE_LDAP_H
#include <ldap.h>
#else
#define LDAP_SUCCESS 0x00
#endif
#include "winldap_private.h"
#include "wldap32.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
PCHAR ldap_dn2ufnA( PCHAR dn )
{
PCHAR ret = NULL;
#ifdef HAVE_LDAP
WCHAR *dnW, *retW;
TRACE( "(%s)\n", debugstr_a(dn) );
dnW = strAtoW( dn );
if (!dnW) return NULL;
retW = ldap_dn2ufnW( dnW );
ret = strWtoA( retW );
strfreeW( dnW );
ldap_memfreeW( retW );
#endif
return ret;
}
PWCHAR ldap_dn2ufnW( PWCHAR dn )
{
PWCHAR ret = NULL;
#ifdef HAVE_LDAP
char *dnU, *retU;
TRACE( "(%s)\n", debugstr_w(dn) );
dnU = strWtoU( dn );
if (!dnU) return NULL;
retU = ldap_dn2ufn( dnU );
ret = strUtoW( retU );
strfreeU( dnU );
ldap_memfree( retU );
#endif
return ret;
}
PCHAR *ldap_explode_dnA( PCHAR dn, ULONG notypes )
{
PCHAR *ret = NULL;
#ifdef HAVE_LDAP
WCHAR *dnW, **retW;
TRACE( "(%s, 0x%08lx)\n", debugstr_a(dn), notypes );
dnW = strAtoW( dn );
if (!dnW) return NULL;
retW = ldap_explode_dnW( dnW, notypes );
ret = strarrayWtoA( retW );
strfreeW( dnW );
ldap_value_freeW( retW );
#endif
return ret;
}
PWCHAR *ldap_explode_dnW( PWCHAR dn, ULONG notypes )
{
PWCHAR *ret = NULL;
#ifdef HAVE_LDAP
char *dnU, **retU;
TRACE( "(%s, 0x%08lx)\n", debugstr_w(dn), notypes );
dnU = strWtoU( dn );
if (!dnU) return NULL;
retU = ldap_explode_dn( dnU, notypes );
ret = strarrayUtoW( retU );
strfreeU( dnU );
ldap_value_free( retU );
#endif
return ret;
}
PCHAR ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
PCHAR ret = NULL;
#ifdef HAVE_LDAP
PWCHAR retW;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
retW = ldap_get_dnW( ld, entry );
ret = strWtoA( retW );
ldap_memfreeW( retW );
#endif
return ret;
}
PWCHAR ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
PWCHAR ret = NULL;
#ifdef HAVE_LDAP
char *retU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
retU = ldap_get_dn( ld, entry );
ret = strUtoW( retU );
ldap_memfree( retU );
#endif
return ret;
}
ULONG ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
{
ULONG ret = LDAP_SUCCESS;
#ifdef HAVE_LDAP
PWCHAR 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;
}
ret = ldap_ufn2dnW( ufnW, &dnW );
if (dnW) {
*dn = strWtoA( dnW );
if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
}
strfreeW( ufnW );
ldap_memfreeW( dnW );
#endif
return ret;
}
ULONG ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
{
ULONG ret = LDAP_SUCCESS;
#ifdef HAVE_LDAP
char *ufnU = NULL;
TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
if (ufn) {
ufnU = strWtoU( ufn );
if (!ufnU) return WLDAP32_LDAP_NO_MEMORY;
/* FIXME: do more than just a copy */
*dn = strUtoW( ufnU );
if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
}
strfreeU( ufnU );
#endif
return ret;
}
/*
* WLDAP32 - LDAP support for Wine
*
* Copyright 2005 Hans Leidekker
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#ifdef HAVE_LDAP_H
#include <ldap.h>
#else
#define LDAP_SUCCESS 0x00
#endif
#include "winldap_private.h"
#include "wldap32.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
void ldap_memfreeA( PCHAR block )
{
TRACE( "(%p)\n", block );
strfreeA( block );
}
void ldap_memfreeW( PWCHAR block )
{
TRACE( "(%p)\n", block );
strfreeW( block );
}
ULONG ldap_value_freeA( PCHAR *vals )
{
TRACE( "(%p)\n", vals );
strarrayfreeA( vals );
return LDAP_SUCCESS;
}
ULONG ldap_value_freeW( PWCHAR *vals )
{
TRACE( "(%p)\n", vals );
strarrayfreeW( vals );
return LDAP_SUCCESS;
}
int LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
{
return WideCharToMultiByte( CP_UTF8, 0, src, srclen, dst, dstlen, NULL, NULL );
}
int LdapUTF8ToUnicode( LPCSTR src, int srclen, LPWSTR dst, int dstlen )
{
return MultiByteToWideChar( CP_UTF8, 0, src, srclen, dst, dstlen );
}
...@@ -128,10 +128,18 @@ ULONG ldap_compare_ext_sA(WLDAP32_LDAP*,PCHAR,PCHAR,PCHAR,struct WLDAP32_berval* ...@@ -128,10 +128,18 @@ ULONG ldap_compare_ext_sA(WLDAP32_LDAP*,PCHAR,PCHAR,PCHAR,struct WLDAP32_berval*
ULONG ldap_compare_ext_sW(WLDAP32_LDAP*,PWCHAR,PWCHAR,PWCHAR,struct WLDAP32_berval*,PLDAPControlW*,PLDAPControlW*); ULONG ldap_compare_ext_sW(WLDAP32_LDAP*,PWCHAR,PWCHAR,PWCHAR,struct WLDAP32_berval*,PLDAPControlW*,PLDAPControlW*);
ULONG ldap_compare_sA(WLDAP32_LDAP*,PCHAR,PCHAR,PCHAR); ULONG ldap_compare_sA(WLDAP32_LDAP*,PCHAR,PCHAR,PCHAR);
ULONG ldap_compare_sW(WLDAP32_LDAP*,PWCHAR,PWCHAR,PWCHAR); ULONG ldap_compare_sW(WLDAP32_LDAP*,PWCHAR,PWCHAR,PWCHAR);
PCHAR ldap_dn2ufnA(PCHAR);
PWCHAR ldap_dn2ufnW(PWCHAR);
PCHAR ldap_err2stringA(ULONG); PCHAR ldap_err2stringA(ULONG);
PWCHAR ldap_err2stringW(ULONG); PWCHAR ldap_err2stringW(ULONG);
PCHAR *ldap_explode_dnA(PCHAR,ULONG);
PWCHAR *ldap_explode_dnW(PWCHAR,ULONG);
PCHAR ldap_get_dnA(WLDAP32_LDAP*,WLDAP32_LDAPMessage*);
PWCHAR ldap_get_dnW(WLDAP32_LDAP*,WLDAP32_LDAPMessage*);
WLDAP32_LDAP *ldap_initA(const PCHAR,ULONG); WLDAP32_LDAP *ldap_initA(const PCHAR,ULONG);
WLDAP32_LDAP *ldap_initW(const PWCHAR,ULONG); WLDAP32_LDAP *ldap_initW(const PWCHAR,ULONG);
void ldap_memfreeA(PCHAR);
void ldap_memfreeW(PWCHAR);
WLDAP32_LDAP *ldap_openA(PCHAR,ULONG); WLDAP32_LDAP *ldap_openA(PCHAR,ULONG);
WLDAP32_LDAP *ldap_openW(PWCHAR,ULONG); WLDAP32_LDAP *ldap_openW(PWCHAR,ULONG);
void WLDAP32_ldap_perror(WLDAP32_LDAP*,const PCHAR); void WLDAP32_ldap_perror(WLDAP32_LDAP*,const PCHAR);
...@@ -162,8 +170,12 @@ ULONG ldap_simple_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR); ...@@ -162,8 +170,12 @@ ULONG ldap_simple_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR);
ULONG ldap_simple_bind_sW(WLDAP32_LDAP*,PWCHAR,PWCHAR); ULONG ldap_simple_bind_sW(WLDAP32_LDAP*,PWCHAR,PWCHAR);
ULONG ldap_start_tls_sA(WLDAP32_PLDAP,PULONG,WLDAP32_LDAPMessage**,PLDAPControlA*,PLDAPControlA*); ULONG ldap_start_tls_sA(WLDAP32_PLDAP,PULONG,WLDAP32_LDAPMessage**,PLDAPControlA*,PLDAPControlA*);
ULONG ldap_start_tls_sW(WLDAP32_PLDAP,PULONG,WLDAP32_LDAPMessage**,PLDAPControlW*,PLDAPControlW*); ULONG ldap_start_tls_sW(WLDAP32_PLDAP,PULONG,WLDAP32_LDAPMessage**,PLDAPControlW*,PLDAPControlW*);
ULONG ldap_ufn2dnA(PCHAR,PCHAR*);
ULONG ldap_ufn2dnW(PWCHAR,PWCHAR*);
ULONG WLDAP32_ldap_unbind(WLDAP32_LDAP*); ULONG WLDAP32_ldap_unbind(WLDAP32_LDAP*);
ULONG WLDAP32_ldap_unbind_s(WLDAP32_LDAP*); ULONG WLDAP32_ldap_unbind_s(WLDAP32_LDAP*);
ULONG ldap_value_freeA(PCHAR*);
ULONG ldap_value_freeW(PWCHAR*);
ULONG LdapGetLastError(void); ULONG LdapGetLastError(void);
ULONG LdapMapErrorToWin32(ULONG); ULONG LdapMapErrorToWin32(ULONG);
......
@ stub LdapGetLastError @ stub LdapGetLastError
@ cdecl LdapMapErrorToWin32(long) @ cdecl LdapMapErrorToWin32(long)
@ cdecl LdapUnicodeToUTF8(wstr long ptr long)
@ cdecl LdapUTF8ToUnicode(str long ptr long)
@ cdecl ber_alloc_t(long) @ cdecl ber_alloc_t(long)
@ cdecl ber_bvdup(ptr) @ cdecl ber_bvdup(ptr)
@ cdecl ber_bvecfree(ptr) @ cdecl ber_bvecfree(ptr)
...@@ -31,12 +33,24 @@ ...@@ -31,12 +33,24 @@
@ cdecl ldap_compare_s(ptr str str str) ldap_compare_sA @ cdecl ldap_compare_s(ptr str str str) ldap_compare_sA
@ cdecl ldap_compare_sA(ptr str str str) @ cdecl ldap_compare_sA(ptr str str str)
@ cdecl ldap_compare_sW(ptr wstr wstr wstr) @ cdecl ldap_compare_sW(ptr wstr wstr wstr)
@ cdecl ldap_dn2ufn(str) ldap_dn2ufnA
@ cdecl ldap_dn2ufnA(str)
@ cdecl ldap_dn2ufnW(wstr)
@ cdecl ldap_err2string(long) ldap_err2stringA @ cdecl ldap_err2string(long) ldap_err2stringA
@ cdecl ldap_err2stringA(long) @ cdecl ldap_err2stringA(long)
@ cdecl ldap_err2stringW(long) @ cdecl ldap_err2stringW(long)
@ cdecl ldap_explode_dn(str long) ldap_explode_dnA
@ cdecl ldap_explode_dnA(str long)
@ cdecl ldap_explode_dnW(wstr long)
@ cdecl ldap_get_dn(ptr ptr) ldap_get_dnA
@ cdecl ldap_get_dnA(ptr ptr)
@ cdecl ldap_get_dnW(ptr ptr)
@ cdecl ldap_init(str long) ldap_initA @ cdecl ldap_init(str long) ldap_initA
@ cdecl ldap_initA(str long) @ cdecl ldap_initA(str long)
@ cdecl ldap_initW(wstr long) @ cdecl ldap_initW(wstr long)
@ cdecl ldap_memfree(ptr) ldap_memfreeA
@ cdecl ldap_memfreeA(ptr)
@ cdecl ldap_memfreeW(ptr)
@ cdecl ldap_open(str long) ldap_openA @ cdecl ldap_open(str long) ldap_openA
@ cdecl ldap_openA(str long) @ cdecl ldap_openA(str long)
@ cdecl ldap_openW(wstr long) @ cdecl ldap_openW(wstr long)
...@@ -71,3 +85,9 @@ ...@@ -71,3 +85,9 @@
@ cdecl ldap_start_tls_sW(ptr ptr ptr ptr ptr) @ cdecl ldap_start_tls_sW(ptr ptr ptr ptr ptr)
@ cdecl ldap_unbind(ptr) WLDAP32_ldap_unbind @ cdecl ldap_unbind(ptr) WLDAP32_ldap_unbind
@ cdecl ldap_unbind_s(ptr) WLDAP32_ldap_unbind_s @ cdecl ldap_unbind_s(ptr) WLDAP32_ldap_unbind_s
@ cdecl ldap_ufn2dn(str ptr) ldap_ufn2dnA
@ cdecl ldap_ufn2dnA(str ptr)
@ cdecl ldap_ufn2dnW(wstr ptr)
@ cdecl ldap_value_free(ptr) ldap_value_freeA
@ cdecl ldap_value_freeA(ptr)
@ cdecl ldap_value_freeW(ptr)
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