wldap32: Don't use varargs functions in the Unix library interface.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-11-03 14:47:38 +01:00
parent 449fae545c
commit cefd34fbda
3 changed files with 20 additions and 142 deletions

View File

@ -334,26 +334,26 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
case 'i':
{
int i = va_arg( list, int );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, i );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, i, 0 );
break;
}
case 'o':
case 's':
{
char *str = va_arg( list, char * );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, str );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)str, 0 );
break;
}
case 't':
{
unsigned int tag = va_arg( list, unsigned int );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, tag );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, tag, 0 );
break;
}
case 'v':
{
char **array = va_arg( list, char ** );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, array );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)array, 0 );
break;
}
case 'V':
@ -365,7 +365,7 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
ret = -1;
break;
}
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, arrayU );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)arrayU, 0 );
bvarrayfreeU( arrayU );
break;
}
@ -374,7 +374,7 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
char *str = va_arg( list, char * );
int len = va_arg( list, int );
new_fmt[0] = 'B'; /* 'X' is deprecated */
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, str, len );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, (ULONG_PTR)str, len );
break;
}
case 'n':
@ -382,7 +382,7 @@ int WINAPIV ber_printf( BerElement *ber, char *fmt, ... )
case '}':
case '[':
case ']':
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt );
ret = ldap_funcs->fn_ber_printf( BER(ber), new_fmt, 0, 0 );
break;
default:
@ -431,7 +431,7 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
case 'a':
{
char *str, **ptr = va_arg( list, char ** );
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &str )) == -1) break;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &str, NULL )) == -1) break;
*ptr = strdupU( str );
ldap_funcs->fn_ldap_memfree( str );
break;
@ -441,19 +441,19 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
case 'i':
{
int *i = va_arg( list, int * );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, i );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, i, NULL );
break;
}
case 't':
{
unsigned int *tag = va_arg( list, unsigned int * );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, tag );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, tag, NULL );
break;
}
case 'v':
{
char *str, **arrayU, **ptr, ***array = va_arg( list, char *** );
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &arrayU )) == -1) break;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &arrayU, NULL )) == -1) break;
*array = strarrayUtoU( arrayU );
ptr = arrayU;
while ((str = *ptr))
@ -478,7 +478,7 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
{
struct berval **berval = va_arg( list, struct berval ** );
struct bervalU *bervalU;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &bervalU )) == -1) break;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &bervalU, NULL )) == -1) break;
*berval = bervalUtoW( bervalU );
ldap_funcs->fn_ber_bvfree( bervalU );
break;
@ -487,7 +487,7 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
{
struct berval ***array = va_arg( list, struct berval *** );
struct bervalU **arrayU;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &arrayU )) == -1) break;
if ((ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, &arrayU, NULL )) == -1) break;
*array = bvarrayUtoW( arrayU );
ldap_funcs->fn_ber_bvecfree( arrayU );
break;
@ -498,7 +498,7 @@ ULONG WINAPIV ber_scanf( BerElement *ber, char *fmt, ... )
case '}':
case '[':
case ']':
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt );
ret = ldap_funcs->fn_ber_scanf( BER(ber), new_fmt, NULL, NULL );
break;
default:

View File

@ -163,140 +163,18 @@ static unsigned int CDECL wrap_ber_skip_tag( void *ber, unsigned int *ret_len )
return ret;
}
static int WINAPIV wrap_ber_printf( void *ber, char *fmt, ... )
static int CDECL wrap_ber_printf( void *ber, char *fmt, ULONG_PTR arg1, ULONG_PTR arg2 )
{
int ret;
__ms_va_list args;
assert( strlen(fmt) == 1 );
__ms_va_start( args, fmt );
switch (fmt[0])
{
case 'b':
case 'e':
case 'i':
{
int i = va_arg( args, int );
ret = ber_printf( ber, fmt, i );
break;
}
case 'o':
case 's':
{
char *str = va_arg( args, char * );
ret = ber_printf( ber, fmt, str );
break;
}
case 't':
{
unsigned int tag = va_arg( args, unsigned int );
ret = ber_printf( ber, fmt, tag );
break;
}
case 'v':
{
char **array = va_arg( args, char ** );
ret = ber_printf( ber, fmt, array );
break;
}
case 'V':
{
struct berval **array = va_arg( args, struct berval ** );
ret = ber_printf( ber, fmt, array );
break;
}
case 'B':
{
char *str = va_arg( args, char * );
int len = va_arg( args, int );
ret = ber_printf( ber, fmt, str, len );
break;
}
case 'n':
case '{':
case '}':
case '[':
case ']':
ret = ber_printf( ber, fmt );
break;
default:
assert( 0 );
}
__ms_va_end( args );
return ret;
return ber_printf( ber, fmt, arg1, arg2 );
}
static int WINAPIV wrap_ber_scanf( void *ber, char *fmt, ... )
static int CDECL wrap_ber_scanf( void *ber, char *fmt, void *arg1, void *arg2 )
{
int ret;
__ms_va_list args;
assert( strlen(fmt) == 1 );
__ms_va_start( args, fmt );
switch (fmt[0])
{
case 'a':
{
char **str = va_arg( args, char ** );
ret = ber_scanf( ber, fmt, str );
break;
}
case 'b':
case 'e':
case 'i':
{
int *i = va_arg( args, int * );
ret = ber_scanf( ber, fmt, i );
break;
}
case 't':
{
unsigned int *tag = va_arg( args, unsigned int * );
ret = ber_scanf( ber, fmt, tag );
break;
}
case 'v':
{
char ***array = va_arg( args, char *** );
ret = ber_scanf( ber, fmt, array );
break;
}
case 'B':
{
char **str = va_arg( args, char ** );
int *len = va_arg( args, int * );
ret = ber_scanf( ber, fmt, str, len );
break;
}
case 'O':
{
struct berval **berval = va_arg( args, struct berval ** );
ret = ber_scanf( ber, fmt, berval );
break;
}
case 'V':
{
struct berval ***array = va_arg( args, struct berval *** );
ret = ber_scanf( ber, fmt, array );
break;
}
case 'n':
case 'x':
case '{':
case '}':
case '[':
case ']':
ret = ber_scanf( ber, fmt );
break;
default:
assert( 0 );
}
__ms_va_end( args );
return ret;
return ber_scanf( ber, fmt, arg1, arg2 );
}
static int CDECL wrap_ldap_abandon_ext( void *ld, int msgid, LDAPControlU **serverctrls, LDAPControlU **clientctrls )

View File

@ -105,8 +105,8 @@ struct ldap_funcs
unsigned int (CDECL *fn_ber_next_element)(void *, unsigned int *, char *);
unsigned int (CDECL *fn_ber_peek_tag)(void *, unsigned int *);
unsigned int (CDECL *fn_ber_skip_tag)(void *, unsigned int *);
int (WINAPIV *fn_ber_printf)(void *, char *, ...);
int (WINAPIV *fn_ber_scanf)(void *, char *, ...);
int (CDECL *fn_ber_printf)(void *, char *, ULONG_PTR arg1, ULONG_PTR arg2 );
int (CDECL *fn_ber_scanf)(void *, char *, void *arg1, void *arg2 );
int (CDECL *fn_ldap_abandon_ext)(void *, int, LDAPControlU **, LDAPControlU **);
int (CDECL *fn_ldap_add_ext)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **, ULONG *);