webservices: Implement WsWriteChars.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
86738d095d
commit
1e187771da
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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*);
|
||||
|
|
Loading…
Reference in New Issue