webservices: Implement WsReadAttribute.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-05-10 14:26:17 +02:00 committed by Alexandre Julliard
parent f541c82612
commit 9f52fec0d8
3 changed files with 90 additions and 1 deletions

View file

@ -4423,6 +4423,42 @@ HRESULT WINAPI WsReadValue( WS_XML_READER *handle, WS_VALUE_TYPE value_type, voi
return hr;
}
/**************************************************************************
* WsReadAttribute [webservices.@]
*/
HRESULT WINAPI WsReadAttribute( WS_XML_READER *handle, const WS_ATTRIBUTE_DESCRIPTION *desc,
WS_READ_OPTION option, WS_HEAP *heap, void *value, ULONG size,
WS_ERROR *error )
{
struct reader *reader = (struct reader *)handle;
HRESULT hr;
TRACE( "%p %p %u %p %p %u %p\n", handle, desc, option, heap, value, size, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!reader || !desc || !value) return E_INVALIDARG;
EnterCriticalSection( &reader->cs );
if (reader->magic != READER_MAGIC)
{
LeaveCriticalSection( &reader->cs );
return E_INVALIDARG;
}
if (!reader->input_type)
{
LeaveCriticalSection( &reader->cs );
return WS_E_INVALID_OPERATION;
}
hr = read_type( reader, WS_ATTRIBUTE_TYPE_MAPPING, desc->type, desc->attributeLocalName,
desc->attributeNs, desc->typeDescription, option, heap, value, size );
LeaveCriticalSection( &reader->cs );
return hr;
}
static inline BOOL is_utf8( const unsigned char *data, ULONG size, ULONG *offset )
{
static const char bom[] = {0xef,0xbb,0xbf};

View file

@ -4351,6 +4351,58 @@ static void test_WsReadQualifiedName(void)
WsFreeReader( reader );
}
static void test_WsReadAttribute(void)
{
WS_XML_STRING localname = {1, (BYTE *)"a"}, ns = {0, NULL};
WS_XML_READER *reader;
WS_ATTRIBUTE_DESCRIPTION desc;
WS_HEAP *heap;
UINT32 *val;
BOOL found;
HRESULT hr;
hr = WsReadAttribute( NULL, NULL, 0, NULL, NULL, 0, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsReadAttribute( reader, NULL, 0, NULL, NULL, 0, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
desc.attributeLocalName = &localname;
desc.attributeNs = &ns;
desc.type = WS_UINT32_TYPE;
desc.typeDescription = NULL;
hr = WsReadAttribute( reader, &desc, 0, NULL, NULL, 0, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsReadAttribute( reader, &desc, WS_READ_REQUIRED_POINTER, NULL, NULL, 0, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateHeap( 1 << 8, 0, NULL, 0, &heap, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsReadAttribute( reader, &desc, WS_READ_REQUIRED_POINTER, heap, NULL, 0, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsReadAttribute( reader, &desc, WS_READ_REQUIRED_POINTER, heap, &val, sizeof(val), NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
prepare_struct_type_test( reader, "<t a='1'>" );
hr = WsReadToStartElement( reader, NULL, NULL, &found, NULL );
ok( hr == S_OK, "got %08x\n", hr );
val = NULL;
hr = WsReadAttribute( reader, &desc, WS_READ_REQUIRED_POINTER, heap, &val, sizeof(val), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( val != NULL, "val not set\n" );
ok( *val == 1, "got %u\n", *val );
WsFreeHeap( heap );
WsFreeReader( reader );
}
START_TEST(reader)
{
test_WsCreateError();
@ -4391,4 +4443,5 @@ START_TEST(reader)
test_WsReadChars();
test_WsReadCharsUtf8();
test_WsReadQualifiedName();
test_WsReadAttribute();
}

View file

@ -102,7 +102,7 @@
@ stub WsPullBytes
@ stub WsPushBytes
@ stub WsReadArray
@ stub WsReadAttribute
@ stdcall WsReadAttribute(ptr ptr long ptr ptr long ptr)
@ stdcall WsReadBody(ptr ptr long ptr ptr long ptr)
@ stdcall WsReadBytes(ptr ptr long ptr ptr)
@ stdcall WsReadChars(ptr ptr long ptr ptr)