Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
bac2d5c3
Commit
bac2d5c3
authored
Oct 09, 2015
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Implement WsReadStartElement.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3ec48f1d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
165 additions
and
1 deletion
+165
-1
reader.c
dlls/webservices/reader.c
+67
-0
reader.c
dlls/webservices/tests/reader.c
+97
-0
webservices.spec
dlls/webservices/webservices.spec
+1
-1
No files found.
dlls/webservices/reader.c
View file @
bac2d5c3
...
...
@@ -557,6 +557,20 @@ static WS_XML_STRING *alloc_xml_string( const char *data, ULONG len )
return
ret
;
}
static
WS_XML_UTF8_TEXT
*
alloc_utf8_text
(
const
char
*
data
,
ULONG
len
)
{
WS_XML_UTF8_TEXT
*
ret
;
if
(
!
(
ret
=
heap_alloc
(
sizeof
(
*
ret
)
+
len
)))
return
NULL
;
ret
->
text
.
textType
=
WS_XML_TEXT_TYPE_UTF8
;
ret
->
value
.
length
=
len
;
ret
->
value
.
bytes
=
(
BYTE
*
)(
ret
+
1
);
ret
->
value
.
dictionary
=
NULL
;
ret
->
value
.
id
=
0
;
if
(
data
)
memcpy
(
ret
->
value
.
bytes
,
data
,
len
);
return
ret
;
}
static
inline
BOOL
read_end_of_data
(
struct
reader
*
reader
)
{
return
reader
->
read_pos
>=
reader
->
read_size
;
...
...
@@ -749,6 +763,45 @@ error:
return
hr
;
}
static
HRESULT
read_text
(
struct
reader
*
reader
)
{
unsigned
int
len
=
0
,
ch
,
skip
;
const
char
*
start
;
struct
node
*
node
;
WS_XML_TEXT_NODE
*
text
;
WS_XML_UTF8_TEXT
*
utf8
;
start
=
read_current_ptr
(
reader
);
for
(;;)
{
if
(
read_end_of_data
(
reader
))
break
;
if
(
!
(
ch
=
read_utf8_char
(
reader
,
&
skip
)))
return
WS_E_INVALID_FORMAT
;
if
(
ch
==
'<'
)
break
;
read_skip
(
reader
,
skip
);
len
+=
skip
;
}
if
(
!
(
node
=
alloc_node
(
WS_XML_NODE_TYPE_TEXT
)))
return
E_OUTOFMEMORY
;
text
=
(
WS_XML_TEXT_NODE
*
)
node
;
if
(
!
(
utf8
=
alloc_utf8_text
(
start
,
len
)))
{
heap_free
(
node
);
return
E_OUTOFMEMORY
;
}
text
->
text
=
(
WS_XML_TEXT
*
)
utf8
;
list_add_after
(
&
reader
->
current
->
entry
,
&
node
->
entry
);
reader
->
current
=
node
;
reader
->
state
=
READER_STATE_TEXT
;
return
S_OK
;
}
static
HRESULT
read_startelement
(
struct
reader
*
reader
)
{
if
(
!
read_cmp
(
reader
,
"<"
,
1
))
return
read_element
(
reader
);
return
read_text
(
reader
);
}
static
HRESULT
read_to_startelement
(
struct
reader
*
reader
,
BOOL
*
found
)
{
HRESULT
hr
;
...
...
@@ -781,6 +834,20 @@ static HRESULT read_to_startelement( struct reader *reader, BOOL *found )
}
/**************************************************************************
* WsReadStartElement [webservices.@]
*/
HRESULT
WINAPI
WsReadStartElement
(
WS_XML_READER
*
handle
,
WS_ERROR
*
error
)
{
struct
reader
*
reader
=
(
struct
reader
*
)
handle
;
TRACE
(
"%p %p
\n
"
,
handle
,
error
);
if
(
error
)
FIXME
(
"ignoring error parameter
\n
"
);
if
(
!
reader
)
return
E_INVALIDARG
;
return
read_startelement
(
reader
);
}
/**************************************************************************
* WsReadToStartElement [webservices.@]
*/
HRESULT
WINAPI
WsReadToStartElement
(
WS_XML_READER
*
handle
,
const
WS_XML_STRING
*
localname
,
...
...
dlls/webservices/tests/reader.c
View file @
bac2d5c3
...
...
@@ -45,6 +45,9 @@ static const char data4[] =
"</o:services>
\r\n
"
"</o:OfficeConfig>
\r\n
"
;
static
const
char
data8
[]
=
"<node1><node2>test</node2></node1>"
;
static
void
test_WsCreateError
(
void
)
{
HRESULT
hr
;
...
...
@@ -598,6 +601,99 @@ static void test_WsReadToStartElement(void)
WsFreeReader
(
reader
);
}
static
void
test_WsReadStartElement
(
void
)
{
HRESULT
hr
;
WS_XML_READER
*
reader
;
const
WS_XML_NODE
*
node
,
*
node2
;
int
found
;
hr
=
WsCreateReader
(
NULL
,
0
,
&
reader
,
NULL
)
;
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
data2
,
sizeof
(
data2
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsFillReader
(
reader
,
sizeof
(
data2
)
-
1
,
NULL
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
found
=
-
1
;
hr
=
WsReadToStartElement
(
reader
,
NULL
,
NULL
,
&
found
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
found
==
TRUE
,
"got %d
\n
"
,
found
);
hr
=
WsReadStartElement
(
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
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
);
if
(
node
)
{
WS_XML_TEXT_NODE
*
text
=
(
WS_XML_TEXT_NODE
*
)
node
;
ok
(
text
->
node
.
nodeType
==
WS_XML_NODE_TYPE_TEXT
,
"got %u
\n
"
,
text
->
node
.
nodeType
);
ok
(
text
->
text
!=
NULL
,
"text not set
\n
"
);
if
(
text
->
text
)
{
WS_XML_UTF8_TEXT
*
utf8
=
(
WS_XML_UTF8_TEXT
*
)
text
->
text
;
ok
(
text
->
text
->
textType
==
WS_XML_TEXT_TYPE_UTF8
,
"got %u
\n
"
,
text
->
text
->
textType
);
ok
(
utf8
->
value
.
length
==
4
,
"got %u
\n
"
,
utf8
->
value
.
length
);
ok
(
!
memcmp
(
utf8
->
value
.
bytes
,
"test"
,
4
),
"wrong data
\n
"
);
}
}
hr
=
WsReadStartElement
(
reader
,
NULL
);
ok
(
hr
==
WS_E_INVALID_FORMAT
,
"got %08x
\n
"
,
hr
);
node2
=
NULL
;
hr
=
WsGetReaderNode
(
reader
,
&
node2
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
node2
==
node
,
"different node
\n
"
);
hr
=
set_input
(
reader
,
data8
,
sizeof
(
data8
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsFillReader
(
reader
,
sizeof
(
data8
)
-
1
,
NULL
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
found
=
-
1
;
hr
=
WsReadToStartElement
(
reader
,
NULL
,
NULL
,
&
found
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
found
==
TRUE
,
"got %d
\n
"
,
found
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
hr
=
WsGetReaderNode
(
reader
,
&
node
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
if
(
node
)
{
WS_XML_ELEMENT_NODE
*
elem
=
(
WS_XML_ELEMENT_NODE
*
)
node
;
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
ok
(
!
memcmp
(
elem
->
localName
->
bytes
,
"node1"
,
5
),
"wrong name
\n
"
);
}
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
);
if
(
node
)
{
WS_XML_ELEMENT_NODE
*
elem
=
(
WS_XML_ELEMENT_NODE
*
)
node
;
ok
(
node
->
nodeType
==
WS_XML_NODE_TYPE_ELEMENT
,
"got %u
\n
"
,
node
->
nodeType
);
ok
(
!
memcmp
(
elem
->
localName
->
bytes
,
"node2"
,
5
),
"wrong name
\n
"
);
}
WsFreeReader
(
reader
);
}
START_TEST
(
reader
)
{
test_WsCreateError
();
...
...
@@ -606,4 +702,5 @@ START_TEST(reader)
test_WsSetInput
();
test_WsFillReader
();
test_WsReadToStartElement
();
test_WsReadStartElement
();
}
dlls/webservices/webservices.spec
View file @
bac2d5c3
...
...
@@ -119,7 +119,7 @@
@ stub WsReadNode
@ stub WsReadQualifiedName
@ stub WsReadStartAttribute
@ st
ub WsReadStartElement
@ st
dcall WsReadStartElement(ptr ptr)
@ stdcall WsReadToStartElement(ptr ptr ptr ptr ptr)
@ stub WsReadType
@ stub WsReadValue
...
...
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