Commit 86738d09 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WsWriteBytes.

parent e6129147
......@@ -3114,6 +3114,73 @@ static void test_WsWriteQualifiedName(void)
WsFreeWriter( writer );
}
static void test_WsWriteBytes(void)
{
WS_XML_STRING localname = {1, (BYTE *)"t"}, localname2 = {1, (BYTE *)"a"}, ns = {0, NULL};
WS_XML_WRITER *writer;
HRESULT hr;
hr = WsWriteBytes( 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 = WsWriteBytes( writer, NULL, 0, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsWriteBytes( writer, "test", 0, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsWriteBytes( writer, NULL, 1, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsWriteBytes( writer, "test", sizeof("test"), NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsWriteBytes( writer, "test", sizeof("test"), 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 = WsWriteBytes( writer, "test", sizeof("test"), 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>dGVzdAA=</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 = WsWriteBytes( writer, "test", sizeof("test"), 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=\"dGVzdAA=\"/>", __LINE__ );
WsFreeWriter( writer );
}
START_TEST(writer)
{
test_WsCreateWriter();
......@@ -3148,4 +3215,5 @@ START_TEST(writer)
test_datetime();
test_repeating_element();
test_WsWriteQualifiedName();
test_WsWriteBytes();
}
......@@ -167,7 +167,7 @@
@ stdcall WsWriteArray(ptr ptr ptr long ptr long long long ptr)
@ stdcall WsWriteAttribute(ptr ptr long ptr long ptr)
@ stdcall WsWriteBody(ptr ptr long ptr long ptr)
@ stub WsWriteBytes
@ stdcall WsWriteBytes(ptr ptr long ptr)
@ stub WsWriteChars
@ stub WsWriteCharsUtf8
@ stdcall WsWriteElement(ptr ptr long ptr long ptr)
......
......@@ -1697,6 +1697,7 @@ HRESULT WINAPI WsWriteText( WS_XML_WRITER *handle, const WS_XML_TEXT *text, WS_E
HRESULT hr;
TRACE( "%p %p %p\n", handle, text, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!writer || !text) return E_INVALIDARG;
......@@ -1715,6 +1716,45 @@ HRESULT WINAPI WsWriteText( WS_XML_WRITER *handle, const WS_XML_TEXT *text, WS_E
return hr;
}
/**************************************************************************
* WsWriteBytes [webservices.@]
*/
HRESULT WINAPI WsWriteBytes( WS_XML_WRITER *handle, const void *bytes, ULONG count, WS_ERROR *error )
{
struct writer *writer = (struct writer *)handle;
WS_XML_BASE64_TEXT base64;
HRESULT hr;
TRACE( "%p %p %u %p\n", handle, bytes, 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;
}
base64.text.textType = WS_XML_TEXT_TYPE_BASE64;
base64.bytes = (BYTE *)bytes;
base64.length = count;
if (writer->state == WRITER_STATE_STARTATTRIBUTE) hr = write_set_attribute_value( writer, &base64.text );
else hr = write_text_node( writer, &base64.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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment