43DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a);
130 static const char *
const prop_names[] =
135 "OmitXmlDeclaration",
142 return prop_names[prop];
375 unsigned int len = 1;
399 unsigned int len = 0;
421 const int initial_len = 0x2000;
426 WARN(
"Failed to get code page for specified encoding.\n");
432 buffer->allocated = initial_len;
457 buffer->allocated = grown_size;
470 if (
buffer->codepage == 1200) {
518 assert(prefix_len >= 0 && local_len >= 0);
523 if (prefix_len && local_len)
533 if (writeroutput->
stream) {
534 ISequentialStream_Release(writeroutput->
stream);
544 hr = IUnknown_QueryInterface(writeroutput->
output, &IID_IStream, (
void**)&writeroutput->
stream);
546 hr = IUnknown_QueryInterface(writeroutput->
output, &IID_ISequentialStream, (
void**)&writeroutput->
stream);
557 if (!output || !output->
stream)
567 WARN(
"write to stream failed %#lx.\n",
hr);
574 }
while (
buffer->written > 0);
584 static const char utf16bom[] = {0xff, 0xfe};
687 while (indent_level--)
711 IXmlWriter_AddRef(iface);
720 TRACE(
"%p, refcount %lu.\n", iface,
ref);
729 TRACE(
"%p, refcount %lu.\n", iface,
ref);
742 if (imalloc) IMalloc_Release(imalloc);
759 IUnknown_Release(&
This->output->IXmlWriterOutput_iface);
761 This->bomwritten = 0;
763 This->indent_level = 0;
774 hr = IUnknown_QueryInterface(output, &IID_IXmlWriterOutput, (
void**)&writeroutput);
779 ERR(
"got external IXmlWriterOutput implementation: %p, vtbl=%p\n",
780 writeroutput, writeroutput->lpVtbl);
781 IUnknown_Release(writeroutput);
786 if (
hr !=
S_OK || !writeroutput) {
860 if (IXmlReader_IsDefault(
reader) && !write_default_attributes)
875 TRACE(
"%p, %p, %d.\n", iface,
reader, write_default_attributes);
890 while (IXmlReader_MoveToNextAttribute(
reader) ==
S_OK)
895 hr = IXmlReader_MoveToElement(
reader);
898 WARN(
"Unexpected node type %d.\n", node_type);
923 BOOL is_xmlns_prefix, is_xmlns_local;
930 switch (writer->
state)
1010 FIXME(
"Prefix autogeneration is not implemented.\n");
1040 switch (
This->state)
1090 switch (
This->state)
1194 switch (writer->
state)
1221 switch (
This->state)
1244 for (
i = 0;
i <
len;
i++) {
1265 unsigned int name_len, pubid_len;
1271 switch (
This->state)
1334 switch (
This->state)
1410 switch (
This->state)
1425 while (IXmlWriter_WriteEndElement(iface) ==
S_OK)
1439 switch (
This->state)
1459 if (
This->starttagopen)
1463 This->starttagopen = 0;
1484 switch (
This->state)
1506 switch (
This->state)
1554 switch (
This->state)
1577 switch (
This->state)
1598 unsigned int start_depth = 0,
depth;
1607 if (shallow)
return S_OK;
1618 if (
FAILED(
hr = IXmlWriter_WriteAttributes(writer,
reader, write_default_attributes)))
return hr;
1619 if (IXmlReader_IsEmptyElement(
reader))
1621 hr = IXmlWriter_WriteEndElement(writer);
1625 if (shallow)
return S_OK;
1628 while ((
hr = IXmlReader_Read(
reader, &node_type)) ==
S_OK)
1643 hr = IXmlWriter_WriteRaw(writer,
value);
1647 hr = IXmlWriter_WriteCData(writer,
value);
1652 hr = IXmlWriter_WriteProcessingInstruction(writer,
name,
value);
1656 hr = IXmlWriter_WriteComment(writer,
value);
1660 hr = IXmlWriter_WriteWhitespace(writer,
value);
1663 hr = IXmlWriter_WriteFullEndElement(writer);
1666 while ((
hr = IXmlReader_MoveToNextAttribute(
reader)) ==
S_OK)
1676 hr = IXmlWriter_WriteStartDocument(writer, standalone);
1679 WARN(
"Unknown node type %d.\n", node_type);
1690 TRACE(
"%p, %p, %d.\n", iface,
reader, write_default_attributes);
1703 TRACE(
"%p, %p, %d.\n", iface,
reader, write_default_attributes);
1718 switch (
This->state)
1758 switch (
This->state)
1784 switch (
This->state)
1829 switch (writer->
state)
1851 characters +=
count;
1862 TRACE(
"(%p)->(%d)\n",
This, standalone);
1864 switch (
This->state)
1886 int prefix_len, local_len;
1896 switch (
This->state)
1937 This->starttagopen = 1;
1963 switch (
This->state)
1990 TRACE(
"%p, %d, %d.\n", iface, wchLow, wchHigh);
1995 switch (writer->
state)
2010 codepoint = ((wchHigh - 0xd800) * 0x400) + (wchLow - 0xdc00) + 0x10000;
2024 switch (writer->
state)
2113 IUnknown_AddRef(iface);
2122 TRACE(
"%p, refcount %ld.\n", iface,
ref);
2131 TRACE(
"%p, refcount %ld.\n", iface,
ref);
2136 if (
This->output) IUnknown_Release(
This->output);
2137 if (
This->stream) ISequentialStream_Release(
This->stream);
2141 if (imalloc) IMalloc_Release(imalloc);
2161 if (!(writer =
m_alloc(imalloc,
sizeof(*writer))))
2163 memset(writer, 0,
sizeof(*writer));
2168 if (imalloc) IMalloc_AddRef(imalloc);
2177 TRACE(
"returning iface %p, hr %#lx.\n", *
obj,
hr);
2190 if (!(writeroutput =
m_alloc(imalloc,
sizeof(*writeroutput))))
2192 memset(writeroutput, 0,
sizeof(*writeroutput));
2195 writeroutput->
ref = 1;
2196 writeroutput->
imalloc = imalloc;
2198 IMalloc_AddRef(imalloc);
2215 *
out = writeroutput;
2217 TRACE(
"Created writer output %p\n", *
out);
#define InterlockedIncrement
#define InterlockedDecrement
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
BOOL is_char(const WCHAR s, const WCHAR c)
static void list_remove(struct list_entry *entry)
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
static void list_add_head(struct list_entry *head, struct list_entry *entry)
static void list_init(struct list_entry *head)
const char * wine_dbg_sprintf(const char *format,...)
#define WideCharToMultiByte
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
BOOL is_namechar(WCHAR ch)
BOOL is_namestartchar(WCHAR ch)
const WCHAR * get_encoding_name(xml_encoding encoding)
xml_encoding get_encoding_from_codepage(UINT codepage)
BOOL is_pubchar(WCHAR ch)
BOOL is_ncnamechar(WCHAR ch)
static HRESULT WINAPI xmlwriter_SetOutput(IXmlWriter *iface, IUnknown *output)
static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR prefix, LPCWSTR local_name, LPCWSTR uri, LPCWSTR value)
static HRESULT write_xmldecl(xmlwriter *writer, XmlStandalone standalone)
static BOOL is_empty_string(const WCHAR *str)
static HRESULT WINAPI xmlwriter_WriteDocType(IXmlWriter *iface, LPCWSTR name, LPCWSTR pubid, LPCWSTR sysid, LPCWSTR subset)
static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)
static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LPCWSTR name, LPCWSTR text)
static HRESULT WINAPI xmlwriter_WriteCData(IXmlWriter *iface, LPCWSTR data)
static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *characters, UINT length)
static HRESULT WINAPI xmlwriter_WriteRawChars(IXmlWriter *iface, const WCHAR *characters, UINT length)
HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
static ULONG WINAPI xmlwriter_AddRef(IXmlWriter *iface)
static struct element * alloc_element(xmlwriter *writer, const WCHAR *prefix, const WCHAR *local)
static ULONG WINAPI xmlwriteroutput_Release(IXmlWriterOutput *iface)
struct _xmlwriter xmlwriter
static xmlwriter * impl_from_IXmlWriter(IXmlWriter *iface)
static HRESULT writer_get_next_write_count(const WCHAR *str, unsigned int length, unsigned int *count)
static HRESULT WINAPI xmlwriter_WriteEndDocument(IXmlWriter *iface)
static void write_output_attribute(xmlwriter *writer, const WCHAR *prefix, int prefix_len, const WCHAR *local, int local_len, const WCHAR *value)
static WCHAR * writer_strndupW(const xmlwriter *writer, const WCHAR *str, int len)
static HRESULT WINAPI xmlwriter_WriteSurrogateCharEntity(IXmlWriter *iface, WCHAR wchLow, WCHAR wchHigh)
static HRESULT WINAPI xmlwriter_WriteCharEntity(IXmlWriter *iface, WCHAR ch)
static HRESULT grow_output_buffer(xmlwriteroutput *output, int length)
static struct ns * writer_find_ns_current(const xmlwriter *writer, const WCHAR *prefix, const WCHAR *uri)
static HRESULT is_valid_ncname(const WCHAR *str, int *out)
static HRESULT write_encoding_bom(xmlwriter *writer)
static struct element * pop_element(xmlwriter *writer)
static BOOL is_valid_xml_space_value(const WCHAR *value)
static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, LPCWSTR pwszLocalName, LPCWSTR pwszNamespaceUri)
static HRESULT writeroutput_query_for_stream(xmlwriteroutput *writeroutput)
static HRESULT is_valid_name(const WCHAR *str, unsigned int *out)
static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, const WCHAR *string)
static HRESULT write_output_buffer_char(xmlwriteroutput *output, WCHAR ch)
static HRESULT WINAPI xmlwriter_WriteEntityRef(IXmlWriter *iface, LPCWSTR pwszName)
static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR prefix, LPCWSTR local, LPCWSTR uri, LPCWSTR value)
static const WCHAR * get_output_encoding_name(xmlwriteroutput *output)
static HRESULT writer_write_attribute(IXmlWriter *writer, IXmlReader *reader, BOOL write_default_attributes)
static struct ns * writer_find_ns(const xmlwriter *writer, const WCHAR *prefix, const WCHAR *uri)
static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_encoding encoding, const WCHAR *encoding_name, xmlwriteroutput **out)
static const struct IXmlWriterVtbl xmlwriter_vtbl
static HRESULT write_escaped_char(xmlwriter *writer, const WCHAR *string, unsigned int count)
static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR prefix, LPCWSTR local_name, LPCWSTR uri)
static HRESULT WINAPI xmlwriter_WriteAttributes(IXmlWriter *iface, IXmlReader *reader, BOOL write_default_attributes)
static HRESULT WINAPI xmlwriter_GetProperty(IXmlWriter *iface, UINT property, LONG_PTR *value)
static const WCHAR xmlnsuriW[]
static HRESULT WINAPI xmlwriter_WriteNodeShallow(IXmlWriter *iface, IXmlReader *reader, BOOL write_default_attributes)
static HRESULT writer_close_starttag(xmlwriter *writer)
static void free_output_buffer(xmlwriteroutput *output)
static void * writeroutput_alloc(xmlwriteroutput *output, size_t len)
static void writeroutput_free(xmlwriteroutput *output, void *mem)
static HRESULT write_output_qname(xmlwriteroutput *output, const WCHAR *prefix, int prefix_len, const WCHAR *local_name, int local_len)
static void write_cdata_section(xmlwriteroutput *output, const WCHAR *data, int len)
HRESULT WINAPI CreateXmlWriterOutputWithEncodingCodePage(IUnknown *stream, IMalloc *imalloc, UINT codepage, IXmlWriterOutput **out)
static HRESULT write_output_buffer_quoted(xmlwriteroutput *output, const WCHAR *data, int len)
static const char * debugstr_writer_prop(XmlWriterProperty prop)
static HRESULT writeroutput_flush_stream(xmlwriteroutput *output)
static HRESULT is_valid_pubid(const WCHAR *str, unsigned int *out)
static void writer_push_element(xmlwriter *writer, struct element *element)
static void writeroutput_release_stream(xmlwriteroutput *writeroutput)
static ULONG WINAPI xmlwriter_Release(IXmlWriter *iface)
static HRESULT WINAPI xmlwriter_WriteNmToken(IXmlWriter *iface, LPCWSTR pwszNmToken)
static HRESULT WINAPI xmlwriter_Flush(IXmlWriter *iface)
static HRESULT writer_write_node(IXmlWriter *writer, IXmlReader *reader, BOOL shallow, BOOL write_default_attributes)
@ XmlWriterState_InvalidEncoding
@ XmlWriterState_DocStarted
@ XmlWriterState_ElemStarted
@ XmlWriterState_DocClosed
@ XmlWriterState_PIDocStarted
static void writer_inc_indent(xmlwriter *writer)
static struct ns * writer_push_ns(xmlwriter *writer, const WCHAR *prefix, int prefix_len, const WCHAR *uri)
static HRESULT WINAPI xmlwriter_WriteNode(IXmlWriter *iface, IXmlReader *reader, BOOL write_default_attributes)
static void write_node_indent(xmlwriter *writer)
static HRESULT WINAPI xmlwriter_WriteWhitespace(IXmlWriter *iface, LPCWSTR text)
static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandalone standalone)
static HRESULT WINAPI xmlwriter_WriteName(IXmlWriter *iface, LPCWSTR pwszName)
static void writer_free_element_stack(xmlwriter *writer)
static void writer_free_element(xmlwriter *writer, struct element *element)
static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface)
static const struct IUnknownVtbl xmlwriteroutputvtbl
static void * writer_alloc(const xmlwriter *writer, size_t len)
static xmlwriteroutput * impl_from_IXmlWriterOutput(IXmlWriterOutput *iface)
static void writer_output_ns(xmlwriter *writer, struct element *element)
static ULONG WINAPI xmlwriteroutput_AddRef(IXmlWriterOutput *iface)
static HRESULT WINAPI xmlwriteroutput_QueryInterface(IXmlWriterOutput *iface, REFIID riid, void **ppvObject)
static void * writeroutput_realloc(xmlwriteroutput *output, void *mem, size_t len)
static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface)
static void writer_dec_indent(xmlwriter *writer)
static HRESULT write_escaped_string(xmlwriter *writer, const WCHAR *string, unsigned int length)
static HRESULT WINAPI xmlwriter_WriteComment(IXmlWriter *iface, LPCWSTR comment)
HRESULT WINAPI CreateXmlWriterOutputWithEncodingName(IUnknown *stream, IMalloc *imalloc, const WCHAR *encoding, IXmlWriterOutput **out)
static HRESULT WINAPI xmlwriter_SetProperty(IXmlWriter *iface, UINT property, LONG_PTR value)
static void writer_free(const xmlwriter *writer, void *mem)
static HRESULT WINAPI xmlwriter_QueryInterface(IXmlWriter *iface, REFIID riid, void **ppvObject)
static HRESULT write_output_buffer(xmlwriteroutput *output, const WCHAR *data, int len)
static WCHAR * writer_strdupW(const xmlwriter *writer, const WCHAR *str)
static BSTR local_name(call_frame_t *frame, int ref)
GLint GLint GLsizei GLsizei GLsizei depth
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
#define memcpy(s1, s2, n)
#define comment(fmt, arg1)
static const char utf16bom[]
static HRESULT get_code_page(xml_encoding encoding, UINT *cp)
static xml_encoding parse_encoding_name(const WCHAR *encoding)
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
#define IsEqualGUID(rguid1, rguid2)
static __inline const char * wine_dbgstr_guid(const GUID *id)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
unsigned int indent_level
IXmlWriter IXmlWriter_iface
XmlConformanceLevel conformance
IXmlWriterOutput IXmlWriterOutput_iface
struct output_buffer buffer
ISequentialStream * stream
Character const *const prefix
#define CONTAINING_RECORD(address, type, field)
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
#define IS_SURROGATE_PAIR(high, low)
#define IS_HIGH_SURROGATE(ch)
#define IS_LOW_SURROGATE(ch)
@ WR_E_XMLPREFIXDECLARATION
@ WR_E_XMLNSURIDECLARATION
@ WR_E_INVALIDSURROGATEPAIR
@ WR_E_XMLNSPREFIXDECLARATION
@ WR_E_NSPREFIXWITHEMPTYNSURI
@ XmlWriterProperty_ConformanceLevel
@ XmlWriterProperty_OmitXmlDeclaration
@ XmlWriterProperty_ByteOrderMark
@ XmlWriterProperty_Indent
@ _XmlWriterProperty_Last
@ XmlConformanceLevel_Document
@ XmlNodeType_ProcessingInstruction
@ XmlNodeType_XmlDeclaration
static void * m_alloc(IMalloc *imalloc, size_t len)
static BOOL is_wchar_space(WCHAR ch)
static void m_free(IMalloc *imalloc, void *mem)
static void * m_realloc(IMalloc *imalloc, void *mem, size_t len)