Wine-devel
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
April 2021
- 70 participants
- 697 discussions
[PATCH 4/5] wldap32: Move support for dn functions to the Unix library.
by Hans Leidekker 15 Apr '21
by Hans Leidekker 15 Apr '21
15 Apr '21
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/dn.c | 127 ++++++++++++++---------------------------
dlls/wldap32/libldap.c | 24 ++++++++
dlls/wldap32/libldap.h | 8 +++
3 files changed, 75 insertions(+), 84 deletions(-)
diff --git a/dlls/wldap32/dn.c b/dlls/wldap32/dn.c
index b35a5dfe1ac..61d421ee233 100644
--- a/dlls/wldap32/dn.c
+++ b/dlls/wldap32/dn.c
@@ -18,49 +18,35 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#endif
/***********************************************************************
* ldap_dn2ufnA (WLDAP32.@)
*
* See ldap_dn2ufnW.
*/
-PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
+char * CDECL ldap_dn2ufnA( char *dn )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ char *ret;
WCHAR *dnW, *retW;
TRACE( "(%s)\n", debugstr_a(dn) );
- dnW = strAtoW( dn );
- if (!dnW) return NULL;
+ if (!(dnW = strAtoW( dn ))) return NULL;
retW = ldap_dn2ufnW( dnW );
ret = strWtoA( retW );
strfreeW( dnW );
ldap_memfreeW( retW );
-
-#endif
return ret;
}
@@ -73,30 +59,26 @@ PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
* dn [I] DN to convert.
*
* RETURNS
- * Success: Pointer to a string containing the user-friendly name.
+ * Success: Pointer to a string containing the user-friendly name.
* Failure: NULL
*
* NOTES
* Free the string with ldap_memfree.
*/
-PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
+WCHAR * CDECL ldap_dn2ufnW( WCHAR *dn )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR *ret;
char *dnU, *retU;
TRACE( "(%s)\n", debugstr_w(dn) );
- dnU = strWtoU( dn );
- if (!dnU) return NULL;
+ if (!(dnU = strWtoU( dn ))) return NULL;
- retU = ldap_dn2ufn( dnU );
+ retU = ldap_funcs->ldap_dn2ufn( dnU );
ret = strUtoW( retU );
strfreeU( dnU );
- ldap_memfree( retU );
-
-#endif
+ ldap_funcs->ldap_memfree( retU );
return ret;
}
@@ -105,24 +87,20 @@ PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
*
* See ldap_explode_dnW.
*/
-PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
+char ** CDECL ldap_explode_dnA( char *dn, ULONG notypes )
{
- PCHAR *ret = NULL;
-#ifdef HAVE_LDAP
+ char **ret;
WCHAR *dnW, **retW;
TRACE( "(%s, 0x%08x)\n", debugstr_a(dn), notypes );
- dnW = strAtoW( dn );
- if (!dnW) return NULL;
+ if (!(dnW = strAtoW( dn ))) return NULL;
retW = ldap_explode_dnW( dnW, notypes );
ret = strarrayWtoA( retW );
strfreeW( dnW );
ldap_value_freeW( retW );
-
-#endif
return ret;
}
@@ -137,30 +115,26 @@ PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
*
* RETURNS
* Success: Pointer to a NULL-terminated array that contains the DN
- * components.
+ * components.
* Failure: NULL
*
* NOTES
* Free the string array with ldap_value_free.
*/
-PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
+WCHAR ** CDECL ldap_explode_dnW( WCHAR *dn, ULONG notypes )
{
- PWCHAR *ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR **ret;
char *dnU, **retU;
TRACE( "(%s, 0x%08x)\n", debugstr_w(dn), notypes );
- dnU = strWtoU( dn );
- if (!dnU) return NULL;
+ if (!(dnU = strWtoU( dn ))) return NULL;
- retU = ldap_explode_dn( dnU, notypes );
+ retU = ldap_funcs->ldap_explode_dn( dnU, notypes );
ret = strarrayUtoW( retU );
strfreeU( dnU );
- ldap_memvfree( (void **)retU );
-
-#endif
+ ldap_funcs->ldap_memvfree( (void **)retU );
return ret;
}
@@ -169,11 +143,10 @@ PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
*
* See ldap_get_dnW.
*/
-PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
+char * CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
- PWCHAR retW;
+ char *ret;
+ WCHAR *retW;
TRACE( "(%p, %p)\n", ld, entry );
@@ -183,8 +156,6 @@ PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
ret = strWtoA( retW );
ldap_memfreeW( retW );
-
-#endif
return ret;
}
@@ -204,22 +175,19 @@ PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
* NOTES
* Free the string with ldap_memfree.
*/
-PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
+WCHAR * CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR *ret;
char *retU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
- retU = ldap_get_dn( ld->ld, entry->Request );
+ retU = ldap_funcs->ldap_get_dn( ld->ld, entry->Request );
ret = strUtoW( retU );
- ldap_memfree( retU );
-
-#endif
+ ldap_funcs->ldap_memfree( retU );
return ret;
}
@@ -228,34 +196,28 @@ PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
*
* See ldap_ufn2dnW.
*/
-ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
+ULONG CDECL ldap_ufn2dnA( char *ufn, char **dn )
{
- ULONG ret = WLDAP32_LDAP_SUCCESS;
-#ifdef HAVE_LDAP
- PWCHAR ufnW = NULL, dnW = NULL;
+ ULONG ret;
+ WCHAR *ufnW = NULL, *dnW = NULL;
TRACE( "(%s, %p)\n", debugstr_a(ufn), dn );
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
-
- if (ufn) {
- ufnW = strAtoW( ufn );
- if (!ufnW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (ufn && !(ufnW = strAtoW( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_ufn2dnW( ufnW, &dnW );
-
- if (dnW) {
- *dn = strWtoA( dnW );
- if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
+ if (dnW)
+ {
+ char *str;
+ if (!(str = strWtoA( dnW ))) ret = WLDAP32_LDAP_NO_MEMORY;
+ else *dn = str;
}
strfreeW( ufnW );
ldap_memfreeW( dnW );
-
-#endif
return ret;
}
@@ -266,7 +228,7 @@ ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
*
* PARAMS
* ufn [I] User-friendly name to convert.
- * dn [O] Receives a pointer to a string containing the DN.
+ * dn [O] Receives a pointer to a string containing the DN.
*
* RETURNS
* Success: LDAP_SUCCESS
@@ -275,10 +237,9 @@ ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
* NOTES
* Free the string with ldap_memfree.
*/
-ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
+ULONG CDECL ldap_ufn2dnW( WCHAR *ufn, WCHAR **dn )
{
ULONG ret = WLDAP32_LDAP_SUCCESS;
-#ifdef HAVE_LDAP
char *ufnU = NULL;
TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
@@ -286,18 +247,16 @@ ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
-
- if (ufn) {
- ufnU = strWtoU( ufn );
- if (!ufnU) return WLDAP32_LDAP_NO_MEMORY;
+ if (ufn)
+ {
+ WCHAR *str;
+ if (!(ufnU = strWtoU( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
/* FIXME: do more than just a copy */
- *dn = strUtoW( ufnU );
- if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
+ if (!(str = strUtoW( ufnU ))) ret = WLDAP32_LDAP_NO_MEMORY;
+ else *dn = str;
}
strfreeU( ufnU );
-
-#endif
return ret;
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index bc1a161127a..c07a898e47c 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -369,6 +369,21 @@ int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serve
return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
+char * CDECL wrap_ldap_dn2ufn( const char *dn )
+{
+ return ldap_dn2ufn( dn );
+}
+
+char ** CDECL wrap_ldap_explode_dn( const char *dn, int notypes )
+{
+ return ldap_explode_dn( dn, notypes );
+}
+
+char * CDECL wrap_ldap_get_dn( void *ld, void *entry )
+{
+ return ldap_get_dn( ld, entry );
+}
+
char * CDECL wrap_ldap_first_attribute( void *ld, void *entry, void **ber )
{
return ldap_first_attribute( ld, entry, (BerElement **)ber );
@@ -389,6 +404,11 @@ void CDECL wrap_ldap_memfree( void *ptr )
return ldap_memfree( ptr );
}
+void CDECL wrap_ldap_memvfree( void **ptr )
+{
+ ldap_memvfree( ptr );
+}
+
int CDECL wrap_ldap_msgfree( void *msg )
{
return ldap_msgfree( msg );
@@ -508,10 +528,14 @@ static const struct ldap_funcs funcs =
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
+ wrap_ldap_dn2ufn,
+ wrap_ldap_explode_dn,
+ wrap_ldap_get_dn,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
wrap_ldap_first_reference,
wrap_ldap_memfree,
+ wrap_ldap_memvfree,
wrap_ldap_msgfree,
wrap_ldap_next_attribute,
wrap_ldap_next_entry,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index f307eaf4327..b339ad752bc 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -112,10 +112,14 @@ extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDA
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
+extern char * CDECL wrap_ldap_dn2ufn(const char *) DECLSPEC_HIDDEN;
+extern char ** CDECL wrap_ldap_explode_dn(const char *, int) DECLSPEC_HIDDEN;
+extern char * CDECL wrap_ldap_get_dn(void *, void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_reference(void *, void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
+extern void CDECL wrap_ldap_memvfree(void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_msgfree(void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_next_attribute(void *, void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
@@ -166,10 +170,14 @@ struct ldap_funcs
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
+ char * (CDECL *ldap_dn2ufn)(const char *);
+ char ** (CDECL *ldap_explode_dn)(const char *, int);
+ char * (CDECL *ldap_get_dn)(void *, void *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
+ void (CDECL *ldap_memvfree)(void **);
int (CDECL *ldap_msgfree)(void *);
char * (CDECL *ldap_next_attribute)(void *, void *, void *);
void * (CDECL *ldap_next_entry)(void *, void *);
--
2.30.2
1
0
[PATCH 3/5] wldap32: Move support for search functions to the Unix library.
by Hans Leidekker 15 Apr '21
by Hans Leidekker 15 Apr '21
15 Apr '21
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/dn.c | 2 +-
dlls/wldap32/error.c | 2 +-
dlls/wldap32/libldap.c | 98 ++++++++-
dlls/wldap32/libldap.h | 36 ++++
dlls/wldap32/misc.c | 250 +++++++++++-----------
dlls/wldap32/parse.c | 10 +-
dlls/wldap32/search.c | 458 +++++++++++------------------------------
dlls/wldap32/value.c | 4 +-
8 files changed, 379 insertions(+), 481 deletions(-)
diff --git a/dlls/wldap32/dn.c b/dlls/wldap32/dn.c
index 6d1a9711016..b35a5dfe1ac 100644
--- a/dlls/wldap32/dn.c
+++ b/dlls/wldap32/dn.c
@@ -214,7 +214,7 @@ PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
if (!ld || !entry) return NULL;
- retU = ldap_get_dn( ld->ld, entry );
+ retU = ldap_get_dn( ld->ld, entry->Request );
ret = strUtoW( retU );
ldap_memfree( retU );
diff --git a/dlls/wldap32/error.c b/dlls/wldap32/error.c
index c1b678788f0..a56adc11c02 100644
--- a/dlls/wldap32/error.c
+++ b/dlls/wldap32/error.c
@@ -152,7 +152,7 @@ ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *re
if (!ld || !res) return ~0u;
- ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free ) );
+ ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res->Request, &error, NULL, NULL, NULL, NULL, free ) );
if (ret == WLDAP32_LDAP_SUCCESS)
ret = error;
else
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index 11a3707f200..bc1a161127a 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -26,6 +26,7 @@
#ifdef HAVE_LDAP
#include <stdarg.h>
+#include <sys/time.h>
#ifdef HAVE_LDAP_H
# include <ldap.h>
#endif
@@ -49,6 +50,7 @@ C_ASSERT( sizeof(LDAPModU) == sizeof(LDAPMod) );
C_ASSERT( sizeof(LDAPControlU) == sizeof(LDAPControl) );
C_ASSERT( sizeof(LDAPSortKeyU) == sizeof(LDAPSortKey) );
C_ASSERT( sizeof(LDAPVLVInfoU) == sizeof(LDAPVLVInfo) );
+C_ASSERT( sizeof(struct timevalU) == sizeof(struct timeval) );
static LDAPMod *nullattrs[] = { NULL };
@@ -294,6 +296,11 @@ int WINAPIV wrap_ber_scanf( void *ber, char *fmt, ... )
return ret;
}
+int CDECL wrap_ldap_abandon_ext( void *ld, int msgid, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
+{
+ return ldap_abandon_ext( ld, msgid, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
+}
+
int CDECL wrap_ldap_add_ext( void *ld, const char *dn, LDAPModU **attrs, LDAPControlU **serverctrls,
LDAPControlU **clientctrls, ULONG *msg )
{
@@ -309,11 +316,6 @@ int CDECL wrap_ldap_add_ext_s( void *ld, const char *dn, LDAPModU **attrs, LDAPC
(LDAPControl **)clientctrls );
}
-void CDECL wrap_ldap_control_free( LDAPControlU *control )
-{
- ldap_control_free( (LDAPControl *)control );
-}
-
int CDECL wrap_ldap_compare_ext( void *ld, const char *dn, const char *attrs, struct bervalU *value,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, ULONG *msg )
{
@@ -329,6 +331,21 @@ int CDECL wrap_ldap_compare_ext_s( void *ld, const char *dn, const char *attrs,
(LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
+void CDECL wrap_ldap_control_free( LDAPControlU *control )
+{
+ ldap_control_free( (LDAPControl *)control );
+}
+
+int CDECL wrap_ldap_count_entries( void *ld, void *chain )
+{
+ return ldap_count_entries( ld, chain );
+}
+
+int CDECL wrap_ldap_count_references( void *ld, void *chain )
+{
+ return ldap_count_references( ld, chain );
+}
+
int CDECL wrap_ldap_create_sort_control( void *ld, LDAPSortKeyU **keylist, int critical, LDAPControlU **control )
{
return ldap_create_sort_control( ld, (LDAPSortKey **)keylist, critical, (LDAPControl **)control );
@@ -352,17 +369,57 @@ int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serve
return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
+char * CDECL wrap_ldap_first_attribute( void *ld, void *entry, void **ber )
+{
+ return ldap_first_attribute( ld, entry, (BerElement **)ber );
+}
+
+void * CDECL wrap_ldap_first_entry( void *ld, void *chain )
+{
+ return ldap_first_entry( ld, chain );
+}
+
+void * CDECL wrap_ldap_first_reference( void *ld, void *chain )
+{
+ return ldap_first_reference( ld, chain );
+}
+
void CDECL wrap_ldap_memfree( void *ptr )
{
return ldap_memfree( ptr );
}
+int CDECL wrap_ldap_msgfree( void *msg )
+{
+ return ldap_msgfree( msg );
+}
+
+char * CDECL wrap_ldap_next_attribute( void *ld, void *entry, void *ber )
+{
+ return ldap_next_attribute( ld, entry, ber );
+}
+
+void * CDECL wrap_ldap_next_entry( void *ld, void *entry )
+{
+ return ldap_next_entry( ld, entry );
+}
+
+void * CDECL wrap_ldap_next_reference( void *ld, void *entry )
+{
+ return ldap_next_reference( ld, entry );
+}
+
int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matcheddn, char **errmsg,
char ***referrals, LDAPControlU ***serverctrls, int free )
{
return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
}
+int CDECL wrap_ldap_result( void *ld, int msgid, int all, struct timevalU *timeout, void **result )
+{
+ return ldap_result( ld, msgid, all, (struct timeval *)timeout, (LDAPMessage **)result );
+}
+
int CDECL wrap_ldap_sasl_bind( void *ld, const char *dn, const char *mech, struct bervalU *cred,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, int *msgid )
{
@@ -393,6 +450,23 @@ int CDECL wrap_ldap_sasl_interactive_bind_s( void *ld, const char *dn, const cha
wrap_sasl_interact, defaults );
}
+int CDECL wrap_ldap_search_ext( void *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly,
+ LDAPControlU **serverctrls, LDAPControlU **clientctrls, struct timevalU *timeout,
+ int sizelimit, ULONG *msg )
+{
+ return ldap_search_ext( ld, base, scope, filter, attrs, attrsonly, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, (struct timeval *)timeout, sizelimit, (int *)msg );
+}
+
+int CDECL wrap_ldap_search_ext_s( void *ld, const char *base, int scope, const char *filter, char **attrs,
+ int attrsonly, LDAPControlU **serverctrls, LDAPControlU **clientctrls,
+ struct timevalU *timeout, int sizelimit, void **result )
+{
+ return ldap_search_ext_s( ld, base, scope, filter, attrs, attrsonly, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, (struct timeval *)timeout, sizelimit,
+ (LDAPMessage **)result );
+}
+
int CDECL wrap_ldap_unbind_ext( void *ld, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
{
return ldap_unbind_ext( ld, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
@@ -422,20 +496,33 @@ static const struct ldap_funcs funcs =
wrap_ber_skip_tag,
wrap_ber_printf,
wrap_ber_scanf,
+ wrap_ldap_abandon_ext,
wrap_ldap_add_ext,
wrap_ldap_add_ext_s,
wrap_ldap_compare_ext,
wrap_ldap_compare_ext_s,
wrap_ldap_control_free,
+ wrap_ldap_count_entries,
+ wrap_ldap_count_references,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
+ wrap_ldap_first_attribute,
+ wrap_ldap_first_entry,
+ wrap_ldap_first_reference,
wrap_ldap_memfree,
+ wrap_ldap_msgfree,
+ wrap_ldap_next_attribute,
+ wrap_ldap_next_entry,
+ wrap_ldap_next_reference,
wrap_ldap_parse_result,
+ wrap_ldap_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
wrap_ldap_sasl_interactive_bind_s,
+ wrap_ldap_search_ext,
+ wrap_ldap_search_ext_s,
wrap_ldap_unbind_ext,
wrap_ldap_unbind_ext_s,
wrap_ldap_value_free_len,
@@ -448,5 +535,4 @@ NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *p
*(const struct ldap_funcs **)ptr_out = &funcs;
return STATUS_SUCCESS;
}
-
#endif /* HAVE_LDAP */
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index 5ebc5bacd54..f307eaf4327 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -60,6 +60,12 @@ typedef struct
void *ldvlv_extradata;
} LDAPVLVInfoU;
+typedef struct timevalU
+{
+ unsigned long tv_sec;
+ unsigned long tv_usec;
+} LDAP_TIMEVALU;
+
#ifndef SASL_CB_LIST_END
#define SASL_CB_LIST_END 0
#define SASL_CB_USER 0x4001
@@ -90,6 +96,7 @@ extern unsigned int CDECL wrap_ber_skip_tag(void *, unsigned int *) DECLSPEC_HID
extern int WINAPIV wrap_ber_printf(void *, char *, ...) DECLSPEC_HIDDEN;
extern int WINAPIV wrap_ber_scanf(void *, char *, ...) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_abandon_ext(void *, int, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_add_ext(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **,
ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_add_ext_s(void *, const char *, LDAPModU **, LDAPControlU **,
@@ -99,19 +106,33 @@ extern int CDECL wrap_ldap_compare_ext(void *, const char *, const char *, struc
extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_control_free(LDAPControlU *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_count_entries(void *, void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_count_references(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
+extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
+extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
+extern void * CDECL wrap_ldap_first_reference(void *, void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_msgfree(void *) DECLSPEC_HIDDEN;
+extern char * CDECL wrap_ldap_next_attribute(void *, void *, void *) DECLSPEC_HIDDEN;
+extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
+extern void * CDECL wrap_ldap_next_reference(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
int) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_result(void *, int, int, struct timevalU *, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, struct bervalU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_interactive_bind_s(void *, const char *, const char *, LDAPControlU **,
LDAPControlU **, unsigned int, void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_search_ext(void *, const char *, int, const char *, char **, int, LDAPControlU **,
+ LDAPControlU **, struct timevalU *, int, ULONG *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_search_ext_s(void *, const char *, int, const char *, char **, int, LDAPControlU **,
+ LDAPControlU **, struct timevalU *, int, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_unbind_ext(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_unbind_ext_s(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_value_free_len(struct bervalU **) DECLSPEC_HIDDEN;
@@ -131,6 +152,7 @@ struct ldap_funcs
int (WINAPIV *ber_printf)(void *, char *, ...);
int (WINAPIV *ber_scanf)(void *, char *, ...);
+ int (CDECL *ldap_abandon_ext)(void *, int, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_add_ext)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_add_ext_s)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_compare_ext)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
@@ -138,18 +160,32 @@ struct ldap_funcs
int (CDECL *ldap_compare_ext_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **);
void (CDECL *ldap_control_free)(LDAPControlU *);
+ int (CDECL *ldap_count_entries)(void *, void *);
+ int (CDECL *ldap_count_references)(void *, void *);
int (CDECL *ldap_create_sort_control)(void *, LDAPSortKeyU **, int, LDAPControlU **);
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
+ char * (CDECL *ldap_first_attribute)(void *, void *, void **);
+ void * (CDECL *ldap_first_entry)(void *, void *);
+ void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
+ int (CDECL *ldap_msgfree)(void *);
+ char * (CDECL *ldap_next_attribute)(void *, void *, void *);
+ void * (CDECL *ldap_next_entry)(void *, void *);
+ void * (CDECL *ldap_next_reference)(void *, void *);
int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
+ int (CDECL *ldap_result)(void *, int, int, struct timevalU *, void **);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
int (CDECL *ldap_sasl_bind_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, struct bervalU **);
int (CDECL *ldap_sasl_interactive_bind_s)(void *, const char *, const char *, LDAPControlU **, LDAPControlU **,
unsigned int, void *);
+ int (CDECL *ldap_search_ext)(void *, const char *, int, const char *, char **, int, LDAPControlU **,
+ LDAPControlU **, struct timevalU *, int, ULONG *);
+ int (CDECL *ldap_search_ext_s)(void *, const char *, int, const char *, char **, int, LDAPControlU **,
+ LDAPControlU **, struct timevalU *, int, void **);
int (CDECL *ldap_unbind_ext)(void *, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_unbind_ext_s)(void *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_value_free_len)(struct bervalU **);
diff --git a/dlls/wldap32/misc.c b/dlls/wldap32/misc.c
index dd1a1ef3f12..234b84d42f9 100644
--- a/dlls/wldap32/misc.c
+++ b/dlls/wldap32/misc.c
@@ -18,22 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "wine/heap.h"
+#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
@@ -52,16 +44,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
*/
ULONG CDECL WLDAP32_ldap_abandon( WLDAP32_LDAP *ld, ULONG msgid )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
-
TRACE( "(%p, 0x%08x)\n", ld, msgid );
if (!ld) return ~0u;
- ret = map_error( ldap_abandon_ext( ld->ld, msgid, NULL, NULL ));
-
-#endif
- return ret;
+ return map_error( ldap_funcs->ldap_abandon_ext( ld->ld, msgid, NULL, NULL ) );
}
/***********************************************************************
@@ -69,7 +55,7 @@ ULONG CDECL WLDAP32_ldap_abandon( WLDAP32_LDAP *ld, ULONG msgid )
*
* See ldap_check_filterW.
*/
-ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
+ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, char *filter )
{
ULONG ret;
WCHAR *filterW = NULL;
@@ -77,11 +63,7 @@ ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
TRACE( "(%p, %s)\n", ld, debugstr_a(filter) );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (filter && !(filterW = strAtoW( filter ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_check_filterW( ld, filterW );
@@ -102,7 +84,7 @@ ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_check_filterW( WLDAP32_LDAP *ld, PWCHAR filter )
+ULONG CDECL ldap_check_filterW( WLDAP32_LDAP *ld, WCHAR *filter )
{
TRACE( "(%p, %s)\n", ld, debugstr_w(filter) );
@@ -155,16 +137,10 @@ WLDAP32_LDAP * CDECL ldap_conn_from_msg( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *
*/
ULONG CDECL WLDAP32_ldap_count_entries( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
-
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return ~0u;
- ret = ldap_count_entries( ld->ld, res );
-
-#endif
- return ret;
+ return ldap_funcs->ldap_count_entries( ld->ld, res->Request );
}
/***********************************************************************
@@ -182,16 +158,10 @@ ULONG CDECL WLDAP32_ldap_count_entries( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *r
*/
ULONG CDECL WLDAP32_ldap_count_references( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP_COUNT_REFERENCES
-
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return 0;
- ret = ldap_count_references( ld->ld, res );
-
-#endif
- return ret;
+ return ldap_funcs->ldap_count_references( ld->ld, res->Request );
}
static ULONG get_escape_size( PCHAR src, ULONG srclen )
@@ -213,7 +183,7 @@ static ULONG get_escape_size( PCHAR src, ULONG srclen )
return size + 1;
}
-static void escape_filter_element( PCHAR src, ULONG srclen, PCHAR dst )
+static void escape_filter_element( char *src, ULONG srclen, char *dst )
{
ULONG i;
static const char fmt[] = "\\%02X";
@@ -236,22 +206,17 @@ static void escape_filter_element( PCHAR src, ULONG srclen, PCHAR dst )
*
* See ldap_escape_filter_elementW.
*/
-ULONG CDECL ldap_escape_filter_elementA( PCHAR src, ULONG srclen, PCHAR dst, ULONG dstlen )
+ULONG CDECL ldap_escape_filter_elementA( char *src, ULONG srclen, char *dst, ULONG dstlen )
{
- ULONG len;
+ ULONG len = get_escape_size( src, srclen );
TRACE( "(%p, 0x%08x, %p, 0x%08x)\n", src, srclen, dst, dstlen );
- len = get_escape_size( src, srclen );
if (!dst) return len;
+ if (!src || dstlen < len) return WLDAP32_LDAP_PARAM_ERROR;
- if (!src || dstlen < len)
- return WLDAP32_LDAP_PARAM_ERROR;
- else
- {
- escape_filter_element( src, srclen, dst );
- return WLDAP32_LDAP_SUCCESS;
- }
+ escape_filter_element( src, srclen, dst );
+ return WLDAP32_LDAP_SUCCESS;
}
/***********************************************************************
@@ -269,13 +234,12 @@ ULONG CDECL ldap_escape_filter_elementA( PCHAR src, ULONG srclen, PCHAR dst, ULO
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_escape_filter_elementW( PCHAR src, ULONG srclen, PWCHAR dst, ULONG dstlen )
+ULONG CDECL ldap_escape_filter_elementW( char *src, ULONG srclen, WCHAR *dst, ULONG dstlen )
{
- ULONG len;
+ ULONG len = get_escape_size( src, srclen );
TRACE( "(%p, 0x%08x, %p, 0x%08x)\n", src, srclen, dst, dstlen );
- len = get_escape_size( src, srclen );
if (!dst) return len;
/* no matter what you throw at it, this is what native returns */
@@ -287,29 +251,29 @@ ULONG CDECL ldap_escape_filter_elementW( PCHAR src, ULONG srclen, PWCHAR dst, UL
*
* See ldap_first_attributeW.
*/
-PCHAR CDECL ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement** ptr )
+char * CDECL ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement **ber )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ char *ret = NULL;
WCHAR *retW;
- TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
+ TRACE( "(%p, %p, %p)\n", ld, entry, ber );
if (!ld || !entry) return NULL;
- retW = ldap_first_attributeW( ld, entry, ptr );
- ret = strWtoA( retW );
- ldap_memfreeW( retW );
+ retW = ldap_first_attributeW( ld, entry->Request, ber );
+ if (retW)
+ {
+ ret = strWtoA( retW );
+ ldap_memfreeW( retW );
+ }
-#endif
return ret;
}
/***********************************************************************
* ldap_first_attributeW (WLDAP32.@)
*
- * Get the first attribute for a given entry.
+ * Get the first attribute for a given entry.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
@@ -323,29 +287,26 @@ PCHAR CDECL ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
* NOTES
* Use ldap_memfree to free the returned string.
*/
-PWCHAR CDECL ldap_first_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement** ptr )
+WCHAR * CDECL ldap_first_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement **ptr )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
- BerElement *berU;
+ WCHAR *ret = NULL;
+ WLDAP32_BerElement *ber;
char *retU;
+ void *berU;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry) return NULL;
- retU = ldap_first_attribute( ld->ld, entry, &berU );
- if (retU)
+ retU = ldap_funcs->ldap_first_attribute( ld->ld, entry->Request, &berU );
+ if (retU && (ber = heap_alloc( sizeof(*ber) )))
{
- WLDAP32_BerElement *ber = heap_alloc( sizeof(*ber) );
ber->opaque = (char *)berU;
*ptr = ber;
ret = strUtoW( retU );
- ldap_memfree( retU );
}
-#endif
+ ldap_funcs->ldap_memfree( retU );
return ret;
}
@@ -363,20 +324,24 @@ PWCHAR CDECL ldap_first_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry
* Failure: NULL
*
* NOTES
- * The returned entry will be freed when the message is freed.
+ * The returned entry will be freed when the message is freed.
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_entry( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
-#ifdef HAVE_LDAP
+ void *msgU;
TRACE( "(%p, %p)\n", ld, res );
if (!ld || !res) return NULL;
- return ldap_first_entry( ld->ld, res );
-#else
+ msgU = ldap_funcs->ldap_first_entry( ld->ld, res->Request );
+ if (msgU)
+ {
+ assert( msgU == res->Request );
+ return res;
+ }
+
return NULL;
-#endif
}
/***********************************************************************
@@ -394,16 +359,20 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_entry( WLDAP32_LDAP *ld, WLDAP32_
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_reference( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
-#ifdef HAVE_LDAP_FIRST_REFERENCE
+ void *msgU;
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return NULL;
- return ldap_first_reference( ld->ld, res );
-#else
+ msgU = ldap_funcs->ldap_first_reference( ld->ld, res->Request );
+ if (msgU)
+ {
+ assert( msgU == res->Request );
+ return res;
+ }
+
return NULL;
-#endif
}
/***********************************************************************
@@ -411,7 +380,7 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_reference( WLDAP32_LDAP *ld, WLDA
*
* See ldap_memfreeW.
*/
-void CDECL ldap_memfreeA( PCHAR block )
+void CDECL ldap_memfreeA( char *block )
{
TRACE( "(%p)\n", block );
strfreeA( block );
@@ -425,7 +394,7 @@ void CDECL ldap_memfreeA( PCHAR block )
* PARAMS
* block [I] Pointer to memory block to be freed.
*/
-void CDECL ldap_memfreeW( PWCHAR block )
+void CDECL ldap_memfreeW( WCHAR *block )
{
TRACE( "(%p)\n", block );
strfreeW( block );
@@ -441,14 +410,21 @@ void CDECL ldap_memfreeW( PWCHAR block )
*/
ULONG CDECL WLDAP32_ldap_msgfree( WLDAP32_LDAPMessage *res )
{
- ULONG ret = WLDAP32_LDAP_SUCCESS;
-#ifdef HAVE_LDAP
+ WLDAP32_LDAPMessage *entry, *list = res;
TRACE( "(%p)\n", res );
- ldap_msgfree( res );
-#endif
- return ret;
+ if (!res) return WLDAP32_LDAP_SUCCESS;
+
+ ldap_funcs->ldap_msgfree( res->Request );
+ while (list)
+ {
+ entry = list;
+ list = entry->lm_next;
+ heap_free( entry );
+ }
+
+ return WLDAP32_LDAP_SUCCESS;
}
/***********************************************************************
@@ -456,22 +432,22 @@ ULONG CDECL WLDAP32_ldap_msgfree( WLDAP32_LDAPMessage *res )
*
* See ldap_next_attributeW.
*/
-PCHAR CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement *ptr )
+char * CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement *ptr )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ char *ret = NULL;
WCHAR *retW;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry || !ptr) return NULL;
- retW = ldap_next_attributeW( ld, entry, ptr );
- ret = strWtoA( retW );
- ldap_memfreeW( retW );
+ retW = ldap_next_attributeW( ld, entry->Request, ptr );
+ if (retW)
+ {
+ ret = strWtoA( retW );
+ ldap_memfreeW( retW );
+ }
-#endif
return ret;
}
@@ -493,25 +469,22 @@ PCHAR CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
* Free the returned string after each iteration with ldap_memfree.
* When done iterating and when ptr != NULL, call ber_free( ptr, 0 ).
*/
-PWCHAR CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement *ber )
+WCHAR * CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement *ptr )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR *ret = NULL;
char *retU;
- TRACE( "(%p, %p, %p)\n", ld, entry, ber );
+ TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
- if (!ld || !entry) return NULL;
+ if (!ld || !entry || !ptr) return NULL;
- retU = ldap_next_attribute( ld->ld, entry, (BerElement *)ber->opaque );
+ retU = ldap_funcs->ldap_next_attribute( ld->ld, entry->Request, ptr->opaque );
if (retU)
{
ret = strUtoW( retU );
- ldap_memfree( retU );
+ ldap_funcs->ldap_memfree( retU );
}
-#endif
return ret;
}
@@ -533,16 +506,23 @@ PWCHAR CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_entry( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
-#ifdef HAVE_LDAP
+ WLDAP32_LDAPMessage *msg = NULL;
+ void *msgU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
- return ldap_next_entry( ld->ld, entry );
-#else
- return NULL;
-#endif
+ if (entry->lm_next) return entry->lm_next;
+
+ msgU = ldap_funcs->ldap_next_entry( ld->ld, entry->Request );
+ if (msgU && (msg = heap_alloc_zero( sizeof(*msg) )))
+ {
+ msg->Request = msgU;
+ entry->lm_next = msg;
+ }
+
+ return msg;
}
/***********************************************************************
@@ -563,16 +543,23 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_entry( WLDAP32_LDAP *ld, WLDAP32_L
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_reference( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
-#ifdef HAVE_LDAP_NEXT_REFERENCE
+ WLDAP32_LDAPMessage *msg = NULL;
+ void *msgU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
- return ldap_next_reference( ld->ld, entry );
-#else
- return NULL;
-#endif
+ if (entry->lm_next) return entry->lm_next;
+
+ msgU = ldap_funcs->ldap_next_reference( ld->ld, entry->Request );
+ if (msgU && (msg = heap_alloc_zero( sizeof(*msg) )))
+ {
+ msg->Request = msgU;
+ entry->lm_next = msg;
+ }
+
+ return msg;
}
/***********************************************************************
@@ -611,18 +598,31 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_reference( WLDAP32_LDAP *ld, WLDAP
* to immediately return any available results. Free returned results
* with ldap_msgfree.
*/
-ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
- struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
+ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all, struct l_timeval *timeout,
+ WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ WLDAP32_LDAPMessage *msg;
+ struct timevalU timeval;
+ void *msgU = NULL;
+ ULONG ret;
TRACE( "(%p, 0x%08x, 0x%08x, %p, %p)\n", ld, msgid, all, timeout, res );
if (!ld || !res || msgid == ~0u) return ~0u;
- ret = ldap_result( ld->ld, msgid, all, (struct timeval *)timeout, res );
-#endif
+ if (timeout)
+ {
+ timeval.tv_sec = timeout->tv_sec;
+ timeval.tv_usec = timeout->tv_usec;
+ }
+
+ ret = ldap_funcs->ldap_result( ld->ld, msgid, all, timeout ? &timeval : NULL, &msgU );
+ if (msgU && (msg = heap_alloc_zero( sizeof(*msg) )))
+ {
+ msg->Request = msgU;
+ *res = msg;
+ }
+
return ret;
}
@@ -635,7 +635,7 @@ ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
* src [I] Wide character string to convert.
* srclen [I] Size of string to convert, in characters.
* dst [O] Pointer to a buffer that receives the converted string.
- * dstlen [I] Size of the destination buffer in characters.
+ * dstlen [I] Size of the destination buffer in characters.
*
* RETURNS
* The number of characters written into the destination buffer.
@@ -643,7 +643,7 @@ ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
* NOTES
* Set dstlen to zero to ask for the required buffer size.
*/
-int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
+int CDECL LdapUnicodeToUTF8( const WCHAR *src, int srclen, char *dst, int dstlen )
{
return WideCharToMultiByte( CP_UTF8, 0, src, srclen, dst, dstlen, NULL, NULL );
}
@@ -657,7 +657,7 @@ int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
* src [I] UTF8 string to convert.
* srclen [I] Size of string to convert, in characters.
* dst [O] Pointer to a buffer that receives the converted string.
- * dstlen [I] Size of the destination buffer in characters.
+ * dstlen [I] Size of the destination buffer in characters.
*
* RETURNS
* The number of characters written into the destination buffer.
@@ -665,7 +665,7 @@ int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
* NOTES
* Set dstlen to zero to ask for the required buffer size.
*/
-int CDECL LdapUTF8ToUnicode( LPCSTR src, int srclen, LPWSTR dst, int dstlen )
+int CDECL LdapUTF8ToUnicode( const char *src, int srclen, WCHAR *dst, int dstlen )
{
return MultiByteToWideChar( CP_UTF8, 0, src, srclen, dst, dstlen );
}
diff --git a/dlls/wldap32/parse.c b/dlls/wldap32/parse.c
index 6bde8542bec..bbaa7b1f842 100644
--- a/dlls/wldap32/parse.c
+++ b/dlls/wldap32/parse.c
@@ -99,7 +99,7 @@ ULONG CDECL ldap_parse_extended_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (!result) return WLDAP32_LDAP_NO_RESULTS_RETURNED;
- ret = map_error( ldap_parse_extended_result( ld->ld, result, &oidU, (struct berval **)data, free ) );
+ ret = map_error( ldap_parse_extended_result( ld->ld, result->Request, &oidU, (struct berval **)data, free ) );
if (oid) {
*oid = strUtoW( oidU );
@@ -153,18 +153,18 @@ ULONG CDECL ldap_parse_referenceA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *messag
* NOTES
* Free the referrals with ldap_value_free.
*/
-ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
+ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
PWCHAR **referrals )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP_PARSE_REFERENCE
char **referralsU = NULL;
- TRACE( "(%p, %p, %p)\n", ld, message, referrals );
+ TRACE( "(%p, %p, %p)\n", ld, result, referrals );
if (!ld) return ~0u;
- ret = map_error( ldap_parse_reference( ld->ld, message, &referralsU, NULL, 0 ));
+ ret = map_error( ldap_parse_reference( ld->ld, result->Request, &referralsU, NULL, 0 ));
*referrals = strarrayUtoW( referralsU );
ldap_memfree( referralsU );
@@ -249,7 +249,7 @@ ULONG CDECL ldap_parse_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- ret = map_error( ldap_parse_result( ld->ld, result, (int *)retcode, &matchedU, &errorU,
+ ret = map_error( ldap_parse_result( ld->ld, result->Request, (int *)retcode, &matchedU, &errorU,
&referralsU, &serverctrlsU, free ));
if (matched) *matched = strUtoW( matchedU );
diff --git a/dlls/wldap32/search.c b/dlls/wldap32/search.c
index 88ecb541c92..b4bf204f817 100644
--- a/dlls/wldap32/search.c
+++ b/dlls/wldap32/search.c
@@ -18,57 +18,34 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "wine/heap.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#endif
/***********************************************************************
* ldap_searchA (WLDAP32.@)
*
* See ldap_searchW.
*/
-ULONG CDECL ldap_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
- PCHAR attrs[], ULONG attrsonly )
+ULONG CDECL ldap_searchA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs, ULONG attrsonly )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(base),
- scope, debugstr_a(filter), attrs, attrsonly );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly );
if (!ld) return ~0u;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
@@ -76,8 +53,6 @@ exit:
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
-
-#endif
return ret;
}
@@ -104,49 +79,14 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
- PWCHAR attrs[], ULONG attrsonly )
+ULONG CDECL ldap_searchW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs, ULONG attrsonly )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
- int msg;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(base),
- scope, debugstr_w(filter), attrs, attrsonly );
-
- if (!ld) return ~0u;
+ ULONG ret, msg;
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly );
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
-
- ret = ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- NULL, NULL, NULL, 0, &msg );
-
- if (ret == LDAP_SUCCESS)
- ret = msg;
- else
- ret = ~0u;
-
-exit:
- strfreeU( baseU );
- strfreeU( filterU );
- strarrayfreeU( attrsU );
-
-#endif
- return ret;
+ ret = ldap_search_extW( ld, base, scope, filter, attrs, attrsonly, NULL, NULL, 0, 0, &msg );
+ if (ret == WLDAP32_LDAP_SUCCESS) return msg;
+ return ~0u;
}
/***********************************************************************
@@ -154,47 +94,26 @@ exit:
*
* See ldap_search_extW.
*/
-ULONG CDECL ldap_search_extA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
- PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
+ULONG CDECL ldap_search_extA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs, ULONG attrsonly,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
- ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
- serverctrls, clientctrls, timelimit, sizelimit, message );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_a(base), scope,
+ debugstr_a(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter)
- {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
- ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly,
- serverctrlsW, clientctrlsW, timelimit, sizelimit, message );
+ ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly, serverctrlsW, clientctrlsW, timelimit,
+ sizelimit, message );
exit:
strfreeW( baseW );
@@ -202,8 +121,6 @@ exit:
strarrayfreeW( attrsW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -235,63 +152,38 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_search_extW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
- PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
+ULONG CDECL ldap_search_extW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs,
+ ULONG attrsonly, LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG timelimit, ULONG sizelimit,
+ ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
- struct timeval tv, *tvp = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
+ struct timevalU timevalU;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
- ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
- serverctrls, clientctrls, timelimit, sizelimit, message );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_w(base), scope,
+ debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, message );
if (!ld) return ~0u;
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- if (timelimit)
- {
- tv.tv_sec = timelimit;
- tv.tv_usec = 0;
- tvp = &tv;
- }
+ if (base && !(baseU = strWtoU( base ))) goto exit;
+ if (filter && !(filterU = strWtoU( filter ))) goto exit;
+ if (attrs && !(attrsU = strarrayWtoU( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
- ret = map_error( ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- serverctrlsU, clientctrlsU, tvp, sizelimit, (int *)message ));
+ timevalU.tv_sec = timelimit;
+ timevalU.tv_usec = 0;
+ ret = map_error( ldap_funcs->ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
+ serverctrlsU, clientctrlsU, timelimit ? &timevalU : NULL, sizelimit,
+ message ) );
exit:
strfreeU( baseU );
strfreeU( filterU );
strarrayfreeU( attrsU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -300,46 +192,27 @@ exit:
*
* See ldap_search_ext_sW.
*/
-ULONG CDECL ldap_search_ext_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
- PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_ext_sA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs,
+ ULONG attrsonly, LDAPControlA **serverctrls, LDAPControlA **clientctrls, struct l_timeval *timeout,
+ ULONG sizelimit, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n",
- ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
- serverctrls, clientctrls, timeout, sizelimit, res );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n", ld, debugstr_a(base), scope,
+ debugstr_a(filter), attrs, attrsonly, serverctrls, clientctrls, timeout, sizelimit, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
- ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly,
- serverctrlsW, clientctrlsW, timeout, sizelimit, res );
+ ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly, serverctrlsW, clientctrlsW, timeout,
+ sizelimit, res );
exit:
strfreeW( baseW );
@@ -347,8 +220,6 @@ exit:
strarrayfreeW( attrsW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -378,47 +249,49 @@ exit:
* NOTES
* Call ldap_msgfree to free the results.
*/
-ULONG CDECL ldap_search_ext_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
- PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_ext_sW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs,
+ ULONG attrsonly, LDAPControlW **serverctrls, LDAPControlW **clientctrls, struct l_timeval *timeout,
+ ULONG sizelimit, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
+ struct timevalU timevalU;
+ void *msgU = NULL;
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n",
- ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
- serverctrls, clientctrls, timeout, sizelimit, res );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n", ld, debugstr_w(base), scope,
+ debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timeout, sizelimit, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
+ if (base && !(baseU = strWtoU( base ))) goto exit;
+ if (filter && !(filterU = strWtoU( filter ))) goto exit;
+ if (attrs && !(attrsU = strarrayWtoU( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ if (timeout)
+ {
+ timevalU.tv_sec = timeout->tv_sec;
+ timevalU.tv_usec = timeout->tv_usec;
}
- ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- serverctrlsU, clientctrlsU, (struct timeval *)timeout,
- sizelimit, res ));
+ ret = map_error( ldap_funcs->ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly, serverctrlsU,
+ clientctrlsU, timeout ? &timevalU : NULL, sizelimit, &msgU ) );
+ if (msgU)
+ {
+ WLDAP32_LDAPMessage *msg = heap_alloc_zero( sizeof(*msg) );
+ if (msg)
+ {
+ msg->Request = msgU;
+ *res = msg;
+ }
+ else
+ {
+ ldap_funcs->ldap_msgfree( msgU );
+ ret = WLDAP32_LDAP_NO_MEMORY;
+ }
+ }
exit:
strfreeU( baseU );
@@ -426,8 +299,6 @@ exit:
strarrayfreeU( attrsU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -436,32 +307,20 @@ exit:
*
* See ldap_search_sW.
*/
-ULONG CDECL ldap_search_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
- PCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_sA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs, ULONG attrsonly,
+ WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_a(base),
- scope, debugstr_a(filter), attrs, attrsonly, res );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_a(base), scope, debugstr_a(filter), attrs,
+ attrsonly, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
@@ -469,8 +328,6 @@ exit:
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
-
-#endif
return ret;
}
@@ -496,43 +353,12 @@ exit:
* NOTES
* Call ldap_msgfree to free the results.
*/
-ULONG CDECL ldap_search_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
- PWCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_sW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs, ULONG attrsonly,
+ WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_w(base),
- scope, debugstr_w(filter), attrs, attrsonly, res );
-
- if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
-
- ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- NULL, NULL, NULL, 0, res ));
-
-exit:
- strfreeU( baseU );
- strfreeU( filterU );
- strarrayfreeU( attrsU );
-
-#endif
- return ret;
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs,
+ attrsonly, res );
+ return ldap_search_ext_sW( ld, base, scope, filter, attrs, attrsonly, NULL, NULL, NULL, 0, res );
}
/***********************************************************************
@@ -540,44 +366,27 @@ exit:
*
* See ldap_search_stW.
*/
-ULONG CDECL ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope,
- const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
- struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope, const PCHAR filter, char **attrs,
+ ULONG attrsonly, struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld,
- debugstr_a(base), scope, debugstr_a(filter), attrs,
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld, debugstr_a(base), scope, debugstr_a(filter), attrs,
attrsonly, timeout, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
- ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
- timeout, res );
+ ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly, timeout, res );
exit:
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
-
-#endif
return ret;
}
@@ -604,43 +413,10 @@ exit:
* NOTES
* Call ldap_msgfree to free the results.
*/
-ULONG CDECL ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope,
- const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly,
- struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope, const PWCHAR filter, WCHAR **attrs,
+ ULONG attrsonly, struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld,
- debugstr_w(base), scope, debugstr_w(filter), attrs,
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs,
attrsonly, timeout, res );
-
- if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
-
- ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- NULL, NULL, (struct timeval *)timeout, 0, res ));
-
-exit:
- strfreeU( baseU );
- strfreeU( filterU );
- strarrayfreeU( attrsU );
-
-#endif
- return ret;
+ return ldap_search_ext_sW( ld, base, scope, filter, attrs, attrsonly, NULL, NULL, timeout, 0, res );
}
diff --git a/dlls/wldap32/value.c b/dlls/wldap32/value.c
index ff13289b309..a7d7d44244f 100644
--- a/dlls/wldap32/value.c
+++ b/dlls/wldap32/value.c
@@ -228,7 +228,7 @@ PWCHAR * CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, P
attrU = strWtoU( attr );
if (!attrU) return NULL;
- bv = ldap_get_values_len( ld->ld, entry, attrU );
+ bv = ldap_get_values_len( ld->ld, entry->Request, attrU );
if (bv)
{
retU = bv2str_array( bv );
@@ -305,7 +305,7 @@ struct WLDAP32_berval ** CDECL ldap_get_values_lenW( WLDAP32_LDAP *ld,
attrU = strWtoU( attr );
if (!attrU) return NULL;
- ret = ldap_get_values_len( ld->ld, message, attrU );
+ ret = ldap_get_values_len( ld->ld, message->Request, attrU );
strfreeU( attrU );
return (struct WLDAP32_berval **)ret;
--
2.30.2
1
0
[PATCH 2/5] wldap32: Move support for error functions to the Unix library.
by Hans Leidekker 15 Apr '21
by Hans Leidekker 15 Apr '21
15 Apr '21
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/error.c | 64 ++++++++++++++++++------------------------
dlls/wldap32/libldap.c | 7 +++++
dlls/wldap32/libldap.h | 3 ++
3 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/dlls/wldap32/error.c b/dlls/wldap32/error.c
index 11ecaf8763b..c1b678788f0 100644
--- a/dlls/wldap32/error.c
+++ b/dlls/wldap32/error.c
@@ -18,47 +18,41 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
+extern HINSTANCE hwldap32 DECLSPEC_HIDDEN;
+
ULONG map_error( int error )
{
switch (error)
{
-#ifdef HAVE_LDAP_H
- case LDAP_SERVER_DOWN: return WLDAP32_LDAP_SERVER_DOWN;
- case LDAP_LOCAL_ERROR: return WLDAP32_LDAP_LOCAL_ERROR;
- case LDAP_DECODING_ERROR: return WLDAP32_LDAP_DECODING_ERROR;
- case LDAP_TIMEOUT: return WLDAP32_LDAP_TIMEOUT;
- case LDAP_AUTH_UNKNOWN: return WLDAP32_LDAP_AUTH_UNKNOWN;
- case LDAP_FILTER_ERROR: return WLDAP32_LDAP_FILTER_ERROR;
- case LDAP_USER_CANCELLED: return WLDAP32_LDAP_USER_CANCELLED;
- case LDAP_PARAM_ERROR: return WLDAP32_LDAP_PARAM_ERROR;
- case LDAP_NO_MEMORY: return WLDAP32_LDAP_NO_MEMORY;
- case LDAP_CONNECT_ERROR: return WLDAP32_LDAP_CONNECT_ERROR;
- case LDAP_NOT_SUPPORTED: return WLDAP32_LDAP_NOT_SUPPORTED;
- case LDAP_CONTROL_NOT_FOUND: return WLDAP32_LDAP_CONTROL_NOT_FOUND;
- case LDAP_NO_RESULTS_RETURNED: return WLDAP32_LDAP_NO_RESULTS_RETURNED;
- case LDAP_MORE_RESULTS_TO_RETURN: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN;
- case LDAP_CLIENT_LOOP: return WLDAP32_LDAP_CLIENT_LOOP;
- case LDAP_REFERRAL_LIMIT_EXCEEDED: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED;
-#endif
+ case 0: return WLDAP32_LDAP_SUCCESS;
+ case -1: return WLDAP32_LDAP_SERVER_DOWN;
+ case -2: return WLDAP32_LDAP_LOCAL_ERROR;
+ case -3: return WLDAP32_LDAP_ENCODING_ERROR;
+ case -4: return WLDAP32_LDAP_DECODING_ERROR;
+ case -5: return WLDAP32_LDAP_TIMEOUT;
+ case -6: return WLDAP32_LDAP_AUTH_UNKNOWN;
+ case -7: return WLDAP32_LDAP_FILTER_ERROR;
+ case -8: return WLDAP32_LDAP_USER_CANCELLED;
+ case -9: return WLDAP32_LDAP_PARAM_ERROR;
+ case -10: return WLDAP32_LDAP_NO_MEMORY;
+ case -11: return WLDAP32_LDAP_CONNECT_ERROR;
+ case -12: return WLDAP32_LDAP_NOT_SUPPORTED;
+ case -13: return WLDAP32_LDAP_CONTROL_NOT_FOUND;
+ case -14: return WLDAP32_LDAP_NO_RESULTS_RETURNED;
+ case -15: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN;
+ case -16: return WLDAP32_LDAP_CLIENT_LOOP;
+ case -17: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED;
default: return error;
}
}
@@ -68,7 +62,7 @@ ULONG map_error( int error )
*
* See ldap_err2stringW.
*/
-PCHAR CDECL ldap_err2stringA( ULONG err )
+char * CDECL ldap_err2stringA( ULONG err )
{
static char buf[256] = "";
@@ -98,7 +92,7 @@ PCHAR CDECL ldap_err2stringA( ULONG err )
* The returned string is statically allocated, you must not
* free this string.
*/
-PWCHAR CDECL ldap_err2stringW( ULONG err )
+WCHAR * CDECL ldap_err2stringW( ULONG err )
{
static WCHAR buf[256] = { 0 };
@@ -151,22 +145,19 @@ void CDECL WLDAP32_ldap_perror( WLDAP32_LDAP *ld, const PCHAR msg )
*/
ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res, ULONG free )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
int error;
TRACE( "(%p, %p, 0x%08x)\n", ld, res, free );
if (!ld || !res) return ~0u;
- ret = ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free );
-
- if (ret == LDAP_SUCCESS)
+ ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free ) );
+ if (ret == WLDAP32_LDAP_SUCCESS)
ret = error;
else
ret = ~0u;
-#endif
return ret;
}
@@ -303,7 +294,6 @@ ULONG CDECL LdapMapErrorToWin32( ULONG err )
{
TRACE( "(0x%08x)\n", err );
- if (err >= ARRAY_SIZE( WLDAP32_errormap ))
- return ERROR_DS_GENERIC_ERROR;
+ if (err >= ARRAY_SIZE( WLDAP32_errormap )) return ERROR_DS_GENERIC_ERROR;
return WLDAP32_errormap[err];
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index be2e540721b..11a3707f200 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -357,6 +357,12 @@ void CDECL wrap_ldap_memfree( void *ptr )
return ldap_memfree( ptr );
}
+int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matcheddn, char **errmsg,
+ char ***referrals, LDAPControlU ***serverctrls, int free )
+{
+ return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
+}
+
int CDECL wrap_ldap_sasl_bind( void *ld, const char *dn, const char *mech, struct bervalU *cred,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, int *msgid )
{
@@ -426,6 +432,7 @@ static const struct ldap_funcs funcs =
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
wrap_ldap_memfree,
+ wrap_ldap_parse_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
wrap_ldap_sasl_interactive_bind_s,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index dde7d3eba17..5ebc5bacd54 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -104,6 +104,8 @@ extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPContro
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
+ int) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
@@ -141,6 +143,7 @@ struct ldap_funcs
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_memfree)(void *);
+ int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
int (CDECL *ldap_sasl_bind_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
--
2.30.2
1
0
[PATCH 1/5] wldap32: Move support for delete functions to the Unix library.
by Hans Leidekker 15 Apr '21
by Hans Leidekker 15 Apr '21
15 Apr '21
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/delete.c | 214 ++++++++++-------------------------------
dlls/wldap32/libldap.c | 15 +++
dlls/wldap32/libldap.h | 4 +
3 files changed, 68 insertions(+), 165 deletions(-)
diff --git a/dlls/wldap32/delete.c b/dlls/wldap32/delete.c
index 95d636e4874..9f2b107f62c 100644
--- a/dlls/wldap32/delete.c
+++ b/dlls/wldap32/delete.c
@@ -18,50 +18,33 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#endif
/***********************************************************************
* ldap_deleteA (WLDAP32.@)
*
* See ldap_deleteW.
*/
-ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
+ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, char *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
WCHAR *dnW = NULL;
TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
if (!ld) return ~0u;
-
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (dn && !(dnW = strAtoW( dn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_deleteW( ld, dnW );
strfreeW( dnW );
-
-#endif
return ret;
}
@@ -83,33 +66,15 @@ ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
+ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, WCHAR *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL;
- int msg;
+ ULONG ret, msg;
TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
- if (!ld) return ~0u;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
- }
-
- ret = ldap_delete_ext( ld->ld, dn ? dnU : "", NULL, NULL, &msg );
-
- if (ret == LDAP_SUCCESS)
- ret = msg;
- else
- ret = ~0u;
-
- strfreeU( dnU );
-
-#endif
- return ret;
+ ret = ldap_delete_extW( ld, dn, NULL, NULL, &msg );
+ if (ret == WLDAP32_LDAP_SUCCESS) return msg;
+ return ~0u;
}
/***********************************************************************
@@ -117,33 +82,20 @@ ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
*
* See ldap_delete_extW.
*/
-ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, ULONG *message )
+ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, char *dn, LDAPControlA **serverctrls,
+ LDAPControlA **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
- clientctrls, message );
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
@@ -151,8 +103,6 @@ exit:
strfreeW( dnW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -177,44 +127,27 @@ exit:
* the operation. The serverctrls and clientctrls parameters are
* optional and should be set to NULL if not used.
*/
-ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, ULONG *message )
+ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls,
+ LDAPControlW **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
- int dummy;
-
- TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
- clientctrls, message );
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
+ TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- ret = map_error( ldap_delete_ext( ld->ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
- message ? (int *)message : &dummy ));
+ 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->ldap_delete_ext( ld->ld, dnU, serverctrlsU, clientctrlsU, message ) );
exit:
strfreeU( dnU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -223,31 +156,20 @@ exit:
*
* See ldap_delete_ext_sW.
*/
-ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls )
+ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, char *dn, LDAPControlA **serverctrls,
+ LDAPControlA **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
- clientctrls );
+ TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
@@ -255,8 +177,6 @@ exit:
strfreeW( dnW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -279,67 +199,47 @@ exit:
* The serverctrls and clientctrls parameters are optional and
* should be set to NULL if not used.
*/
-ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls )
+ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls,
+ LDAPControlW **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
- TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
- clientctrls );
+ TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- ret = map_error( ldap_delete_ext_s( ld->ld, dn ? dnU : "", serverctrlsU, clientctrlsU ));
+ 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->ldap_delete_ext_s( ld->ld, dnU, serverctrlsU, clientctrlsU ) );
exit:
strfreeU( dnU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
-
+
/***********************************************************************
* ldap_delete_sA (WLDAP32.@)
*
* See ldap_delete_sW.
*/
-ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
+ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, char *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
WCHAR *dnW = NULL;
TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (dn && !(dnW = strAtoW( dn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_delete_sW( ld, dnW );
strfreeW( dnW );
-
-#endif
return ret;
}
@@ -356,24 +256,8 @@ ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
+ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, WCHAR *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL;
-
TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
-
- if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
- }
-
- ret = map_error( ldap_delete_ext_s( ld->ld, dn ? dnU : "", NULL, NULL ));
- strfreeU( dnU );
-
-#endif
- return ret;
+ return ldap_delete_ext_sW( ld, dn, NULL, NULL );
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index 34cd3e98746..be2e540721b 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -339,6 +339,19 @@ int CDECL wrap_ldap_create_vlv_control( void *ld, LDAPVLVInfoU *info, LDAPContro
return ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, (LDAPControl **)control );
}
+int CDECL wrap_ldap_delete_ext( void *ld, const char *dn, LDAPControlU **serverctrls, LDAPControlU **clientctrls,
+ ULONG *msg )
+{
+ int dummy;
+ return ldap_delete_ext( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls,
+ msg ? (int *)msg : &dummy );
+}
+
+int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
+{
+ return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
+}
+
void CDECL wrap_ldap_memfree( void *ptr )
{
return ldap_memfree( ptr );
@@ -410,6 +423,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_control_free,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
+ wrap_ldap_delete_ext,
+ wrap_ldap_delete_ext_s,
wrap_ldap_memfree,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index c582e9f923d..dde7d3eba17 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -101,6 +101,8 @@ extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, str
extern void CDECL wrap_ldap_control_free(LDAPControlU *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
@@ -136,6 +138,8 @@ struct ldap_funcs
void (CDECL *ldap_control_free)(LDAPControlU *);
int (CDECL *ldap_create_sort_control)(void *, LDAPSortKeyU **, int, LDAPControlU **);
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
+ int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
+ int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_memfree)(void *);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
--
2.30.2
1
0
[PATCH v2] xmllite: Avoid out of bounds access in readerinput_get_utf8_convlen().
by Paul Gofman 15 Apr '21
by Paul Gofman 15 Apr '21
15 Apr '21
And consequently in readerinput_shrinkraw().
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
v2:
- move the 'written' check to readerinput_growraw();
- add readerinput_growraw() failure check in readerinput_shrinkraw().
dlls/xmllite/reader.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index 13d841eb94d..a5a75c29887 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -844,6 +844,8 @@ static HRESULT readerinput_growraw(xmlreaderinput *readerinput)
readerinput->pending = hr == E_PENDING;
if (FAILED(hr)) return hr;
buffer->written += read;
+ if (!buffer->written)
+ return MX_E_INPUTEND;
return hr;
}
@@ -929,6 +931,8 @@ static int readerinput_get_utf8_convlen(xmlreaderinput *readerinput)
encoded_buffer *buffer = &readerinput->buffer->encoded;
int len = buffer->written;
+ assert(len);
+
/* complete single byte char */
if (!(buffer->data[len-1] & 0x80)) return len;
@@ -966,6 +970,7 @@ static void readerinput_shrinkraw(xmlreaderinput *readerinput, int len)
if (len == -1)
len = readerinput_get_convlen(readerinput);
+ assert(len >= 0);
memmove(buffer->data, buffer->data + buffer->cur + (buffer->written - len), len);
/* everything below cur is lost too */
buffer->written -= len + buffer->cur;
@@ -1068,7 +1073,9 @@ static HRESULT reader_more(xmlreader *reader)
WCHAR *ptr;
/* get some raw data from stream first */
- hr = readerinput_growraw(readerinput);
+ if (FAILED(hr = readerinput_growraw(readerinput)))
+ return hr;
+
len = readerinput_get_convlen(readerinput);
prev_len = dest->written / sizeof(WCHAR);
--
2.30.2
2
1
[PATCH] xmllite: Avoid out of bounds access in readerinput_get_utf8_convlen().
by Paul Gofman 15 Apr '21
by Paul Gofman 15 Apr '21
15 Apr '21
And consequently in readerinput_shrinkraw().
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
Spotted as a crash reproducible under certain conditions during Forza Horizon 4 start.
The out of bounds access in readerinput_get_utf8_convlen() is reproducible with the
existing tests, that just doesn't usually result in the crash as
'if (!(buffer->data[len-1] & 0x80)) return len;' ends up returning 0 for zero length
most of the time.
dlls/xmllite/reader.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index 13d841eb94d..aa193128e4b 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -929,6 +929,8 @@ static int readerinput_get_utf8_convlen(xmlreaderinput *readerinput)
encoded_buffer *buffer = &readerinput->buffer->encoded;
int len = buffer->written;
+ assert(len);
+
/* complete single byte char */
if (!(buffer->data[len-1] & 0x80)) return len;
@@ -966,6 +968,7 @@ static void readerinput_shrinkraw(xmlreaderinput *readerinput, int len)
if (len == -1)
len = readerinput_get_convlen(readerinput);
+ assert(len >= 0);
memmove(buffer->data, buffer->data + buffer->cur + (buffer->written - len), len);
/* everything below cur is lost too */
buffer->written -= len + buffer->cur;
@@ -1069,6 +1072,9 @@ static HRESULT reader_more(xmlreader *reader)
/* get some raw data from stream first */
hr = readerinput_growraw(readerinput);
+ if (!src->written)
+ return hr ? hr : MX_E_INPUTEND;
+
len = readerinput_get_convlen(readerinput);
prev_len = dest->written / sizeof(WCHAR);
--
2.30.2
2
1
Validating that SendInput with INPUT_HARDWARE type should be no-op.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50506
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
v2: Remove the #ifdef _WIN64 and mark 32bit test results as broken.
dlls/user32/input.c | 18 ++++++
dlls/user32/tests/input.c | 113 ++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 8992c463c48..22e53585f00 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -182,6 +182,24 @@ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
UINT i;
NTSTATUS status;
+ if (size != sizeof(INPUT))
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return 0;
+ }
+
+ if (!count)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return 0;
+ }
+
+ if (!inputs)
+ {
+ SetLastError( ERROR_NOACCESS );
+ return 0;
+ }
+
for (i = 0; i < count; i++)
{
if (inputs[i].type == INPUT_MOUSE)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 646a9a66eb5..0bbd03c615e 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -4212,6 +4212,118 @@ static void test_UnregisterDeviceNotification(void)
ok(ret == FALSE, "Unregistering NULL Device Notification returned: %d\n", ret);
}
+static void test_SendInput(void)
+{
+ INPUT input[16];
+ UINT res, i;
+ HWND hwnd;
+ MSG msg;
+
+ hwnd = CreateWindowW( L"static", L"test", WS_OVERLAPPED, 0, 0, 100, 100, 0, 0, 0, 0 );
+ ok( hwnd != 0, "CreateWindowW failed\n" );
+
+ ShowWindow( hwnd, SW_SHOWNORMAL );
+ UpdateWindow( hwnd );
+ SetForegroundWindow( hwnd );
+ SetFocus( hwnd );
+ empty_message_queue();
+
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 0, NULL, 0 );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 1, NULL, 0 );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 1, NULL, sizeof(*input) );
+ ok( res == 0 && (GetLastError() == ERROR_NOACCESS || GetLastError() == ERROR_INVALID_PARAMETER),
+ "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 0, input, sizeof(*input) );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 0, NULL, sizeof(*input) );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+
+ memset( input, 0, sizeof(input) );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 1, input, sizeof(*input) );
+ ok( res == 1 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, sizeof(*input) );
+ ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 1, input, 0 );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 1, input, sizeof(*input) + 1 );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 1, input, sizeof(*input) - 1 );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+
+ for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_KEYBOARD;
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, offsetof( INPUT, ki ) + sizeof(KEYBDINPUT) );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, sizeof(*input) );
+ ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ empty_message_queue();
+
+ for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE;
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, offsetof( INPUT, hi ) + sizeof(HARDWAREINPUT) );
+ ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() );
+
+ input[0].hi.uMsg = WM_KEYDOWN;
+ input[0].hi.wParamL = 0;
+ input[0].hi.wParamH = 'A';
+ input[1].hi.uMsg = WM_KEYUP;
+ input[1].hi.wParamL = 0;
+ input[1].hi.wParamH = 'A' | 0xc000;
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, sizeof(*input) );
+ todo_wine
+ ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) ||
+ broken(res == 16 && GetLastError() == 0xdeadbeef) /* 32bit */,
+ "SendInput returned %u, error %#x\n", res, GetLastError() );
+ while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg);
+ todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message );
+ empty_message_queue();
+
+ memset( input, 0, sizeof(input) );
+ input[0].type = INPUT_HARDWARE;
+ input[1].type = INPUT_KEYBOARD;
+ input[1].ki.wVk = 'A';
+ input[1].ki.dwFlags = 0;
+ input[2].type = INPUT_KEYBOARD;
+ input[2].ki.wVk = 'A';
+ input[2].ki.dwFlags = KEYEVENTF_KEYUP;
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, sizeof(*input) );
+ todo_wine
+ ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) ||
+ broken(res == 16 && GetLastError() == 0xdeadbeef),
+ "SendInput returned %u, error %#x\n", res, GetLastError() );
+ while ((res = wait_for_message(&msg)) && (msg.message == WM_TIMER || broken(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP)))
+ DispatchMessageA(&msg);
+ todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message );
+ empty_message_queue();
+
+ for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE + 1;
+ SetLastError( 0xdeadbeef );
+ res = SendInput( 16, input, sizeof(*input) );
+ todo_wine ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() );
+ while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg);
+ todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message );
+ empty_message_queue();
+
+ trace( "done\n" );
+ DestroyWindow( hwnd );
+}
+
START_TEST(input)
{
char **argv;
@@ -4234,6 +4346,7 @@ START_TEST(input)
return;
}
+ test_SendInput();
test_Input_blackbox();
test_Input_whitebox();
test_Input_unicode();
--
2.31.0
4
12
[PATCH 5/5] gdi32: Reselect font and pen when changing world transforms for enhanced metafiles.
by Zhiyi Zhang 15 Apr '21
by Zhiyi Zhang 15 Apr '21
15 Apr '21
Reselect font and pen into enhanced metafile device contexts after world transform is changed so
that content can be drawn using the correct size. Also modifying the world transform for enhanced
metafiles doesn't generate EMR_SELECTOBJECT records according to winedump outputs.
Fix an issue that Tally may produce a print preview with a too large font or with a black side bar.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/gdi32/dc.c | 3 +-
dlls/gdi32/enhmfdrv/dc.c | 78 ++++++++++++++++++++++++----
dlls/gdi32/enhmfdrv/enhmetafiledrv.h | 1 +
dlls/gdi32/enhmfdrv/init.c | 1 +
dlls/gdi32/enhmfdrv/objects.c | 2 +
dlls/gdi32/tests/metafile.c | 1 -
6 files changed, 72 insertions(+), 14 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index eb9dbf85668..74bf0a8dd50 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -363,8 +363,7 @@ void DC_UpdateXforms( DC *dc )
/* Reselect the font and pen back into the dc so that the size
gets updated. */
- if (linear_xform_cmp( &oldworld2vport, &dc->xformWorld2Vport ) &&
- !GdiIsMetaFileDC(dc->hSelf))
+ if (linear_xform_cmp( &oldworld2vport, &dc->xformWorld2Vport ))
{
SelectObject(dc->hSelf, dc->hFont);
SelectObject(dc->hSelf, dc->hPen);
diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c
index 72b6afeee8b..1c87643ea96 100644
--- a/dlls/gdi32/enhmfdrv/dc.c
+++ b/dlls/gdi32/enhmfdrv/dc.c
@@ -235,19 +235,27 @@ INT CDECL EMFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode )
INT CDECL EMFDRV_SetMapMode( PHYSDEV dev, INT mode )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetMapMode );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETMAPMODE emr;
+ INT ret;
+
emr.emr.iType = EMR_SETMAPMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return 0;
- return next->funcs->pSetMapMode( next, mode );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetMapMode( next, mode );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetViewportExtEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETVIEWPORTEXTEX emr;
+ BOOL ret;
emr.emr.iType = EMR_SETVIEWPORTEXTEX;
emr.emr.nSize = sizeof(emr);
@@ -255,13 +263,18 @@ BOOL CDECL EMFDRV_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
emr.szlExtent.cy = cy;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pSetViewportExtEx( next, cx, cy, size );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetViewportExtEx( next, cx, cy, size );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetWindowExtEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETWINDOWEXTEX emr;
+ BOOL ret;
emr.emr.iType = EMR_SETWINDOWEXTEX;
emr.emr.nSize = sizeof(emr);
@@ -269,13 +282,18 @@ BOOL CDECL EMFDRV_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
emr.szlExtent.cy = cy;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pSetWindowExtEx( next, cx, cy, size );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetWindowExtEx( next, cx, cy, size );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetViewportOrgEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETVIEWPORTORGEX emr;
+ BOOL ret;
emr.emr.iType = EMR_SETVIEWPORTORGEX;
emr.emr.nSize = sizeof(emr);
@@ -283,13 +301,18 @@ BOOL CDECL EMFDRV_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
emr.ptlOrigin.y = y;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pSetViewportOrgEx( next, x, y, pt );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetViewportOrgEx( next, x, y, pt );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetWindowOrgEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETWINDOWORGEX emr;
+ BOOL ret;
emr.emr.iType = EMR_SETWINDOWORGEX;
emr.emr.nSize = sizeof(emr);
@@ -297,13 +320,18 @@ BOOL CDECL EMFDRV_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
emr.ptlOrigin.y = y;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pSetWindowOrgEx( next, x, y, pt );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetWindowOrgEx( next, x, y, pt );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_ScaleViewportExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pScaleViewportExtEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSCALEVIEWPORTEXTEX emr;
+ BOOL ret;
emr.emr.iType = EMR_SCALEVIEWPORTEXTEX;
emr.emr.nSize = sizeof(emr);
@@ -313,7 +341,10 @@ BOOL CDECL EMFDRV_ScaleViewportExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNu
emr.yDenom = yDenom;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pScaleViewportExtEx( next, xNum, xDenom, yNum, yDenom, size );
+ physDev->modifying_transform++;
+ ret = next->funcs->pScaleViewportExtEx( next, xNum, xDenom, yNum, yDenom, size );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size )
@@ -335,32 +366,44 @@ BOOL CDECL EMFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum,
DWORD CDECL EMFDRV_SetLayout( PHYSDEV dev, DWORD layout )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetMapMode );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETLAYOUT emr;
+ DWORD ret;
emr.emr.iType = EMR_SETLAYOUT;
emr.emr.nSize = sizeof(emr);
emr.iMode = layout;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return GDI_ERROR;
- return next->funcs->pSetLayout( next, layout );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetLayout( next, layout );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_SetWorldTransform( PHYSDEV dev, const XFORM *xform)
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetWorldTransform );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETWORLDTRANSFORM emr;
+ BOOL ret;
emr.emr.iType = EMR_SETWORLDTRANSFORM;
emr.emr.nSize = sizeof(emr);
emr.xform = *xform;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pSetWorldTransform( next, xform );
+ physDev->modifying_transform++;
+ ret = next->funcs->pSetWorldTransform( next, xform );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD mode)
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pModifyWorldTransform );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRMODIFYWORLDTRANSFORM emr;
+ BOOL ret;
emr.emr.iType = EMR_MODIFYWORLDTRANSFORM;
emr.emr.nSize = sizeof(emr);
@@ -380,14 +423,19 @@ BOOL CDECL EMFDRV_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD m
emr.iMode = mode;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pModifyWorldTransform( next, xform, mode );
+ physDev->modifying_transform++;
+ ret = next->funcs->pModifyWorldTransform( next, xform, mode );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetViewportOrgEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETVIEWPORTORGEX emr;
POINT prev;
+ BOOL ret;
GetViewportOrgEx( dev->hdc, &prev );
@@ -397,14 +445,19 @@ BOOL CDECL EMFDRV_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
emr.ptlOrigin.y = prev.y + y;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pOffsetViewportOrgEx( next, x, y, pt );
+ physDev->modifying_transform++;
+ ret = next->funcs->pOffsetViewportOrgEx( next, x, y, pt );
+ physDev->modifying_transform--;
+ return ret;
}
BOOL CDECL EMFDRV_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetWindowOrgEx );
+ EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSETWINDOWORGEX emr;
POINT prev;
+ BOOL ret;
GetWindowOrgEx( dev->hdc, &prev );
@@ -414,7 +467,10 @@ BOOL CDECL EMFDRV_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
emr.ptlOrigin.y = prev.y + y;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
- return next->funcs->pOffsetWindowOrgEx( next, x, y, pt );
+ physDev->modifying_transform++;
+ ret = next->funcs->pOffsetWindowOrgEx( next, x, y, pt );
+ physDev->modifying_transform--;
+ return ret;
}
DWORD CDECL EMFDRV_SetMapperFlags( PHYSDEV dev, DWORD flags )
diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h
index 253f96cd8ec..fd463bd29e3 100644
--- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h
+++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h
@@ -41,6 +41,7 @@ typedef struct
HBRUSH dc_brush;
HPEN dc_pen;
INT restoring; /* RestoreDC counter */
+ INT modifying_transform;/* Counter for functions that can change world transform */
BOOL path;
INT dev_caps[COLORMGMTCAPS + 1];
} EMFDRV_PDEVICE;
diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c
index 07416db265e..6c41aa88feb 100644
--- a/dlls/gdi32/enhmfdrv/init.c
+++ b/dlls/gdi32/enhmfdrv/init.c
@@ -372,6 +372,7 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->dc_brush = 0;
physDev->dc_pen = 0;
physDev->restoring = 0;
+ physDev->modifying_transform = 0;
physDev->path = FALSE;
if (hdc) /* if no ref, use current display */
diff --git a/dlls/gdi32/enhmfdrv/objects.c b/dlls/gdi32/enhmfdrv/objects.c
index e21dfe2a47a..a60ca1a3b82 100644
--- a/dlls/gdi32/enhmfdrv/objects.c
+++ b/dlls/gdi32/enhmfdrv/objects.c
@@ -285,6 +285,7 @@ HFONT CDECL EMFDRV_SelectFont( PHYSDEV dev, HFONT hFont, UINT *aa_flags )
int i;
if (physDev->restoring) goto done; /* don't output SelectObject records during RestoreDC */
+ if (physDev->modifying_transform) goto done; /* don't output SelectObject records when modifying the world transform */
/* If the object is a stock font object, do not need to create it.
* See definitions in wingdi.h for range of stock fonts.
@@ -370,6 +371,7 @@ HPEN CDECL EMFDRV_SelectPen(PHYSDEV dev, HPEN hPen, const struct brush_pattern *
int i;
if (physDev->restoring) return hPen; /* don't output SelectObject records during RestoreDC */
+ if (physDev->modifying_transform) return hPen; /* don't output SelectObject records when modifying the world transform */
/* If the object is a stock pen object, do not need to create it.
* See definitions in wingdi.h for range of stock pens.
diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c
index e2592988cea..bc6ba16b194 100644
--- a/dlls/gdi32/tests/metafile.c
+++ b/dlls/gdi32/tests/metafile.c
@@ -5060,7 +5060,6 @@ static void test_emf_text_extends(void)
ok(ret, "GetTextExtentPoint32W failed, error %d\n", GetLastError());
ret = GetTextExtentPoint32W(emf_dc, L"W", 1, &size2);
ok(ret, "GetTextExtentPoint32W failed, error %d\n", GetLastError());
-todo_wine
ok(size2.cx == size.cx && size2.cy == size.cy, "Expected size %dx%d, got %dx%d\n",
size.cx, size.cy, size2.cx, size2.cy);
--
2.27.0
2
1
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/winebus.sys/main.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
index 8d3dec4779a..7d3f5064f84 100644
--- a/dlls/winebus.sys/main.c
+++ b/dlls/winebus.sys/main.c
@@ -112,6 +112,8 @@ struct pnp_device
struct device_extension
{
+ CRITICAL_SECTION cs;
+
struct pnp_device *pnp_device;
WORD vid, pid, input;
@@ -127,7 +129,6 @@ struct device_extension
BOOL last_report_read;
DWORD buffer_size;
LIST_ENTRY irp_queue;
- CRITICAL_SECTION report_cs;
BYTE platform_private[1];
};
@@ -285,8 +286,8 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid,
memset(ext->platform_private, 0, platform_data_size);
InitializeListHead(&ext->irp_queue);
- InitializeCriticalSection(&ext->report_cs);
- ext->report_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": report_cs");
+ InitializeCriticalSection(&ext->cs);
+ ext->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": cs");
/* add to list of pnp devices */
pnp_dev->device = device;
@@ -366,7 +367,7 @@ void bus_remove_hid_device(DEVICE_OBJECT *device)
TRACE("(%p)\n", device);
/* Cancel pending IRPs */
- EnterCriticalSection(&ext->report_cs);
+ EnterCriticalSection(&ext->cs);
while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue)
{
irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry);
@@ -374,10 +375,10 @@ void bus_remove_hid_device(DEVICE_OBJECT *device)
irp->IoStatus.Information = 0;
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
- ext->report_cs.DebugInfo->Spare[0] = 0;
- DeleteCriticalSection(&ext->report_cs);
+ ext->cs.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection(&ext->cs);
HeapFree(GetProcessHeap(), 0, ext->serial);
HeapFree(GetProcessHeap(), 0, ext->last_report);
@@ -783,12 +784,12 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
{
HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer);
TRACE_(hid_report)("IOCTL_HID_GET_INPUT_REPORT\n");
- EnterCriticalSection(&ext->report_cs);
+ EnterCriticalSection(&ext->cs);
status = ext->vtbl->begin_report_processing(device);
if (status != STATUS_SUCCESS)
{
irp->IoStatus.u.Status = status;
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
break;
}
@@ -798,18 +799,18 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
if (status == STATUS_SUCCESS)
packet->reportBufferLen = irp->IoStatus.Information;
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
break;
}
case IOCTL_HID_READ_REPORT:
{
TRACE_(hid_report)("IOCTL_HID_READ_REPORT\n");
- EnterCriticalSection(&ext->report_cs);
+ EnterCriticalSection(&ext->cs);
status = ext->vtbl->begin_report_processing(device);
if (status != STATUS_SUCCESS)
{
irp->IoStatus.u.Status = status;
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
break;
}
if (!ext->last_report_read)
@@ -824,7 +825,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
InsertTailList(&ext->irp_queue, &irp->Tail.Overlay.s.ListEntry);
status = STATUS_PENDING;
}
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
break;
}
case IOCTL_HID_SET_OUTPUT_REPORT:
@@ -880,7 +881,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
if (!length || !report)
return;
- EnterCriticalSection(&ext->report_cs);
+ EnterCriticalSection(&ext->cs);
if (length > ext->buffer_size)
{
HeapFree(GetProcessHeap(), 0, ext->last_report);
@@ -891,7 +892,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
ext->buffer_size = 0;
ext->last_report_size = 0;
ext->last_report_read = TRUE;
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
return;
}
else
@@ -914,7 +915,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
ext->last_report_read = TRUE;
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
- LeaveCriticalSection(&ext->report_cs);
+ LeaveCriticalSection(&ext->cs);
}
DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value)
--
2.30.2
1
4
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/combase/tests/Makefile.in | 1 +
dlls/combase/tests/roapi.c | 59 +----
dlls/combase/tests/string.c | 443 +++++++++++++++------------------
include/roapi.h | 2 +
4 files changed, 208 insertions(+), 297 deletions(-)
diff --git a/dlls/combase/tests/Makefile.in b/dlls/combase/tests/Makefile.in
index ca6c48f3f2e..1c3d77725b3 100644
--- a/dlls/combase/tests/Makefile.in
+++ b/dlls/combase/tests/Makefile.in
@@ -1,4 +1,5 @@
TESTDLL = combase.dll
+IMPORTS = combase
C_SRCS = \
roapi.c \
diff --git a/dlls/combase/tests/roapi.c b/dlls/combase/tests/roapi.c
index b9cb476aafe..1efcc801dcb 100644
--- a/dlls/combase/tests/roapi.c
+++ b/dlls/combase/tests/roapi.c
@@ -26,38 +26,8 @@
#include "initguid.h"
#include "roapi.h"
-
#include "wine/test.h"
-static HRESULT (WINAPI *pRoActivateInstance)(HSTRING, IInspectable **);
-static HRESULT (WINAPI *pRoInitialize)(RO_INIT_TYPE);
-static void (WINAPI *pRoUninitialize)(void);
-static HRESULT (WINAPI *pRoGetActivationFactory)(HSTRING, REFIID, void **);
-
-static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
-static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
-
-#define SET(x) p##x = (void*)GetProcAddress(hmod, #x)
-
-static BOOL init_functions(void)
-{
- HMODULE hmod = LoadLibraryA("combase.dll");
- if (!hmod)
- {
- win_skip("Failed to load combase.dll, skipping tests\n");
- return FALSE;
- }
- SET(RoActivateInstance);
- SET(RoInitialize);
- SET(RoUninitialize);
- SET(RoGetActivationFactory);
-
- SET(WindowsCreateString);
- SET(WindowsDeleteString);
-
- return TRUE;
-}
-
static void test_ActivationFactories(void)
{
HRESULT hr;
@@ -65,47 +35,38 @@ static void test_ActivationFactories(void)
IActivationFactory *factory = NULL;
IInspectable *inspect = NULL;
- if(!pRoGetActivationFactory || !pRoActivateInstance)
- {
- win_skip("RoGetActivationFactory not available\n");
- return;
- }
-
- hr = pWindowsCreateString(L"Windows.Data.Xml.Dom.XmlDocument",
+ hr = WindowsCreateString(L"Windows.Data.Xml.Dom.XmlDocument",
ARRAY_SIZE(L"Windows.Data.Xml.Dom.XmlDocument") - 1, &str);
ok(hr == S_OK, "got %08x\n", hr);
- hr = pWindowsCreateString(L"Does.Not.Exist", ARRAY_SIZE(L"Does.Not.Exist") - 1, &str2);
+ hr = WindowsCreateString(L"Does.Not.Exist", ARRAY_SIZE(L"Does.Not.Exist") - 1, &str2);
ok(hr == S_OK, "got %08x\n", hr);
- hr = pRoInitialize(RO_INIT_MULTITHREADED);
+ hr = RoInitialize(RO_INIT_MULTITHREADED);
ok(hr == S_OK, "got %08x\n", hr);
- hr = pRoGetActivationFactory(str2, &IID_IActivationFactory, (void **)&factory);
+ hr = RoGetActivationFactory(str2, &IID_IActivationFactory, (void **)&factory);
ok(hr == REGDB_E_CLASSNOTREG, "got %08x\n", hr);
- hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
+ hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
todo_wine ok(hr == S_OK, "got %08x\n", hr);
if(factory)
IActivationFactory_Release(factory);
- hr = pRoActivateInstance(str2, &inspect);
+ hr = RoActivateInstance(str2, &inspect);
ok(hr == REGDB_E_CLASSNOTREG, "got %08x\n", hr);
- hr = pRoActivateInstance(str, &inspect);
+ hr = RoActivateInstance(str, &inspect);
todo_wine ok(hr == S_OK, "got %08x\n", hr);
if(inspect)
IInspectable_Release(inspect);
- pWindowsDeleteString(str2);
- pWindowsDeleteString(str);
- pRoUninitialize();
+ WindowsDeleteString(str2);
+ WindowsDeleteString(str);
+ RoUninitialize();
}
START_TEST(roapi)
{
- if (!init_functions())
- return;
-
test_ActivationFactories();
}
diff --git a/dlls/combase/tests/string.c b/dlls/combase/tests/string.c
index a84973ff56b..5ebf669a426 100644
--- a/dlls/combase/tests/string.c
+++ b/dlls/combase/tests/string.c
@@ -27,57 +27,6 @@
#include "wine/test.h"
-static HRESULT (WINAPI *pWindowsCompareStringOrdinal)(HSTRING, HSTRING, INT32 *);
-static HRESULT (WINAPI *pWindowsConcatString)(HSTRING, HSTRING, HSTRING *);
-static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
-static HRESULT (WINAPI *pWindowsCreateStringReference)(LPCWSTR, UINT32, HSTRING_HEADER *, HSTRING *);
-static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
-static HRESULT (WINAPI *pWindowsDeleteStringBuffer)(HSTRING_BUFFER);
-static HRESULT (WINAPI *pWindowsDuplicateString)(HSTRING, HSTRING *);
-static UINT32 (WINAPI *pWindowsGetStringLen)(HSTRING);
-static LPCWSTR (WINAPI *pWindowsGetStringRawBuffer)(HSTRING, UINT32 *);
-static BOOL (WINAPI *pWindowsIsStringEmpty)(HSTRING);
-static HRESULT (WINAPI *pWindowsPreallocateStringBuffer)(UINT32, WCHAR **, HSTRING_BUFFER *);
-static HRESULT (WINAPI *pWindowsPromoteStringBuffer)(HSTRING_BUFFER, HSTRING *);
-static HRESULT (WINAPI *pWindowsStringHasEmbeddedNull)(HSTRING, BOOL *);
-static HRESULT (WINAPI *pWindowsSubstring)(HSTRING, UINT32, HSTRING *);
-static HRESULT (WINAPI *pWindowsSubstringWithSpecifiedLength)(HSTRING, UINT32, UINT32, HSTRING *);
-static HRESULT (WINAPI *pWindowsTrimStringEnd)(HSTRING, HSTRING, HSTRING *);
-static HRESULT (WINAPI *pWindowsTrimStringStart)(HSTRING, HSTRING, HSTRING *);
-
-#define SET(x) p##x = (void*)GetProcAddress(hmod, #x)
-
-static BOOL init_functions(void)
-{
- HMODULE hmod = LoadLibraryA("combase.dll");
- if (!hmod)
- {
- win_skip("Failed to load combase.dll, skipping tests\n");
- return FALSE;
- }
- SET(WindowsCompareStringOrdinal);
- SET(WindowsConcatString);
- SET(WindowsCreateString);
- SET(WindowsCreateStringReference);
- SET(WindowsDeleteString);
- SET(WindowsDeleteStringBuffer);
- SET(WindowsDuplicateString);
- SET(WindowsGetStringLen);
- SET(WindowsGetStringRawBuffer);
- SET(WindowsIsStringEmpty);
- SET(WindowsPreallocateStringBuffer);
- SET(WindowsPromoteStringBuffer);
- SET(WindowsStringHasEmbeddedNull);
- SET(WindowsSubstring);
- SET(WindowsSubstringWithSpecifiedLength);
- SET(WindowsTrimStringEnd);
- SET(WindowsTrimStringStart);
- return TRUE;
-}
-
-#undef SET
-
-
#define check_string(str, content, length, has_null) _check_string(__LINE__, str, content, length, has_null)
static void _check_string(int line, HSTRING str, LPCWSTR content, UINT32 length, BOOL has_null)
{
@@ -86,16 +35,16 @@ static void _check_string(int line, HSTRING str, LPCWSTR content, UINT32 length,
UINT32 out_length;
LPCWSTR ptr;
- ok_(__FILE__, line)(pWindowsIsStringEmpty(str) == empty, "WindowsIsStringEmpty failed\n");
- ok_(__FILE__, line)(pWindowsStringHasEmbeddedNull(str, &out_null) == S_OK, "pWindowsStringHasEmbeddedNull failed\n");
+ ok_(__FILE__, line)(WindowsIsStringEmpty(str) == empty, "WindowsIsStringEmpty failed\n");
+ ok_(__FILE__, line)(WindowsStringHasEmbeddedNull(str, &out_null) == S_OK, "WindowsStringHasEmbeddedNull failed\n");
ok_(__FILE__, line)(out_null == has_null, "WindowsStringHasEmbeddedNull failed\n");
- ok_(__FILE__, line)(pWindowsGetStringLen(str) == length, "WindowsGetStringLen failed\n");
- ptr = pWindowsGetStringRawBuffer(str, &out_length);
+ ok_(__FILE__, line)(WindowsGetStringLen(str) == length, "WindowsGetStringLen failed\n");
+ ptr = WindowsGetStringRawBuffer(str, &out_length);
/* WindowsGetStringRawBuffer should return a non-null, null terminated empty string
* even if str is NULL. */
ok_(__FILE__, line)(ptr != NULL, "WindowsGetStringRawBuffer returned null\n");
ok_(__FILE__, line)(out_length == length, "WindowsGetStringRawBuffer returned incorrect length\n");
- ptr = pWindowsGetStringRawBuffer(str, NULL);
+ ptr = WindowsGetStringRawBuffer(str, NULL);
ok_(__FILE__, line)(ptr != NULL, "WindowsGetStringRawBuffer returned null\n");
ok_(__FILE__, line)(ptr[length] == '\0', "WindowsGetStringRawBuffer doesn't return a null terminated buffer\n");
ok_(__FILE__, line)(memcmp(ptr, content, sizeof(*content) * length) == 0, "Incorrect string content\n");
@@ -113,80 +62,80 @@ static void test_create_delete(void)
HSTRING_HEADER header;
/* Test normal creation of a string */
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
check_string(str, input_string, 6, FALSE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test error handling in WindowsCreateString */
- ok(pWindowsCreateString(input_string, 6, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsCreateString(NULL, 6, &str) == E_POINTER, "Incorrect error handling\n");
+ ok(WindowsCreateString(input_string, 6, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsCreateString(NULL, 6, &str) == E_POINTER, "Incorrect error handling\n");
/* Test handling of a NULL string */
- ok(pWindowsDeleteString(NULL) == S_OK, "Failed to delete null string\n");
+ ok(WindowsDeleteString(NULL) == S_OK, "Failed to delete null string\n");
/* Test creation of a string reference */
- ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
check_string(str, input_string, 6, FALSE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
/* Test error handling in WindowsCreateStringReference */
/* Strings to CreateStringReference must be null terminated with the correct
* length. According to MSDN this should be E_INVALIDARG, but it returns
* 0x80000017 in practice. */
- ok(FAILED(pWindowsCreateStringReference(input_string, 5, &header, &str)), "Incorrect error handling\n");
+ ok(FAILED(WindowsCreateStringReference(input_string, 5, &header, &str)), "Incorrect error handling\n");
/* If the input string is non-null, it must be null-terminated even if the
* length is zero. */
- ok(FAILED(pWindowsCreateStringReference(input_string, 0, &header, &str)), "Incorrect error handling\n");
- ok(pWindowsCreateStringReference(input_string, 6, NULL, &str) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsCreateStringReference(input_string, 6, &header, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsCreateStringReference(NULL, 6, &header, &str) == E_POINTER, "Incorrect error handling\n");
+ ok(FAILED(WindowsCreateStringReference(input_string, 0, &header, &str)), "Incorrect error handling\n");
+ ok(WindowsCreateStringReference(input_string, 6, NULL, &str) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsCreateStringReference(input_string, 6, &header, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsCreateStringReference(NULL, 6, &header, &str) == E_POINTER, "Incorrect error handling\n");
/* Test creating a string without a null-termination at the specified length */
- ok(pWindowsCreateString(input_string, 3, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string, 3, &str) == S_OK, "Failed to create string\n");
check_string(str, input_string, 3, FALSE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test an empty string */
- ok(pWindowsCreateString(L"", 0, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(L"", 0, &str) == S_OK, "Failed to create string\n");
ok(str == NULL, "Empty string not a null string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateString(input_string, 0, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string, 0, &str) == S_OK, "Failed to create string\n");
ok(str == NULL, "Empty string not a null string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateStringReference(L"", 0, &header, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateStringReference(L"", 0, &header, &str) == S_OK, "Failed to create string\n");
ok(str == NULL, "Empty string not a null string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateString(NULL, 0, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(NULL, 0, &str) == S_OK, "Failed to create string\n");
ok(str == NULL, "Empty string not a null string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateStringReference(NULL, 0, &header, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateStringReference(NULL, 0, &header, &str) == S_OK, "Failed to create string\n");
ok(str == NULL, "Empty string not a null string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
}
static void test_duplicate(void)
{
HSTRING str, str2;
HSTRING_HEADER header;
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
- ok(pWindowsDuplicateString(str, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsDuplicateString(str, &str2) == S_OK, "Failed to duplicate string\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsDuplicateString(str, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsDuplicateString(str, &str2) == S_OK, "Failed to duplicate string\n");
ok(str == str2, "Duplicated string created new string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
- ok(pWindowsDuplicateString(str, &str2) == S_OK, "Failed to duplicate string\n");
+ ok(WindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
+ ok(WindowsDuplicateString(str, &str2) == S_OK, "Failed to duplicate string\n");
ok(str != str2, "Duplicated string ref didn't create new string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
- ok(pWindowsDuplicateString(NULL, &str2) == S_OK, "Failed to duplicate NULL string\n");
+ ok(WindowsDuplicateString(NULL, &str2) == S_OK, "Failed to duplicate NULL string\n");
ok(str2 == NULL, "Duplicated string created new string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
}
static void test_access(void)
@@ -198,22 +147,22 @@ static void test_access(void)
check_string(NULL, NULL, 0, FALSE);
/* Test strings with embedded null chars */
- ok(pWindowsCreateString(input_embed_null, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_embed_null, 6, &str) == S_OK, "Failed to create string\n");
check_string(str, input_embed_null, 6, TRUE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateStringReference(input_embed_null, 6, &header, &str) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_embed_null, 6, &header, &str) == S_OK, "Failed to create string ref\n");
check_string(str, input_embed_null, 6, TRUE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
/* Test normal creation of a string with trailing null */
- ok(pWindowsCreateString(input_string, 7, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string, 7, &str) == S_OK, "Failed to create string\n");
check_string(str, input_string, 7, TRUE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateStringReference(input_string, 7, &header, &str) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string, 7, &header, &str) == S_OK, "Failed to create string ref\n");
check_string(str, input_string, 7, TRUE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
}
static void test_string_buffer(void)
@@ -225,43 +174,43 @@ static void test_string_buffer(void)
HSTRING str;
/* Test creation of an empty buffer */
- ok(pWindowsPreallocateStringBuffer(0, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
+ ok(WindowsPreallocateStringBuffer(0, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
ok(ptr != NULL, "Empty string didn't return a buffer pointer\n");
- ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
+ ok(WindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
ok(str == NULL, "Empty string isn't a null string\n");
check_string(str, L"", 0, FALSE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteStringBuffer(NULL) == S_OK, "Failed to delete null string buffer\n");
+ ok(WindowsDeleteStringBuffer(NULL) == S_OK, "Failed to delete null string buffer\n");
/* Test creation and deletion of string buffers */
- ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
- ok(pWindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n");
+ ok(WindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
+ ok(WindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n");
/* Test creation and promotion of string buffers */
- ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
+ ok(WindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
ok(ptr[6] == '\0', "Preallocated string buffer didn't have null termination\n");
memcpy(ptr, input_string, 6 * sizeof(*input_string));
- ok(pWindowsPromoteStringBuffer(buf, NULL) == E_POINTER, "Incorrect error handling\n");
- ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
+ ok(WindowsPromoteStringBuffer(buf, NULL) == E_POINTER, "Incorrect error handling\n");
+ ok(WindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
check_string(str, input_string, 6, FALSE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test error handling in preallocation */
- ok(pWindowsPreallocateStringBuffer(6, NULL, &buf) == E_POINTER, "Incorrect error handling\n");
- ok(pWindowsPreallocateStringBuffer(6, &ptr, NULL) == E_POINTER, "Incorrect error handling\n");
+ ok(WindowsPreallocateStringBuffer(6, NULL, &buf) == E_POINTER, "Incorrect error handling\n");
+ ok(WindowsPreallocateStringBuffer(6, &ptr, NULL) == E_POINTER, "Incorrect error handling\n");
- ok(pWindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
+ ok(WindowsPreallocateStringBuffer(6, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
ptr[6] = 'a'; /* Overwrite the buffer's null termination, promotion should fail */
- ok(pWindowsPromoteStringBuffer(buf, &str) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n");
+ ok(WindowsPromoteStringBuffer(buf, &str) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsDeleteStringBuffer(buf) == S_OK, "Failed to delete string buffer\n");
/* Test strings with trailing null chars */
- ok(pWindowsPreallocateStringBuffer(7, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
+ ok(WindowsPreallocateStringBuffer(7, &ptr, &buf) == S_OK, "Failed to preallocate string buffer\n");
memcpy(ptr, input_string, 7 * sizeof(*input_string));
- ok(pWindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
+ ok(WindowsPromoteStringBuffer(buf, &str) == S_OK, "Failed to promote string buffer\n");
check_string(str, input_string, 7, TRUE);
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
}
static void test_substring(void)
@@ -270,76 +219,76 @@ static void test_substring(void)
HSTRING_HEADER header;
/* Test substring of string buffers */
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
- ok(pWindowsSubstring(str, 2, &substr) == S_OK, "Failed to create substring\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsSubstring(str, 2, &substr) == S_OK, "Failed to create substring\n");
check_string(substr, output_substring, 4, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 2, 3, &substr) == S_OK, "Failed to create substring\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 2, 3, &substr) == S_OK, "Failed to create substring\n");
check_string(substr, output_substring, 3, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test duplication of string using substring */
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
- ok(pWindowsSubstring(str, 0, &substr) == S_OK, "Failed to create substring\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsSubstring(str, 0, &substr) == S_OK, "Failed to create substring\n");
ok(str != substr, "Duplicated string didn't create new string\n");
check_string(substr, input_string, 6, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 0, 6, &substr) == S_OK, "Failed to create substring\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 0, 6, &substr) == S_OK, "Failed to create substring\n");
ok(str != substr, "Duplicated string didn't create new string\n");
check_string(substr, input_string, 6, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test substring of string reference */
- ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
- ok(pWindowsSubstring(str, 2, &substr) == S_OK, "Failed to create substring of string ref\n");
+ ok(WindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
+ ok(WindowsSubstring(str, 2, &substr) == S_OK, "Failed to create substring of string ref\n");
check_string(substr, output_substring, 4, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 2, 3, &substr) == S_OK, "Failed to create substring of string ref\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 2, 3, &substr) == S_OK, "Failed to create substring of string ref\n");
check_string(substr, output_substring, 3, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
/* Test duplication of string reference using substring */
- ok(pWindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
- ok(pWindowsSubstring(str, 0, &substr) == S_OK, "Failed to create substring of string ref\n");
+ ok(WindowsCreateStringReference(input_string, 6, &header, &str) == S_OK, "Failed to create string ref\n");
+ ok(WindowsSubstring(str, 0, &substr) == S_OK, "Failed to create substring of string ref\n");
ok(str != substr, "Duplicated string ref didn't create new string\n");
check_string(substr, input_string, 6, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 0, 6, &substr) == S_OK, "Failed to create substring of string ref\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 0, 6, &substr) == S_OK, "Failed to create substring of string ref\n");
ok(str != substr, "Duplicated string ref didn't create new string\n");
check_string(substr, input_string, 6, FALSE);
- ok(pWindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(substr) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string ref\n");
/* Test get substring of empty string */
- ok(pWindowsSubstring(NULL, 0, &substr) == S_OK, "Failed to duplicate NULL string\n");
+ ok(WindowsSubstring(NULL, 0, &substr) == S_OK, "Failed to duplicate NULL string\n");
ok(substr == NULL, "Substring created new string\n");
- ok(pWindowsSubstringWithSpecifiedLength(NULL, 0, 0, &substr) == S_OK, "Failed to duplicate NULL string\n");
+ ok(WindowsSubstringWithSpecifiedLength(NULL, 0, 0, &substr) == S_OK, "Failed to duplicate NULL string\n");
ok(substr == NULL, "Substring created new string\n");
/* Test get empty substring of string */
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
- ok(pWindowsSubstring(str, 6, &substr) == S_OK, "Failed to create substring\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsSubstring(str, 6, &substr) == S_OK, "Failed to create substring\n");
ok(substr == NULL, "Substring created new string\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 6, 0, &substr) == S_OK, "Failed to create substring\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 6, 0, &substr) == S_OK, "Failed to create substring\n");
ok(substr == NULL, "Substring created new string\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test handling of using too high start index or length */
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
- ok(pWindowsSubstring(str, 7, &substr) == E_BOUNDS, "Incorrect error handling\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 7, 0, &substr) == E_BOUNDS, "Incorrect error handling\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 6, 1, &substr) == E_BOUNDS, "Incorrect error handling\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 7, ~0U, &substr) == E_BOUNDS, "Incorrect error handling\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsSubstring(str, 7, &substr) == E_BOUNDS, "Incorrect error handling\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 7, 0, &substr) == E_BOUNDS, "Incorrect error handling\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 6, 1, &substr) == E_BOUNDS, "Incorrect error handling\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 7, ~0U, &substr) == E_BOUNDS, "Incorrect error handling\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
/* Test handling of a NULL string */
- ok(pWindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
- ok(pWindowsSubstring(str, 7, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsSubstringWithSpecifiedLength(str, 7, 0, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsDeleteString(str) == S_OK, "Failed to delete string\n");
+ ok(WindowsCreateString(input_string, 6, &str) == S_OK, "Failed to create string\n");
+ ok(WindowsSubstring(str, 7, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsSubstringWithSpecifiedLength(str, 7, 0, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsDeleteString(str) == S_OK, "Failed to delete string\n");
}
static void test_concat(void)
@@ -348,53 +297,53 @@ static void test_concat(void)
HSTRING_HEADER header1, header2;
/* Test concatenation of string buffers */
- ok(pWindowsCreateString(input_string1, 3, &str1) == S_OK, "Failed to create string\n");
- ok(pWindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string1, 3, &str1) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
- ok(pWindowsConcatString(str1, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsConcatString(str1, NULL, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(str1, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsConcatString(str1, NULL, &concat) == S_OK, "Failed to concatenate string\n");
ok(str1 == concat, "Concatenate created new string\n");
check_string(concat, input_string1, 3, FALSE);
- ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
- ok(pWindowsConcatString(NULL, str2, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsConcatString(NULL, str2, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(NULL, str2, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsConcatString(NULL, str2, &concat) == S_OK, "Failed to concatenate string\n");
ok(str2 == concat, "Concatenate created new string\n");
check_string(concat, input_string2, 3, FALSE);
- ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
- ok(pWindowsConcatString(str1, str2, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsConcatString(str1, str2, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(str1, str2, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsConcatString(str1, str2, &concat) == S_OK, "Failed to concatenate string\n");
check_string(concat, input_string, 6, FALSE);
- ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
/* Test concatenation of string references */
- ok(pWindowsCreateStringReference(input_string1, 3, &header1, &str1) == S_OK, "Failed to create string ref\n");
- ok(pWindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string1, 3, &header1, &str1) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
- ok(pWindowsConcatString(str1, NULL, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(str1, NULL, &concat) == S_OK, "Failed to concatenate string\n");
ok(str1 != concat, "Concatenate string ref didn't create new string\n");
check_string(concat, input_string1, 3, FALSE);
- ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
- ok(pWindowsConcatString(NULL, str2, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(NULL, str2, &concat) == S_OK, "Failed to concatenate string\n");
ok(str2 != concat, "Concatenate string ref didn't create new string\n");
check_string(concat, input_string2, 3, FALSE);
- ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
- ok(pWindowsConcatString(str1, str2, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(str1, str2, &concat) == S_OK, "Failed to concatenate string\n");
check_string(concat, input_string, 6, FALSE);
- ok(pWindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(concat) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
/* Test concatenation of two empty strings */
- ok(pWindowsConcatString(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsConcatString(NULL, NULL, &concat) == S_OK, "Failed to concatenate string\n");
+ ok(WindowsConcatString(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsConcatString(NULL, NULL, &concat) == S_OK, "Failed to concatenate string\n");
ok(concat == NULL, "Concatenate created new string\n");
}
@@ -405,56 +354,56 @@ static void test_compare(void)
INT32 res;
/* Test comparison of string buffers */
- ok(pWindowsCreateString(input_string1, 3, &str1) == S_OK, "Failed to create string\n");
- ok(pWindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string1, 3, &str1) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
- ok(pWindowsCompareStringOrdinal(str1, str1, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str1, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str1, str2, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str1, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str2, str1, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str2, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str2, str2, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str2, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str1, NULL, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str1, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(NULL, str1, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(NULL, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str2, NULL, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str2, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(NULL, str2, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(NULL, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
/* Test comparison of string references */
- ok(pWindowsCreateStringReference(input_string1, 3, &header1, &str1) == S_OK, "Failed to create string ref\n");
- ok(pWindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string1, 3, &header1, &str1) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
- ok(pWindowsCompareStringOrdinal(str1, str1, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str1, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str1, str2, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str1, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str2, str1, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str2, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str2, str2, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str2, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == 0, "Expected 0, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str1, NULL, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str1, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(NULL, str1, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(NULL, str1, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(str2, NULL, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(str2, NULL, &res) == S_OK, "Failed to compare string\n");
ok(res == 1, "Expected 1, got %d\n", res);
- ok(pWindowsCompareStringOrdinal(NULL, str2, &res) == S_OK, "Failed to compare string\n");
+ ok(WindowsCompareStringOrdinal(NULL, str2, &res) == S_OK, "Failed to compare string\n");
ok(res == -1, "Expected -1, got %d\n", res);
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
/* Test comparison of two empty strings */
- ok(pWindowsCompareStringOrdinal(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsCompareStringOrdinal(NULL, NULL, &res) == S_OK, "Failed to compare NULL string\n");
+ ok(WindowsCompareStringOrdinal(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsCompareStringOrdinal(NULL, NULL, &res) == S_OK, "Failed to compare NULL string\n");
ok(res == 0, "Expected 0, got %d\n", res);
}
@@ -464,76 +413,74 @@ static void test_trim(void)
HSTRING_HEADER header1, header2;
/* Test trimming of string buffers */
- ok(pWindowsCreateString(input_string, 6, &str1) == S_OK, "Failed to create string\n");
- ok(pWindowsCreateString(input_string1, 3, &str2) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string, 6, &str1) == S_OK, "Failed to create string\n");
+ ok(WindowsCreateString(input_string1, 3, &str2) == S_OK, "Failed to create string\n");
- ok(pWindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
check_string(trimmed, input_string2, 3, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
ok(trimmed == str1, "Trimmed string created new string\n");
check_string(trimmed, input_string, 6, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
- ok(pWindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+ ok(WindowsCreateString(input_string2, 3, &str2) == S_OK, "Failed to create string\n");
- ok(pWindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
ok(trimmed == str1, "Trimmed string created new string\n");
check_string(trimmed, input_string, 6, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
check_string(trimmed, input_string1, 3, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
/* Test trimming of string references */
- ok(pWindowsCreateStringReference(input_string, 6, &header1, &str1) == S_OK, "Failed to create string ref\n");
- ok(pWindowsCreateStringReference(input_string1, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string, 6, &header1, &str1) == S_OK, "Failed to create string ref\n");
+ ok(WindowsCreateStringReference(input_string1, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
- ok(pWindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
check_string(trimmed, input_string2, 3, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
ok(trimmed != str1, "Trimmed string ref didn't create new string\n");
check_string(trimmed, input_string, 6, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
- ok(pWindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsCreateStringReference(input_string2, 3, &header2, &str2) == S_OK, "Failed to create string ref\n");
- ok(pWindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsTrimStringStart(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
ok(trimmed != str1, "Trimmed string ref didn't create new string\n");
check_string(trimmed, input_string, 6, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsTrimStringEnd(str1, str2, &trimmed) == S_OK, "Failed to trim string\n");
check_string(trimmed, input_string1, 3, FALSE);
- ok(pWindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(trimmed) == S_OK, "Failed to delete string\n");
- ok(pWindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str2) == S_OK, "Failed to delete string ref\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string ref\n");
/* Test handling of NULL strings */
- ok(pWindowsCreateString(input_string, 6, &str1) == S_OK, "Failed to create string\n");
- ok(pWindowsTrimStringStart(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsTrimStringStart(NULL, str1, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsTrimStringStart(NULL, NULL, &trimmed) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsTrimStringStart(NULL, str1, &trimmed) == S_OK, "Failed to trim empty string\n");
+ ok(WindowsCreateString(input_string, 6, &str1) == S_OK, "Failed to create string\n");
+ ok(WindowsTrimStringStart(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsTrimStringStart(NULL, str1, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsTrimStringStart(NULL, NULL, &trimmed) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsTrimStringStart(NULL, str1, &trimmed) == S_OK, "Failed to trim empty string\n");
ok(trimmed == NULL, "Trimming created new string\n");
- ok(pWindowsTrimStringEnd(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsTrimStringEnd(NULL, str1, NULL) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsTrimStringEnd(NULL, NULL, &trimmed) == E_INVALIDARG, "Incorrect error handling\n");
- ok(pWindowsTrimStringEnd(NULL, str1, &trimmed) == S_OK, "Failed to trim empty string\n");
+ ok(WindowsTrimStringEnd(NULL, NULL, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsTrimStringEnd(NULL, str1, NULL) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsTrimStringEnd(NULL, NULL, &trimmed) == E_INVALIDARG, "Incorrect error handling\n");
+ ok(WindowsTrimStringEnd(NULL, str1, &trimmed) == S_OK, "Failed to trim empty string\n");
ok(trimmed == NULL, "Trimming created new string\n");
- ok(pWindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
+ ok(WindowsDeleteString(str1) == S_OK, "Failed to delete string\n");
}
START_TEST(string)
{
- if (!init_functions())
- return;
test_create_delete();
test_duplicate();
test_access();
diff --git a/include/roapi.h b/include/roapi.h
index 9f717e88e34..bcaa8e9fea0 100644
--- a/include/roapi.h
+++ b/include/roapi.h
@@ -42,6 +42,8 @@ typedef HRESULT (WINAPI *PFNGETACTIVATIONFACTORY)(HSTRING, IActivationFactory **
extern "C" {
#endif
+HRESULT WINAPI RoActivateInstance(HSTRING classid, IInspectable **instance);
+HRESULT WINAPI RoGetActivationFactory(HSTRING classid, REFIID iid, void **class_factory);
HRESULT WINAPI RoInitialize(RO_INIT_TYPE type);
void WINAPI RoUninitialize(void);
--
2.30.2
1
0