Hans Leidekker : webservices: Parse attribute names.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 20 10:50:02 CST 2016


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Jan 20 14:53:40 2016 +0100

webservices: Parse attribute names.

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

---

 dlls/webservices/reader.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index 3ea38ac..184335f 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -822,6 +822,32 @@ HRESULT append_attribute( WS_XML_ELEMENT_NODE *elem, WS_XML_ATTRIBUTE *attr )
     return S_OK;
 }
 
+static HRESULT parse_name( const unsigned char *str, unsigned int len,
+                           WS_XML_STRING **prefix, WS_XML_STRING **localname )
+{
+    const unsigned char *name_ptr = str, *prefix_ptr = NULL;
+    unsigned int i, name_len = len, prefix_len = 0;
+
+    for (i = 0; i < len; i++)
+    {
+        if (str[i] == ':')
+        {
+            prefix_ptr = str;
+            prefix_len = i;
+            name_ptr = &str[i + 1];
+            name_len -= i + 1;
+            break;
+        }
+    }
+    if (!(*prefix = alloc_xml_string( prefix_ptr, prefix_len ))) return E_OUTOFMEMORY;
+    if (!(*localname = alloc_xml_string( name_ptr, name_len )))
+    {
+        heap_free( *prefix );
+        return E_OUTOFMEMORY;
+    }
+    return S_OK;
+}
+
 static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
 {
     WS_XML_ATTRIBUTE *attr;
@@ -842,10 +868,9 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
     }
     if (!len) goto error;
 
+    if ((hr = parse_name( start, len, &attr->prefix, &attr->localName )) != S_OK) goto error;
+    if (!attr->prefix->length) attr->prefix->bytes = NULL;
     hr = E_OUTOFMEMORY;
-    if (!(attr->localName = alloc_xml_string( start, len ))) goto error;
-    if (!(attr->prefix = alloc_xml_string( NULL, 0 ))) goto error;
-    attr->prefix->bytes = NULL;
     if (!(attr->ns = alloc_xml_string( NULL, 0 ))) goto error;
     attr->ns->bytes = NULL;
 




More information about the wine-cvs mailing list