Commit 9f52fec0 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WsReadAttribute.

parent f541c826
...@@ -4423,6 +4423,42 @@ HRESULT WINAPI WsReadValue( WS_XML_READER *handle, WS_VALUE_TYPE value_type, voi ...@@ -4423,6 +4423,42 @@ HRESULT WINAPI WsReadValue( WS_XML_READER *handle, WS_VALUE_TYPE value_type, voi
return hr; 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 inline BOOL is_utf8( const unsigned char *data, ULONG size, ULONG *offset )
{ {
static const char bom[] = {0xef,0xbb,0xbf}; static const char bom[] = {0xef,0xbb,0xbf};
......
...@@ -4351,6 +4351,58 @@ static void test_WsReadQualifiedName(void) ...@@ -4351,6 +4351,58 @@ static void test_WsReadQualifiedName(void)
WsFreeReader( reader ); 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) START_TEST(reader)
{ {
test_WsCreateError(); test_WsCreateError();
...@@ -4391,4 +4443,5 @@ START_TEST(reader) ...@@ -4391,4 +4443,5 @@ START_TEST(reader)
test_WsReadChars(); test_WsReadChars();
test_WsReadCharsUtf8(); test_WsReadCharsUtf8();
test_WsReadQualifiedName(); test_WsReadQualifiedName();
test_WsReadAttribute();
} }
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
@ stub WsPullBytes @ stub WsPullBytes
@ stub WsPushBytes @ stub WsPushBytes
@ stub WsReadArray @ stub WsReadArray
@ stub WsReadAttribute @ stdcall WsReadAttribute(ptr ptr long ptr ptr long ptr)
@ stdcall WsReadBody(ptr ptr long ptr ptr long ptr) @ stdcall WsReadBody(ptr ptr long ptr ptr long ptr)
@ stdcall WsReadBytes(ptr ptr long ptr ptr) @ stdcall WsReadBytes(ptr ptr long ptr ptr)
@ stdcall WsReadChars(ptr ptr long ptr ptr) @ stdcall WsReadChars(ptr ptr long ptr ptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment