diff --git a/dlls/wldap32/ber.c b/dlls/wldap32/ber.c index 53534982798..8110a07b3c2 100644 --- a/dlls/wldap32/ber.c +++ b/dlls/wldap32/ber.c @@ -24,6 +24,9 @@ #include "windef.h" #include "winbase.h" #include "winldap.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wldap32); #ifndef LBER_ERROR # define LBER_ERROR (~0U) @@ -166,13 +169,87 @@ ULONG WLDAP32_ber_skip_tag( BerElement *berelement, ULONG *len ) } -#ifndef HAVE_LDAP - -INT ber_printf( BerElement *berelement, PCHAR fmt, ... ) +/*********************************************************************** + * ber_printf (WLDAP32.@) + */ +INT WLDAP32_ber_printf( BerElement *berelement, PCHAR fmt, ... ) { +#ifdef HAVE_LDAP + va_list list; + int ret = 0; + char new_fmt[2]; + + new_fmt[1] = 0; + va_start( list, fmt ); + while (*fmt) + { + new_fmt[0] = *fmt++; + switch(new_fmt[0]) + { + case 'b': + case 'e': + case 'i': + { + int i = va_arg( list, int ); + ret = ber_printf( berelement, new_fmt, i ); + break; + } + case 'o': + case 's': + { + char *str = va_arg( list, char * ); + ret = ber_printf( berelement, new_fmt, str ); + break; + } + case 't': + { + unsigned int tag = va_arg( list, unsigned int ); + ret = ber_printf( berelement, new_fmt, tag ); + break; + } + case 'v': + { + char **array = va_arg( list, char ** ); + ret = ber_printf( berelement, new_fmt, array ); + break; + } + case 'V': + { + struct berval **array = va_arg( list, struct berval ** ); + ret = ber_printf( berelement, new_fmt, array ); + break; + } + case 'X': + { + char *str = va_arg( list, char * ); + int len = va_arg( list, int ); + ret = ber_printf( berelement, "B" /* 'X' is deprecated */, str, len ); + break; + } + case 'n': + case '{': + case '}': + case '[': + case ']': + ret = ber_printf( berelement, new_fmt ); + break; + default: + FIXME( "Unknown format '%c'\n", new_fmt[0] ); + ret = -1; + break; + } + if (ret == -1) break; + } + va_end( list ); + return ret; +#else return LBER_ERROR; +#endif } + +#ifndef HAVE_LDAP + INT ber_scanf( BerElement *berelement, PCHAR fmt, ... ) { return LBER_ERROR; diff --git a/dlls/wldap32/wldap32.spec b/dlls/wldap32/wldap32.spec index 93d4b188002..1c3a68a8a71 100644 --- a/dlls/wldap32/wldap32.spec +++ b/dlls/wldap32/wldap32.spec @@ -225,7 +225,7 @@ 307 cdecl ber_first_element(ptr ptr ptr) WLDAP32_ber_first_element 308 cdecl ber_next_element(ptr ptr ptr) WLDAP32_ber_next_element 309 cdecl ber_flatten(ptr ptr) WLDAP32_ber_flatten -310 varargs ber_printf(ptr str) +310 varargs ber_printf(ptr str) WLDAP32_ber_printf 311 varargs ber_scanf(ptr str) 312 cdecl ldap_conn_from_msg(ptr ptr) 313 cdecl ldap_sasl_bindW(ptr wstr wstr ptr ptr ptr ptr)