Commit b2009d02 authored by Alexandre Julliard's avatar Alexandre Julliard

wldap32: Convert the Unix library to the __wine_unix_call interface.

parent 3cc3dd78
MODULE = wldap32.dll
UNIXLIB = wldap32.so
IMPORTLIB = wldap32
IMPORTS = user32
EXTRAINCL = $(LDAP_CFLAGS)
......
......@@ -157,8 +157,11 @@ ULONG CDECL ldap_add_extW( LDAP *ld, WCHAR *dn, LDAPModW **attrs, LDAPControlW *
if (attrs && !(attrsU = modarrayWtoU( attrs ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_add_ext( CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU, message ) );
else
{
struct ldap_add_ext_params params = { CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU, message };
ret = map_error( LDAP_CALL( ldap_add_ext, &params ));
}
exit:
free( dnU );
......@@ -237,8 +240,11 @@ ULONG CDECL ldap_add_ext_sW( LDAP *ld, WCHAR *dn, LDAPModW **attrs, LDAPControlW
if (attrs && !(attrsU = modarrayWtoU( attrs ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_add_ext_s( CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU ) );
else
{
struct ldap_add_ext_s_params params = { CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU };
ret = map_error( LDAP_CALL( ldap_add_ext_s, &params ));
}
exit:
free( dnU );
......
......@@ -49,9 +49,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
BerElement * CDECL ber_alloc_t( int options )
{
BerElement *ret;
struct ber_alloc_t_params params;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
if (ldap_funcs->fn_ber_alloc_t( options, (void **)&BER(ret) ))
params.options = options;
params.ret = (void **)&BER(ret);
if (LDAP_CALL( ber_alloc_t, &params ))
{
free( ret );
return NULL;
......@@ -142,7 +145,8 @@ void CDECL ber_bvfree( BERVAL *berval )
*/
ULONG CDECL ber_first_element( BerElement *ber, ULONG *len, char **opaque )
{
return ldap_funcs->fn_ber_first_element( BER(ber), len, opaque );
struct ber_first_element_params params = { BER(ber), len, opaque };
return LDAP_CALL( ber_first_element, &params );
}
......@@ -166,11 +170,12 @@ int CDECL ber_flatten( BerElement *ber, BERVAL **berval )
{
struct bervalU *bervalU;
struct berval *bervalW;
struct ber_flatten_params params = { BER(ber), &bervalU };
if (ldap_funcs->fn_ber_flatten( BER(ber), &bervalU )) return LBER_ERROR;
if (LDAP_CALL( ber_flatten, &params )) return LBER_ERROR;
if (!(bervalW = bervalUtoW( bervalU ))) return LBER_ERROR;
ldap_funcs->fn_ber_bvfree( bervalU );
LDAP_CALL( ber_bvfree, bervalU );
if (!bervalW) return LBER_ERROR;
*berval = bervalW;
return 0;
......@@ -195,7 +200,8 @@ int CDECL ber_flatten( BerElement *ber, BERVAL **berval )
*/
void CDECL ber_free( BerElement *ber, int freebuf )
{
ldap_funcs->fn_ber_free( BER(ber), freebuf );
struct ber_free_params params = { BER(ber), freebuf };
LDAP_CALL( ber_free, &params );
free( ber );
}
......@@ -219,6 +225,7 @@ BerElement * CDECL ber_init( BERVAL *berval )
{
struct bervalU *bervalU;
BerElement *ret;
struct ber_init_params params;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
if (!(bervalU = bervalWtoU( berval )))
......@@ -226,7 +233,9 @@ BerElement * CDECL ber_init( BERVAL *berval )
free( ret );
return NULL;
}
if (ldap_funcs->fn_ber_init( bervalU, (void **)&BER(ret) ))
params.berval = bervalU;
params.ret = (void **)&BER(ret);
if (LDAP_CALL( ber_init, &params ))
{
free( ret );
ret = NULL;
......@@ -256,7 +265,8 @@ BerElement * CDECL ber_init( BERVAL *berval )
*/
ULONG CDECL ber_next_element( BerElement *ber, ULONG *len, char *opaque )
{
return ldap_funcs->fn_ber_next_element( BER(ber), len, opaque );
struct ber_next_element_params params = { BER(ber), len, opaque };
return LDAP_CALL( ber_next_element, &params );
}
......@@ -275,7 +285,8 @@ ULONG CDECL ber_next_element( BerElement *ber, ULONG *len, char *opaque )
*/
ULONG CDECL ber_peek_tag( BerElement *ber, ULONG *len )
{
return ldap_funcs->fn_ber_peek_tag( BER(ber), len );
struct ber_peek_tag_params params = { BER(ber), len };
return LDAP_CALL( ber_peek_tag, &params );
}
......@@ -294,7 +305,8 @@ ULONG CDECL ber_peek_tag( BerElement *ber, ULONG *len )
*/
ULONG CDECL ber_skip_tag( BerElement *ber, ULONG *len )
{
return ldap_funcs->fn_ber_skip_tag( BER(ber), len );
struct ber_skip_tag_params params = { BER(ber), len };
return LDAP_CALL( ber_skip_tag, &params );
}
......@@ -326,36 +338,29 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
va_start( list, fmt );
while (*fmt)
{
struct ber_printf_params params = { BER(ber), new_fmt };
new_fmt[0] = *fmt++;
switch (new_fmt[0])
{
case 'b':
case 'e':
case 'i':
{
int i = va_arg( list, int );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, i, 0 );
params.arg1 = va_arg( list, int );
ret = LDAP_CALL( ber_printf, &params );
break;
}
case 'o':
case 's':
{
char *str = va_arg( list, char * );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)str, 0 );
params.arg1 = (ULONG_PTR)va_arg( list, char * );
ret = LDAP_CALL( ber_printf, &params );
break;
}
case 't':
{
unsigned int tag = va_arg( list, unsigned int );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, tag, 0 );
params.arg1 = va_arg( list, unsigned int );
ret = LDAP_CALL( ber_printf, &params );
break;
}
case 'v':
{
char **array = va_arg( list, char ** );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)array, 0 );
params.arg1 = (ULONG_PTR)va_arg( list, char ** );
ret = LDAP_CALL( ber_printf, &params );
break;
}
case 'V':
{
struct berval **array = va_arg( list, struct berval ** );
......@@ -365,16 +370,17 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
ret = -1;
break;
}
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)arrayU, 0 );
params.arg1 = (ULONG_PTR)arrayU;
ret = LDAP_CALL( ber_printf, &params );
bvarrayfreeU( arrayU );
break;
}
case 'X':
{
char *str = va_arg( list, char * );
int len = va_arg( list, int );
params.arg1 = (ULONG_PTR)va_arg( list, char * );
params.arg2 = va_arg( list, int );
new_fmt[0] = 'B'; /* 'X' is deprecated */
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)str, len );
ret = LDAP_CALL( ber_printf, &params );
break;
}
case 'n':
......@@ -382,7 +388,7 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
case '}':
case '[':
case ']':
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, 0, 0 );
ret = LDAP_CALL( ber_printf, &params );
break;
default:
......@@ -425,71 +431,74 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
va_start( list, fmt );
while (*fmt)
{
struct ber_scanf_params params = { BER(ber), new_fmt };
new_fmt[0] = *fmt++;
switch (new_fmt[0])
{
case 'a':
{
char *str, **ptr = va_arg( list, char ** );
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &str, NULL )) == -1) break;
params.arg1 = &str;
if ((ret = LDAP_CALL( ber_scanf, &params )) == -1) break;
*ptr = strdupU( str );
ldap_funcs->fn_ldap_memfree( str );
LDAP_CALL( ldap_memfree, str );
break;
}
case 'b':
case 'e':
case 'i':
{
int *i = va_arg( list, int * );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, i, NULL );
params.arg1 = va_arg( list, int * );
ret = LDAP_CALL( ber_scanf, &params );
break;
}
case 't':
{
unsigned int *tag = va_arg( list, unsigned int * );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, tag, NULL );
params.arg1 = va_arg( list, unsigned int * );
ret = LDAP_CALL( ber_scanf, &params );
break;
}
case 'v':
{
char *str, **arrayU, **ptr, ***array = va_arg( list, char *** );
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &arrayU, NULL )) == -1) break;
params.arg1 = &arrayU;
if ((ret = LDAP_CALL( ber_scanf, &params )) == -1) break;
*array = strarrayUtoU( arrayU );
ptr = arrayU;
while ((str = *ptr))
{
ldap_funcs->fn_ldap_memfree( str );
LDAP_CALL( ldap_memfree, str );
ptr++;
}
ldap_funcs->fn_ldap_memfree( arrayU );
LDAP_CALL( ldap_memfree, arrayU );
break;
}
case 'B':
{
char *strU, **str = va_arg( list, char ** );
int *len = va_arg( list, int * );
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &strU, len )) == -1) break;
params.arg1 = &strU;
params.arg2 = len;
if ((ret = LDAP_CALL( ber_scanf, &params )) == -1) break;
*str = malloc( *len );
memcpy( *str, strU, *len );
ldap_funcs->fn_ldap_memfree( strU );
LDAP_CALL( ldap_memfree, strU );
break;
}
case 'O':
{
struct berval **berval = va_arg( list, struct berval ** );
struct bervalU *bervalU;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &bervalU, NULL )) == -1) break;
params.arg1 = &bervalU;
if ((ret = LDAP_CALL( ber_scanf, &params )) == -1) break;
*berval = bervalUtoW( bervalU );
ldap_funcs->fn_ber_bvfree( bervalU );
LDAP_CALL( ber_bvfree, bervalU );
break;
}
case 'V':
{
struct berval ***array = va_arg( list, struct berval *** );
struct bervalU **arrayU;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &arrayU, NULL )) == -1) break;
params.arg1 = &arrayU;
if ((ret = LDAP_CALL( ber_scanf, &params )) == -1) break;
*array = bvarrayUtoW( arrayU );
ldap_funcs->fn_ber_bvecfree( arrayU );
LDAP_CALL( ber_bvecfree, arrayU );
break;
}
case 'n':
......@@ -498,7 +507,7 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
case '}':
case '[':
case ']':
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, NULL, NULL );
ret = LDAP_CALL( ber_scanf, &params );
break;
default:
......
......@@ -94,7 +94,10 @@ ULONG CDECL ldap_bindW( LDAP *ld, WCHAR *dn, WCHAR *cred, ULONG method )
pwd.bv_val = credU;
}
ret = map_error( ldap_funcs->fn_ldap_sasl_bind( CTX(ld), dnU, 0, &pwd, NULL, NULL, &msg ) );
{
struct ldap_sasl_bind_params params = { CTX(ld), dnU, 0, &pwd, NULL, NULL, &msg };
ret = map_error( LDAP_CALL( ldap_sasl_bind, &params ));
}
if (ret == LDAP_SUCCESS)
ret = msg;
else
......@@ -173,7 +176,10 @@ ULONG CDECL ldap_bind_sW( LDAP *ld, WCHAR *dn, WCHAR *cred, ULONG method )
pwd.bv_val = credU;
}
ret = map_error( ldap_funcs->fn_ldap_sasl_bind_s( CTX(ld), dnU, 0, &pwd, NULL, NULL, NULL ) );
{
struct ldap_sasl_bind_s_params params = { CTX(ld), dnU, 0, &pwd, NULL, NULL, NULL };
ret = map_error( LDAP_CALL( ldap_sasl_bind_s, &params ));
}
}
else if (method == LDAP_AUTH_NEGOTIATE)
{
......@@ -197,10 +203,13 @@ ULONG CDECL ldap_bind_sW( LDAP *ld, WCHAR *dn, WCHAR *cred, ULONG method )
idU.Password = (unsigned char *)strnWtoU( id->Password, id->PasswordLength, &idU.PasswordLength );
}
ret = map_error( ldap_funcs->fn_ldap_sasl_interactive_bind_s( CTX(ld),
{
struct ldap_sasl_interactive_bind_s_params params = { CTX(ld),
NULL /* server will ignore DN anyway */,
NULL /* query supportedSASLMechanisms */,
NULL, NULL, 2 /* LDAP_SASL_QUIET */, &idU ) );
NULL, NULL, 2 /* LDAP_SASL_QUIET */, &idU };
ret = map_error( LDAP_CALL( ldap_sasl_interactive_bind_s, &params ));
}
if (id && (id->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI))
{
......@@ -296,12 +305,13 @@ ULONG CDECL ldap_sasl_bindW( LDAP *ld, const PWCHAR dn, const PWCHAR mechanism,
if (!(mechanismU = strWtoU( mechanism ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else
{
struct ldap_sasl_bind_params params = { CTX(ld), dnU, mechanismU, &credU, serverctrlsU, clientctrlsU, message };
credU.bv_len = cred->bv_len;
credU.bv_val = cred->bv_val;
ret = map_error( ldap_funcs->fn_ldap_sasl_bind( CTX(ld), dnU, mechanismU, &credU, serverctrlsU, clientctrlsU,
message ) );
ret = map_error( LDAP_CALL( ldap_sasl_bind, &params ));
}
exit:
free( dnU );
......@@ -386,14 +396,16 @@ ULONG CDECL ldap_sasl_bind_sW( LDAP *ld, const PWCHAR dn, const PWCHAR mechanism
credU.bv_len = cred->bv_len;
credU.bv_val = cred->bv_val;
ret = map_error( ldap_funcs->fn_ldap_sasl_bind_s( CTX(ld), dnU, mechanismU, &credU, serverctrlsU, clientctrlsU,
&dataU ) );
{
struct ldap_sasl_bind_s_params params = { CTX(ld), dnU, mechanismU, &credU, serverctrlsU, clientctrlsU, &dataU };
ret = map_error( LDAP_CALL( ldap_sasl_bind_s, &params ));
}
if (ret == LDAP_SUCCESS)
{
BERVAL *ptr;
if (!(ptr = bervalUtoW( dataU ))) ret = LDAP_NO_MEMORY;
else *serverdata = ptr;
ldap_funcs->fn_ber_bvfree( dataU );
LDAP_CALL( ber_bvfree, dataU );
}
exit:
......@@ -465,7 +477,10 @@ ULONG CDECL ldap_simple_bindW( LDAP *ld, WCHAR *dn, WCHAR *passwd )
pwd.bv_val = passwdU;
}
ret = map_error( ldap_funcs->fn_ldap_sasl_bind( CTX(ld), dnU, 0, &pwd, NULL, NULL, &msg ) );
{
struct ldap_sasl_bind_params params = { CTX(ld), dnU, 0, &pwd, NULL, NULL, &msg };
ret = map_error( LDAP_CALL( ldap_sasl_bind, &params ));
}
if (ret == LDAP_SUCCESS)
ret = msg;
else
......@@ -537,7 +552,10 @@ ULONG CDECL ldap_simple_bind_sW( LDAP *ld, WCHAR *dn, WCHAR *passwd )
pwd.bv_val = passwdU;
}
ret = map_error( ldap_funcs->fn_ldap_sasl_bind_s( CTX(ld), dnU, 0, &pwd, NULL, NULL, NULL ) );
{
struct ldap_sasl_bind_s_params params = { CTX(ld), dnU, 0, &pwd, NULL, NULL, NULL };
ret = map_error( LDAP_CALL( ldap_sasl_bind_s, &params ));
}
exit:
free( dnU );
......@@ -563,10 +581,14 @@ ULONG CDECL ldap_unbind( LDAP *ld )
TRACE( "(%p)\n", ld );
if (!ld) return LDAP_PARAM_ERROR;
if (ld)
{
struct ldap_unbind_ext_params params = { CTX(ld), NULL, NULL };
ret = map_error( LDAP_CALL( ldap_unbind_ext, &params ));
}
else return LDAP_PARAM_ERROR;
ret = map_error( ldap_funcs->fn_ldap_unbind_ext( CTX(ld), NULL, NULL ));
if (SERVER_CTRLS(ld)) ldap_funcs->fn_ldap_value_free_len( SERVER_CTRLS(ld) );
if (SERVER_CTRLS(ld)) LDAP_CALL( ldap_value_free_len, SERVER_CTRLS(ld) );
free( ld );
return ret;
......@@ -590,10 +612,14 @@ ULONG CDECL ldap_unbind_s( LDAP *ld )
TRACE( "(%p)\n", ld );
if (!ld) return LDAP_PARAM_ERROR;
if (ld)
{
struct ldap_unbind_ext_s_params params = { CTX(ld), NULL, NULL };
ret = map_error( LDAP_CALL( ldap_unbind_ext_s, &params ));
}
else return LDAP_PARAM_ERROR;
ret = map_error( ldap_funcs->fn_ldap_unbind_ext_s( CTX(ld), NULL, NULL ) );
if (SERVER_CTRLS(ld)) ldap_funcs->fn_ldap_value_free_len( SERVER_CTRLS(ld) );
if (SERVER_CTRLS(ld)) LDAP_CALL( ldap_value_free_len, SERVER_CTRLS(ld) );
free( ld );
return ret;
......
......@@ -170,9 +170,12 @@ ULONG CDECL ldap_compare_extW( LDAP *ld, WCHAR *dn, WCHAR *attr, WCHAR *value, s
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else
{
struct ldap_compare_ext_params params = { CTX(ld), dnU, attrU, dataU ? dataU : &val, serverctrlsU, clientctrlsU, message };
ret = map_error( LDAP_CALL( ldap_compare_ext, &params ));
}
ret = map_error( ldap_funcs->fn_ldap_compare_ext( CTX(ld), dnU, attrU, dataU ? dataU : &val, serverctrlsU,
clientctrlsU, message ) );
exit:
free( dnU );
free( attrU );
......@@ -268,9 +271,11 @@ ULONG CDECL ldap_compare_ext_sW( LDAP *ld, WCHAR *dn, WCHAR *attr, WCHAR *value,
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_compare_ext_s( CTX(ld), dnU, attrU, dataU ? dataU : &val, serverctrlsU,
clientctrlsU ) );
else
{
struct ldap_compare_ext_s_params params = { CTX(ld), dnU, attrU, dataU ? dataU : &val, serverctrlsU, clientctrlsU };
ret = map_error( LDAP_CALL( ldap_compare_ext_s, &params ));
}
exit:
free( dnU );
free( attrU );
......
......@@ -151,15 +151,19 @@ ULONG CDECL ldap_create_sort_controlW( LDAP *ld, LDAPSortKeyW **sortkey, UCHAR c
if (!ld || !sortkey || !control) return LDAP_PARAM_ERROR;
if (!(sortkeyU = sortkeyarrayWtoU( sortkey ))) return LDAP_NO_MEMORY;
if ((sortkeyU = sortkeyarrayWtoU( sortkey )))
{
struct ldap_create_sort_control_params params = { CTX(ld), sortkeyU, critical, &controlU };
ret = map_error( LDAP_CALL( ldap_create_sort_control, &params ));
}
else return LDAP_NO_MEMORY;
ret = map_error( ldap_funcs->fn_ldap_create_sort_control( CTX(ld), sortkeyU, critical, &controlU ) );
if (ret == LDAP_SUCCESS)
{
LDAPControlW *controlW = controlUtoW( controlU );
if (controlW) *control = controlW;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ldap_control_free( controlU );
LDAP_CALL( ldap_control_free, controlU );
}
sortkeyarrayfreeU( sortkeyU );
......@@ -225,14 +229,17 @@ INT CDECL ldap_create_vlv_controlW( LDAP *ld, LDAPVLVInfo *info, UCHAR critical,
if (!ld || !control) return ~0u;
if (info && !(infoU = vlvinfoWtoU( info ))) return LDAP_NO_MEMORY;
ret = map_error( ldap_funcs->fn_ldap_create_vlv_control( CTX(ld), infoU, &controlU ) );
else
{
struct ldap_create_vlv_control_params params = { CTX(ld), infoU, &controlU };
ret = map_error( LDAP_CALL( ldap_create_vlv_control, &params ));
}
if (ret == LDAP_SUCCESS)
{
LDAPControlW *controlW = controlUtoW( controlU );
if (controlW) *control = controlW;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ldap_control_free( controlU );
LDAP_CALL( ldap_control_free, controlU );
}
vlvinfofreeU( infoU );
......
......@@ -142,8 +142,11 @@ ULONG CDECL ldap_delete_extW( LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls, L
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_delete_ext( CTX(ld), dnU, serverctrlsU, clientctrlsU, message ) );
else
{
struct ldap_delete_ext_params params = { CTX(ld), dnU, serverctrlsU, clientctrlsU, message };
ret = map_error( LDAP_CALL( ldap_delete_ext, &params ));
}
exit:
free( dnU );
......@@ -212,8 +215,11 @@ ULONG CDECL ldap_delete_ext_sW( LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls,
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_delete_ext_s( CTX(ld), dnU, serverctrlsU, clientctrlsU ) );
else
{
struct ldap_delete_ext_s_params params = { CTX(ld), dnU, serverctrlsU, clientctrlsU };
ret = map_error( LDAP_CALL( ldap_delete_ext_s, &params ));
}
exit:
free( dnU );
......
......@@ -68,18 +68,21 @@ char * CDECL ldap_dn2ufnA( char *dn )
*/
WCHAR * CDECL ldap_dn2ufnW( WCHAR *dn )
{
WCHAR *ret;
WCHAR *ret = NULL;
char *dnU, *retU;
TRACE( "(%s)\n", debugstr_w(dn) );
if (!(dnU = strWtoU( dn ))) return NULL;
if ((dnU = strWtoU( dn )))
{
struct ldap_dn2ufn_params params = { dnU, &retU };
LDAP_CALL( ldap_dn2ufn, &params );
ldap_funcs->fn_ldap_dn2ufn( dnU, &retU );
ret = strUtoW( retU );
free( dnU );
ldap_funcs->fn_ldap_memfree( retU );
LDAP_CALL( ldap_memfree, retU );
}
return ret;
}
......@@ -124,18 +127,20 @@ char ** CDECL ldap_explode_dnA( char *dn, ULONG notypes )
*/
WCHAR ** CDECL ldap_explode_dnW( WCHAR *dn, ULONG notypes )
{
WCHAR **ret;
WCHAR **ret = NULL;
char *dnU, **retU;
TRACE( "(%s, 0x%08x)\n", debugstr_w(dn), notypes );
if (!(dnU = strWtoU( dn ))) return NULL;
ldap_funcs->fn_ldap_explode_dn( dnU, notypes, &retU );
if ((dnU = strWtoU( dn )))
{
struct ldap_explode_dn_params params = { dnU, notypes, &retU };
LDAP_CALL( ldap_explode_dn, &params );
ret = strarrayUtoW( retU );
free( dnU );
ldap_funcs->fn_ldap_memvfree( (void **)retU );
LDAP_CALL( ldap_memvfree, retU );
}
return ret;
}
......@@ -178,17 +183,19 @@ char * CDECL ldap_get_dnA( LDAP *ld, LDAPMessage *entry )
*/
WCHAR * CDECL ldap_get_dnW( LDAP *ld, LDAPMessage *entry )
{
WCHAR *ret;
WCHAR *ret = NULL;
char *retU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
ldap_funcs->fn_ldap_get_dn( CTX(ld), MSG(entry), &retU );
if (ld && entry)
{
struct ldap_get_dn_params params = { CTX(ld), MSG(entry), &retU };
LDAP_CALL( ldap_get_dn, &params );
ret = strUtoW( retU );
ldap_funcs->fn_ldap_memfree( retU );
LDAP_CALL( ldap_memfree, retU );
}
return ret;
}
......
......@@ -146,20 +146,16 @@ void CDECL ldap_perror( LDAP *ld, const PCHAR msg )
*/
ULONG CDECL ldap_result2error( LDAP *ld, LDAPMessage *res, ULONG free )
{
ULONG ret;
int error;
TRACE( "(%p, %p, 0x%08x)\n", ld, res, free );
if (!ld || !res) return ~0u;
ret = map_error( ldap_funcs->fn_ldap_parse_result( CTX(ld), MSG(res), &error, NULL, NULL, NULL, NULL, free ) );
if (ret == LDAP_SUCCESS)
ret = error;
else
ret = ~0u;
return ret;
if (ld && res)
{
struct ldap_parse_result_params params = { CTX(ld), MSG(res), &error, NULL, NULL, NULL, NULL, free };
if (!LDAP_CALL( ldap_parse_result, &params )) return error;
}
return ~0u;
}
/***********************************************************************
......
......@@ -124,9 +124,11 @@ ULONG CDECL ldap_extended_operationW( LDAP *ld, WCHAR *oid, struct berval *data,
if (data && !(dataU = bervalWtoU( data ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_extended_operation( CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU,
message ) );
else
{
struct ldap_extended_operation_params params = { CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU, message };
ret = map_error( LDAP_CALL( ldap_extended_operation, &params ));
}
exit:
free( oidU );
......@@ -212,22 +214,25 @@ ULONG CDECL ldap_extended_operation_sW( LDAP *ld, WCHAR *oid, struct berval *dat
if (data && !(dataU = bervalWtoU( data ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else
{
struct ldap_extended_operation_s_params params = { CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU, &retoidU, &retdataU };
ret = map_error( LDAP_CALL( ldap_extended_operation_s, &params ));
}
ret = map_error( ldap_funcs->fn_ldap_extended_operation_s( CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU,
&retoidU, &retdataU ) );
if (retoid && retoidU)
{
WCHAR *str = strUtoW( retoidU );
if (str) *retoid = str;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ldap_memfree( retoidU );
LDAP_CALL( ldap_memfree, retoidU );
}
if (retdata && retdataU)
{
struct berval *bv = bervalUtoW( retdataU );
if (bv) *retdata = bv;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ber_bvfree( retdataU );
LDAP_CALL( ber_bvfree, retdataU );
}
exit:
......
......@@ -195,15 +195,19 @@ static LDAP *create_context( const char *url )
{
LDAP *ld;
int version = LDAP_VERSION3;
struct ldap_initialize_params params;
if (!(ld = calloc( 1, sizeof( *ld )))) return NULL;
if (map_error( ldap_funcs->fn_ldap_initialize( &CTX(ld), url ) ) != LDAP_SUCCESS)
params.ld = &CTX(ld);
params.url = url;
if (map_error( LDAP_CALL( ldap_initialize, &params )) == LDAP_SUCCESS)
{
struct ldap_set_option_params opt_params = { CTX(ld), LDAP_OPT_PROTOCOL_VERSION, &version };
LDAP_CALL( ldap_set_option, &opt_params );
return ld;
}
free( ld );
return NULL;
}
ldap_funcs->fn_ldap_set_option( CTX(ld), LDAP_OPT_PROTOCOL_VERSION, &version );
return ld;
}
/***********************************************************************
......@@ -538,8 +542,11 @@ ULONG CDECL ldap_start_tls_sW( LDAP *ld, ULONG *retval, LDAPMessage **result, LD
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_start_tls_s( CTX(ld), serverctrlsU, clientctrlsU ) );
else
{
struct ldap_start_tls_s_params params = { CTX(ld), serverctrlsU, clientctrlsU };
ret = map_error( LDAP_CALL( ldap_start_tls_s, &params ));
}
exit:
controlarrayfreeU( serverctrlsU );
......
......@@ -30,7 +30,7 @@ HINSTANCE hwldap32;
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
const struct ldap_funcs *ldap_funcs = NULL;
unixlib_handle_t ldap_handle = 0;
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{
......@@ -41,7 +41,8 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
case DLL_PROCESS_ATTACH:
hwldap32 = hinst;
DisableThreadLibraryCalls( hinst );
if (__wine_init_unix_lib( hinst, reason, NULL, &ldap_funcs ))
if (NtQueryVirtualMemory( GetCurrentProcess(), hinst, MemoryWineUnixFuncs,
&ldap_handle, sizeof(ldap_handle), NULL ))
ERR( "No libldap support, expect problems\n" );
break;
}
......
......@@ -48,7 +48,11 @@ ULONG CDECL ldap_abandon( LDAP *ld, ULONG msgid )
TRACE( "(%p, 0x%08x)\n", ld, msgid );
if (!ld) return ~0u;
return map_error( ldap_funcs->fn_ldap_abandon_ext( CTX(ld), msgid, NULL, NULL ) );
else
{
struct ldap_abandon_ext_params params = { CTX(ld), msgid };
return map_error( LDAP_CALL( ldap_abandon_ext, &params ));
}
}
/***********************************************************************
......@@ -141,7 +145,11 @@ ULONG CDECL ldap_count_entries( LDAP *ld, LDAPMessage *res )
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return ~0u;
return ldap_funcs->fn_ldap_count_entries( CTX(ld), MSG(res) );
else
{
struct ldap_count_entries_params params = { CTX(ld), MSG(res) };
return LDAP_CALL( ldap_count_entries, &params );
}
}
/***********************************************************************
......@@ -162,7 +170,11 @@ ULONG CDECL ldap_count_references( LDAP *ld, LDAPMessage *res )
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return 0;
return ldap_funcs->fn_ldap_count_references( CTX(ld), MSG(res) );
else
{
struct ldap_count_references_params params = { CTX(ld), MSG(res) };
return LDAP_CALL( ldap_count_references, &params );
}
}
static ULONG get_escape_size( PCHAR src, ULONG srclen )
......@@ -297,9 +309,13 @@ WCHAR * CDECL ldap_first_attributeW( LDAP *ld, LDAPMessage *entry, BerElement **
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry) return NULL;
if (ld && entry)
{
struct ldap_first_attribute_params params = { CTX(ld), MSG(entry), &berU, &retU };
LDAP_CALL( ldap_first_attribute, &params );
}
else return NULL;
ldap_funcs->fn_ldap_first_attribute( CTX(ld), MSG(entry), &berU, &retU );
if (retU && (ber = malloc( sizeof(*ber) )))
{
BER(ber) = (char *)berU;
......@@ -307,7 +323,7 @@ WCHAR * CDECL ldap_first_attributeW( LDAP *ld, LDAPMessage *entry, BerElement **
ret = strUtoW( retU );
}
ldap_funcs->fn_ldap_memfree( retU );
LDAP_CALL( ldap_memfree, retU );
return ret;
}
......@@ -333,14 +349,15 @@ LDAPMessage * CDECL ldap_first_entry( LDAP *ld, LDAPMessage *res )
TRACE( "(%p, %p)\n", ld, res );
if (!ld || !res) return NULL;
if (!ldap_funcs->fn_ldap_first_entry( CTX(ld), MSG(res), &msgU ))
if (ld && res)
{
struct ldap_first_entry_params params = { CTX(ld), MSG(res), &msgU };
if (!LDAP_CALL( ldap_first_entry, &params ))
{
assert( msgU == MSG(res) );
return res;
}
}
return NULL;
}
......@@ -363,14 +380,15 @@ LDAPMessage * CDECL ldap_first_reference( LDAP *ld, LDAPMessage *res )
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return NULL;
if (!ldap_funcs->fn_ldap_first_reference( CTX(ld), MSG(res), &msgU ))
if (ld)
{
struct ldap_first_reference_params params = { CTX(ld), MSG(res), &msgU };
if (!LDAP_CALL( ldap_first_reference, &params ))
{
assert( msgU == MSG(res) );
return res;
}
}
return NULL;
}
......@@ -415,7 +433,7 @@ ULONG CDECL ldap_msgfree( LDAPMessage *res )
if (!res) return LDAP_SUCCESS;
ldap_funcs->fn_ldap_msgfree( MSG(res) );
LDAP_CALL( ldap_msgfree, MSG(res) );
while (list)
{
entry = list;
......@@ -475,14 +493,15 @@ WCHAR * CDECL ldap_next_attributeW( LDAP *ld, LDAPMessage *entry, BerElement *pt
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry || !ptr) return NULL;
if (!ldap_funcs->fn_ldap_next_attribute( CTX(ld), MSG(entry), BER(ptr), &retU ))
if (ld && entry && ptr)
{
struct ldap_next_attribute_params params = { CTX(ld), MSG(entry), BER(ptr), &retU };
if (!LDAP_CALL( ldap_next_attribute, &params ))
{
ret = strUtoW( retU );
ldap_funcs->fn_ldap_memfree( retU );
LDAP_CALL( ldap_memfree, retU );
}
}
return ret;
}
......@@ -512,8 +531,12 @@ LDAPMessage * CDECL ldap_next_entry( LDAP *ld, LDAPMessage *entry )
if (!ld || !entry) return NULL;
if (entry->lm_next) return entry->lm_next;
else
{
struct ldap_next_entry_params params = { CTX(ld), MSG(entry), &msgU };
LDAP_CALL( ldap_next_entry, &params );
}
ldap_funcs->fn_ldap_next_entry( CTX(ld), MSG(entry), &msgU );
if (msgU && (msg = calloc( 1, sizeof(*msg) )))
{
MSG(msg) = msgU;
......@@ -549,8 +572,11 @@ LDAPMessage * CDECL ldap_next_reference( LDAP *ld, LDAPMessage *entry )
if (!ld || !entry) return NULL;
if (entry->lm_next) return entry->lm_next;
ldap_funcs->fn_ldap_next_reference( CTX(ld), MSG(entry), &msgU );
else
{
struct ldap_next_reference_params params = { CTX(ld), MSG(entry), &msgU };
LDAP_CALL( ldap_next_reference, &params );
}
if (msgU && (msg = calloc( 1, sizeof(*msg) )))
{
MSG(msg) = msgU;
......@@ -601,11 +627,13 @@ ULONG CDECL ldap_result( LDAP *ld, ULONG msgid, ULONG all, struct l_timeval *tim
LDAPMessage *msg;
struct timevalU timeval;
void *msgU = NULL;
ULONG ret;
ULONG ret = ~0u;
TRACE( "(%p, 0x%08x, 0x%08x, %p, %p)\n", ld, msgid, all, timeout, res );
if (!ld || !res || msgid == ~0u) return ~0u;
if (ld && res && msgid != ~0u)
{
struct ldap_result_params params = { CTX(ld), msgid, all, timeout ? &timeval : NULL, &msgU };
if (timeout)
{
......@@ -613,7 +641,8 @@ ULONG CDECL ldap_result( LDAP *ld, ULONG msgid, ULONG all, struct l_timeval *tim
timeval.tv_usec = timeout->tv_usec;
}
ret = ldap_funcs->fn_ldap_result( CTX(ld), msgid, all, timeout ? &timeval : NULL, &msgU );
ret = LDAP_CALL( ldap_result, &params );
}
if (msgU && (msg = calloc( 1, sizeof(*msg) )))
{
MSG(msg) = msgU;
......
......@@ -157,8 +157,11 @@ ULONG CDECL ldap_modify_extW( LDAP *ld, WCHAR *dn, LDAPModW **mods, LDAPControlW
if (mods && !(modsU = modarrayWtoU( mods ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_modify_ext( CTX(ld), dnU, modsU, serverctrlsU, clientctrlsU, message ) );
else
{
struct ldap_modify_ext_params params = { CTX(ld), dnU, modsU, serverctrlsU, clientctrlsU, message };
ret = map_error( LDAP_CALL( ldap_modify_ext, &params ));
}
exit:
free( dnU );
......@@ -237,8 +240,11 @@ ULONG CDECL ldap_modify_ext_sW( LDAP *ld, WCHAR *dn, LDAPModW **mods, LDAPContro
if (mods && !(modsU = modarrayWtoU( mods ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_modify_ext_s( CTX(ld), dnU, modsU, serverctrlsU, clientctrlsU ) );
else
{
struct ldap_modify_ext_s_params params = { CTX(ld), dnU, modsU, serverctrlsU, clientctrlsU };
ret = map_error( LDAP_CALL( ldap_modify_ext_s, &params ));
}
exit:
free( dnU );
......
......@@ -134,18 +134,19 @@ ULONG CDECL ldap_modrdn2W( LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
if (!ld || !newdn) return ~0u;
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (!(newdnU = strWtoU( newdn ))) goto exit;
if (dn && !(dnU = strWtoU( dn ))) return LDAP_NO_MEMORY;
ret = ldap_funcs->fn_ldap_rename( CTX(ld), dnU, newdnU, NULL, delete, NULL, NULL, &msg );
if ((newdnU = strWtoU( newdn )))
{
struct ldap_rename_params params = { CTX(ld), dnU, newdnU, NULL, delete, NULL, NULL, &msg };
ret = LDAP_CALL( ldap_rename, &params );
if (ret == LDAP_SUCCESS)
ret = msg;
else
ret = ~0u;
exit:
free( dnU );
free( newdnU );
}
free( dnU );
return ret;
}
......@@ -198,14 +199,15 @@ ULONG CDECL ldap_modrdn2_sW( LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
if (!ld || !newdn) return LDAP_PARAM_ERROR;
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (!(newdnU = strWtoU( newdn ))) goto exit;
if (dn && !(dnU = strWtoU( dn ))) return LDAP_NO_MEMORY;
ret = map_error( ldap_funcs->fn_ldap_rename_s( CTX(ld), dnU, newdnU, NULL, delete, NULL, NULL ));
exit:
free( dnU );
if ((newdnU = strWtoU( newdn )))
{
struct ldap_rename_s_params params = { CTX(ld), dnU, newdnU, NULL, delete, NULL, NULL };
ret = map_error( LDAP_CALL( ldap_rename_s, &params ));
free( newdnU );
}
free( dnU );
return ret;
}
......
......@@ -184,10 +184,13 @@ ULONG CDECL ldap_get_optionW( LDAP *ld, int option, void *value )
if (!featureW->ldapaif_name) return LDAP_PARAM_ERROR;
featureU.ldapaif_info_version = featureW->ldapaif_info_version;
if (!(featureU.ldapaif_name = strWtoU( featureW->ldapaif_name ))) return LDAP_NO_MEMORY;
if ((featureU.ldapaif_name = strWtoU( featureW->ldapaif_name )))
{
struct ldap_get_option_params params = { CTX(ld), option, &featureU };
featureU.ldapaif_version = 0;
ret = map_error( ldap_funcs->fn_ldap_get_option( CTX(ld), option, &featureU ) );
ret = map_error( LDAP_CALL( ldap_get_option, &params ));
}
else return LDAP_NO_MEMORY;
if (ret == LDAP_SUCCESS) featureW->ldapaif_version = featureU.ldapaif_version;
free( featureU.ldapaif_name );
......@@ -197,11 +200,12 @@ ULONG CDECL ldap_get_optionW( LDAP *ld, int option, void *value )
{
LDAPAPIInfoU infoU;
LDAPAPIInfoW *infoW = value;
struct ldap_get_option_params params = { CTX(ld), option, &infoU };
memset( &infoU, 0, sizeof(infoU) );
infoU.ldapai_info_version = infoW->ldapai_info_version;
ret = map_error( ldap_funcs->fn_ldap_get_option( CTX(ld), option, &infoU ) );
ret = map_error( LDAP_CALL( ldap_get_option, &params ));
if (ret == LDAP_SUCCESS)
{
infoW->ldapai_api_version = infoU.ldapai_api_version;
......@@ -211,13 +215,13 @@ ULONG CDECL ldap_get_optionW( LDAP *ld, int option, void *value )
return LDAP_NO_MEMORY;
if (infoU.ldapai_vendor_name && !(infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name )))
{
ldap_funcs->fn_ldap_memvfree( (void **)infoU.ldapai_extensions );
LDAP_CALL( ldap_memvfree, infoU.ldapai_extensions );
return LDAP_NO_MEMORY;
}
infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
ldap_funcs->fn_ldap_memvfree( (void **)infoU.ldapai_extensions );
ldap_funcs->fn_ldap_memfree( infoU.ldapai_vendor_name );
LDAP_CALL( ldap_memvfree, infoU.ldapai_extensions );
LDAP_CALL( ldap_memfree, infoU.ldapai_vendor_name );
}
return ret;
}
......@@ -229,7 +233,10 @@ ULONG CDECL ldap_get_optionW( LDAP *ld, int option, void *value )
case LDAP_OPT_REFERRALS:
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT:
return map_error( ldap_funcs->fn_ldap_get_option( CTX(ld), option, value ));
{
struct ldap_get_option_params params = { CTX(ld), option, value };
return map_error( LDAP_CALL( ldap_get_option, &params ));
}
case LDAP_OPT_CACHE_ENABLE:
case LDAP_OPT_CACHE_FN_PTRS:
......@@ -371,22 +378,30 @@ static BOOL query_supported_server_ctrls( LDAP *ld )
struct bervalU **ctrls = SERVER_CTRLS(ld);
ULONG ret;
if (ctrls) return TRUE;
ret = map_error( ldap_funcs->fn_ldap_search_ext_s( CTX(ld), (char *)"", LDAP_SCOPE_BASE, (char *)"(objectClass=*)",
attrs, FALSE, NULL, NULL, NULL, 0, &res ) );
if (ret != LDAP_SUCCESS) return FALSE;
if (!ctrls)
{
struct ldap_search_ext_s_params params = { CTX(ld), (char *)"", LDAP_SCOPE_BASE,
(char *)"(objectClass=*)", attrs, FALSE, NULL, NULL, NULL, 0, &res };
ret = map_error( LDAP_CALL( ldap_search_ext_s, &params ));
}
else return TRUE;
if (!ldap_funcs->fn_ldap_first_entry( CTX(ld), res, &entry ))
if (ret == LDAP_SUCCESS)
{
struct ldap_first_entry_params params = { CTX(ld), res, &entry };
if (!LDAP_CALL( ldap_first_entry, &params ))
{
ULONG count, i;
ldap_funcs->fn_ldap_get_values_len( CTX(ld), entry, attrs[0], &ctrls );
count = ldap_funcs->fn_ldap_count_values_len( ctrls );
struct ldap_get_values_len_params get_params = { CTX(ld), entry, attrs[0], &ctrls };
LDAP_CALL( ldap_get_values_len, &get_params );
count = LDAP_CALL( ldap_count_values_len, ctrls );
for (i = 0; i < count; i++) TRACE("%u: %s\n", i, debugstr_an( ctrls[i]->bv_val, ctrls[i]->bv_len ));
*(struct bervalU ***)&SERVER_CTRLS(ld) = ctrls;
}
}
else return FALSE;
ldap_funcs->fn_ldap_msgfree( res );
LDAP_CALL( ldap_msgfree, res );
return ctrls != NULL;
}
......@@ -398,7 +413,7 @@ static BOOL is_supported_server_ctrls( LDAP *ld, LDAPControlU **ctrls )
return TRUE; /* can't verify, let the server handle it on next query */
user_count = controlarraylenU( ctrls );
server_count = ldap_funcs->fn_ldap_count_values_len( SERVER_CTRLS(ld) );
server_count = LDAP_CALL( ldap_count_values_len, SERVER_CTRLS(ld) );
for (n = 0; n < user_count; n++)
{
......@@ -454,18 +469,21 @@ ULONG CDECL ldap_set_optionW( LDAP *ld, int option, void *value )
if (!is_supported_server_ctrls( ld, ctrlsU ))
ret = LDAP_PARAM_ERROR;
else
ret = map_error( ldap_funcs->fn_ldap_set_option( CTX(ld), option, ctrlsU ) );
{
struct ldap_set_option_params params = { CTX(ld), option, ctrlsU };
ret = map_error( LDAP_CALL( ldap_set_option, &params ));
}
controlarrayfreeU( ctrlsU );
return ret;
}
case LDAP_OPT_REFERRALS:
{
void *openldap_referral = LDAP_OPT_ON;
struct ldap_set_option_params params = { CTX(ld), option, LDAP_OPT_ON };
if (value == LDAP_OPT_OFF)
openldap_referral = LDAP_OPT_OFF;
params.value = LDAP_OPT_OFF;
else
FIXME("upgrading referral value %p to LDAP_OPT_ON (OpenLDAP lacks sufficient granularity)\n", value);
return map_error( ldap_funcs->fn_ldap_set_option( CTX(ld), option, openldap_referral ) );
return map_error( LDAP_CALL( ldap_set_option, &params ));
}
case LDAP_OPT_DEREF:
case LDAP_OPT_DESC:
......@@ -473,7 +491,10 @@ ULONG CDECL ldap_set_optionW( LDAP *ld, int option, void *value )
case LDAP_OPT_PROTOCOL_VERSION:
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT:
return map_error( ldap_funcs->fn_ldap_set_option( CTX(ld), option, value ));
{
struct ldap_set_option_params params = { CTX(ld), option, value };
return map_error( LDAP_CALL( ldap_set_option, &params ));
}
case LDAP_OPT_CACHE_ENABLE:
case LDAP_OPT_CACHE_FN_PTRS:
......
......@@ -87,21 +87,24 @@ ULONG CDECL ldap_parse_extended_resultW( LDAP *ld, LDAPMessage *result, WCHAR **
if (!ld) return LDAP_PARAM_ERROR;
if (!result) return LDAP_NO_RESULTS_RETURNED;
ret = map_error( ldap_funcs->fn_ldap_parse_extended_result( CTX(ld), result, &oidU, &dataU, free ) );
else
{
struct ldap_parse_extended_result_params params = { CTX(ld), result, &oidU, &dataU, free };
ret = map_error( LDAP_CALL( ldap_parse_extended_result, &params ));
}
if (oid && oidU)
{
WCHAR *str;
if ((str = strUtoW( oidU ))) *oid = str;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ldap_memfree( oidU );
LDAP_CALL( ldap_memfree, oidU );
}
if (data && dataU)
{
struct berval *bv;
if ((bv = bervalUtoW( dataU ))) *data = bv;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ber_bvfree( dataU );
LDAP_CALL( ber_bvfree, dataU );
}
return ret;
......@@ -151,20 +154,22 @@ ULONG CDECL ldap_parse_referenceA( LDAP *ld, LDAPMessage *message, char ***refer
*/
ULONG CDECL ldap_parse_referenceW( LDAP *ld, LDAPMessage *message, WCHAR ***referrals )
{
ULONG ret;
ULONG ret = ~0u;
char **referralsU = NULL;
TRACE( "(%p, %p, %p)\n", ld, message, referrals );
if (!ld) return ~0u;
ret = map_error( ldap_funcs->fn_ldap_parse_reference( CTX(ld), message, &referralsU, NULL, 0 ) );
if (ld)
{
struct ldap_parse_reference_params params = { CTX(ld), message, &referralsU, NULL, 0 };
ret = map_error( LDAP_CALL( ldap_parse_reference, &params ));
}
if (referralsU)
{
WCHAR **ref;
if ((ref = strarrayUtoW( referralsU ))) *referrals = ref;
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ldap_memfree( referralsU );
LDAP_CALL( ldap_memfree, referralsU );
}
return ret;
}
......@@ -235,20 +240,23 @@ ULONG CDECL ldap_parse_resultW( LDAP *ld, LDAPMessage *result, ULONG *retcode, W
TRACE( "(%p, %p, %p, %p, %p, %p, %p, 0x%02x)\n", ld, result, retcode, matched, error, referrals, serverctrls,
free );
if (!ld) return LDAP_PARAM_ERROR;
ret = map_error( ldap_funcs->fn_ldap_parse_result( CTX(ld), MSG(result), (int *)retcode, &matchedU, &errorU,
&referralsU, &serverctrlsU, free ) );
if (ld)
{
struct ldap_parse_result_params params = { CTX(ld), MSG(result), (int *)retcode, &matchedU,
&errorU, &referralsU, &serverctrlsU, free };
ret = map_error( LDAP_CALL( ldap_parse_result, &params ));
}
else return LDAP_PARAM_ERROR;
if (matched) *matched = strUtoW( matchedU );
if (error) *error = strUtoW( errorU );
if (referrals) *referrals = strarrayUtoW( referralsU );
if (serverctrls) *serverctrls = controlarrayUtoW( serverctrlsU );
ldap_funcs->fn_ldap_memfree( matchedU );
ldap_funcs->fn_ldap_memfree( errorU );
ldap_funcs->fn_ldap_memvfree( (void **)referralsU );
ldap_funcs->fn_ldap_controls_free( serverctrlsU );
LDAP_CALL( ldap_memfree, matchedU );
LDAP_CALL( ldap_memfree, errorU );
LDAP_CALL( ldap_memvfree, referralsU );
LDAP_CALL( ldap_controls_free, serverctrlsU );
return ret;
}
......@@ -318,8 +326,11 @@ ULONG CDECL ldap_parse_sort_controlW( LDAP *ld, LDAPControlW **control, ULONG *r
controlarrayfreeU( controlU );
return LDAP_CONTROL_NOT_FOUND;
}
ret = map_error( ldap_funcs->fn_ldap_parse_sortresponse_control( CTX(ld), sortcontrol, &res, &attrU ) );
else
{
struct ldap_parse_sortresponse_control_params params = { CTX(ld), sortcontrol, &res, &attrU };
ret = map_error( LDAP_CALL( ldap_parse_sortresponse_control, &params ));
}
if (ret == LDAP_SUCCESS)
{
WCHAR *str;
......@@ -329,7 +340,7 @@ ULONG CDECL ldap_parse_sort_controlW( LDAP *ld, LDAPControlW **control, ULONG *r
*result = res;
}
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ldap_memfree( attrU );
LDAP_CALL( ldap_memfree, attrU );
}
controlarrayfreeU( controlU );
......@@ -401,9 +412,11 @@ int CDECL ldap_parse_vlv_controlW( LDAP *ld, LDAPControlW **control, ULONG *targ
controlarrayfreeU( controlU );
return LDAP_CONTROL_NOT_FOUND;
}
ret = map_error( ldap_funcs->fn_ldap_parse_vlvresponse_control( CTX(ld), vlvcontrolU, &pos, &count, &ctxU,
errcode ) );
else
{
struct ldap_parse_vlvresponse_control_params params = { CTX(ld), vlvcontrolU, &pos, &count, &ctxU, errcode };
ret = map_error( LDAP_CALL( ldap_parse_vlvresponse_control, &params ));
}
if (ret == LDAP_SUCCESS)
{
struct berval *bv;
......@@ -414,7 +427,7 @@ int CDECL ldap_parse_vlv_controlW( LDAP *ld, LDAPControlW **control, ULONG *targ
*listcount = count;
}
else ret = LDAP_NO_MEMORY;
ldap_funcs->fn_ber_bvfree( ctxU );
LDAP_CALL( ber_bvfree, ctxU );
}
controlarrayfreeU( controlU );
......
......@@ -104,9 +104,11 @@ ULONG CDECL ldap_rename_extW( LDAP *ld, WCHAR *dn, WCHAR *newrdn, WCHAR *newpare
if (newparent && !(newparentU = strWtoU( newparent ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_rename( CTX(ld), dnU, newrdnU, newparentU, delete, serverctrlsU, clientctrlsU,
message ) );
else
{
struct ldap_rename_params params = { CTX(ld), dnU, newrdnU, newparentU, delete, serverctrlsU, clientctrlsU, message };
ret = map_error( LDAP_CALL( ldap_rename, &params ));
}
exit:
free( dnU );
free( newrdnU );
......@@ -184,9 +186,11 @@ ULONG CDECL ldap_rename_ext_sW( LDAP *ld, WCHAR *dn, WCHAR *newrdn, WCHAR *newpa
if (newparent && !(newparentU = strWtoU( newparent ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->fn_ldap_rename_s( CTX(ld), dnU, newrdnU, newparentU, delete, serverctrlsU,
clientctrlsU ) );
else
{
struct ldap_rename_s_params params = { CTX(ld), dnU, newrdnU, newparentU, delete, serverctrlsU, clientctrlsU };
ret = map_error( LDAP_CALL( ldap_rename_s, &params ));
}
exit:
free( dnU );
free( newrdnU );
......
......@@ -176,8 +176,11 @@ ULONG CDECL ldap_search_extW( LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter,
timevalU.tv_sec = timelimit;
timevalU.tv_usec = 0;
ret = map_error( ldap_funcs->fn_ldap_search_ext( CTX(ld), baseU, scope, filterU, attrsU, attrsonly, serverctrlsU,
clientctrlsU, timelimit ? &timevalU : NULL, sizelimit, message ) );
{
struct ldap_search_ext_params params = { CTX(ld), baseU, scope, filterU, attrsU, attrsonly,
serverctrlsU, clientctrlsU, timelimit ? &timevalU : NULL, sizelimit, message };
ret = map_error( LDAP_CALL( ldap_search_ext, &params ));
}
exit:
free( baseU );
free( filterU );
......@@ -276,8 +279,12 @@ ULONG CDECL ldap_search_ext_sW( LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filte
timevalU.tv_usec = timeout->tv_usec;
}
ret = map_error( ldap_funcs->fn_ldap_search_ext_s( CTX(ld), baseU, scope, filterU, attrsU, attrsonly, serverctrlsU,
clientctrlsU, timeout ? &timevalU : NULL, sizelimit, &msgU ) );
{
struct ldap_search_ext_s_params params = { CTX(ld), baseU, scope, filterU, attrsU, attrsonly,
serverctrlsU, clientctrlsU, timeout ? &timevalU : NULL, sizelimit, &msgU };
ret = map_error( LDAP_CALL( ldap_search_ext_s, &params ));
}
if (msgU)
{
LDAPMessage *msg = calloc( 1, sizeof(*msg) );
......@@ -288,7 +295,7 @@ ULONG CDECL ldap_search_ext_sW( LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filte
}
else
{
ldap_funcs->fn_ldap_msgfree( msgU );
LDAP_CALL( ldap_msgfree, msgU );
ret = LDAP_NO_MEMORY;
}
}
......
......@@ -195,18 +195,20 @@ WCHAR ** CDECL ldap_get_valuesW( LDAP *ld, LDAPMessage *entry, WCHAR *attr )
TRACE( "(%p, %p, %s)\n", ld, entry, debugstr_w(attr) );
if (!ld || !entry || !attr || !(attrU = strWtoU( attr ))) return NULL;
if (ld && entry && attr && (attrU = strWtoU( attr )))
{
struct ldap_get_values_len_params params = { CTX(ld), MSG(entry), attrU, &bv };
if (!ldap_funcs->fn_ldap_get_values_len( CTX(ld), MSG(entry), attrU, &bv ))
if (!LDAP_CALL( ldap_get_values_len, &params ))
{
retU = bv2str_array( bv );
ret = strarrayUtoW( retU );
ldap_funcs->fn_ldap_value_free_len( bv );
LDAP_CALL( ldap_value_free_len, bv );
strarrayfreeU( retU );
}
free( attrU );
}
return ret;
}
......@@ -257,15 +259,18 @@ struct berval ** CDECL ldap_get_values_lenW( LDAP *ld, LDAPMessage *message, WCH
TRACE( "(%p, %p, %s)\n", ld, message, debugstr_w(attr) );
if (!ld || !message || !attr || !(attrU = strWtoU( attr ))) return NULL;
if (ld && message && attr && (attrU = strWtoU( attr )))
{
struct ldap_get_values_len_params params = { CTX(ld), MSG(message), attrU, &retU };
if (!ldap_funcs->fn_ldap_get_values_len( CTX(ld), MSG(message), attrU, &retU ))
if (!LDAP_CALL( ldap_get_values_len, &params ))
{
ret = bvarrayUtoW( retU );
bvarrayfreeU( retU );
}
free( attrU );
}
return ret;
}
......
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