msi/tests: Avoid #if 0 to make sure code still compiles.
[wine/multimedia.git] / dlls / msxml3 / msxml_private.h
blobb9ec42357cff80ea05bf00a2d1063ee26a02468b
1 /*
2 * Common definitions
4 * Copyright 2005 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __MSXML_PRIVATE__
22 #define __MSXML_PRIVATE__
24 #include "dispex.h"
26 #include "wine/unicode.h"
28 #ifndef __WINE_CONFIG_H
29 # error You must include config.h to use this header
30 #endif
32 typedef enum {
33 MSXML_DEFAULT = 0,
34 MSXML3 = 30,
35 MSXML4 = 40,
36 MSXML6 = 60
37 } MSXML_VERSION;
39 /* typelibs */
40 typedef enum tid_t {
41 IXMLDOMAttribute_tid,
42 IXMLDOMCDATASection_tid,
43 IXMLDOMComment_tid,
44 IXMLDOMDocument_tid,
45 IXMLDOMDocument2_tid,
46 IXMLDOMDocumentFragment_tid,
47 IXMLDOMDocumentType_tid,
48 IXMLDOMElement_tid,
49 IXMLDOMEntityReference_tid,
50 IXMLDOMImplementation_tid,
51 IXMLDOMNamedNodeMap_tid,
52 IXMLDOMNode_tid,
53 IXMLDOMNodeList_tid,
54 IXMLDOMParseError_tid,
55 IXMLDOMProcessingInstruction_tid,
56 IXMLDOMSchemaCollection_tid,
57 IXMLDOMSelection_tid,
58 IXMLDOMText_tid,
59 IXMLElement_tid,
60 IXMLDocument_tid,
61 IXMLHTTPRequest_tid,
62 IXSLProcessor_tid,
63 IXSLTemplate_tid,
64 IVBSAXAttributes_tid,
65 IVBSAXContentHandler_tid,
66 IVBSAXDeclHandler_tid,
67 IVBSAXDTDHandler_tid,
68 IVBSAXEntityResolver_tid,
69 IVBSAXErrorHandler_tid,
70 IVBSAXLexicalHandler_tid,
71 IVBSAXLocator_tid,
72 IVBSAXXMLFilter_tid,
73 IVBSAXXMLReader_tid,
74 IMXAttributes_tid,
75 IMXReaderControl_tid,
76 IMXWriter_tid,
77 IVBMXNamespaceManager_tid,
78 LAST_tid
79 } tid_t;
81 /* The XDR datatypes (urn:schemas-microsoft-com:datatypes)
82 * These are actually valid for XSD schemas as well
83 * See datatypes.xsd
85 typedef enum _XDR_DT {
86 DT_INVALID = -1,
87 DT_BIN_BASE64,
88 DT_BIN_HEX,
89 DT_BOOLEAN,
90 DT_CHAR,
91 DT_DATE,
92 DT_DATE_TZ,
93 DT_DATETIME,
94 DT_DATETIME_TZ,
95 DT_ENTITY,
96 DT_ENTITIES,
97 DT_ENUMERATION,
98 DT_FIXED_14_4,
99 DT_FLOAT,
100 DT_I1,
101 DT_I2,
102 DT_I4,
103 DT_I8,
104 DT_ID,
105 DT_IDREF,
106 DT_IDREFS,
107 DT_INT,
108 DT_NMTOKEN,
109 DT_NMTOKENS,
110 DT_NOTATION,
111 DT_NUMBER,
112 DT_R4,
113 DT_R8,
114 DT_STRING,
115 DT_TIME,
116 DT_TIME_TZ,
117 DT_UI1,
118 DT_UI2,
119 DT_UI4,
120 DT_UI8,
121 DT_URI,
122 DT_UUID
123 } XDR_DT;
124 #define DT__N_TYPES (DT_UUID+1)
126 extern HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
127 extern void release_typelib(void) DECLSPEC_HIDDEN;
129 typedef struct dispex_data_t dispex_data_t;
130 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
132 #define MSXML_DISPID_CUSTOM_MIN 0x60000000
133 #define MSXML_DISPID_CUSTOM_MAX 0x6fffffff
135 typedef struct {
136 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
137 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*);
138 } dispex_static_data_vtbl_t;
140 typedef struct {
141 const dispex_static_data_vtbl_t *vtbl;
142 const tid_t disp_tid;
143 dispex_data_t *data;
144 const tid_t* const iface_tids;
145 } dispex_static_data_t;
147 typedef struct {
148 IDispatchEx IDispatchEx_iface;
150 IUnknown *outer;
152 dispex_static_data_t *data;
153 dispex_dynamic_data_t *dynamic_data;
154 } DispatchEx;
156 extern HINSTANCE MSXML_hInstance DECLSPEC_HIDDEN;
158 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*) DECLSPEC_HIDDEN;
159 BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN;
161 /* memory allocation functions */
163 static inline void *heap_alloc(size_t len)
165 return HeapAlloc(GetProcessHeap(), 0, len);
168 static inline void *heap_alloc_zero(size_t len)
170 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
173 static inline void *heap_realloc(void *mem, size_t len)
175 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
178 static inline BOOL heap_free(void *mem)
180 return HeapFree(GetProcessHeap(), 0, mem);
183 static inline LPWSTR heap_strdupW(LPCWSTR str)
185 LPWSTR ret = NULL;
187 if(str) {
188 DWORD size;
190 size = (strlenW(str)+1)*sizeof(WCHAR);
191 ret = heap_alloc(size);
192 memcpy(ret, str, size);
195 return ret;
198 static inline LPSTR heap_strdupWtoA(LPCWSTR str)
200 LPSTR ret = NULL;
202 if(str) {
203 DWORD len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
204 ret = heap_alloc(len+1);
205 if(!ret)
206 return NULL;
208 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len+1, NULL, NULL);
211 return ret;
214 #ifdef HAVE_LIBXML2
216 extern void schemasInit(void) DECLSPEC_HIDDEN;
217 extern void schemasCleanup(void) DECLSPEC_HIDDEN;
219 #ifndef HAVE_XMLFIRSTELEMENTCHILD
220 static inline xmlNodePtr wine_xmlFirstElementChild(xmlNodePtr parent)
222 xmlNodePtr child;
223 for (child = parent->children; child != NULL; child = child->next)
224 if (child->type == XML_ELEMENT_NODE)
225 break;
227 return child;
229 #define xmlFirstElementChild wine_xmlFirstElementChild
230 #endif
232 /* constructors */
233 extern IUnknown *create_domdoc( xmlNodePtr ) DECLSPEC_HIDDEN;
234 extern IUnknown *create_xmldoc( void ) DECLSPEC_HIDDEN;
235 extern IXMLDOMNode *create_node( xmlNodePtr ) DECLSPEC_HIDDEN;
236 extern IUnknown *create_element( xmlNodePtr ) DECLSPEC_HIDDEN;
237 extern IUnknown *create_attribute( xmlNodePtr ) DECLSPEC_HIDDEN;
238 extern IUnknown *create_text( xmlNodePtr ) DECLSPEC_HIDDEN;
239 extern IUnknown *create_pi( xmlNodePtr ) DECLSPEC_HIDDEN;
240 extern IUnknown *create_comment( xmlNodePtr ) DECLSPEC_HIDDEN;
241 extern IUnknown *create_cdata( xmlNodePtr ) DECLSPEC_HIDDEN;
242 extern IXMLDOMNodeList *create_children_nodelist( xmlNodePtr ) DECLSPEC_HIDDEN;
243 extern IXMLDOMNamedNodeMap *create_nodemap( const xmlNodePtr ) DECLSPEC_HIDDEN;
244 extern IUnknown *create_doc_Implementation(void) DECLSPEC_HIDDEN;
245 extern IUnknown *create_doc_fragment( xmlNodePtr ) DECLSPEC_HIDDEN;
246 extern IUnknown *create_doc_entity_ref( xmlNodePtr ) DECLSPEC_HIDDEN;
247 extern IUnknown *create_doc_type( xmlNodePtr ) DECLSPEC_HIDDEN;
248 extern HRESULT create_selection( xmlNodePtr, xmlChar*, IXMLDOMNodeList** ) DECLSPEC_HIDDEN;
250 /* data accessors */
251 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type ) DECLSPEC_HIDDEN;
253 /* helpers */
254 extern xmlChar *xmlChar_from_wchar( LPCWSTR str ) DECLSPEC_HIDDEN;
256 extern void xmldoc_init( xmlDocPtr doc, MSXML_VERSION version ) DECLSPEC_HIDDEN;
257 extern LONG xmldoc_add_ref( xmlDocPtr doc ) DECLSPEC_HIDDEN;
258 extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN;
259 extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
260 extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
261 extern void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node) DECLSPEC_HIDDEN;
262 extern xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc) DECLSPEC_HIDDEN;
264 extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own ) DECLSPEC_HIDDEN;
266 extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap) DECLSPEC_HIDDEN;
267 extern void wineXmlCallbackError(char const* caller, xmlErrorPtr err) DECLSPEC_HIDDEN;
269 #define LIBXML2_LOG_CALLBACK __WINE_PRINTF_ATTR(2,3)
271 #define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
272 wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
274 #define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
275 wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
277 #define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
278 wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
280 #define LIBXML2_CALLBACK_SERROR(caller, err) wineXmlCallbackError(#caller, err)
282 extern BOOL is_preserving_whitespace(xmlNodePtr node) DECLSPEC_HIDDEN;
283 extern BOOL is_xpathmode(const xmlDocPtr doc) DECLSPEC_HIDDEN;
284 extern void set_xpathmode(xmlDocPtr doc, BOOL xpath) DECLSPEC_HIDDEN;
286 /* IXMLDOMNode Internal Structure */
287 typedef struct _xmlnode
289 DispatchEx dispex;
290 IXMLDOMNode *iface;
291 IXMLDOMNode *parent;
292 xmlNodePtr node;
293 } xmlnode;
295 extern void init_xmlnode(xmlnode*,xmlNodePtr,IXMLDOMNode*,dispex_static_data_t*) DECLSPEC_HIDDEN;
296 extern void destroy_xmlnode(xmlnode*) DECLSPEC_HIDDEN;
297 extern BOOL node_query_interface(xmlnode*,REFIID,void**) DECLSPEC_HIDDEN;
298 extern xmlnode *get_node_obj(IXMLDOMNode*) DECLSPEC_HIDDEN;
300 extern HRESULT node_append_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
301 extern HRESULT node_get_nodeName(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
302 extern HRESULT node_get_content(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
303 extern HRESULT node_set_content(xmlnode*,LPCWSTR) DECLSPEC_HIDDEN;
304 extern HRESULT node_put_value(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
305 extern HRESULT node_put_value_escaped(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
306 extern HRESULT node_get_parent(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
307 extern HRESULT node_get_child_nodes(xmlnode*,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
308 extern HRESULT node_get_first_child(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
309 extern HRESULT node_get_last_child(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
310 extern HRESULT node_get_previous_sibling(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
311 extern HRESULT node_get_next_sibling(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
312 extern HRESULT node_insert_before(xmlnode*,IXMLDOMNode*,const VARIANT*,IXMLDOMNode**) DECLSPEC_HIDDEN;
313 extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
314 extern HRESULT node_put_text(xmlnode*,BSTR) DECLSPEC_HIDDEN;
315 extern HRESULT node_get_xml(xmlnode*,BOOL,BOOL,BSTR*) DECLSPEC_HIDDEN;
316 extern HRESULT node_clone(xmlnode*,VARIANT_BOOL,IXMLDOMNode**) DECLSPEC_HIDDEN;
317 extern HRESULT node_get_prefix(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
318 extern HRESULT node_get_base_name(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
319 extern HRESULT node_get_namespaceURI(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
320 extern HRESULT node_remove_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
321 extern HRESULT node_has_childnodes(const xmlnode*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
322 extern HRESULT node_get_owner_doc(const xmlnode*,IXMLDOMDocument**) DECLSPEC_HIDDEN;
323 extern HRESULT node_get_text(const xmlnode*,BSTR*) DECLSPEC_HIDDEN;
324 extern HRESULT node_select_nodes(const xmlnode*,BSTR,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
325 extern HRESULT node_select_singlenode(const xmlnode*,BSTR,IXMLDOMNode**) DECLSPEC_HIDDEN;
326 extern HRESULT node_transform_node(const xmlnode*,IXMLDOMNode*,BSTR*) DECLSPEC_HIDDEN;
328 extern HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document) DECLSPEC_HIDDEN;
330 extern HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2* iface, xmlNodePtr tree) DECLSPEC_HIDDEN;
331 extern XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node) DECLSPEC_HIDDEN;
333 extern XDR_DT str_to_dt(xmlChar const* str, int len /* calculated if -1 */) DECLSPEC_HIDDEN;
334 extern XDR_DT bstr_to_dt(OLECHAR const* bstr, int len /* calculated if -1 */) DECLSPEC_HIDDEN;
335 extern xmlChar const* dt_to_str(XDR_DT dt) DECLSPEC_HIDDEN;
336 extern const char* debugstr_dt(XDR_DT dt) DECLSPEC_HIDDEN;
337 extern OLECHAR const* dt_to_bstr(XDR_DT dt) DECLSPEC_HIDDEN;
338 extern HRESULT dt_validate(XDR_DT dt, xmlChar const* content) DECLSPEC_HIDDEN;
340 extern BSTR EnsureCorrectEOL(BSTR) DECLSPEC_HIDDEN;
342 extern xmlChar* tagName_to_XPath(const BSTR tagName) DECLSPEC_HIDDEN;
344 static inline BSTR bstr_from_xmlChar(const xmlChar *str)
346 BSTR ret = NULL;
348 if(str) {
349 DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0);
350 ret = SysAllocStringLen(NULL, len-1);
351 if(ret)
352 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len);
354 else
355 ret = SysAllocStringLen(NULL, 0);
357 return ret;
360 static inline HRESULT return_bstr(const WCHAR *value, BSTR *p)
362 if(!p)
363 return E_INVALIDARG;
365 if(value) {
366 *p = SysAllocString(value);
367 if(!*p)
368 return E_OUTOFMEMORY;
369 }else {
370 *p = NULL;
373 return S_OK;
376 static inline HRESULT return_null_node(IXMLDOMNode **p)
378 if(!p)
379 return E_INVALIDARG;
380 *p = NULL;
381 return S_FALSE;
384 static inline HRESULT return_null_ptr(void **p)
386 if(!p)
387 return E_INVALIDARG;
388 *p = NULL;
389 return S_FALSE;
392 static inline HRESULT return_null_var(VARIANT *p)
394 if(!p)
395 return E_INVALIDARG;
397 V_VT(p) = VT_NULL;
398 return S_FALSE;
401 static inline HRESULT return_null_bstr(BSTR *p)
403 if(!p)
404 return E_INVALIDARG;
406 *p = NULL;
407 return S_FALSE;
410 static inline xmlChar *xmlchar_from_wcharn(const WCHAR *str, int nchars)
412 xmlChar *xmlstr;
413 DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, nchars, NULL, 0, NULL, NULL );
415 xmlstr = heap_alloc( len+1 );
416 if ( xmlstr )
418 WideCharToMultiByte( CP_UTF8, 0, str, nchars, (LPSTR) xmlstr, len+1, NULL, NULL );
419 xmlstr[len] = 0;
421 return xmlstr;
424 static inline xmlChar *xmlchar_from_wchar( const WCHAR *str )
426 return xmlchar_from_wcharn(str, -1);
429 #endif
431 extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
432 LONG line, LONG linepos, LONG filepos ) DECLSPEC_HIDDEN;
433 extern HRESULT DOMDocument_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
434 extern HRESULT SchemaCache_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
435 extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN;
436 extern HRESULT SAXXMLReader_create(IUnknown*, void**) DECLSPEC_HIDDEN;
437 extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN;
438 extern HRESULT XSLTemplate_create(IUnknown*, void**) DECLSPEC_HIDDEN;
439 extern HRESULT MXWriter_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
440 extern HRESULT MXNamespaceManager_create(IUnknown*,void**) DECLSPEC_HIDDEN;
441 extern HRESULT XMLParser_create(IUnknown*,void**) DECLSPEC_HIDDEN;
443 static inline const CLSID* DOMDocument_version(MSXML_VERSION v)
445 switch (v)
447 default:
448 case MSXML_DEFAULT: return &CLSID_DOMDocument;
449 case MSXML3: return &CLSID_DOMDocument30;
450 case MSXML4: return &CLSID_DOMDocument40;
451 case MSXML6: return &CLSID_DOMDocument60;
455 static inline const CLSID* SchemaCache_version(MSXML_VERSION v)
457 switch (v)
459 default:
460 case MSXML_DEFAULT: return &CLSID_XMLSchemaCache;
461 case MSXML3: return &CLSID_XMLSchemaCache30;
462 case MSXML4: return &CLSID_XMLSchemaCache40;
463 case MSXML6: return &CLSID_XMLSchemaCache60;
467 typedef struct bsc_t bsc_t;
469 HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**) DECLSPEC_HIDDEN;
470 void detach_bsc(bsc_t*) DECLSPEC_HIDDEN;
472 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
474 /* Error Codes - not defined anywhere in the public headers */
475 #define E_XML_ELEMENT_UNDECLARED 0xC00CE00D
476 #define E_XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E
477 /* ... */
478 #define E_XML_EMPTY_NOT_ALLOWED 0xC00CE011
479 #define E_XML_ELEMENT_NOT_COMPLETE 0xC00CE012
480 #define E_XML_ROOT_NAME_MISMATCH 0xC00CE013
481 #define E_XML_INVALID_CONTENT 0xC00CE014
482 #define E_XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015
483 #define E_XML_ATTRIBUTE_FIXED 0xC00CE016
484 #define E_XML_ATTRIBUTE_VALUE 0xC00CE017
485 #define E_XML_ILLEGAL_TEXT 0xC00CE018
486 /* ... */
487 #define E_XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020
489 #endif /* __MSXML_PRIVATE__ */