Commit 887af1b3 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement the Message Framing Protocol.

parent bb2344b7
......@@ -400,6 +400,13 @@ static HRESULT write_message( WS_MESSAGE *msg, WS_XML_WRITER *writer, const WS_E
return WsWriteEnvelopeEnd( msg, NULL );
}
static HRESULT set_output( WS_XML_WRITER *writer )
{
WS_XML_WRITER_TEXT_ENCODING text = { {WS_XML_WRITER_ENCODING_TYPE_TEXT}, WS_CHARSET_UTF8 };
WS_XML_WRITER_BUFFER_OUTPUT buf = { {WS_XML_WRITER_OUTPUT_TYPE_BUFFER} };
return WsSetOutput( writer, &text.encoding, &buf.output, NULL, 0, NULL );
}
static HRESULT send_message( WS_CHANNEL *channel, WS_MESSAGE *msg, WS_MESSAGE_DESCRIPTION *desc,
WS_PARAMETER_DESCRIPTION *params, ULONG count, const void **args )
{
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
......@@ -62,21 +63,21 @@ static inline int cmp_string( const unsigned char *str, ULONG len, const unsigne
}
/* return -1 and string id if found, sort index if not found */
static int find_string( const WS_XML_DICTIONARY *dict, const ULONG *sorted, const unsigned char *data,
ULONG len, ULONG *ret_id )
int find_string( const struct dictionary *dict, const unsigned char *data, ULONG len, ULONG *id )
{
int i, c, min = 0, max = dict->stringCount - 1;
int i, c, min = 0, max = dict->dict.stringCount - 1;
const WS_XML_STRING *strings = dict->dict.strings;
while (min <= max)
{
i = (min + max) / 2;
c = cmp_string( data, len, dict->strings[sorted[i]].bytes, dict->strings[sorted[i]].length );
c = cmp_string( data, len, strings[dict->sorted[i]].bytes, strings[dict->sorted[i]].length );
if (c < 0)
max = i - 1;
else if (c > 0)
min = i + 1;
else
{
*ret_id = dict->strings[sorted[i]].id;
if (id) *id = strings[dict->sorted[i]].id;
return -1;
}
}
......@@ -91,6 +92,7 @@ static BOOL grow_dict( struct dictionary *dict, ULONG size )
WS_XML_STRING *tmp;
ULONG new_size, *tmp_sorted;
assert( !dict->dict.isConst );
if (dict->size >= dict->dict.stringCount + size) return TRUE;
if (dict->size + size > MAX_DICTIONARY_SIZE) return FALSE;
......@@ -118,9 +120,23 @@ static BOOL grow_dict( struct dictionary *dict, ULONG size )
return TRUE;
}
static BOOL insert_string( struct dictionary *dict, unsigned char *data, ULONG len, int i, ULONG *ret_id )
void clear_dict( struct dictionary *dict )
{
ULONG i;
assert( !dict->dict.isConst );
for (i = 0; i < dict->dict.stringCount; i++) heap_free( dict->dict.strings[i].bytes );
heap_free( dict->dict.strings );
dict->dict.strings = NULL;
dict->dict.stringCount = 0;
heap_free( dict->sorted );
dict->sorted = NULL;
dict->size = 0;
}
BOOL insert_string( struct dictionary *dict, unsigned char *data, ULONG len, int i, ULONG *ret_id )
{
ULONG id = dict->dict.stringCount;
assert( !dict->dict.isConst );
if (!grow_dict( dict, 1 )) return FALSE;
memmove( &dict->sorted[i] + 1, &dict->sorted[i], (dict->dict.stringCount - i) * sizeof(*dict->sorted) );
dict->sorted[i] = id;
......@@ -130,19 +146,29 @@ static BOOL insert_string( struct dictionary *dict, unsigned char *data, ULONG l
dict->dict.strings[id].dictionary = &dict->dict;
dict->dict.strings[id].id = id;
dict->dict.stringCount++;
*ret_id = id;
if (ret_id) *ret_id = id;
return TRUE;
}
HRESULT CALLBACK insert_string_cb( void *state, const WS_XML_STRING *str, BOOL *found, ULONG *id, WS_ERROR *error )
{
struct dictionary *dict = state;
int index = find_string( dict, str->bytes, str->length, id );
assert( !dict->dict.isConst );
if (index == -1 || insert_string( dict, str->bytes, str->length, index, id )) *found = TRUE;
else *found = FALSE;
return S_OK;
}
HRESULT add_xml_string( WS_XML_STRING *str )
{
int index;
ULONG id;
if (str->dictionary) return S_OK;
EnterCriticalSection( &dict_cs );
if ((index = find_string( &dict_builtin.dict, dict_builtin.sorted, str->bytes, str->length, &id )) == -1)
if ((index = find_string( &dict_builtin, str->bytes, str->length, &id )) == -1)
{
heap_free( str->bytes );
*str = dict_builtin.dict.strings[id];
......@@ -197,9 +223,8 @@ WS_XML_STRING *dup_xml_string( const WS_XML_STRING *src )
*ret = *src;
return ret;
}
EnterCriticalSection( &dict_cs );
if ((index = find_string( &dict_builtin.dict, dict_builtin.sorted, src->bytes, src->length, &id )) == -1)
if ((index = find_string( &dict_builtin, src->bytes, src->length, &id )) == -1)
{
*ret = dict_builtin.dict.strings[id];
LeaveCriticalSection( &dict_cs );
......
......@@ -44,6 +44,11 @@ struct dictionary
struct dictionary dict_builtin DECLSPEC_HIDDEN;
const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
BOOL insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN;
HRESULT CALLBACK insert_string_cb( void *, const WS_XML_STRING *, BOOL *, ULONG *, WS_ERROR * ) DECLSPEC_HIDDEN;
void clear_dict( struct dictionary * ) DECLSPEC_HIDDEN;
const char *debugstr_xmlstr( const WS_XML_STRING * ) DECLSPEC_HIDDEN;
WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
WS_XML_STRING *dup_xml_string( const WS_XML_STRING * ) DECLSPEC_HIDDEN;
......@@ -54,7 +59,6 @@ void free_attribute( WS_XML_ATTRIBUTE * ) DECLSPEC_HIDDEN;
WS_TYPE map_value_type( WS_VALUE_TYPE ) DECLSPEC_HIDDEN;
BOOL set_fpword( unsigned short, unsigned short * ) DECLSPEC_HIDDEN;
void restore_fpword( unsigned short ) DECLSPEC_HIDDEN;
HRESULT set_output( WS_XML_WRITER * ) DECLSPEC_HIDDEN;
ULONG get_type_size( WS_TYPE, const void * ) DECLSPEC_HIDDEN;
HRESULT read_header( WS_XML_READER *, const WS_XML_STRING *, const WS_XML_STRING *, WS_TYPE,
const void *, WS_READ_OPTION, WS_HEAP *, void *, ULONG ) DECLSPEC_HIDDEN;
......
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