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
41f22e4c
Commit
41f22e4c
authored
Mar 22, 2016
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Implement WriteRaw().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
85210d46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
37 deletions
+123
-37
writer.c
dlls/xmllite/tests/writer.c
+62
-0
writer.c
dlls/xmllite/writer.c
+61
-37
No files found.
dlls/xmllite/tests/writer.c
View file @
41f22e4c
...
...
@@ -880,6 +880,67 @@ static void test_WriteCData(void)
IStream_Release
(
stream
);
}
static
void
test_WriteRaw
(
void
)
{
static
const
WCHAR
rawW
[]
=
{
'a'
,
'<'
,
':'
,
0
};
IXmlWriter
*
writer
;
IStream
*
stream
;
HGLOBAL
hglobal
;
HRESULT
hr
;
char
*
ptr
;
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
pCreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRaw
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRaw
(
writer
,
rawW
);
ok
(
hr
==
E_UNEXPECTED
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRaw
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRaw
(
writer
,
rawW
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteComment
(
writer
,
rawW
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteEndDocument
(
writer
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRaw
(
writer
,
rawW
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
GetHGlobalFromStream
(
stream
,
&
hglobal
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
ptr
!=
NULL
,
"got %p
\n
"
,
ptr
);
ok
(
!
strncmp
(
ptr
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>"
"a<:"
,
41
),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
IXmlWriter_Release
(
writer
);
IStream_Release
(
stream
);
}
START_TEST
(
writer
)
{
if
(
!
init_pointers
())
...
...
@@ -896,4 +957,5 @@ START_TEST(writer)
test_writeenddocument
();
test_WriteComment
();
test_WriteCData
();
test_WriteRaw
();
}
dlls/xmllite/writer.c
View file @
41f22e4c
...
...
@@ -372,6 +372,40 @@ static HRESULT write_encoding_bom(xmlwriter *writer)
return
S_OK
;
}
static
HRESULT
write_xmldecl
(
xmlwriter
*
writer
,
XmlStandalone
standalone
)
{
static
const
WCHAR
versionW
[]
=
{
'<'
,
'?'
,
'x'
,
'm'
,
'l'
,
' '
,
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
};
static
const
WCHAR
encodingW
[]
=
{
' '
,
'e'
,
'n'
,
'c'
,
'o'
,
'd'
,
'i'
,
'n'
,
'g'
,
'='
};
write_encoding_bom
(
writer
);
writer
->
state
=
XmlWriterState_DocStarted
;
if
(
writer
->
omitxmldecl
)
return
S_OK
;
/* version */
write_output_buffer
(
writer
->
output
,
versionW
,
ARRAY_SIZE
(
versionW
));
/* encoding */
write_output_buffer
(
writer
->
output
,
encodingW
,
ARRAY_SIZE
(
encodingW
));
write_output_buffer_quoted
(
writer
->
output
,
get_encoding_name
(
writer
->
output
->
encoding
),
-
1
);
/* standalone */
if
(
standalone
==
XmlStandalone_Omit
)
write_output_buffer
(
writer
->
output
,
closepiW
,
ARRAY_SIZE
(
closepiW
));
else
{
static
const
WCHAR
standaloneW
[]
=
{
' '
,
's'
,
't'
,
'a'
,
'n'
,
'd'
,
'a'
,
'l'
,
'o'
,
'n'
,
'e'
,
'='
,
'\"'
};
static
const
WCHAR
yesW
[]
=
{
'y'
,
'e'
,
's'
,
'\"'
,
'?'
,
'>'
};
static
const
WCHAR
noW
[]
=
{
'n'
,
'o'
,
'\"'
,
'?'
,
'>'
};
write_output_buffer
(
writer
->
output
,
standaloneW
,
ARRAY_SIZE
(
standaloneW
));
if
(
standalone
==
XmlStandalone_Yes
)
write_output_buffer
(
writer
->
output
,
yesW
,
ARRAY_SIZE
(
yesW
));
else
write_output_buffer
(
writer
->
output
,
noW
,
ARRAY_SIZE
(
noW
));
}
return
S_OK
;
}
static
HRESULT
writer_close_starttag
(
xmlwriter
*
writer
)
{
HRESULT
hr
;
...
...
@@ -890,13 +924,32 @@ static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, LPCWSTR pw
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
xmlwriter_WriteRaw
(
IXmlWriter
*
iface
,
LPCWSTR
pwszD
ata
)
static
HRESULT
WINAPI
xmlwriter_WriteRaw
(
IXmlWriter
*
iface
,
LPCWSTR
d
ata
)
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
FIXME
(
"%p %s
\n
"
,
This
,
wine_dbgstr_w
(
pwszD
ata
));
TRACE
(
"%p %s
\n
"
,
This
,
debugstr_w
(
d
ata
));
return
E_NOTIMPL
;
if
(
!
data
)
return
S_OK
;
switch
(
This
->
state
)
{
case
XmlWriterState_Initial
:
return
E_UNEXPECTED
;
case
XmlWriterState_Ready
:
write_xmldecl
(
This
,
XmlStandalone_Omit
);
/* fallthrough */
case
XmlWriterState_DocStarted
:
case
XmlWriterState_PIDocStarted
:
break
;
default:
return
WR_E_INVALIDACTION
;
}
write_output_buffer
(
This
->
output
,
data
,
-
1
);
This
->
state
=
XmlWriterState_DocClosed
;
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_WriteRawChars
(
IXmlWriter
*
iface
,
const
WCHAR
*
pwch
,
UINT
cwch
)
...
...
@@ -908,10 +961,9 @@ static HRESULT WINAPI xmlwriter_WriteRawChars(IXmlWriter *iface, const WCHAR *p
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
xmlwriter_WriteStartDocument
(
IXmlWriter
*
iface
,
XmlStandalone
standalone
)
{
static
const
WCHAR
versionW
[]
=
{
'<'
,
'?'
,
'x'
,
'm'
,
'l'
,
' '
,
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
};
static
const
WCHAR
encodingW
[]
=
{
' '
,
'e'
,
'n'
,
'c'
,
'o'
,
'd'
,
'i'
,
'n'
,
'g'
,
'='
};
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
standalone
);
...
...
@@ -923,41 +975,13 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
case
XmlWriterState_PIDocStarted
:
This
->
state
=
XmlWriterState_DocStarted
;
return
S_OK
;
case
XmlWriterState_DocStarted
:
case
XmlWriterState_ElemStarted
:
case
XmlWriterState_DocClosed
:
return
WR_E_INVALIDACTION
;
case
XmlWriterState_Ready
:
break
;
default:
;
}
write_encoding_bom
(
This
);
This
->
state
=
XmlWriterState_DocStarted
;
if
(
This
->
omitxmldecl
)
return
S_OK
;
/* version */
write_output_buffer
(
This
->
output
,
versionW
,
ARRAY_SIZE
(
versionW
));
/* encoding */
write_output_buffer
(
This
->
output
,
encodingW
,
ARRAY_SIZE
(
encodingW
));
write_output_buffer_quoted
(
This
->
output
,
get_encoding_name
(
This
->
output
->
encoding
),
-
1
);
/* standalone */
if
(
standalone
==
XmlStandalone_Omit
)
write_output_buffer
(
This
->
output
,
closepiW
,
ARRAY_SIZE
(
closepiW
));
else
{
static
const
WCHAR
standaloneW
[]
=
{
' '
,
's'
,
't'
,
'a'
,
'n'
,
'd'
,
'a'
,
'l'
,
'o'
,
'n'
,
'e'
,
'='
,
'\"'
};
static
const
WCHAR
yesW
[]
=
{
'y'
,
'e'
,
's'
,
'\"'
,
'?'
,
'>'
};
static
const
WCHAR
noW
[]
=
{
'n'
,
'o'
,
'\"'
,
'?'
,
'>'
};
write_output_buffer
(
This
->
output
,
standaloneW
,
ARRAY_SIZE
(
standaloneW
));
if
(
standalone
==
XmlStandalone_Yes
)
write_output_buffer
(
This
->
output
,
yesW
,
ARRAY_SIZE
(
yesW
));
else
write_output_buffer
(
This
->
output
,
noW
,
ARRAY_SIZE
(
noW
));
return
WR_E_INVALIDACTION
;
}
return
S_OK
;
return
write_xmldecl
(
This
,
standalone
)
;
}
static
HRESULT
WINAPI
xmlwriter_WriteStartElement
(
IXmlWriter
*
iface
,
LPCWSTR
prefix
,
LPCWSTR
local_name
,
LPCWSTR
uri
)
...
...
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