Commit 0f3f49e1 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

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

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