webservices: Implement WsWriteStartCData and WsWriteEndCData.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
48975081b8
commit
db591a0583
|
@ -971,6 +971,54 @@ static void test_WsWriteAttribute(void)
|
|||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
static void test_WsWriteStartCData(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
WS_XML_WRITER *writer;
|
||||
WS_XML_STRING localname = {1, (BYTE *)"t"}, ns = {0, NULL};
|
||||
WS_XML_UTF8_TEXT text;
|
||||
|
||||
hr = WsCreateWriter( NULL, 0, &writer, NULL ) ;
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = set_output( writer );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteEndCData( writer, NULL );
|
||||
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
|
||||
|
||||
hr = set_output( writer );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "", __LINE__ );
|
||||
|
||||
hr = WsWriteStartCData( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<t><![CDATA[", __LINE__ );
|
||||
|
||||
text.text.textType = WS_XML_TEXT_TYPE_UTF8;
|
||||
text.value.bytes = (BYTE *)"<data>";
|
||||
text.value.length = 6;
|
||||
hr = WsWriteText( writer, &text.text, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<t><![CDATA[<data>", __LINE__ );
|
||||
|
||||
hr = WsWriteEndCData( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<t><![CDATA[<data>]]>", __LINE__ );
|
||||
|
||||
hr = WsWriteEndElement( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<t><![CDATA[<data>]]></t>", __LINE__ );
|
||||
|
||||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
START_TEST(writer)
|
||||
{
|
||||
test_WsCreateWriter();
|
||||
|
@ -980,9 +1028,10 @@ START_TEST(writer)
|
|||
test_WsWriteStartElement();
|
||||
test_WsWriteStartAttribute();
|
||||
test_WsWriteType();
|
||||
test_basic_type();
|
||||
test_simple_struct_type();
|
||||
test_WsWriteElement();
|
||||
test_WsWriteValue();
|
||||
test_WsWriteAttribute();
|
||||
test_basic_type();
|
||||
test_simple_struct_type();
|
||||
test_WsWriteStartCData();
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
@ stub WsWriteCharsUtf8
|
||||
@ stdcall WsWriteElement(ptr ptr long ptr long ptr)
|
||||
@ stdcall WsWriteEndAttribute(ptr ptr)
|
||||
@ stub WsWriteEndCData
|
||||
@ stdcall WsWriteEndCData(ptr ptr)
|
||||
@ stdcall WsWriteEndElement(ptr ptr)
|
||||
@ stdcall WsWriteEndStartElement(ptr ptr)
|
||||
@ stub WsWriteEnvelopeEnd
|
||||
|
@ -182,7 +182,7 @@
|
|||
@ stub WsWriteNode
|
||||
@ stub WsWriteQualifiedName
|
||||
@ stdcall WsWriteStartAttribute(ptr ptr ptr ptr long ptr)
|
||||
@ stub WsWriteStartCData
|
||||
@ stdcall WsWriteStartCData(ptr ptr)
|
||||
@ stdcall WsWriteStartElement(ptr ptr ptr ptr ptr)
|
||||
@ stdcall WsWriteText(ptr ptr ptr)
|
||||
@ stdcall WsWriteType(ptr long long ptr long ptr long ptr)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2015 Hans Leidekker for CodeWeavers
|
||||
* Copyright 2015, 2016 Hans Leidekker for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -64,9 +64,11 @@ enum writer_state
|
|||
WRITER_STATE_STARTELEMENT,
|
||||
WRITER_STATE_STARTENDELEMENT,
|
||||
WRITER_STATE_STARTATTRIBUTE,
|
||||
WRITER_STATE_STARTCDATA,
|
||||
WRITER_STATE_ENDSTARTELEMENT,
|
||||
WRITER_STATE_TEXT,
|
||||
WRITER_STATE_ENDELEMENT
|
||||
WRITER_STATE_ENDELEMENT,
|
||||
WRITER_STATE_ENDCDATA
|
||||
};
|
||||
|
||||
struct writer
|
||||
|
@ -727,6 +729,49 @@ HRESULT WINAPI WsWriteStartAttribute( WS_XML_WRITER *handle, const WS_XML_STRING
|
|||
return write_add_attribute( writer, prefix, localname, ns, single );
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* WsWriteStartCData [webservices.@]
|
||||
*/
|
||||
HRESULT WINAPI WsWriteStartCData( WS_XML_WRITER *handle, WS_ERROR *error )
|
||||
{
|
||||
struct writer *writer = (struct writer *)handle;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE( "%p %p\n", handle, error );
|
||||
if (error) FIXME( "ignoring error parameter\n" );
|
||||
|
||||
if (!writer) return E_INVALIDARG;
|
||||
|
||||
/* flush current start element if necessary */
|
||||
if (writer->state == WRITER_STATE_STARTELEMENT && ((hr = write_endstartelement( writer )) != S_OK))
|
||||
return hr;
|
||||
|
||||
if ((hr = write_grow_buffer( writer, 9 )) != S_OK) return hr;
|
||||
write_bytes( writer, (const BYTE *)"<![CDATA[", 9 );
|
||||
writer->state = WRITER_STATE_STARTCDATA;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* WsWriteEndCData [webservices.@]
|
||||
*/
|
||||
HRESULT WINAPI WsWriteEndCData( WS_XML_WRITER *handle, WS_ERROR *error )
|
||||
{
|
||||
struct writer *writer = (struct writer *)handle;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE( "%p %p\n", handle, error );
|
||||
if (error) FIXME( "ignoring error parameter\n" );
|
||||
|
||||
if (!writer) return E_INVALIDARG;
|
||||
if (writer->state != WRITER_STATE_STARTCDATA) return WS_E_INVALID_OPERATION;
|
||||
|
||||
if ((hr = write_grow_buffer( writer, 3 )) != S_OK) return hr;
|
||||
write_bytes( writer, (const BYTE *)"]]>", 3 );
|
||||
writer->state = WRITER_STATE_ENDCDATA;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT write_add_element_node( struct writer *writer, const WS_XML_STRING *prefix,
|
||||
const WS_XML_STRING *localname, const WS_XML_STRING *ns )
|
||||
{
|
||||
|
|
|
@ -590,10 +590,12 @@ HRESULT WINAPI WsWriteAttribute(WS_XML_WRITER*, const WS_ATTRIBUTE_DESCRIPTION*,
|
|||
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*);
|
||||
HRESULT WINAPI WsWriteEndCData(WS_XML_WRITER*, WS_ERROR*);
|
||||
HRESULT WINAPI WsWriteEndElement(WS_XML_WRITER*, WS_ERROR*);
|
||||
HRESULT WINAPI WsWriteEndStartElement(WS_XML_WRITER*, WS_ERROR*);
|
||||
HRESULT WINAPI WsWriteStartAttribute(WS_XML_WRITER*, const WS_XML_STRING*, const WS_XML_STRING*,
|
||||
const WS_XML_STRING*, BOOL, WS_ERROR*);
|
||||
HRESULT WINAPI WsWriteStartCData(WS_XML_WRITER*, WS_ERROR*);
|
||||
HRESULT WINAPI WsWriteStartElement(WS_XML_WRITER*, const WS_XML_STRING*, const WS_XML_STRING*,
|
||||
const WS_XML_STRING*, WS_ERROR*);
|
||||
HRESULT WINAPI WsWriteText(WS_XML_WRITER*, const WS_XML_TEXT*, WS_ERROR*);
|
||||
|
|
Loading…
Reference in New Issue