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

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2021-04-15 12:20:04 +02:00 committed by Alexandre Julliard
parent d8a2463abc
commit 0f3f49e12c
3 changed files with 37 additions and 37 deletions

View File

@ -18,47 +18,41 @@
* 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 "winuser.h"
#include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h"
#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
extern HINSTANCE hwldap32 DECLSPEC_HIDDEN;
ULONG map_error( int error )
{
switch (error)
{
#ifdef HAVE_LDAP_H
case LDAP_SERVER_DOWN: return WLDAP32_LDAP_SERVER_DOWN;
case LDAP_LOCAL_ERROR: return WLDAP32_LDAP_LOCAL_ERROR;
case LDAP_DECODING_ERROR: return WLDAP32_LDAP_DECODING_ERROR;
case LDAP_TIMEOUT: return WLDAP32_LDAP_TIMEOUT;
case LDAP_AUTH_UNKNOWN: return WLDAP32_LDAP_AUTH_UNKNOWN;
case LDAP_FILTER_ERROR: return WLDAP32_LDAP_FILTER_ERROR;
case LDAP_USER_CANCELLED: return WLDAP32_LDAP_USER_CANCELLED;
case LDAP_PARAM_ERROR: return WLDAP32_LDAP_PARAM_ERROR;
case LDAP_NO_MEMORY: return WLDAP32_LDAP_NO_MEMORY;
case LDAP_CONNECT_ERROR: return WLDAP32_LDAP_CONNECT_ERROR;
case LDAP_NOT_SUPPORTED: return WLDAP32_LDAP_NOT_SUPPORTED;
case LDAP_CONTROL_NOT_FOUND: return WLDAP32_LDAP_CONTROL_NOT_FOUND;
case LDAP_NO_RESULTS_RETURNED: return WLDAP32_LDAP_NO_RESULTS_RETURNED;
case LDAP_MORE_RESULTS_TO_RETURN: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN;
case LDAP_CLIENT_LOOP: return WLDAP32_LDAP_CLIENT_LOOP;
case LDAP_REFERRAL_LIMIT_EXCEEDED: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED;
#endif
case 0: return WLDAP32_LDAP_SUCCESS;
case -1: return WLDAP32_LDAP_SERVER_DOWN;
case -2: return WLDAP32_LDAP_LOCAL_ERROR;
case -3: return WLDAP32_LDAP_ENCODING_ERROR;
case -4: return WLDAP32_LDAP_DECODING_ERROR;
case -5: return WLDAP32_LDAP_TIMEOUT;
case -6: return WLDAP32_LDAP_AUTH_UNKNOWN;
case -7: return WLDAP32_LDAP_FILTER_ERROR;
case -8: return WLDAP32_LDAP_USER_CANCELLED;
case -9: return WLDAP32_LDAP_PARAM_ERROR;
case -10: return WLDAP32_LDAP_NO_MEMORY;
case -11: return WLDAP32_LDAP_CONNECT_ERROR;
case -12: return WLDAP32_LDAP_NOT_SUPPORTED;
case -13: return WLDAP32_LDAP_CONTROL_NOT_FOUND;
case -14: return WLDAP32_LDAP_NO_RESULTS_RETURNED;
case -15: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN;
case -16: return WLDAP32_LDAP_CLIENT_LOOP;
case -17: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED;
default: return error;
}
}
@ -68,7 +62,7 @@ ULONG map_error( int error )
*
* See ldap_err2stringW.
*/
PCHAR CDECL ldap_err2stringA( ULONG err )
char * CDECL ldap_err2stringA( ULONG err )
{
static char buf[256] = "";
@ -98,7 +92,7 @@ PCHAR CDECL ldap_err2stringA( ULONG err )
* The returned string is statically allocated, you must not
* free this string.
*/
PWCHAR CDECL ldap_err2stringW( ULONG err )
WCHAR * CDECL ldap_err2stringW( ULONG err )
{
static WCHAR buf[256] = { 0 };
@ -151,22 +145,19 @@ void CDECL WLDAP32_ldap_perror( WLDAP32_LDAP *ld, const PCHAR msg )
*/
ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res, ULONG free )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret;
int error;
TRACE( "(%p, %p, 0x%08x)\n", ld, res, free );
if (!ld || !res) return ~0u;
ret = ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free );
if (ret == LDAP_SUCCESS)
ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free ) );
if (ret == WLDAP32_LDAP_SUCCESS)
ret = error;
else
ret = ~0u;
#endif
return ret;
}
@ -303,7 +294,6 @@ ULONG CDECL LdapMapErrorToWin32( ULONG err )
{
TRACE( "(0x%08x)\n", err );
if (err >= ARRAY_SIZE( WLDAP32_errormap ))
return ERROR_DS_GENERIC_ERROR;
if (err >= ARRAY_SIZE( WLDAP32_errormap )) return ERROR_DS_GENERIC_ERROR;
return WLDAP32_errormap[err];
}

View File

@ -357,6 +357,12 @@ void CDECL wrap_ldap_memfree( void *ptr )
return ldap_memfree( ptr );
}
int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matcheddn, char **errmsg,
char ***referrals, LDAPControlU ***serverctrls, int free )
{
return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
}
int CDECL wrap_ldap_sasl_bind( void *ld, const char *dn, const char *mech, struct bervalU *cred,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, int *msgid )
{
@ -426,6 +432,7 @@ static const struct ldap_funcs funcs =
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
wrap_ldap_memfree,
wrap_ldap_parse_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
wrap_ldap_sasl_interactive_bind_s,

View File

@ -104,6 +104,8 @@ extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPContro
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 void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
int) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
@ -141,6 +143,7 @@ struct ldap_funcs
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_memfree)(void *);
int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
int (CDECL *ldap_sasl_bind_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,