Hans Leidekker : webservices: Implement WsReadAttribute.

Alexandre Julliard julliard at winehq.org
Wed May 10 17:23:15 CDT 2017


Module: wine
Branch: master
Commit: 9f52fec0d81bfc36d2ad5f04f4267be44bb1304c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9f52fec0d81bfc36d2ad5f04f4267be44bb1304c

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed May 10 14:26:17 2017 +0200

webservices: Implement WsReadAttribute.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/webservices/reader.c         | 36 ++++++++++++++++++++++++++
 dlls/webservices/tests/reader.c   | 53 +++++++++++++++++++++++++++++++++++++++
 dlls/webservices/webservices.spec |  2 +-
 3 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index d53b330..0cfc844 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -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};
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index 1fe37c5..1598cb2 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -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();
 }
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 728457c..a6b8452 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -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)




More information about the wine-cvs mailing list