Commit 33cebe51 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WsCreateMessage and WsFreeMessage.

parent a684e0bc
......@@ -5,6 +5,7 @@ IMPORTS = user32
C_SRCS = \
channel.c \
main.c \
msg.c \
proxy.c \
reader.c \
url.c \
......
/*
* 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 <stdarg.h>
#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 );
}
......@@ -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
......
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