From 33cebe51e1a291bbc21378a3f7c9614504b45c5e Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 15 Jun 2016 09:21:23 +0200 Subject: [PATCH] webservices: Implement WsCreateMessage and WsFreeMessage. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/Makefile.in | 1 + dlls/webservices/msg.c | 128 ++++++++++++++++++++++++++++++++++++++ dlls/webservices/webservices.spec | 4 +- 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 dlls/webservices/msg.c diff --git a/dlls/webservices/Makefile.in b/dlls/webservices/Makefile.in index acb7d0ea2e3..12b647aa3ad 100644 --- a/dlls/webservices/Makefile.in +++ b/dlls/webservices/Makefile.in @@ -5,6 +5,7 @@ IMPORTS = user32 C_SRCS = \ channel.c \ main.c \ + msg.c \ proxy.c \ reader.c \ url.c \ diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c new file mode 100644 index 00000000000..85a27f53bb5 --- /dev/null +++ b/dlls/webservices/msg.c @@ -0,0 +1,128 @@ +/* + * Copyright 2016 Hans Leidekker for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "webservices.h" + +#include "wine/debug.h" +#include "wine/list.h" +#include "webservices_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(webservices); + +static const struct prop_desc msg_props[] = +{ + { sizeof(WS_MESSAGE_STATE), TRUE }, /* WS_MESSAGE_PROPERTY_STATE */ + { sizeof(WS_HEAP *), TRUE }, /* WS_MESSAGE_PROPERTY_HEAP */ + { sizeof(WS_ENVELOPE_VERSION), FALSE }, /* WS_MESSAGE_PROPERTY_ENVELOPE_VERSION */ + { sizeof(WS_ADDRESSING_VERSION), FALSE }, /* WS_MESSAGE_PROPERTY_ADDRESSING_VERSION */ + { sizeof(WS_XML_BUFFER *), TRUE }, /* WS_MESSAGE_PROPERTY_HEADER_BUFFER */ + { sizeof(WS_XML_NODE_POSITION *), TRUE }, /* WS_MESSAGE_PROPERTY_HEADER_POSITION */ + { sizeof(WS_XML_READER *), TRUE }, /* WS_MESSAGE_PROPERTY_BODY_READER */ + { sizeof(WS_XML_WRITER *), TRUE }, /* WS_MESSAGE_PROPERTY_BODY_WRITER */ + { sizeof(BOOL), TRUE }, /* WS_MESSAGE_PROPERTY_IS_ADDRESSED */ +}; + +struct msg +{ + WS_MESSAGE_STATE state; + ULONG prop_count; + struct prop prop[sizeof(msg_props)/sizeof(msg_props[0])]; +}; + +static struct msg *alloc_msg(void) +{ + static const ULONG count = sizeof(msg_props)/sizeof(msg_props[0]); + struct msg *ret; + ULONG size = sizeof(*ret) + prop_size( msg_props, count ); + + if (!(ret = heap_alloc_zero( size ))) return NULL; + ret->state = WS_MESSAGE_STATE_EMPTY; + prop_init( msg_props, count, ret->prop, &ret[1] ); + ret->prop_count = count; + return ret; +} + +static void free_msg( struct msg *msg ) +{ + heap_free( msg ); +} + +static HRESULT create_msg( WS_ENVELOPE_VERSION env_version, WS_ADDRESSING_VERSION addr_version, + const WS_MESSAGE_PROPERTY *properties, ULONG count, WS_MESSAGE **handle ) +{ + struct msg *msg; + HRESULT hr; + ULONG i; + + if (!(msg = alloc_msg())) return E_OUTOFMEMORY; + + prop_set( msg->prop, msg->prop_count, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION, &env_version, + sizeof(env_version) ); + prop_set( msg->prop, msg->prop_count, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION, &addr_version, + sizeof(addr_version) ); + + for (i = 0; i < count; i++) + { + if (properties[i].id == WS_MESSAGE_PROPERTY_ENVELOPE_VERSION || + properties[i].id == WS_MESSAGE_PROPERTY_ADDRESSING_VERSION) + { + free_msg( msg ); + return E_INVALIDARG; + } + hr = prop_set( msg->prop, msg->prop_count, properties[i].id, properties[i].value, + properties[i].valueSize ); + if (hr != S_OK) + { + free_msg( msg ); + return hr; + } + } + + *handle = (WS_MESSAGE *)msg; + return S_OK; +} + +/************************************************************************** + * WsCreateMessage [webservices.@] + */ +HRESULT WINAPI WsCreateMessage( WS_ENVELOPE_VERSION env_version, WS_ADDRESSING_VERSION addr_version, + const WS_MESSAGE_PROPERTY *properties, ULONG count, WS_MESSAGE **handle, + WS_ERROR *error ) +{ + TRACE( "%u %u %p %u %p %p\n", env_version, addr_version, properties, count, handle, error ); + if (error) FIXME( "ignoring error parameter\n" ); + + if (!handle || !env_version || !addr_version) return E_INVALIDARG; + return create_msg( env_version, addr_version, properties, count, handle ); +} + +/************************************************************************** + * WsFreeMessage [webservices.@] + */ +void WINAPI WsFreeMessage( WS_MESSAGE *handle ) +{ + struct msg *msg = (struct msg *)handle; + + TRACE( "%p\n", handle ); + free_msg( msg ); +} diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec index 3c6262b790e..c7794a35a0a 100644 --- a/dlls/webservices/webservices.spec +++ b/dlls/webservices/webservices.spec @@ -26,7 +26,7 @@ @ stub WsCreateFaultFromError @ stdcall WsCreateHeap(long long ptr long ptr ptr) @ stub WsCreateListener -@ stub WsCreateMessage +@ stdcall WsCreateMessage(long long ptr long ptr ptr) @ stub WsCreateMessageForChannel @ stub WsCreateMetadata @ stdcall WsCreateReader(ptr long ptr ptr) @@ -52,7 +52,7 @@ @ stdcall WsFreeError(ptr) @ stdcall WsFreeHeap(ptr) @ stub WsFreeListener -@ stub WsFreeMessage +@ stdcall WsFreeMessage(ptr) @ stub WsFreeMetadata @ stdcall WsFreeReader(ptr) @ stub WsFreeSecurityToken -- 2.11.4.GIT