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
46393a3f
Commit
46393a3f
authored
Feb 10, 2016
by
Hans Leidekker
Committed by
Alexandre Julliard
Feb 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Implement WsFindAttribute.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
acf0c929
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
7 deletions
+149
-7
reader.c
dlls/webservices/reader.c
+59
-6
reader.c
dlls/webservices/tests/reader.c
+89
-0
webservices.spec
dlls/webservices/webservices.spec
+1
-1
No files found.
dlls/webservices/reader.c
View file @
46393a3f
...
...
@@ -1068,12 +1068,12 @@ static HRESULT read_to_startelement( struct reader *reader, BOOL *found )
return
hr
;
}
static
BOOL
cmp_local
name
(
const
unsigned
char
*
name1
,
ULONG
len1
,
const
unsigned
char
*
name2
,
ULONG
len2
)
static
int
cmp_
name
(
const
unsigned
char
*
name1
,
ULONG
len1
,
const
unsigned
char
*
name2
,
ULONG
len2
)
{
ULONG
i
;
if
(
len1
!=
len2
)
return
FALSE
;
for
(
i
=
0
;
i
<
len1
;
i
++
)
{
if
(
toupper
(
name1
[
i
]
)
!=
toupper
(
name2
[
i
]
))
return
FALSE
;
}
return
TRUE
;
if
(
len1
!=
len2
)
return
1
;
for
(
i
=
0
;
i
<
len1
;
i
++
)
{
if
(
toupper
(
name1
[
i
]
)
!=
toupper
(
name2
[
i
]
))
return
1
;
}
return
0
;
}
struct
node
*
find_parent_element
(
struct
node
*
node
,
const
WS_XML_STRING
*
prefix
,
...
...
@@ -1088,10 +1088,10 @@ struct node *find_parent_element( struct node *node, const WS_XML_STRING *prefix
if
(
!
localname
)
return
parent
;
str
=
parent
->
hdr
.
prefix
;
if
(
!
cmp_local
name
(
str
->
bytes
,
str
->
length
,
prefix
->
bytes
,
prefix
->
length
))
continue
;
if
(
cmp_
name
(
str
->
bytes
,
str
->
length
,
prefix
->
bytes
,
prefix
->
length
))
continue
;
str
=
parent
->
hdr
.
localName
;
if
(
!
cmp_local
name
(
str
->
bytes
,
str
->
length
,
localname
->
bytes
,
localname
->
length
))
continue
;
if
(
cmp_
name
(
str
->
bytes
,
str
->
length
,
localname
->
bytes
,
localname
->
length
))
continue
;
return
parent
;
}
...
...
@@ -1579,6 +1579,59 @@ static HRESULT read_get_attribute_text( struct reader *reader, WS_XML_UTF8_TEXT
return
S_OK
;
}
static
BOOL
find_attribute
(
struct
reader
*
reader
,
const
WS_XML_STRING
*
localname
,
const
WS_XML_STRING
*
ns
,
ULONG
*
index
)
{
ULONG
i
;
WS_XML_ELEMENT_NODE
*
elem
=
&
reader
->
current
->
hdr
;
if
(
!
localname
)
{
*
index
=
reader
->
current_attr
;
return
TRUE
;
}
for
(
i
=
0
;
i
<
elem
->
attributeCount
;
i
++
)
{
const
WS_XML_STRING
*
localname2
=
elem
->
attributes
[
i
]
->
localName
;
const
WS_XML_STRING
*
ns2
=
elem
->
attributes
[
i
]
->
ns
;
if
(
!
cmp_name
(
localname
->
bytes
,
localname
->
length
,
localname2
->
bytes
,
localname2
->
length
)
&&
!
cmp_name
(
ns
->
bytes
,
ns
->
length
,
ns2
->
bytes
,
ns2
->
length
))
{
*
index
=
i
;
return
TRUE
;
}
}
return
FALSE
;
}
/**************************************************************************
* WsFindAttribute [webservices.@]
*/
HRESULT
WINAPI
WsFindAttribute
(
WS_XML_READER
*
handle
,
const
WS_XML_STRING
*
localname
,
const
WS_XML_STRING
*
ns
,
BOOL
required
,
ULONG
*
index
,
WS_ERROR
*
error
)
{
struct
reader
*
reader
=
(
struct
reader
*
)
handle
;
TRACE
(
"%p %s %s %d %p %p
\n
"
,
handle
,
debugstr_xmlstr
(
localname
),
debugstr_xmlstr
(
ns
),
required
,
index
,
error
);
if
(
error
)
FIXME
(
"ignoring error parameter
\n
"
);
if
(
!
reader
||
!
localname
||
!
ns
||
!
index
)
return
E_INVALIDARG
;
if
(
reader
->
current
->
hdr
.
node
.
nodeType
!=
WS_XML_NODE_TYPE_ELEMENT
)
return
WS_E_INVALID_OPERATION
;
if
(
!
find_attribute
(
reader
,
localname
,
ns
,
index
))
{
if
(
required
)
return
WS_E_INVALID_FORMAT
;
*
index
=
~
0u
;
return
S_FALSE
;
}
return
S_OK
;
}
static
HRESULT
read_type_bool
(
struct
reader
*
reader
,
WS_TYPE_MAPPING
mapping
,
const
WS_BOOL_DESCRIPTION
*
desc
,
BOOL
*
ret
)
{
...
...
dlls/webservices/tests/reader.c
View file @
46393a3f
...
...
@@ -1871,6 +1871,94 @@ static void test_cdata(void)
WsFreeReader
(
reader
);
}
static
void
test_WsFindAttribute
(
void
)
{
static
const
char
test
[]
=
"<t attr='value' attr2='value2'></t>"
;
WS_XML_STRING
ns
=
{
0
,
NULL
},
localname
=
{
4
,
(
BYTE
*
)
"attr"
};
WS_XML_STRING
localname2
=
{
5
,
(
BYTE
*
)
"attr2"
},
localname3
=
{
5
,
(
BYTE
*
)
"attr3"
};
WS_XML_READER
*
reader
;
ULONG
index
;
HRESULT
hr
;
hr
=
WsCreateReader
(
NULL
,
0
,
&
reader
,
NULL
)
;
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsFindAttribute
(
reader
,
&
localname
,
&
ns
,
TRUE
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsFindAttribute
(
reader
,
&
localname
,
NULL
,
TRUE
,
&
index
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsFindAttribute
(
reader
,
NULL
,
&
ns
,
TRUE
,
&
index
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
index
=
0xdeadbeef
;
hr
=
WsFindAttribute
(
reader
,
&
localname
,
&
ns
,
TRUE
,
&
index
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
!
index
,
"got %u
\n
"
,
index
);
index
=
0xdeadbeef
;
hr
=
WsFindAttribute
(
reader
,
&
localname2
,
&
ns
,
TRUE
,
&
index
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
index
==
1
,
"got %u
\n
"
,
index
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
index
=
0xdeadbeef
;
hr
=
WsFindAttribute
(
reader
,
&
localname
,
&
ns
,
TRUE
,
&
index
,
NULL
);
ok
(
hr
==
WS_E_INVALID_OPERATION
,
"got %08x
\n
"
,
hr
);
ok
(
index
==
0xdeadbeef
,
"got %u
\n
"
,
index
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
index
=
0xdeadbeef
;
hr
=
WsFindAttribute
(
reader
,
&
localname3
,
&
ns
,
TRUE
,
&
index
,
NULL
);
ok
(
hr
==
WS_E_INVALID_FORMAT
,
"got %08x
\n
"
,
hr
);
ok
(
index
==
0xdeadbeef
,
"got %u
\n
"
,
index
);
hr
=
set_input
(
reader
,
test
,
sizeof
(
test
)
-
1
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsReadNode
(
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
index
=
0xdeadbeef
;
hr
=
WsFindAttribute
(
reader
,
&
localname3
,
&
ns
,
FALSE
,
&
index
,
NULL
);
ok
(
hr
==
S_FALSE
,
"got %08x
\n
"
,
hr
);
ok
(
index
==
~
0u
,
"got %u
\n
"
,
index
);
WsFreeReader
(
reader
);
}
START_TEST
(
reader
)
{
test_WsCreateError
();
...
...
@@ -1890,4 +1978,5 @@ START_TEST(reader)
test_WsMoveReader
();
test_simple_struct_type
();
test_cdata
();
test_WsFindAttribute
();
}
dlls/webservices/webservices.spec
View file @
46393a3f
...
...
@@ -45,7 +45,7 @@
@ stub WsFileTimeToDateTime
@ stub WsFillBody
@ stdcall WsFillReader(ptr long ptr ptr)
@ st
ub WsFindAttribute
@ st
dcall WsFindAttribute(ptr ptr ptr long ptr ptr)
@ stub WsFlushBody
@ stub WsFlushWriter
@ stub WsFreeChannel
...
...
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