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
);
39 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE */
40 { sizeof(UINT64
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_STREAMED_MESSAGE_SIZE */
41 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_STREAMED_START_SIZE */
42 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_STREAMED_FLUSH_SIZE */
43 { sizeof(WS_ENCODING
), FALSE
}, /* WS_CHANNEL_PROPERTY_ENCODING */
44 { sizeof(WS_ENVELOPE_VERSION
), FALSE
}, /* WS_CHANNEL_PROPERTY_ENVELOPE_VERSION */
45 { sizeof(WS_ADDRESSING_VERSION
), FALSE
}, /* WS_CHANNEL_PROPERTY_ADDRESSING_VERSION */
46 { sizeof(ULONG
), FALSE
}, /* WS_CHANNEL_PROPERTY_MAX_SESSION_DICTIONARY_SIZE */
47 { sizeof(WS_CHANNEL_STATE
), TRUE
}, /* WS_CHANNEL_PROPERTY_STATE */
50 static struct channel
*alloc_channel(void)
52 static const ULONG count
= sizeof(channel_props
)/sizeof(channel_props
[0]);
54 ULONG i
, size
= sizeof(*ret
) + count
* sizeof(WS_CHANNEL_PROPERTY
);
57 for (i
= 0; i
< count
; i
++) size
+= channel_props
[i
].size
;
58 if (!(ret
= heap_alloc_zero( size
))) return NULL
;
60 ptr
= (char *)&ret
->prop
[count
];
61 for (i
= 0; i
< count
; i
++)
63 ret
->prop
[i
].value
= ptr
;
64 ret
->prop
[i
].valueSize
= channel_props
[i
].size
;
65 ptr
+= ret
->prop
[i
].valueSize
;
67 ret
->prop_count
= count
;
71 static HRESULT
set_channel_prop( struct channel
*channel
, WS_CHANNEL_PROPERTY_ID id
, const void *value
,
74 if (id
>= channel
->prop_count
|| size
!= channel_props
[id
].size
|| channel_props
[id
].readonly
)
77 memcpy( channel
->prop
[id
].value
, value
, size
);
81 void free_channel( struct channel
*channel
)
86 HRESULT
create_channel( WS_CHANNEL_TYPE type
, WS_CHANNEL_BINDING binding
,
87 const WS_CHANNEL_PROPERTY
*properties
, ULONG count
, struct channel
**ret
)
89 struct channel
*channel
;
90 ULONG i
, msg_size
= 65536;
93 if (!(channel
= alloc_channel())) return E_OUTOFMEMORY
;
95 set_channel_prop( channel
, WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE
, &msg_size
, sizeof(msg_size
) );
97 for (i
= 0; i
< count
; i
++)
99 hr
= set_channel_prop( channel
, properties
[i
].id
, properties
[i
].value
, properties
[i
].valueSize
);
102 free_channel( channel
);
107 channel
->type
= type
;
108 channel
->binding
= binding
;
114 /**************************************************************************
115 * WsCreateChannel [webservices.@]
117 HRESULT WINAPI
WsCreateChannel( WS_CHANNEL_TYPE type
, WS_CHANNEL_BINDING binding
,
118 const WS_CHANNEL_PROPERTY
*properties
, ULONG count
,
119 const WS_SECURITY_DESCRIPTION
*desc
, WS_CHANNEL
**handle
,
122 struct channel
*channel
;
125 TRACE( "%u %u %p %u %p %p %p\n", type
, binding
, properties
, count
, desc
, handle
, error
);
126 if (error
) FIXME( "ignoring error parameter\n" );
127 if (desc
) FIXME( "ignoring security description\n" );
129 if (!handle
) return E_INVALIDARG
;
131 if (type
!= WS_CHANNEL_TYPE_REQUEST
)
133 FIXME( "channel type %u not implemented\n", type
);
136 if (binding
!= WS_HTTP_CHANNEL_BINDING
)
138 FIXME( "channel binding %u not implemented\n", binding
);
142 if ((hr
= create_channel( type
, binding
, properties
, count
, &channel
)) != S_OK
)
145 *handle
= (WS_CHANNEL
*)channel
;
149 /**************************************************************************
150 * WsFreeChannel [webservices.@]
152 void WINAPI
WsFreeChannel( WS_CHANNEL
*handle
)
154 struct channel
*channel
= (struct channel
*)handle
;
156 TRACE( "%p\n", handle
);
157 free_channel( channel
);