webservices: Implement WsGetReaderPosition.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-07-04 11:35:38 +02:00 committed by Alexandre Julliard
parent 13faf34b07
commit 5ad0066068
3 changed files with 73 additions and 4 deletions

View File

@ -432,6 +432,7 @@ struct reader
ULONG nb_prefixes; ULONG nb_prefixes;
ULONG nb_prefixes_allocated; ULONG nb_prefixes_allocated;
WS_XML_READER_INPUT_TYPE input_type; WS_XML_READER_INPUT_TYPE input_type;
struct xmlbuf *input_buf;
const unsigned char *input_data; const unsigned char *input_data;
ULONG input_size; ULONG input_size;
ULONG prop_count; ULONG prop_count;
@ -570,6 +571,7 @@ static HRESULT read_init_state( struct reader *reader )
destroy_nodes( reader->root ); destroy_nodes( reader->root );
reader->root = NULL; reader->root = NULL;
reader->input_buf = NULL;
clear_prefixes( reader->prefixes, reader->nb_prefixes ); clear_prefixes( reader->prefixes, reader->nb_prefixes );
reader->nb_prefixes = 1; reader->nb_prefixes = 1;
if (!(node = alloc_node( WS_XML_NODE_TYPE_EOF ))) return E_OUTOFMEMORY; if (!(node = alloc_node( WS_XML_NODE_TYPE_EOF ))) return E_OUTOFMEMORY;
@ -3823,9 +3825,10 @@ static WS_CHARSET detect_charset( const unsigned char *data, ULONG size, ULONG *
return ret; return ret;
} }
static void set_input_buffer( struct reader *reader, const unsigned char *data, ULONG size ) static void set_input_buffer( struct reader *reader, struct xmlbuf *buf, const unsigned char *data, ULONG size )
{ {
reader->input_type = WS_XML_READER_INPUT_TYPE_BUFFER; reader->input_type = WS_XML_READER_INPUT_TYPE_BUFFER;
reader->input_buf = buf;
reader->input_data = data; reader->input_data = data;
reader->input_size = size; reader->input_size = size;
@ -3891,7 +3894,8 @@ HRESULT WINAPI WsSetInput( WS_XML_READER *handle, const WS_XML_READER_ENCODING *
case WS_XML_READER_INPUT_TYPE_BUFFER: case WS_XML_READER_INPUT_TYPE_BUFFER:
{ {
WS_XML_READER_BUFFER_INPUT *buf = (WS_XML_READER_BUFFER_INPUT *)input; WS_XML_READER_BUFFER_INPUT *buf = (WS_XML_READER_BUFFER_INPUT *)input;
set_input_buffer( reader, (const unsigned char *)buf->encodedData + offset, buf->encodedDataSize - offset ); set_input_buffer( reader, NULL, (const unsigned char *)buf->encodedData + offset,
buf->encodedDataSize - offset );
break; break;
} }
default: default:
@ -3937,7 +3941,7 @@ HRESULT WINAPI WsSetInputToBuffer( WS_XML_READER *handle, WS_XML_BUFFER *buffer,
&charset, sizeof(charset) ); &charset, sizeof(charset) );
if (hr != S_OK) return hr; if (hr != S_OK) return hr;
set_input_buffer( reader, (const unsigned char *)xmlbuf->ptr + offset, xmlbuf->size - offset ); set_input_buffer( reader, xmlbuf, (const unsigned char *)xmlbuf->ptr + offset, xmlbuf->size - offset );
if (!(node = alloc_node( WS_XML_NODE_TYPE_BOF ))) return E_OUTOFMEMORY; if (!(node = alloc_node( WS_XML_NODE_TYPE_BOF ))) return E_OUTOFMEMORY;
read_insert_bof( reader, node ); read_insert_bof( reader, node );
return S_OK; return S_OK;
@ -3957,3 +3961,21 @@ HRESULT WINAPI WsXmlStringEquals( const WS_XML_STRING *str1, const WS_XML_STRING
if (!memcmp( str1->bytes, str2->bytes, str1->length )) return S_OK; if (!memcmp( str1->bytes, str2->bytes, str1->length )) return S_OK;
return S_FALSE; return S_FALSE;
} }
/**************************************************************************
* WsGetReaderPosition [webservices.@]
*/
HRESULT WINAPI WsGetReaderPosition( WS_XML_READER *handle, WS_XML_NODE_POSITION *pos, WS_ERROR *error )
{
struct reader *reader = (struct reader *)handle;
TRACE( "%p %p %p\n", handle, pos, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!reader || !pos) return E_INVALIDARG;
if (!reader->input_buf) return WS_E_INVALID_OPERATION;
pos->buffer = (WS_XML_BUFFER *)reader->input_buf;
pos->node = reader->current;
return S_OK;
}

View File

@ -3449,6 +3449,52 @@ static void test_WsResetError(void)
WsFreeError( error ); WsFreeError( error );
} }
static void test_WsGetReaderPosition(void)
{
WS_HEAP *heap;
WS_XML_READER *reader;
WS_XML_BUFFER *buffer;
WS_XML_NODE_POSITION pos;
HRESULT hr;
hr = WsGetReaderPosition( NULL, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsCreateReader( NULL, 0, &reader, NULL ) ;
ok( hr == S_OK, "got %08x\n", hr );
/* reader must be set to an XML buffer */
hr = WsGetReaderPosition( reader, &pos, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = set_input( reader, "<t/>", sizeof("<t/>") - 1 );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderPosition( reader, &pos, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = WsCreateXmlBuffer( heap, NULL, 0, &buffer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsSetInputToBuffer( reader, buffer, NULL, 0, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderPosition( reader, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
pos.buffer = pos.node = NULL;
hr = WsGetReaderPosition( reader, &pos, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( pos.buffer != NULL, "buffer not set\n" );
ok( pos.node != NULL, "node not set\n" );
WsFreeReader( reader );
WsFreeHeap( heap );
}
START_TEST(reader) START_TEST(reader)
{ {
test_WsCreateError(); test_WsCreateError();
@ -3481,4 +3527,5 @@ START_TEST(reader)
test_WsReadElement(); test_WsReadElement();
test_WsReadValue(); test_WsReadValue();
test_WsResetError(); test_WsResetError();
test_WsGetReaderPosition();
} }

View File

@ -81,7 +81,7 @@
@ stub WsGetPolicyProperty @ stub WsGetPolicyProperty
@ stdcall WsGetPrefixFromNamespace(ptr ptr long ptr ptr) @ stdcall WsGetPrefixFromNamespace(ptr ptr long ptr ptr)
@ stdcall WsGetReaderNode(ptr ptr ptr) @ stdcall WsGetReaderNode(ptr ptr ptr)
@ stub WsGetReaderPosition @ stdcall WsGetReaderPosition(ptr ptr ptr)
@ stdcall WsGetReaderProperty(ptr long ptr long ptr) @ stdcall WsGetReaderProperty(ptr long ptr long ptr)
@ stub WsGetSecurityContextProperty @ stub WsGetSecurityContextProperty
@ stub WsGetSecurityTokenProperty @ stub WsGetSecurityTokenProperty