Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/msxml3/tests/domdoc.c | 44 +++++++++++++++++++++-------- dlls/msxml3/tests/httpreq.c | 19 +++++++++++++ dlls/msxml3/tests/saxreader.c | 52 +++++++++++++++++------------------ dlls/msxml3/tests/schema.c | 22 ++++++++++++++- 4 files changed, 99 insertions(+), 38 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index a7890d56f71..d2a4d867bae 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -54,6 +54,21 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); DEFINE_GUID(IID_transformdest_unknown,0xf5078f3a,0xc551,0x11d3,0x89,0xb9,0x00,0x00,0xf8,0x1f,0xe2,0x21);
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + static int g_unexpectedcall, g_expectedcall;
struct msxmlsupported_data_t @@ -1480,6 +1495,14 @@ static void test_domdoc( void ) doc = create_document(&IID_IXMLDOMDocument); if (!doc) return;
+ check_interface(doc, &IID_IXMLDOMDocument, TRUE); + check_interface(doc, &IID_IPersistStreamInit, TRUE); + check_interface(doc, &IID_IObjectWithSite, TRUE); + check_interface(doc, &IID_IObjectSafety, TRUE); + check_interface(doc, &IID_IConnectionPointContainer, TRUE); + check_interface(doc, &IID_IDispatch, TRUE); + check_interface(doc, &IID_IDispatchEx, TRUE); + if (0) { /* crashes on native */ @@ -2110,7 +2133,6 @@ static void test_persiststream(void) IPersistStream *stream; IXMLDOMDocument *doc; ULARGE_INTEGER size; - IPersist *persist; IStream *istream; HRESULT hr; CLSID clsid; @@ -2130,11 +2152,8 @@ static void test_persiststream(void) ok(hr == S_OK, "got 0x%08x\n", hr); ok((IUnknown *)stream == (IUnknown *)streaminit, "got %p, %p\n", stream, streaminit);
- hr = IPersistStream_QueryInterface(stream, &IID_IPersist, (void **)&persist); - ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr); - - hr = IXMLDOMDocument_QueryInterface(doc, &IID_IPersist, (void **)&persist); - ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr); + check_interface(stream, &IID_IPersist, FALSE); + check_interface(doc, &IID_IPersist, FALSE);
hr = IPersistStreamInit_GetClassID(streaminit, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); @@ -9039,6 +9058,10 @@ static void test_xsltemplate(void) if (!is_clsid_supported(&CLSID_XSLTemplate, &IID_IXSLTemplate)) return; template = create_xsltemplate(&IID_IXSLTemplate);
+ check_interface(template, &IID_IXSLTemplate, TRUE); + check_interface(template, &IID_IDispatch, TRUE); + check_interface(template, &IID_IDispatchEx, TRUE); + /* works as reset */ hr = IXSLTemplate_putref_stylesheet(template, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -10790,7 +10813,6 @@ static void test_mxnamespacemanager(void) IMXNamespaceManager *nsmgr; IUnknown *unk1, *unk2; WCHAR buffW[250]; - IDispatch *disp; IUnknown *unk; HRESULT hr; INT len; @@ -10799,10 +10821,10 @@ static void test_mxnamespacemanager(void) &IID_IMXNamespaceManager, (void**)&nsmgr); EXPECT_HR(hr, S_OK);
- /* IMXNamespaceManager inherits from IUnknown */ - hr = IMXNamespaceManager_QueryInterface(nsmgr, &IID_IDispatch, (void**)&disp); - EXPECT_HR(hr, S_OK); - IDispatch_Release(disp); + check_interface(nsmgr, &IID_IDispatch, TRUE); + check_interface(nsmgr, &IID_IDispatchEx, TRUE); + check_interface(nsmgr, &IID_IMXNamespaceManager, TRUE); + check_interface(nsmgr, &IID_IVBMXNamespaceManager, TRUE);
hr = IMXNamespaceManager_QueryInterface(nsmgr, &IID_IVBMXNamespaceManager, (void**)&mgr2); EXPECT_HR(hr, S_OK); diff --git a/dlls/msxml3/tests/httpreq.c b/dlls/msxml3/tests/httpreq.c index 4a23f1d82a8..2491e499638 100644 --- a/dlls/msxml3/tests/httpreq.c +++ b/dlls/msxml3/tests/httpreq.c @@ -50,6 +50,21 @@ static void _expect_ref(IUnknown* obj, ULONG ref, int line) ok_(__FILE__, line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); }
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + static const char xmltestA[] = "http://test.winehq.org/tests/xmltest.xml"; static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
@@ -1457,6 +1472,10 @@ static void test_XMLHTTP(void)
xhr = create_xhr();
+ check_interface(xhr, &IID_IXMLHttpRequest, TRUE); + check_interface(xhr, &IID_IDispatch, TRUE); + check_interface(xhr, &IID_IDispatchEx, FALSE); + VariantInit(&dummy); V_VT(&dummy) = VT_ERROR; V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND; diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index e401aafc87d..ad093af6a12 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -48,6 +48,21 @@ static void _expect_ref(IUnknown* obj, ULONG ref, int line) ok_(__FILE__, line)(rc == ref, "expected refcount %d, got %d\n", ref, rc); }
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + static LONG get_refcount(void *iface) { IUnknown *unk = iface; @@ -4861,6 +4876,11 @@ static void test_saxreader_dispex(void) &IID_ISAXXMLReader, (void**)&reader); EXPECT_HR(hr, S_OK);
+ check_interface(reader, &IID_ISAXXMLReader, TRUE); + check_interface(reader, &IID_IVBSAXXMLReader, TRUE); + check_interface(reader, &IID_IDispatch, TRUE); + check_interface(reader, &IID_IDispatchEx, TRUE); + hr = ISAXXMLReader_QueryInterface(reader, &IID_IUnknown, (void**)&unk); EXPECT_HR(hr, S_OK); test_obj_dispex(unk); @@ -5811,40 +5831,20 @@ static void test_mxattr_dispex(void)
static void test_mxattr_qi(void) { - IVBSAXAttributes *vbsaxattr, *vbsaxattr2; - ISAXAttributes *saxattr; IMXAttributes *mxattr; HRESULT hr;
hr = CoCreateInstance(&CLSID_SAXAttributes, NULL, CLSCTX_INPROC_SERVER, - &IID_IMXAttributes, (void**)&mxattr); + &IID_IMXAttributes, (void **)&mxattr); EXPECT_HR(hr, S_OK);
- EXPECT_REF(mxattr, 1); - hr = IMXAttributes_QueryInterface(mxattr, &IID_ISAXAttributes, (void**)&saxattr); - EXPECT_HR(hr, S_OK); - - EXPECT_REF(mxattr, 2); - EXPECT_REF(saxattr, 2); - - hr = IMXAttributes_QueryInterface(mxattr, &IID_IVBSAXAttributes, (void**)&vbsaxattr); - EXPECT_HR(hr, S_OK); - - EXPECT_REF(vbsaxattr, 3); - EXPECT_REF(mxattr, 3); - EXPECT_REF(saxattr, 3); - - hr = ISAXAttributes_QueryInterface(saxattr, &IID_IVBSAXAttributes, (void**)&vbsaxattr2); - EXPECT_HR(hr, S_OK); - - EXPECT_REF(vbsaxattr, 4); - EXPECT_REF(mxattr, 4); - EXPECT_REF(saxattr, 4); + check_interface(mxattr, &IID_IMXAttributes, TRUE); + check_interface(mxattr, &IID_ISAXAttributes, TRUE); + check_interface(mxattr, &IID_IVBSAXAttributes, TRUE); + check_interface(mxattr, &IID_IDispatch, TRUE); + check_interface(mxattr, &IID_IDispatchEx, TRUE);
IMXAttributes_Release(mxattr); - ISAXAttributes_Release(saxattr); - IVBSAXAttributes_Release(vbsaxattr); - IVBSAXAttributes_Release(vbsaxattr2); }
static struct msxmlsupported_data_t saxattr_support_data[] = diff --git a/dlls/msxml3/tests/schema.c b/dlls/msxml3/tests/schema.c index 8dc9dcd7e22..4cdfedf9c29 100644 --- a/dlls/msxml3/tests/schema.c +++ b/dlls/msxml3/tests/schema.c @@ -37,6 +37,21 @@ #define EXPECT_HR(hr,hr_exp) \ ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + static const CHAR xdr_schema1_uri[] = "x-schema:test1.xdr"; static const CHAR xdr_schema1_xml[] = "<?xml version='1.0'?>" @@ -1808,8 +1823,13 @@ static void test_ifaces(void) hr = IXMLDOMSchemaCollection2_QueryInterface(cache, &CLSID_XMLSchemaCache60, (void**)&unk); ok (hr == S_OK, "Could not get CLSID_XMLSchemaCache60 iface: %08x\n", hr); ok (unk == (IUnknown*)cache, "unk != cache\n"); - IUnknown_Release(unk); + + check_interface(cache, &IID_IXMLDOMSchemaCollection, TRUE); + check_interface(cache, &IID_IXMLDOMSchemaCollection2, TRUE); + check_interface(cache, &IID_IDispatch, TRUE); + check_interface(cache, &IID_IDispatchEx, TRUE); + IXMLDOMSchemaCollection2_Release(cache); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/msxml3/dispex.c | 33 +++------- dlls/msxml3/msxml_dispex.h | 116 ++++++++++++++++++++++++++++++++++++ dlls/msxml3/msxml_private.h | 86 +------------------------- 3 files changed, 127 insertions(+), 108 deletions(-) create mode 100644 dlls/msxml3/msxml_dispex.h
diff --git a/dlls/msxml3/dispex.c b/dlls/msxml3/dispex.c index b1fb72847e7..2ee03241946 100644 --- a/dlls/msxml3/dispex.c +++ b/dlls/msxml3/dispex.c @@ -18,30 +18,16 @@
#define COBJMACROS
-#include "config.h" - #include <stdarg.h> -#ifdef HAVE_LIBXML2 -# include <libxml/parser.h> -# include <libxml/xmlerror.h> -#endif - -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "winnls.h" -#include "ole2.h" -#include "msxml6.h" -#include "msxml6did.h" -#include "wininet.h" -#include "urlmon.h" -#include "winreg.h" -#include "shlwapi.h" + +#include "msxml2.h" +#include "msxml2did.h" +#include "dispex.h"
#include "wine/debug.h" -#include "wine/unicode.h" +#include "wine/heap.h"
-#include "msxml_private.h" +#include "msxml_dispex.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
@@ -54,7 +40,6 @@ static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg = }; static CRITICAL_SECTION cs_dispex_static_data = { &cs_dispex_static_data_dbg, -1, 0, 0, 0, 0 };
- enum lib_version_t { LibXml = 0, @@ -258,7 +243,7 @@ static int dispid_cmp(const void *p1, const void *p2)
static int func_name_cmp(const void *p1, const void *p2) { - return strcmpiW((*(func_info_t* const*)p1)->name, (*(func_info_t* const*)p2)->name); + return lstrcmpiW((*(func_info_t* const*)p1)->name, (*(func_info_t* const*)p2)->name); }
static dispex_data_t *preprocess_dispex_data(DispatchEx *This) @@ -439,9 +424,9 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW while(min <= max) { n = (min+max)/2;
- c = strcmpiW(data->name_table[n]->name, bstrName); + c = lstrcmpiW(data->name_table[n]->name, bstrName); if(!c) { - if((grfdex & fdexNameCaseSensitive) && strcmpW(data->name_table[n]->name, bstrName)) + if((grfdex & fdexNameCaseSensitive) && lstrcmpW(data->name_table[n]->name, bstrName)) break;
*pid = data->name_table[n]->id; diff --git a/dlls/msxml3/msxml_dispex.h b/dlls/msxml3/msxml_dispex.h new file mode 100644 index 00000000000..c9dbc29ddc5 --- /dev/null +++ b/dlls/msxml3/msxml_dispex.h @@ -0,0 +1,116 @@ +/* + * Copyright 2005 Mike McCormack + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __MSXML_DISPEX__ +#define __MSXML_DISPEX__ + +#include "dispex.h" + +#include "wine/heap.h" +#include "wine/list.h" + +typedef enum +{ + MSXML_DEFAULT = 0, + MSXML2 = 20, + MSXML26 = 26, + MSXML3 = 30, + MSXML4 = 40, + MSXML6 = 60 +} MSXML_VERSION; + +typedef enum tid_t +{ + NULL_tid, + IXMLDOMAttribute_tid, + IXMLDOMCDATASection_tid, + IXMLDOMComment_tid, + IXMLDOMDocument_tid, + IXMLDOMDocument2_tid, + IXMLDOMDocument3_tid, + IXMLDOMDocumentFragment_tid, + IXMLDOMDocumentType_tid, + IXMLDOMElement_tid, + IXMLDOMEntityReference_tid, + IXMLDOMImplementation_tid, + IXMLDOMNamedNodeMap_tid, + IXMLDOMNode_tid, + IXMLDOMNodeList_tid, + IXMLDOMParseError2_tid, + IXMLDOMProcessingInstruction_tid, + IXMLDOMSchemaCollection_tid, + IXMLDOMSchemaCollection2_tid, + IXMLDOMSelection_tid, + IXMLDOMText_tid, + IXMLElement_tid, + IXMLDocument_tid, + IXMLHTTPRequest_tid, + IXSLProcessor_tid, + IXSLTemplate_tid, + IVBSAXAttributes_tid, + IVBSAXContentHandler_tid, + IVBSAXDeclHandler_tid, + IVBSAXDTDHandler_tid, + IVBSAXEntityResolver_tid, + IVBSAXErrorHandler_tid, + IVBSAXLexicalHandler_tid, + IVBSAXLocator_tid, + IVBSAXXMLFilter_tid, + IVBSAXXMLReader_tid, + IMXAttributes_tid, + IMXReaderControl_tid, + IMXWriter_tid, + IVBMXNamespaceManager_tid, + IServerXMLHTTPRequest_tid, + LAST_tid +} tid_t; + +extern HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN; +extern void release_typelib(void) DECLSPEC_HIDDEN; + +typedef struct dispex_data_t dispex_data_t; + +typedef struct +{ + HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*); + HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*); +} dispex_static_data_vtbl_t; + +typedef struct +{ + const dispex_static_data_vtbl_t *vtbl; + const tid_t disp_tid; + dispex_data_t *data; + const tid_t* const iface_tids; +} dispex_static_data_t; + +typedef struct +{ + IDispatchEx IDispatchEx_iface; + + IUnknown *outer; + + dispex_static_data_t *data; +} DispatchEx; + +void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*) DECLSPEC_HIDDEN; +void release_dispex(DispatchEx*) DECLSPEC_HIDDEN; +BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN; +const IID *get_riid_from_tid(enum tid_t tid) DECLSPEC_HIDDEN; + +#endif /* __MSXML_DISPEX__ */ diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index a59e00bf2b3..41e16e4406c 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -27,67 +27,15 @@ #include "wine/heap.h" #include "wine/list.h"
+#include "msxml_dispex.h" + #ifndef __WINE_CONFIG_H # error You must include config.h to use this header #endif
-typedef enum { - MSXML_DEFAULT = 0, - MSXML2 = 20, - MSXML26 = 26, - MSXML3 = 30, - MSXML4 = 40, - MSXML6 = 60 -} MSXML_VERSION; - extern const CLSID * DOMDocument_version(MSXML_VERSION v) DECLSPEC_HIDDEN; extern const CLSID * SchemaCache_version(MSXML_VERSION v) DECLSPEC_HIDDEN;
-/* typelibs */ -typedef enum tid_t { - NULL_tid, - IXMLDOMAttribute_tid, - IXMLDOMCDATASection_tid, - IXMLDOMComment_tid, - IXMLDOMDocument_tid, - IXMLDOMDocument2_tid, - IXMLDOMDocument3_tid, - IXMLDOMDocumentFragment_tid, - IXMLDOMDocumentType_tid, - IXMLDOMElement_tid, - IXMLDOMEntityReference_tid, - IXMLDOMImplementation_tid, - IXMLDOMNamedNodeMap_tid, - IXMLDOMNode_tid, - IXMLDOMNodeList_tid, - IXMLDOMParseError2_tid, - IXMLDOMProcessingInstruction_tid, - IXMLDOMSchemaCollection_tid, - IXMLDOMSchemaCollection2_tid, - IXMLDOMSelection_tid, - IXMLDOMText_tid, - IXMLElement_tid, - IXMLDocument_tid, - IXMLHTTPRequest_tid, - IXSLProcessor_tid, - IXSLTemplate_tid, - IVBSAXAttributes_tid, - IVBSAXContentHandler_tid, - IVBSAXDeclHandler_tid, - IVBSAXDTDHandler_tid, - IVBSAXEntityResolver_tid, - IVBSAXErrorHandler_tid, - IVBSAXLexicalHandler_tid, - IVBSAXLocator_tid, - IVBSAXXMLFilter_tid, - IVBSAXXMLReader_tid, - IMXAttributes_tid, - IMXReaderControl_tid, - IMXWriter_tid, - IVBMXNamespaceManager_tid, - IServerXMLHTTPRequest_tid, - LAST_tid -} tid_t;
/* The XDR datatypes (urn:schemas-microsoft-com:datatypes) * These are actually valid for XSD schemas as well @@ -134,38 +82,8 @@ typedef enum _XDR_DT { LAST_DT } XDR_DT;
-extern HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN; -extern void release_typelib(void) DECLSPEC_HIDDEN; - -typedef struct dispex_data_t dispex_data_t; - -typedef struct { - HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*); - HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*); -} dispex_static_data_vtbl_t; - -typedef struct { - const dispex_static_data_vtbl_t *vtbl; - const tid_t disp_tid; - dispex_data_t *data; - const tid_t* const iface_tids; -} dispex_static_data_t; - -typedef struct { - IDispatchEx IDispatchEx_iface; - - IUnknown *outer; - - dispex_static_data_t *data; -} DispatchEx; - extern HINSTANCE MSXML_hInstance DECLSPEC_HIDDEN;
-void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*) DECLSPEC_HIDDEN; -void release_dispex(DispatchEx*) DECLSPEC_HIDDEN; -BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN; -const IID *get_riid_from_tid(enum tid_t tid) DECLSPEC_HIDDEN; - /* memory allocation functions */
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t size)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/msxml3/mxnamespace.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/dlls/msxml3/mxnamespace.c b/dlls/msxml3/mxnamespace.c index dc6ff9c85ad..422bd388ced 100644 --- a/dlls/msxml3/mxnamespace.c +++ b/dlls/msxml3/mxnamespace.c @@ -20,14 +20,7 @@
#define COBJMACROS
-#include "config.h" - #include <stdarg.h> -#ifdef HAVE_LIBXML2 -# include <libxml/parser.h> -# include <libxml/xmlerror.h> -# include <libxml/encoding.h> -#endif
#include "windef.h" #include "winbase.h" @@ -35,7 +28,7 @@ #include "ole2.h" #include "msxml6.h"
-#include "msxml_private.h" +#include "msxml_dispex.h"
#include "wine/debug.h"
@@ -101,7 +94,7 @@ static HRESULT declare_prefix(namespacemanager *This, const WCHAR *prefix, const
ns = NULL; for (i = 0; i < ctxt->count; i++) - if (!strcmpW(ctxt->ns[i].prefix, prefix)) + if (!lstrcmpW(ctxt->ns[i].prefix, prefix)) { ns = &ctxt->ns[i]; break; @@ -150,7 +143,7 @@ static HRESULT get_declared_prefix_uri(const struct list *ctxts, const WCHAR *ur { int i; for (i = 0; i < ctxt->count; i++) - if (!strcmpW(ctxt->ns[i].uri, uri)) + if (!lstrcmpW(ctxt->ns[i].uri, uri)) { *prefix = ctxt->ns[i].prefix; return S_OK; @@ -166,7 +159,7 @@ static HRESULT get_uri_from_prefix(const struct nscontext *ctxt, const WCHAR *pr int i;
for (i = 0; i < ctxt->count; i++) - if (!strcmpW(ctxt->ns[i].prefix, prefix)) + if (!lstrcmpW(ctxt->ns[i].prefix, prefix)) { *uri = ctxt->ns[i].uri; return S_OK; @@ -286,7 +279,7 @@ static HRESULT WINAPI namespacemanager_declarePrefix(IMXNamespaceManager *iface,
TRACE("(%p)->(%s %s)\n", This, debugstr_w(prefix), debugstr_w(namespaceURI));
- if (prefix && (!strcmpW(prefix, xmlW) || !strcmpW(prefix, xmlnsW) || !namespaceURI)) + if (prefix && (!lstrcmpW(prefix, xmlW) || !lstrcmpW(prefix, xmlnsW) || !namespaceURI)) return E_INVALIDARG;
return declare_prefix(This, prefix, namespaceURI); @@ -311,7 +304,7 @@ static HRESULT WINAPI namespacemanager_getDeclaredPrefix(IMXNamespaceManager *if if (prefix) { if (*prefix_len < (INT)SysStringLen(prfx)) return E_XML_BUFFERTOOSMALL; - strcpyW(prefix, prfx); + lstrcpyW(prefix, prfx); }
*prefix_len = SysStringLen(prfx); @@ -339,7 +332,7 @@ static HRESULT WINAPI namespacemanager_getPrefix(IMXNamespaceManager *iface, if (prefix) { if (*prefix_len < (INT)SysStringLen(prfx)) return E_XML_BUFFERTOOSMALL; - strcpyW(prefix, prfx); + lstrcpyW(prefix, prfx); }
*prefix_len = SysStringLen(prfx); @@ -375,7 +368,7 @@ static HRESULT WINAPI namespacemanager_getURI(IMXNamespaceManager *iface, if (uri) { if (*uri_len < (INT)SysStringLen(urib)) return E_XML_BUFFERTOOSMALL; - strcpyW(uri, urib); + lstrcpyW(uri, urib); } } else
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/msxml3/msxml_dispex.h | 31 +++++++++++++++++++++++++++++++ dlls/msxml3/msxml_private.h | 28 ---------------------------- dlls/msxml3/mxwriter.c | 12 ++++-------- 3 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/dlls/msxml3/msxml_dispex.h b/dlls/msxml3/msxml_dispex.h index c9dbc29ddc5..ec3860c2754 100644 --- a/dlls/msxml3/msxml_dispex.h +++ b/dlls/msxml3/msxml_dispex.h @@ -113,4 +113,35 @@ void release_dispex(DispatchEx*) DECLSPEC_HIDDEN; BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN; const IID *get_riid_from_tid(enum tid_t tid) DECLSPEC_HIDDEN;
+static inline HRESULT return_bstr(const WCHAR *value, BSTR *p) +{ + if (!p) + return E_INVALIDARG; + + if (value) + { + *p = SysAllocString(value); + if (!*p) + return E_OUTOFMEMORY; + } + else + *p = NULL; + + return S_OK; +} + +static inline HRESULT return_bstrn(const WCHAR *value, int len, BSTR *p) +{ + if (value) + { + *p = SysAllocStringLen(value, len); + if (!*p) + return E_OUTOFMEMORY; + } + else + *p = NULL; + + return S_OK; +} + #endif /* __MSXML_DISPEX__ */ diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index 41e16e4406c..43c6de6454e 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -340,34 +340,6 @@ static inline xmlChar *heap_strdupxmlChar(const xmlChar *str)
#endif
-static inline HRESULT return_bstr(const WCHAR *value, BSTR *p) -{ - if(!p) - return E_INVALIDARG; - - if(value) { - *p = SysAllocString(value); - if(!*p) - return E_OUTOFMEMORY; - }else { - *p = NULL; - } - - return S_OK; -} - -static inline HRESULT return_bstrn(const WCHAR *value, int len, BSTR *p) -{ - if(value) { - *p = SysAllocStringLen(value, len); - if(!*p) - return E_OUTOFMEMORY; - }else - *p = NULL; - - return S_OK; -} - static inline HRESULT return_null_node(IXMLDOMNode **p) { if(!p) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index b1ca5a0ca41..a7eae112fb4 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -20,12 +20,8 @@ */
#define COBJMACROS -#include "config.h"
#include <stdarg.h> -#ifdef HAVE_LIBXML2 -# include <libxml/parser.h> -#endif
#include "windef.h" #include "winbase.h" @@ -34,9 +30,9 @@ #include "msxml6.h"
#include "wine/debug.h" -#include "wine/list.h" +#include "wine/unicode.h"
-#include "msxml_private.h" +#include "msxml_dispex.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
@@ -258,7 +254,7 @@ static xml_encoding parse_encoding_name(const WCHAR *encoding) { n = (min+max)/2;
- c = strcmpiW(xml_encoding_map[n].encoding, encoding); + c = lstrcmpiW(xml_encoding_map[n].encoding, encoding); if (!c) return xml_encoding_map[n].enc;
@@ -347,7 +343,7 @@ static HRESULT write_output_buffer(mxwriter *writer, const WCHAR *data, int len) if (!len || !*data) return S_OK;
- src_len = len == -1 ? strlenW(data) : len; + src_len = len == -1 ? lstrlenW(data) : len; if (writer->dest) { buff = &buffer->encoded;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/msxml3/httprequest.c | 76 ++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 12 deletions(-)
diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c index 7286eb97bb7..20ec389739e 100644 --- a/dlls/msxml3/httprequest.c +++ b/dlls/msxml3/httprequest.c @@ -1127,6 +1127,58 @@ static HRESULT httprequest_get_statusText(httprequest *This, BSTR *status) return S_OK; }
+enum response_encoding +{ + RESPONSE_ENCODING_NONE, + RESPONSE_ENCODING_UCS4BE, + RESPONSE_ENCODING_UCS4LE, + RESPONSE_ENCODING_UCS4_2143, + RESPONSE_ENCODING_UCS4_3412, + RESPONSE_ENCODING_EBCDIC, + RESPONSE_ENCODING_UTF8, + RESPONSE_ENCODING_UTF16LE, + RESPONSE_ENCODING_UTF16BE, +}; + +static unsigned int detect_response_encoding(const BYTE *in, unsigned int len) +{ + if (len >= 4) + { + if (in[0] == 0 && in[1] == 0 && in[2] == 0 && in[3] == 0x3c) + return RESPONSE_ENCODING_UCS4BE; + if (in[0] == 0x3c && in[1] == 0 && in[2] == 0 && in[3] == 0) + return RESPONSE_ENCODING_UCS4LE; + if (in[0] == 0 && in[1] == 0 && in[2] == 0x3c && in[3] == 0) + return RESPONSE_ENCODING_UCS4_2143; + if (in[0] == 0 && in[1] == 0x3c && in[2] == 0 && in[3] == 0) + return RESPONSE_ENCODING_UCS4_3412; + if (in[0] == 0x4c && in[1] == 0x6f && in[2] == 0xa7 && in[3] == 0x94) + return RESPONSE_ENCODING_EBCDIC; + if (in[0] == 0x3c && in[1] == 0x3f && in[2] == 0x78 && in[3] == 0x6d) + return RESPONSE_ENCODING_UTF8; + if (in[0] == 0x3c && in[1] == 0 && in[2] == 0x3f && in[3] == 0) + return RESPONSE_ENCODING_UTF16LE; + if (in[0] == 0 && in[1] == 0x3c && in[2] == 0 && in[3] == 0x3f) + return RESPONSE_ENCODING_UTF16BE; + } + + if (len >= 3) + { + if (in[0] == 0xef && in[1] == 0xbb && in[2] == 0xbf) + return RESPONSE_ENCODING_UTF8; + } + + if (len >= 2) + { + if (in[0] == 0xfe && in[1] == 0xff) + return RESPONSE_ENCODING_UTF16BE; + if (in[0] == 0xff && in[1] == 0xfe) + return RESPONSE_ENCODING_UTF16LE; + } + + return RESPONSE_ENCODING_NONE; +} + static HRESULT httprequest_get_responseText(httprequest *This, BSTR *body) { HGLOBAL hglobal; @@ -1138,34 +1190,34 @@ static HRESULT httprequest_get_responseText(httprequest *This, BSTR *body) hr = GetHGlobalFromStream(This->bsc->stream, &hglobal); if (hr == S_OK) { - xmlChar *ptr = GlobalLock(hglobal); + const char *ptr = GlobalLock(hglobal); DWORD size = GlobalSize(hglobal); - xmlCharEncoding encoding = XML_CHAR_ENCODING_UTF8; + unsigned int encoding = RESPONSE_ENCODING_NONE;
/* try to determine data encoding */ if (size >= 4) { - encoding = xmlDetectCharEncoding(ptr, 4); - TRACE("detected encoding: %s\n", debugstr_a(xmlGetCharEncodingName(encoding))); - if ( encoding != XML_CHAR_ENCODING_UTF8 && - encoding != XML_CHAR_ENCODING_UTF16LE && - encoding != XML_CHAR_ENCODING_NONE ) + encoding = detect_response_encoding((const BYTE *)ptr, 4); + TRACE("detected encoding: %u.\n", encoding); + + if (encoding != RESPONSE_ENCODING_UTF8 && + encoding != RESPONSE_ENCODING_UTF16LE && + encoding != RESPONSE_ENCODING_NONE ) { - FIXME("unsupported encoding: %s\n", debugstr_a(xmlGetCharEncodingName(encoding))); + FIXME("unsupported response encoding: %u.\n", encoding); GlobalUnlock(hglobal); return E_FAIL; } }
/* without BOM assume UTF-8 */ - if (encoding == XML_CHAR_ENCODING_UTF8 || - encoding == XML_CHAR_ENCODING_NONE ) + if (encoding == RESPONSE_ENCODING_UTF8 || encoding == RESPONSE_ENCODING_NONE) { - DWORD length = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)ptr, size, NULL, 0); + DWORD length = MultiByteToWideChar(CP_UTF8, 0, ptr, size, NULL, 0);
*body = SysAllocStringLen(NULL, length); if (*body) - MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)ptr, size, *body, length); + MultiByteToWideChar( CP_UTF8, 0, ptr, size, *body, length); } else *body = SysAllocStringByteLen((LPCSTR)ptr, size);