Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
83bdbc1e
Commit
83bdbc1e
authored
Jun 14, 2017
by
Hans Leidekker
Committed by
Alexandre Julliard
Jun 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Implement WsReadXmlBuffer.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
087631bb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
269 additions
and
1 deletion
+269
-1
reader.c
dlls/webservices/reader.c
+69
-0
reader.c
dlls/webservices/tests/reader.c
+198
-0
webservices.spec
dlls/webservices/webservices.spec
+1
-1
webservices.h
include/webservices.h
+1
-0
No files found.
dlls/webservices/reader.c
View file @
83bdbc1e
...
...
@@ -5968,6 +5968,75 @@ HRESULT WINAPI WsReadCharsUtf8( WS_XML_READER *handle, BYTE *bytes, ULONG max_co
return
S_OK
;
}
static
HRESULT
move_to_element
(
struct
reader
*
reader
)
{
HRESULT
hr
;
if
(
node_type
(
reader
->
current
)
==
WS_XML_NODE_TYPE_BOF
&&
(
hr
=
read_move_to
(
reader
,
WS_MOVE_TO_CHILD_NODE
,
NULL
))
!=
S_OK
)
return
hr
;
if
(
node_type
(
reader
->
current
)
!=
WS_XML_NODE_TYPE_ELEMENT
)
return
E_FAIL
;
return
S_OK
;
}
static
HRESULT
copy_tree
(
struct
reader
*
reader
,
WS_XML_WRITER
*
writer
)
{
const
struct
node
*
node
,
*
parent
;
BOOL
done
=
FALSE
;
HRESULT
hr
;
if
((
hr
=
move_to_element
(
reader
))
!=
S_OK
)
return
hr
;
parent
=
reader
->
current
;
for
(;;)
{
node
=
reader
->
current
;
if
((
hr
=
WsWriteNode
(
writer
,
(
const
WS_XML_NODE
*
)
node
,
NULL
))
!=
S_OK
)
break
;
if
(
node_type
(
node
)
==
WS_XML_NODE_TYPE_END_ELEMENT
&&
node
->
parent
==
parent
)
done
=
TRUE
;
if
((
hr
=
read_next_node
(
reader
))
!=
S_OK
||
done
)
break
;
}
return
hr
;
}
/**************************************************************************
* WsReadXmlBuffer [webservices.@]
*/
HRESULT
WINAPI
WsReadXmlBuffer
(
WS_XML_READER
*
handle
,
WS_HEAP
*
heap
,
WS_XML_BUFFER
**
ret
,
WS_ERROR
*
error
)
{
struct
reader
*
reader
=
(
struct
reader
*
)
handle
;
WS_XML_WRITER
*
writer
=
NULL
;
WS_XML_BUFFER
*
buffer
;
HRESULT
hr
;
TRACE
(
"%p %p %p %p
\n
"
,
handle
,
heap
,
ret
,
error
);
if
(
error
)
FIXME
(
"ignoring error parameter
\n
"
);
if
(
!
reader
||
!
heap
)
return
E_INVALIDARG
;
if
(
!
ret
)
return
E_FAIL
;
EnterCriticalSection
(
&
reader
->
cs
);
if
(
reader
->
magic
!=
READER_MAGIC
)
{
LeaveCriticalSection
(
&
reader
->
cs
);
return
E_INVALIDARG
;
}
if
(
!
reader
->
input_type
)
{
LeaveCriticalSection
(
&
reader
->
cs
);
return
WS_E_INVALID_OPERATION
;
}
if
((
hr
=
WsCreateWriter
(
NULL
,
0
,
&
writer
,
NULL
))
!=
S_OK
)
goto
done
;
if
((
hr
=
WsCreateXmlBuffer
(
heap
,
NULL
,
0
,
&
buffer
,
NULL
))
!=
S_OK
)
goto
done
;
if
((
hr
=
WsSetOutputToBuffer
(
writer
,
buffer
,
NULL
,
0
,
NULL
))
!=
S_OK
)
goto
done
;
if
((
hr
=
copy_tree
(
reader
,
writer
))
==
S_OK
)
*
ret
=
buffer
;
done:
if
(
hr
!=
S_OK
)
free_xmlbuf
(
(
struct
xmlbuf
*
)
buffer
);
WsFreeWriter
(
writer
);
LeaveCriticalSection
(
&
reader
->
cs
);
return
hr
;
}
HRESULT
get_param_desc
(
const
WS_STRUCT_DESCRIPTION
*
desc
,
USHORT
index
,
const
WS_FIELD_DESCRIPTION
**
ret
)
{
if
(
index
>=
desc
->
fieldCount
)
return
E_INVALIDARG
;
...
...
dlls/webservices/tests/reader.c
View file @
83bdbc1e
...
...
@@ -5212,6 +5212,203 @@ static void test_dictionary(void)
WsFreeReader
(
reader
);
}
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
void
check_output_buffer
(
WS_XML_BUFFER
*
buffer
,
const
char
*
expected
,
unsigned
int
line
)
{
WS_XML_WRITER
*
writer
;
WS_BYTES
bytes
;
ULONG
size
=
sizeof
(
bytes
);
int
len
=
strlen
(
expected
);
HRESULT
hr
;
hr
=
WsCreateWriter
(
NULL
,
0
,
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
set_output
(
writer
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteXmlBuffer
(
writer
,
buffer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
memset
(
&
bytes
,
0
,
sizeof
(
bytes
)
);
hr
=
WsGetWriterProperty
(
writer
,
WS_XML_WRITER_PROPERTY_BYTES
,
&
bytes
,
size
,
NULL
);
ok
(
hr
==
S_OK
,
"%u: got %08x
\n
"
,
line
,
hr
);
ok
(
bytes
.
length
==
len
,
"%u: got %u expected %u
\n
"
,
line
,
bytes
.
length
,
len
);
if
(
bytes
.
length
!=
len
)
return
;
ok
(
!
memcmp
(
bytes
.
bytes
,
expected
,
len
),
"%u: got %s expected %s
\n
"
,
line
,
bytes
.
bytes
,
expected
);
WsFreeWriter
(
writer
);
}
static
HRESULT
prepare_xml_buffer_test
(
WS_XML_READER
*
reader
,
WS_HEAP
*
heap
)
{
WS_XML_STRING
localname
=
{
1
,
(
BYTE
*
)
"t"
},
localname2
=
{
1
,
(
BYTE
*
)
"u"
},
ns
=
{
0
,
NULL
};
WS_XML_WRITER
*
writer
;
WS_XML_BUFFER
*
buffer
;
HRESULT
hr
;
hr
=
WsCreateWriter
(
NULL
,
0
,
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsCreateXmlBuffer
(
heap
,
NULL
,
0
,
&
buffer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsSetOutputToBuffer
(
writer
,
buffer
,
NULL
,
0
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
localname
,
&
ns
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
localname2
,
&
ns
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteEndElement
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteEndElement
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsSetInputToBuffer
(
reader
,
buffer
,
NULL
,
0
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
WsFreeWriter
(
writer
);
return
S_OK
;
}
static
void
test_WsReadXmlBuffer
(
void
)
{
const
WS_XML_NODE
*
node
;
WS_XML_READER
*
reader
;
WS_XML_BUFFER
*
buffer
;
WS_HEAP
*
heap
;
HRESULT
hr
;
hr
=
WsReadXmlBuffer
(
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
hr
=
WsCreateReader
(
NULL
,
0
,
&
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadXmlBuffer
(
reader
,
NULL
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
hr
=
WsCreateHeap
(
1
<<
16
,
0
,
NULL
,
0
,
&
heap
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
NULL
,
NULL
);
ok
(
hr
==
E_FAIL
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
todo_wine
ok
(
hr
==
E_FAIL
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
"<t><u><v/></u></t></w>"
,
sizeof
(
"<t><u><v/></u></t></w>"
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadToStartElement
(
reader
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadStartElement
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at element */
buffer
=
NULL
;
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
buffer
!=
NULL
,
"buffer not set
\n
"
);
check_output_buffer
(
buffer
,
"<u><v/></u>"
,
__LINE__
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_END_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at end element */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
E_FAIL
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
"<t><u/></t><v/>"
,
sizeof
(
"<t><u/></t><v/>"
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_BOF
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at BOF */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
todo_wine
ok
(
hr
==
WS_E_INVALID_FORMAT
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
todo_wine
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_END_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
hr
=
set_input
(
reader
,
"<!--comment--><t></t>"
,
sizeof
(
"<!--comment--><t></t>"
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_COMMENT
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at non-element */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
E_FAIL
,
"got %08x
\n
"
,
hr
);
hr
=
prepare_xml_buffer_test
(
reader
,
heap
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_BOF
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at BOF, input buffer */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
check_output_buffer
(
buffer
,
"<t><u/></t>"
,
__LINE__
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_EOF
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at EOF, input buffer */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
E_FAIL
,
"got %08x
\n
"
,
hr
);
hr
=
prepare_xml_buffer_test
(
reader
,
heap
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at element, input buffer */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
check_output_buffer
(
buffer
,
"<u/>"
,
__LINE__
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_END_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
/* reader positioned at end element, input buffer */
hr
=
WsReadXmlBuffer
(
reader
,
heap
,
&
buffer
,
NULL
);
ok
(
hr
==
E_FAIL
,
"got %08x
\n
"
,
hr
);
WsFreeReader
(
reader
);
WsFreeHeap
(
heap
);
}
START_TEST
(
reader
)
{
test_WsCreateError
();
...
...
@@ -5256,4 +5453,5 @@ START_TEST(reader)
test_WsSkipNode
();
test_binary_encoding
();
test_dictionary
();
test_WsReadXmlBuffer
();
}
dlls/webservices/webservices.spec
View file @
83bdbc1e
...
...
@@ -123,7 +123,7 @@
@ stdcall WsReadToStartElement(ptr ptr ptr ptr ptr)
@ stdcall WsReadType(ptr long long ptr long ptr ptr long ptr)
@ stdcall WsReadValue(ptr long ptr long ptr)
@ st
ub WsReadXmlBuffer
@ st
dcall WsReadXmlBuffer(ptr ptr ptr ptr)
@ stub WsReadXmlBufferFromBytes
@ stdcall WsReceiveMessage(ptr ptr ptr long long long ptr ptr long ptr ptr ptr)
@ stub WsRegisterOperationForCancel
...
...
include/webservices.h
View file @
83bdbc1e
...
...
@@ -1647,6 +1647,7 @@ HRESULT WINAPI WsReadToStartElement(WS_XML_READER*, const WS_XML_STRING*, const
HRESULT
WINAPI
WsReadType
(
WS_XML_READER
*
,
WS_TYPE_MAPPING
,
WS_TYPE
,
const
void
*
,
WS_READ_OPTION
,
WS_HEAP
*
,
void
*
,
ULONG
,
WS_ERROR
*
);
HRESULT
WINAPI
WsReadValue
(
WS_XML_READER
*
,
WS_VALUE_TYPE
,
void
*
,
ULONG
,
WS_ERROR
*
);
HRESULT
WINAPI
WsReadXmlBuffer
(
WS_XML_READER
*
,
WS_HEAP
*
,
WS_XML_BUFFER
**
,
WS_ERROR
*
);
HRESULT
WINAPI
WsReceiveMessage
(
WS_CHANNEL
*
,
WS_MESSAGE
*
,
const
WS_MESSAGE_DESCRIPTION
**
,
ULONG
,
WS_RECEIVE_OPTION
,
WS_READ_OPTION
,
WS_HEAP
*
,
void
*
,
ULONG
,
ULONG
*
,
const
WS_ASYNC_CONTEXT
*
,
WS_ERROR
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment