Hans Leidekker : webservices: Implement WsWriteChars.
Alexandre Julliard
julliard at winehq.org
Fri Apr 28 12:44:31 CDT 2017
Module: wine
Branch: master
Commit: 1e187771da7dbadc8a89787b569da8ca735a28d6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1e187771da7dbadc8a89787b569da8ca735a28d6
Author: Hans Leidekker <hans at codeweavers.com>
Date: Fri Apr 28 12:12:50 2017 +0200
webservices: Implement WsWriteChars.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/webservices/tests/writer.c | 75 +++++++++++++++++++++++++++++++++++++++
dlls/webservices/webservices.spec | 2 +-
dlls/webservices/writer.c | 39 ++++++++++++++++++++
include/webservices.h | 1 +
4 files changed, 116 insertions(+), 1 deletion(-)
diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c
index d53cb13..d0e5dee 100644
--- a/dlls/webservices/tests/writer.c
+++ b/dlls/webservices/tests/writer.c
@@ -3181,6 +3181,80 @@ static void test_WsWriteBytes(void)
WsFreeWriter( writer );
}
+static void test_WsWriteChars(void)
+{
+ WS_XML_STRING localname = {1, (BYTE *)"t"}, localname2 = {1, (BYTE *)"a"}, ns = {0, NULL};
+ static const WCHAR testW[] = {'t','e','s','t'};
+ WS_XML_WRITER *writer;
+ HRESULT hr;
+
+ hr = WsWriteChars( NULL, NULL, 0, NULL );
+ ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+ hr = WsCreateWriter( NULL, 0, &writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, NULL, 0, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 0, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, NULL, 1, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 4, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
+ hr = set_output( writer );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 4, NULL );
+ ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
+
+ hr = set_output( writer );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ /* element */
+ hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 4, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 4, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteEndElement( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ check_output( writer, "<t>testtest</t>", __LINE__ );
+
+ hr = set_output( writer );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ /* attribute */
+ hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteStartAttribute( writer, NULL, &localname2, &ns, FALSE, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 4, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteChars( writer, testW, 4, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteEndAttribute( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsWriteEndElement( writer, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ check_output( writer, "<t a=\"testtest\"/>", __LINE__ );
+
+ WsFreeWriter( writer );
+}
+
START_TEST(writer)
{
test_WsCreateWriter();
@@ -3216,4 +3290,5 @@ START_TEST(writer)
test_repeating_element();
test_WsWriteQualifiedName();
test_WsWriteBytes();
+ test_WsWriteChars();
}
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 304e917..dbed698 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -168,7 +168,7 @@
@ stdcall WsWriteAttribute(ptr ptr long ptr long ptr)
@ stdcall WsWriteBody(ptr ptr long ptr long ptr)
@ stdcall WsWriteBytes(ptr ptr long ptr)
-@ stub WsWriteChars
+@ stdcall WsWriteChars(ptr ptr long ptr)
@ stub WsWriteCharsUtf8
@ stdcall WsWriteElement(ptr ptr long ptr long ptr)
@ stdcall WsWriteEndAttribute(ptr ptr)
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 059acb0..f094885 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -1755,6 +1755,45 @@ HRESULT WINAPI WsWriteBytes( WS_XML_WRITER *handle, const void *bytes, ULONG cou
return hr;
}
+/**************************************************************************
+ * WsWriteChars [webservices.@]
+ */
+HRESULT WINAPI WsWriteChars( WS_XML_WRITER *handle, const WCHAR *chars, ULONG count, WS_ERROR *error )
+{
+ struct writer *writer = (struct writer *)handle;
+ WS_XML_UTF16_TEXT utf16;
+ HRESULT hr;
+
+ TRACE( "%p %s %u %p\n", handle, debugstr_wn(chars, count), count, error );
+ if (error) FIXME( "ignoring error parameter\n" );
+
+ if (!writer) return E_INVALIDARG;
+
+ EnterCriticalSection( &writer->cs );
+
+ if (writer->magic != WRITER_MAGIC)
+ {
+ LeaveCriticalSection( &writer->cs );
+ return E_INVALIDARG;
+ }
+
+ if (!writer->output_type)
+ {
+ LeaveCriticalSection( &writer->cs );
+ return WS_E_INVALID_OPERATION;
+ }
+
+ utf16.text.textType = WS_XML_TEXT_TYPE_UTF16;
+ utf16.bytes = (BYTE *)chars;
+ utf16.byteCount = count * sizeof(WCHAR);
+
+ if (writer->state == WRITER_STATE_STARTATTRIBUTE) hr = write_set_attribute_value( writer, &utf16.text );
+ else hr = write_text_node( writer, &utf16.text );
+
+ LeaveCriticalSection( &writer->cs );
+ return hr;
+}
+
static HRESULT write_type_text( struct writer *writer, WS_TYPE_MAPPING mapping, const WS_XML_TEXT *text )
{
switch (mapping)
diff --git a/include/webservices.h b/include/webservices.h
index 71b12ea..64c8e35 100644
--- a/include/webservices.h
+++ b/include/webservices.h
@@ -1666,6 +1666,7 @@ HRESULT WINAPI WsWriteAttribute(WS_XML_WRITER*, const WS_ATTRIBUTE_DESCRIPTION*,
HRESULT WINAPI WsWriteBody(WS_MESSAGE*, const WS_ELEMENT_DESCRIPTION*, WS_WRITE_OPTION, const void*,
ULONG, WS_ERROR*);
HRESULT WINAPI WsWriteBytes(WS_XML_WRITER*, const void*, ULONG, WS_ERROR*);
+HRESULT WINAPI WsWriteChars(WS_XML_WRITER*, const WCHAR*, ULONG, WS_ERROR*);
HRESULT WINAPI WsWriteElement(WS_XML_WRITER*, const WS_ELEMENT_DESCRIPTION*, WS_WRITE_OPTION,
const void*, ULONG, WS_ERROR*);
HRESULT WINAPI WsWriteEndAttribute(WS_XML_WRITER*, WS_ERROR*);
More information about the wine-cvs
mailing list