From 760190b524ab5c0e6f6804ed195ff8e626d6aa53 Mon Sep 17 00:00:00 2001 From: Owen Rudge Date: Wed, 28 Jun 2017 22:13:26 +0100 Subject: [PATCH] wsdapi: Implement WSDXMLGetValueFromAny. Signed-off-by: Owen Rudge Signed-off-by: Alexandre Julliard --- dlls/wsdapi/wsdapi.spec | 2 +- dlls/wsdapi/xml.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/wsdutil.h | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/dlls/wsdapi/wsdapi.spec b/dlls/wsdapi/wsdapi.spec index 41d62bbfd76..22457c9b2ea 100644 --- a/dlls/wsdapi/wsdapi.spec +++ b/dlls/wsdapi/wsdapi.spec @@ -42,4 +42,4 @@ @ stdcall WSDXMLCleanupElement(ptr) @ stdcall WSDXMLCreateContext(ptr) @ stub WSDXMLGetNameFromBuiltinNamespace -@ stub WSDXMLGetValueFromAny +@ stdcall WSDXMLGetValueFromAny(wstr wstr ptr wstr) diff --git a/dlls/wsdapi/xml.c b/dlls/wsdapi/xml.c index 71e9661f20d..145c394f852 100644 --- a/dlls/wsdapi/xml.c +++ b/dlls/wsdapi/xml.c @@ -238,6 +238,46 @@ HRESULT WINAPI WSDXMLCleanupElement(WSDXML_ELEMENT *pAny) return S_OK; } +HRESULT WINAPI WSDXMLGetValueFromAny(const WCHAR *pszNamespace, const WCHAR *pszName, WSDXML_ELEMENT *pAny, LPCWSTR *ppszValue) +{ + WSDXML_ELEMENT *element; + WSDXML_TEXT *text; + + if (pAny == NULL) + return E_INVALIDARG; + + if (ppszValue == NULL) + return E_POINTER; + + if ((pszNamespace == NULL) || (pszName == NULL) || (lstrlenW(pszNamespace) > WSD_MAX_TEXT_LENGTH) || (lstrlenW(pszName) > WSD_MAX_TEXT_LENGTH)) + return E_INVALIDARG; + + element = pAny; + + while (element != NULL) + { + if (element->Node.Type == ElementType) + { + if ((lstrcmpW(element->Name->LocalName, pszName) == 0) && (lstrcmpW(element->Name->Space->Uri, pszNamespace) == 0)) + { + if ((element->FirstChild == NULL) || (element->FirstChild->Type != TextType)) + { + return E_FAIL; + } + + text = (WSDXML_TEXT *) element->FirstChild; + *ppszValue = (LPCWSTR) text->Text; + + return S_OK; + } + } + + element = (WSDXML_ELEMENT *) element->Node.Next; + } + + return E_FAIL; +} + /* IWSDXMLContext implementation */ struct xmlNamespace diff --git a/include/wsdutil.h b/include/wsdutil.h index 2980d4034ac..402a4130bbc 100644 --- a/include/wsdutil.h +++ b/include/wsdutil.h @@ -28,5 +28,6 @@ HRESULT WINAPI WSDXMLAddChild(WSDXML_ELEMENT *pParent, WSDXML_ELEMENT *pChild); HRESULT WINAPI WSDXMLAddSibling(WSDXML_ELEMENT *pFirst, WSDXML_ELEMENT *pSecond); HRESULT WINAPI WSDXMLBuildAnyForSingleElement(WSDXML_NAME *pElementName, LPCWSTR pszText, WSDXML_ELEMENT **ppAny); HRESULT WINAPI WSDXMLCleanupElement(WSDXML_ELEMENT *pAny); +HRESULT WINAPI WSDXMLGetValueFromAny(const WCHAR *pszNamespace, const WCHAR *pszName, WSDXML_ELEMENT *pAny, LPCWSTR *ppszValue); #endif