webservices: Add support for writing comments in binary mode.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e0b5496ccb
commit
df5c1b6ed8
|
@ -3130,8 +3130,10 @@ static void test_repeating_element(void)
|
|||
static const WS_XML_STRING *init_xmlstring( const char *src, WS_XML_STRING *str )
|
||||
{
|
||||
if (!src) return NULL;
|
||||
str->length = strlen( src );
|
||||
str->bytes = (BYTE *)src;
|
||||
str->length = strlen( src );
|
||||
str->bytes = (BYTE *)src;
|
||||
str->dictionary = NULL;
|
||||
str->id = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -3453,6 +3455,8 @@ static void test_binary_encoding(void)
|
|||
{0x40,0x01,'t',0x05,0x02,'p','2',0x01,'t',0x98,0x00,0x09,0x02,'p','2',0x02,'n','s',0x01};
|
||||
static const char res103[] =
|
||||
{0x40,0x01,'t',0x05,0x02,'p','2',0x01,'t',0x98,0x04,'t','e','s','t',0x09,0x02,'p','2',0x02,'n','s',0x01};
|
||||
static const char res200[] =
|
||||
{0x02,0x07,'c','o','m','m','e','n','t'};
|
||||
WS_XML_WRITER_BINARY_ENCODING bin = {{WS_XML_WRITER_ENCODING_TYPE_BINARY}};
|
||||
WS_XML_WRITER_BUFFER_OUTPUT buf = {{WS_XML_WRITER_OUTPUT_TYPE_BUFFER}};
|
||||
static const char prefix[] = "p", prefix2[] = "p2";
|
||||
|
@ -3460,6 +3464,7 @@ static void test_binary_encoding(void)
|
|||
const WS_XML_STRING *prefix_ptr, *localname_ptr, *ns_ptr;
|
||||
WS_XML_STRING str, str2, str3, localname2 = {1, (BYTE *)"t"}, empty = {0, NULL};
|
||||
WS_XML_UTF8_TEXT utf8 = {{WS_XML_TEXT_TYPE_UTF8}};
|
||||
WS_XML_COMMENT_NODE comment = {{WS_XML_NODE_TYPE_COMMENT}};
|
||||
WS_XML_WRITER *writer;
|
||||
HRESULT hr;
|
||||
ULONG i;
|
||||
|
@ -3549,6 +3554,15 @@ static void test_binary_encoding(void)
|
|||
if (hr == S_OK) check_output_bin( writer, attr_tests[i].result, attr_tests[i].len_result, __LINE__ );
|
||||
}
|
||||
|
||||
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
comment.value.bytes = (BYTE *)"comment";
|
||||
comment.value.length = sizeof("comment") - 1;
|
||||
hr = WsWriteNode( writer, &comment.node, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
if (hr == S_OK) check_output_bin( writer, res200, sizeof(res200), __LINE__ );
|
||||
|
||||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
|
|
|
@ -3551,7 +3551,7 @@ static HRESULT write_add_comment_node( struct writer *writer, const WS_XML_STRIN
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT write_comment( struct writer *writer )
|
||||
static HRESULT write_comment_text( struct writer *writer )
|
||||
{
|
||||
const WS_XML_COMMENT_NODE *comment = (const WS_XML_COMMENT_NODE *)writer->current;
|
||||
HRESULT hr;
|
||||
|
@ -3563,6 +3563,28 @@ static HRESULT write_comment( struct writer *writer )
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT write_comment_bin( struct writer *writer )
|
||||
{
|
||||
const WS_XML_COMMENT_NODE *comment = (const WS_XML_COMMENT_NODE *)writer->current;
|
||||
HRESULT hr;
|
||||
|
||||
if ((hr = write_grow_buffer( writer, 1 )) != S_OK) return hr;
|
||||
write_char( writer, RECORD_COMMENT );
|
||||
return write_string( writer, comment->value.bytes, comment->value.length );
|
||||
}
|
||||
|
||||
static HRESULT write_comment( struct writer *writer )
|
||||
{
|
||||
switch (writer->output_enc)
|
||||
{
|
||||
case WS_XML_WRITER_ENCODING_TYPE_TEXT: return write_comment_text( writer );
|
||||
case WS_XML_WRITER_ENCODING_TYPE_BINARY: return write_comment_bin( writer );
|
||||
default:
|
||||
ERR( "unhandled encoding %u\n", writer->output_enc );
|
||||
return WS_E_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT write_comment_node( struct writer *writer, const WS_XML_STRING *value )
|
||||
{
|
||||
HRESULT hr;
|
||||
|
|
Loading…
Reference in New Issue