webservices: Implement WsWriteCharsUtf8.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1e187771da
commit
ba014d9998
|
@ -3255,6 +3255,80 @@ static void test_WsWriteChars(void)
|
|||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
static void test_WsWriteCharsUtf8(void)
|
||||
{
|
||||
WS_XML_STRING localname = {1, (BYTE *)"t"}, localname2 = {1, (BYTE *)"a"}, ns = {0, NULL};
|
||||
static const BYTE test[] = {'t','e','s','t'};
|
||||
WS_XML_WRITER *writer;
|
||||
HRESULT hr;
|
||||
|
||||
hr = WsWriteCharsUtf8( 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 = WsWriteCharsUtf8( writer, NULL, 0, NULL );
|
||||
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteCharsUtf8( writer, test, 0, NULL );
|
||||
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteCharsUtf8( writer, NULL, 1, NULL );
|
||||
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteCharsUtf8( 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 = WsWriteCharsUtf8( 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 = WsWriteCharsUtf8( writer, test, sizeof(test), NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteCharsUtf8( 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>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 = WsWriteCharsUtf8( writer, test, sizeof(test), NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteCharsUtf8( 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=\"testtest\"/>", __LINE__ );
|
||||
|
||||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
START_TEST(writer)
|
||||
{
|
||||
test_WsCreateWriter();
|
||||
|
@ -3291,4 +3365,5 @@ START_TEST(writer)
|
|||
test_WsWriteQualifiedName();
|
||||
test_WsWriteBytes();
|
||||
test_WsWriteChars();
|
||||
test_WsWriteCharsUtf8();
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
@ stdcall WsWriteBody(ptr ptr long ptr long ptr)
|
||||
@ stdcall WsWriteBytes(ptr ptr long ptr)
|
||||
@ stdcall WsWriteChars(ptr ptr long ptr)
|
||||
@ stub WsWriteCharsUtf8
|
||||
@ stdcall WsWriteCharsUtf8(ptr ptr long ptr)
|
||||
@ stdcall WsWriteElement(ptr ptr long ptr long ptr)
|
||||
@ stdcall WsWriteEndAttribute(ptr ptr)
|
||||
@ stdcall WsWriteEndCData(ptr ptr)
|
||||
|
|
|
@ -1794,6 +1794,45 @@ HRESULT WINAPI WsWriteChars( WS_XML_WRITER *handle, const WCHAR *chars, ULONG co
|
|||
return hr;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* WsWriteCharsUtf8 [webservices.@]
|
||||
*/
|
||||
HRESULT WINAPI WsWriteCharsUtf8( WS_XML_WRITER *handle, const BYTE *bytes, ULONG count, WS_ERROR *error )
|
||||
{
|
||||
struct writer *writer = (struct writer *)handle;
|
||||
WS_XML_UTF8_TEXT utf8;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE( "%p %s %u %p\n", handle, debugstr_an((const char *)bytes, 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;
|
||||
}
|
||||
|
||||
utf8.text.textType = WS_XML_TEXT_TYPE_UTF8;
|
||||
utf8.value.bytes = (BYTE *)bytes;
|
||||
utf8.value.length = count;
|
||||
|
||||
if (writer->state == WRITER_STATE_STARTATTRIBUTE) hr = write_set_attribute_value( writer, &utf8.text );
|
||||
else hr = write_text_node( writer, &utf8.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)
|
||||
|
|
|
@ -1667,6 +1667,7 @@ HRESULT WINAPI WsWriteBody(WS_MESSAGE*, const WS_ELEMENT_DESCRIPTION*, WS_WRITE_
|
|||
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 WsWriteCharsUtf8(WS_XML_WRITER*, const BYTE*, 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