xref: /reactos/dll/win32/msxml3/msxml_private.h (revision 9f0f6adf)
1 /*
2  *    Common definitions
3  *
4  * Copyright 2005 Mike McCormack
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #ifndef __MSXML_PRIVATE__
22 #define __MSXML_PRIVATE__
23 
24 #include "dispex.h"
25 
26 #include "wine/unicode.h"
27 #include "wine/heap.h"
28 #include "wine/list.h"
29 
30 #ifndef __WINE_CONFIG_H
31 # error You must include config.h to use this header
32 #endif
33 
34 typedef enum {
35     MSXML_DEFAULT = 0,
36     MSXML2        = 20,
37     MSXML26       = 26,
38     MSXML3        = 30,
39     MSXML4        = 40,
40     MSXML6        = 60
41 } MSXML_VERSION;
42 
43 /* typelibs */
44 typedef enum tid_t {
45     NULL_tid,
46     IXMLDOMAttribute_tid,
47     IXMLDOMCDATASection_tid,
48     IXMLDOMComment_tid,
49     IXMLDOMDocument_tid,
50     IXMLDOMDocument2_tid,
51     IXMLDOMDocument3_tid,
52     IXMLDOMDocumentFragment_tid,
53     IXMLDOMDocumentType_tid,
54     IXMLDOMElement_tid,
55     IXMLDOMEntityReference_tid,
56     IXMLDOMImplementation_tid,
57     IXMLDOMNamedNodeMap_tid,
58     IXMLDOMNode_tid,
59     IXMLDOMNodeList_tid,
60     IXMLDOMParseError2_tid,
61     IXMLDOMProcessingInstruction_tid,
62     IXMLDOMSchemaCollection_tid,
63     IXMLDOMSchemaCollection2_tid,
64     IXMLDOMSelection_tid,
65     IXMLDOMText_tid,
66     IXMLElement_tid,
67     IXMLDocument_tid,
68     IXMLHTTPRequest_tid,
69     IXSLProcessor_tid,
70     IXSLTemplate_tid,
71     IVBSAXAttributes_tid,
72     IVBSAXContentHandler_tid,
73     IVBSAXDeclHandler_tid,
74     IVBSAXDTDHandler_tid,
75     IVBSAXEntityResolver_tid,
76     IVBSAXErrorHandler_tid,
77     IVBSAXLexicalHandler_tid,
78     IVBSAXLocator_tid,
79     IVBSAXXMLFilter_tid,
80     IVBSAXXMLReader_tid,
81     IMXAttributes_tid,
82     IMXReaderControl_tid,
83     IMXWriter_tid,
84     IVBMXNamespaceManager_tid,
85     IServerXMLHTTPRequest_tid,
86     LAST_tid
87 } tid_t;
88 
89 /* The XDR datatypes (urn:schemas-microsoft-com:datatypes)
90  * These are actually valid for XSD schemas as well
91  * See datatypes.xsd
92  */
93 typedef enum _XDR_DT {
94     DT_INVALID = -1,
95     DT_BIN_BASE64,
96     DT_BIN_HEX,
97     DT_BOOLEAN,
98     DT_CHAR,
99     DT_DATE,
100     DT_DATE_TZ,
101     DT_DATETIME,
102     DT_DATETIME_TZ,
103     DT_ENTITY,
104     DT_ENTITIES,
105     DT_ENUMERATION,
106     DT_FIXED_14_4,
107     DT_FLOAT,
108     DT_I1,
109     DT_I2,
110     DT_I4,
111     DT_I8,
112     DT_ID,
113     DT_IDREF,
114     DT_IDREFS,
115     DT_INT,
116     DT_NMTOKEN,
117     DT_NMTOKENS,
118     DT_NOTATION,
119     DT_NUMBER,
120     DT_R4,
121     DT_R8,
122     DT_STRING,
123     DT_TIME,
124     DT_TIME_TZ,
125     DT_UI1,
126     DT_UI2,
127     DT_UI4,
128     DT_UI8,
129     DT_URI,
130     DT_UUID,
131     LAST_DT
132 } XDR_DT;
133 
134 extern HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
135 extern void release_typelib(void) DECLSPEC_HIDDEN;
136 
137 typedef struct dispex_data_t dispex_data_t;
138 
139 typedef struct {
140     HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
141     HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*);
142 } dispex_static_data_vtbl_t;
143 
144 typedef struct {
145     const dispex_static_data_vtbl_t *vtbl;
146     const tid_t disp_tid;
147     dispex_data_t *data;
148     const tid_t* const iface_tids;
149 } dispex_static_data_t;
150 
151 typedef struct {
152     IDispatchEx IDispatchEx_iface;
153 
154     IUnknown *outer;
155 
156     dispex_static_data_t *data;
157 } DispatchEx;
158 
159 extern HINSTANCE MSXML_hInstance DECLSPEC_HIDDEN;
160 
161 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*) DECLSPEC_HIDDEN;
162 void release_dispex(DispatchEx*) DECLSPEC_HIDDEN;
163 BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN;
164 const IID *get_riid_from_tid(enum tid_t tid) DECLSPEC_HIDDEN;
165 
166 /* memory allocation functions */
167 
heap_realloc_zero(void * mem,size_t size)168 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t size)
169 {
170     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size);
171 }
172 
heap_strdupW(LPCWSTR str)173 static inline LPWSTR heap_strdupW(LPCWSTR str)
174 {
175     LPWSTR ret = NULL;
176 
177     if(str) {
178         DWORD size;
179 
180         size = (strlenW(str)+1)*sizeof(WCHAR);
181         ret = heap_alloc(size);
182         if(ret)
183             memcpy(ret, str, size);
184     }
185 
186     return ret;
187 }
188 
189 /* XSLProcessor parameter list */
190 struct xslprocessor_par
191 {
192     struct list entry;
193     BSTR name;
194     BSTR value;
195 };
196 
197 struct xslprocessor_params
198 {
199     struct list  list;
200     unsigned int count;
201 };
202 
203 #ifdef HAVE_LIBXML2
204 
205 extern void schemasInit(void) DECLSPEC_HIDDEN;
206 extern void schemasCleanup(void) DECLSPEC_HIDDEN;
207 
208 #ifndef HAVE_XMLFIRSTELEMENTCHILD
wine_xmlFirstElementChild(xmlNodePtr parent)209 static inline xmlNodePtr wine_xmlFirstElementChild(xmlNodePtr parent)
210 {
211     xmlNodePtr child;
212     for (child = parent->children; child != NULL; child = child->next)
213         if (child->type == XML_ELEMENT_NODE)
214             break;
215 
216     return child;
217 }
218 #define xmlFirstElementChild wine_xmlFirstElementChild
219 #endif
220 
221 /* IXMLDOMNode Internal Structure */
222 typedef struct _xmlnode
223 {
224     DispatchEx   dispex;
225     IXMLDOMNode *iface;
226     IXMLDOMNode *parent;
227     xmlNodePtr   node;
228 } xmlnode;
229 
230 /* IXMLDOMNamedNodeMap custom function table */
231 struct nodemap_funcs
232 {
233     HRESULT (*get_named_item)(const xmlNodePtr,BSTR,IXMLDOMNode**);
234     HRESULT (*set_named_item)(xmlNodePtr,IXMLDOMNode*,IXMLDOMNode**);
235     HRESULT (*remove_named_item)(xmlNodePtr,BSTR,IXMLDOMNode**);
236     HRESULT (*get_item)(xmlNodePtr,LONG,IXMLDOMNode**);
237     HRESULT (*get_length)(xmlNodePtr,LONG*);
238     HRESULT (*get_qualified_item)(const xmlNodePtr,BSTR,BSTR,IXMLDOMNode**);
239     HRESULT (*remove_qualified_item)(xmlNodePtr,BSTR,BSTR,IXMLDOMNode**);
240     HRESULT (*next_node)(const xmlNodePtr,LONG*,IXMLDOMNode**);
241 };
242 
243 /* used by IEnumVARIANT to access outer object items */
244 struct enumvariant_funcs
245 {
246     HRESULT (*get_item)(IUnknown*, LONG, VARIANT*);
247     HRESULT (*next)(IUnknown*);
248 };
249 
250 /* constructors */
251 extern IUnknown         *create_domdoc( xmlNodePtr ) DECLSPEC_HIDDEN;
252 extern IUnknown         *create_xmldoc( void ) DECLSPEC_HIDDEN;
253 extern IXMLDOMNode      *create_node( xmlNodePtr ) DECLSPEC_HIDDEN;
254 extern IUnknown         *create_element( xmlNodePtr ) DECLSPEC_HIDDEN;
255 extern IUnknown         *create_attribute( xmlNodePtr, BOOL ) DECLSPEC_HIDDEN;
256 extern IUnknown         *create_text( xmlNodePtr ) DECLSPEC_HIDDEN;
257 extern IUnknown         *create_pi( xmlNodePtr ) DECLSPEC_HIDDEN;
258 extern IUnknown         *create_comment( xmlNodePtr ) DECLSPEC_HIDDEN;
259 extern IUnknown         *create_cdata( xmlNodePtr ) DECLSPEC_HIDDEN;
260 extern IXMLDOMNodeList  *create_children_nodelist( xmlNodePtr ) DECLSPEC_HIDDEN;
261 extern IXMLDOMNamedNodeMap *create_nodemap( xmlNodePtr, const struct nodemap_funcs* ) DECLSPEC_HIDDEN;
262 extern IUnknown         *create_doc_Implementation(void) DECLSPEC_HIDDEN;
263 extern IUnknown         *create_doc_fragment( xmlNodePtr ) DECLSPEC_HIDDEN;
264 extern IUnknown         *create_doc_entity_ref( xmlNodePtr ) DECLSPEC_HIDDEN;
265 extern IUnknown         *create_doc_type( xmlNodePtr ) DECLSPEC_HIDDEN;
266 extern HRESULT           create_selection( xmlNodePtr, xmlChar*, IXMLDOMNodeList** ) DECLSPEC_HIDDEN;
267 extern HRESULT           create_enumvariant( IUnknown*, BOOL, const struct enumvariant_funcs*, IEnumVARIANT**) DECLSPEC_HIDDEN;
268 
269 /* data accessors */
270 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type ) DECLSPEC_HIDDEN;
271 
272 /* helpers */
273 extern xmlChar *xmlChar_from_wchar( LPCWSTR str ) DECLSPEC_HIDDEN;
274 
275 extern void xmldoc_init( xmlDocPtr doc, MSXML_VERSION version ) DECLSPEC_HIDDEN;
276 extern LONG xmldoc_add_ref( xmlDocPtr doc ) DECLSPEC_HIDDEN;
277 extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN;
278 extern LONG xmldoc_add_refs( xmlDocPtr doc, LONG refs ) DECLSPEC_HIDDEN;
279 extern LONG xmldoc_release_refs ( xmlDocPtr doc, LONG refs ) DECLSPEC_HIDDEN;
280 extern void xmlnode_add_ref(xmlNodePtr node) DECLSPEC_HIDDEN;
281 extern void xmlnode_release(xmlNodePtr node) DECLSPEC_HIDDEN;
282 extern int xmlnode_get_inst_cnt( xmlnode *node ) DECLSPEC_HIDDEN;
283 extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
284 extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
285 extern void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node) DECLSPEC_HIDDEN;
286 extern xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc) DECLSPEC_HIDDEN;
287 extern MSXML_VERSION xmldoc_version( xmlDocPtr doc ) DECLSPEC_HIDDEN;
288 
289 extern HRESULT XMLElement_create( xmlNodePtr node, LPVOID *ppObj, BOOL own ) DECLSPEC_HIDDEN;
290 
291 extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap) DECLSPEC_HIDDEN;
292 extern void wineXmlCallbackError(char const* caller, xmlErrorPtr err) DECLSPEC_HIDDEN;
293 
294 #define LIBXML2_LOG_CALLBACK __WINE_PRINTF_ATTR(2,3)
295 
296 #define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
297         wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
298 
299 #define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
300         wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
301 
302 #define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
303         wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
304 
305 #define LIBXML2_CALLBACK_SERROR(caller, err) wineXmlCallbackError(#caller, err)
306 
307 extern BOOL is_preserving_whitespace(xmlNodePtr node) DECLSPEC_HIDDEN;
308 extern BOOL is_xpathmode(const xmlDocPtr doc) DECLSPEC_HIDDEN;
309 extern void set_xpathmode(xmlDocPtr doc, BOOL xpath) DECLSPEC_HIDDEN;
310 
311 extern void init_xmlnode(xmlnode*,xmlNodePtr,IXMLDOMNode*,dispex_static_data_t*) DECLSPEC_HIDDEN;
312 extern void destroy_xmlnode(xmlnode*) DECLSPEC_HIDDEN;
313 extern BOOL node_query_interface(xmlnode*,REFIID,void**) DECLSPEC_HIDDEN;
314 extern xmlnode *get_node_obj(IXMLDOMNode*) DECLSPEC_HIDDEN;
315 
316 extern HRESULT node_append_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
317 extern HRESULT node_get_nodeName(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
318 extern HRESULT node_get_content(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
319 extern HRESULT node_set_content(xmlnode*,LPCWSTR) DECLSPEC_HIDDEN;
320 extern HRESULT node_put_value(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
321 extern HRESULT node_put_value_escaped(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
322 extern HRESULT node_get_parent(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
323 extern HRESULT node_get_child_nodes(xmlnode*,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
324 extern HRESULT node_get_first_child(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
325 extern HRESULT node_get_last_child(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
326 extern HRESULT node_get_previous_sibling(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
327 extern HRESULT node_get_next_sibling(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
328 extern HRESULT node_insert_before(xmlnode*,IXMLDOMNode*,const VARIANT*,IXMLDOMNode**) DECLSPEC_HIDDEN;
329 extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
330 extern HRESULT node_put_text(xmlnode*,BSTR) DECLSPEC_HIDDEN;
331 extern HRESULT node_get_xml(xmlnode*,BOOL,BSTR*) DECLSPEC_HIDDEN;
332 extern HRESULT node_clone(xmlnode*,VARIANT_BOOL,IXMLDOMNode**) DECLSPEC_HIDDEN;
333 extern HRESULT node_get_prefix(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
334 extern HRESULT node_get_base_name(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
335 extern HRESULT node_get_namespaceURI(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
336 extern HRESULT node_remove_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
337 extern HRESULT node_has_childnodes(const xmlnode*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
338 extern HRESULT node_get_owner_doc(const xmlnode*,IXMLDOMDocument**) DECLSPEC_HIDDEN;
339 extern HRESULT node_get_text(const xmlnode*,BSTR*) DECLSPEC_HIDDEN;
340 extern HRESULT node_select_nodes(const xmlnode*,BSTR,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
341 extern HRESULT node_select_singlenode(const xmlnode*,BSTR,IXMLDOMNode**) DECLSPEC_HIDDEN;
342 extern HRESULT node_transform_node(const xmlnode*,IXMLDOMNode*,BSTR*) DECLSPEC_HIDDEN;
343 extern HRESULT node_transform_node_params(const xmlnode*,IXMLDOMNode*,BSTR*,ISequentialStream*,
344     const struct xslprocessor_params*) DECLSPEC_HIDDEN;
345 extern HRESULT node_create_supporterrorinfo(const tid_t*,void**) DECLSPEC_HIDDEN;
346 
347 extern HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document) DECLSPEC_HIDDEN;
348 
349 extern HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2*, xmlNodePtr) DECLSPEC_HIDDEN;
350 extern XDR_DT  SchemaCache_get_node_dt(IXMLDOMSchemaCollection2*, xmlNodePtr) DECLSPEC_HIDDEN;
351 extern HRESULT cache_from_doc_ns(IXMLDOMSchemaCollection2*, xmlnode*) DECLSPEC_HIDDEN;
352 
353 extern XDR_DT str_to_dt(xmlChar const* str, int len /* calculated if -1 */) DECLSPEC_HIDDEN;
354 extern XDR_DT bstr_to_dt(OLECHAR const* bstr, int len /* calculated if -1 */) DECLSPEC_HIDDEN;
355 extern xmlChar const* dt_to_str(XDR_DT dt) DECLSPEC_HIDDEN;
356 extern const char* debugstr_dt(XDR_DT dt) DECLSPEC_HIDDEN;
357 extern OLECHAR const* dt_to_bstr(XDR_DT dt) DECLSPEC_HIDDEN;
358 extern HRESULT dt_validate(XDR_DT dt, xmlChar const* content) DECLSPEC_HIDDEN;
359 
360 extern BSTR EnsureCorrectEOL(BSTR) DECLSPEC_HIDDEN;
361 
362 extern xmlChar* tagName_to_XPath(const BSTR tagName) DECLSPEC_HIDDEN;
363 
364 #ifdef SONAME_LIBXSLT
365 #  include <libxslt/documents.h>
366 extern xmlDocPtr xslt_doc_default_loader(const xmlChar *uri, xmlDictPtr dict, int options,
367     void *_ctxt, xsltLoadType type) DECLSPEC_HIDDEN;
368 #endif /* SONAME_LIBXSLT */
369 
bstr_from_xmlChar(const xmlChar * str)370 static inline BSTR bstr_from_xmlChar(const xmlChar *str)
371 {
372     BSTR ret = NULL;
373 
374     if(str) {
375         DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0);
376         ret = SysAllocStringLen(NULL, len-1);
377         if(ret)
378             MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len);
379     }
380     else
381         ret = SysAllocStringLen(NULL, 0);
382 
383     return ret;
384 }
385 
xmlchar_from_wcharn(const WCHAR * str,int nchars,BOOL use_xml_alloc)386 static inline xmlChar *xmlchar_from_wcharn(const WCHAR *str, int nchars, BOOL use_xml_alloc)
387 {
388     xmlChar *xmlstr;
389     DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, nchars, NULL, 0, NULL, NULL );
390 
391     xmlstr = use_xml_alloc ? xmlMalloc( len + 1 ) : heap_alloc( len + 1 );
392     if ( xmlstr )
393     {
394         WideCharToMultiByte( CP_UTF8, 0, str, nchars, (LPSTR) xmlstr, len+1, NULL, NULL );
395         xmlstr[len] = 0;
396     }
397     return xmlstr;
398 }
399 
xmlchar_from_wchar(const WCHAR * str)400 static inline xmlChar *xmlchar_from_wchar( const WCHAR *str )
401 {
402     return xmlchar_from_wcharn(str, -1, FALSE);
403 }
404 
heap_strdupxmlChar(const xmlChar * str)405 static inline xmlChar *heap_strdupxmlChar(const xmlChar *str)
406 {
407     xmlChar *ret = NULL;
408 
409     if(str) {
410         DWORD size;
411 
412         size = (xmlStrlen(str)+1)*sizeof(xmlChar);
413         ret = heap_alloc(size);
414         memcpy(ret, str, size);
415     }
416 
417     return ret;
418 }
419 
420 #endif
421 
return_bstr(const WCHAR * value,BSTR * p)422 static inline HRESULT return_bstr(const WCHAR *value, BSTR *p)
423 {
424     if(!p)
425         return E_INVALIDARG;
426 
427     if(value) {
428         *p = SysAllocString(value);
429         if(!*p)
430             return E_OUTOFMEMORY;
431     }else {
432         *p = NULL;
433     }
434 
435     return S_OK;
436 }
437 
return_bstrn(const WCHAR * value,int len,BSTR * p)438 static inline HRESULT return_bstrn(const WCHAR *value, int len, BSTR *p)
439 {
440     if(value) {
441         *p = SysAllocStringLen(value, len);
442         if(!*p)
443             return E_OUTOFMEMORY;
444     }else
445         *p = NULL;
446 
447     return S_OK;
448 }
449 
return_null_node(IXMLDOMNode ** p)450 static inline HRESULT return_null_node(IXMLDOMNode **p)
451 {
452     if(!p)
453         return E_INVALIDARG;
454     *p = NULL;
455     return S_FALSE;
456 }
457 
return_null_ptr(void ** p)458 static inline HRESULT return_null_ptr(void **p)
459 {
460     if(!p)
461         return E_INVALIDARG;
462     *p = NULL;
463     return S_FALSE;
464 }
465 
return_null_var(VARIANT * p)466 static inline HRESULT return_null_var(VARIANT *p)
467 {
468     if(!p)
469         return E_INVALIDARG;
470 
471     V_VT(p) = VT_NULL;
472     return S_FALSE;
473 }
474 
return_null_bstr(BSTR * p)475 static inline HRESULT return_null_bstr(BSTR *p)
476 {
477     if(!p)
478         return E_INVALIDARG;
479 
480     *p = NULL;
481     return S_FALSE;
482 }
483 
return_var_false(VARIANT_BOOL * p)484 static inline HRESULT return_var_false(VARIANT_BOOL *p)
485 {
486     if(!p)
487         return E_INVALIDARG;
488 
489     *p = VARIANT_FALSE;
490     return S_FALSE;
491 }
492 
493 extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
494                                              LONG line, LONG linepos, LONG filepos ) DECLSPEC_HIDDEN;
495 extern HRESULT DOMDocument_create(MSXML_VERSION, void**) DECLSPEC_HIDDEN;
496 extern HRESULT SchemaCache_create(MSXML_VERSION, void**) DECLSPEC_HIDDEN;
497 extern HRESULT XMLDocument_create(void**) DECLSPEC_HIDDEN;
498 extern HRESULT SAXXMLReader_create(MSXML_VERSION, void**) DECLSPEC_HIDDEN;
499 extern HRESULT SAXAttributes_create(MSXML_VERSION, void**) DECLSPEC_HIDDEN;
500 extern HRESULT XMLHTTPRequest_create(void **) DECLSPEC_HIDDEN;
501 extern HRESULT ServerXMLHTTP_create(void **) DECLSPEC_HIDDEN;
502 extern HRESULT XSLTemplate_create(void**) DECLSPEC_HIDDEN;
503 extern HRESULT MXWriter_create(MSXML_VERSION, void**) DECLSPEC_HIDDEN;
504 extern HRESULT MXNamespaceManager_create(void**) DECLSPEC_HIDDEN;
505 extern HRESULT XMLParser_create(void**) DECLSPEC_HIDDEN;
506 extern HRESULT XMLView_create(void**) DECLSPEC_HIDDEN;
507 
DOMDocument_version(MSXML_VERSION v)508 static inline const CLSID* DOMDocument_version(MSXML_VERSION v)
509 {
510     switch (v)
511     {
512     default:
513     case MSXML_DEFAULT: return &CLSID_DOMDocument;
514     case MSXML3: return &CLSID_DOMDocument30;
515     case MSXML4: return &CLSID_DOMDocument40;
516     case MSXML6: return &CLSID_DOMDocument60;
517     }
518 }
519 
SchemaCache_version(MSXML_VERSION v)520 static inline const CLSID* SchemaCache_version(MSXML_VERSION v)
521 {
522     switch (v)
523     {
524     default:
525     case MSXML_DEFAULT: return &CLSID_XMLSchemaCache;
526     case MSXML3: return &CLSID_XMLSchemaCache30;
527     case MSXML4: return &CLSID_XMLSchemaCache40;
528     case MSXML6: return &CLSID_XMLSchemaCache60;
529     }
530 }
531 
532 typedef struct bsc_t bsc_t;
533 
534 HRESULT create_moniker_from_url(LPCWSTR, IMoniker**) DECLSPEC_HIDDEN;
535 HRESULT create_uri(const WCHAR *, IUri **) DECLSPEC_HIDDEN;
536 HRESULT bind_url(IMoniker*, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**) DECLSPEC_HIDDEN;
537 HRESULT detach_bsc(bsc_t*) DECLSPEC_HIDDEN;
538 
539 /* Error Codes - not defined anywhere in the public headers */
540 #define E_XML_ELEMENT_UNDECLARED            0xC00CE00D
541 #define E_XML_ELEMENT_ID_NOT_FOUND          0xC00CE00E
542 /* ... */
543 #define E_XML_EMPTY_NOT_ALLOWED             0xC00CE011
544 #define E_XML_ELEMENT_NOT_COMPLETE          0xC00CE012
545 #define E_XML_ROOT_NAME_MISMATCH            0xC00CE013
546 #define E_XML_INVALID_CONTENT               0xC00CE014
547 #define E_XML_ATTRIBUTE_NOT_DEFINED         0xC00CE015
548 #define E_XML_ATTRIBUTE_FIXED               0xC00CE016
549 #define E_XML_ATTRIBUTE_VALUE               0xC00CE017
550 #define E_XML_ILLEGAL_TEXT                  0xC00CE018
551 /* ... */
552 #define E_XML_REQUIRED_ATTRIBUTE_MISSING    0xC00CE020
553 
554 #define NODE_PRIV_TRAILING_IGNORABLE_WS     0x40000000
555 #define NODE_PRIV_CHILD_IGNORABLE_WS        0x80000000
556 #define NODE_PRIV_REFCOUNT_MASK             ~(NODE_PRIV_TRAILING_IGNORABLE_WS|NODE_PRIV_CHILD_IGNORABLE_WS)
557 #endif /* __MSXML_PRIVATE__ */
558