2 * Copyright 2016 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "webservices.h"
26 #include "wine/debug.h"
27 #include "wine/list.h"
28 #include "webservices_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(webservices
);
32 static const struct prop_desc msg_props
[] =
34 { sizeof(WS_MESSAGE_STATE
), TRUE
}, /* WS_MESSAGE_PROPERTY_STATE */
35 { sizeof(WS_HEAP
*), TRUE
}, /* WS_MESSAGE_PROPERTY_HEAP */
36 { sizeof(WS_ENVELOPE_VERSION
), FALSE
}, /* WS_MESSAGE_PROPERTY_ENVELOPE_VERSION */
37 { sizeof(WS_ADDRESSING_VERSION
), FALSE
}, /* WS_MESSAGE_PROPERTY_ADDRESSING_VERSION */
38 { sizeof(WS_XML_BUFFER
*), TRUE
}, /* WS_MESSAGE_PROPERTY_HEADER_BUFFER */
39 { sizeof(WS_XML_NODE_POSITION
*), TRUE
}, /* WS_MESSAGE_PROPERTY_HEADER_POSITION */
40 { sizeof(WS_XML_READER
*), TRUE
}, /* WS_MESSAGE_PROPERTY_BODY_READER */
41 { sizeof(WS_XML_WRITER
*), TRUE
}, /* WS_MESSAGE_PROPERTY_BODY_WRITER */
42 { sizeof(BOOL
), TRUE
}, /* WS_MESSAGE_PROPERTY_IS_ADDRESSED */
47 WS_MESSAGE_STATE state
;
49 struct prop prop
[sizeof(msg_props
)/sizeof(msg_props
[0])];
52 static struct msg
*alloc_msg(void)
54 static const ULONG count
= sizeof(msg_props
)/sizeof(msg_props
[0]);
56 ULONG size
= sizeof(*ret
) + prop_size( msg_props
, count
);
58 if (!(ret
= heap_alloc_zero( size
))) return NULL
;
59 ret
->state
= WS_MESSAGE_STATE_EMPTY
;
60 prop_init( msg_props
, count
, ret
->prop
, &ret
[1] );
61 ret
->prop_count
= count
;
65 static void free_msg( struct msg
*msg
)
70 static HRESULT
create_msg( WS_ENVELOPE_VERSION env_version
, WS_ADDRESSING_VERSION addr_version
,
71 const WS_MESSAGE_PROPERTY
*properties
, ULONG count
, WS_MESSAGE
**handle
)
77 if (!(msg
= alloc_msg())) return E_OUTOFMEMORY
;
79 prop_set( msg
->prop
, msg
->prop_count
, WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
, &env_version
,
80 sizeof(env_version
) );
81 prop_set( msg
->prop
, msg
->prop_count
, WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
, &addr_version
,
82 sizeof(addr_version
) );
84 for (i
= 0; i
< count
; i
++)
86 if (properties
[i
].id
== WS_MESSAGE_PROPERTY_ENVELOPE_VERSION
||
87 properties
[i
].id
== WS_MESSAGE_PROPERTY_ADDRESSING_VERSION
)
92 hr
= prop_set( msg
->prop
, msg
->prop_count
, properties
[i
].id
, properties
[i
].value
,
93 properties
[i
].valueSize
);
101 *handle
= (WS_MESSAGE
*)msg
;
105 /**************************************************************************
106 * WsCreateMessage [webservices.@]
108 HRESULT WINAPI
WsCreateMessage( WS_ENVELOPE_VERSION env_version
, WS_ADDRESSING_VERSION addr_version
,
109 const WS_MESSAGE_PROPERTY
*properties
, ULONG count
, WS_MESSAGE
**handle
,
112 TRACE( "%u %u %p %u %p %p\n", env_version
, addr_version
, properties
, count
, handle
, error
);
113 if (error
) FIXME( "ignoring error parameter\n" );
115 if (!handle
|| !env_version
|| !addr_version
) return E_INVALIDARG
;
116 return create_msg( env_version
, addr_version
, properties
, count
, handle
);
119 /**************************************************************************
120 * WsFreeMessage [webservices.@]
122 void WINAPI
WsFreeMessage( WS_MESSAGE
*handle
)
124 struct msg
*msg
= (struct msg
*)handle
;
126 TRACE( "%p\n", handle
);
130 /**************************************************************************
131 * WsGetMessageProperty [webservices.@]
133 HRESULT WINAPI
WsGetMessageProperty( WS_MESSAGE
*handle
, WS_MESSAGE_PROPERTY_ID id
, void *buf
,
134 ULONG size
, WS_ERROR
*error
)
136 struct msg
*msg
= (struct msg
*)handle
;
138 TRACE( "%p %u %p %u %p\n", handle
, id
, buf
, size
, error
);
139 if (error
) FIXME( "ignoring error parameter\n" );
141 return prop_get( msg
->prop
, msg
->prop_count
, id
, buf
, size
);
144 /**************************************************************************
145 * WsSetMessageProperty [webservices.@]
147 HRESULT WINAPI
WsSetMessageProperty( WS_MESSAGE
*handle
, WS_MESSAGE_PROPERTY_ID id
, const void *value
,
148 ULONG size
, WS_ERROR
*error
)
150 struct msg
*msg
= (struct msg
*)handle
;
152 TRACE( "%p %u %p %u\n", handle
, id
, value
, size
);
153 if (error
) FIXME( "ignoring error parameter\n" );
155 return prop_set( msg
->prop
, msg
->prop_count
, id
, value
, size
);