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