include: Add the missing inaddr.h and in6addr.h include directives.
[wine.git] / dlls / msxml3 / msxml_private.h
blobbb517a7e29daf2f159872e6089c4328cdd9e7279
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 NULL_tid,
42 IXMLDOMAttribute_tid,
43 IXMLDOMCDATASection_tid,
44 IXMLDOMComment_tid,
45 IXMLDOMDocument_tid,
46 IXMLDOMDocument2_tid,
47 IXMLDOMDocument3_tid,
48 IXMLDOMDocumentFragment_tid,
49 IXMLDOMDocumentType_tid,
50 IXMLDOMElement_tid,
51 IXMLDOMEntityReference_tid,
52 IXMLDOMImplementation_tid,
53 IXMLDOMNamedNodeMap_tid,
54 IXMLDOMNode_tid,
55 IXMLDOMNodeList_tid,
56 IXMLDOMParseError_tid,
57 IXMLDOMProcessingInstruction_tid,
58 IXMLDOMSchemaCollection_tid,
59 IXMLDOMSelection_tid,
60 IXMLDOMText_tid,
61 IXMLElement_tid,
62 IXMLDocument_tid,
63 IXMLHTTPRequest_tid,
64 IXSLProcessor_tid,
65 IXSLTemplate_tid,
66 IVBSAXAttributes_tid,
67 IVBSAXContentHandler_tid,
68 IVBSAXDeclHandler_tid,
69 IVBSAXDTDHandler_tid,
70 IVBSAXEntityResolver_tid,
71 IVBSAXErrorHandler_tid,
72 IVBSAXLexicalHandler_tid,
73 IVBSAXLocator_tid,
74 IVBSAXXMLFilter_tid,
75 IVBSAXXMLReader_tid,
76 IMXAttributes_tid,
77 IMXReaderControl_tid,
78 IMXWriter_tid,
79 IVBMXNamespaceManager_tid,
80 LAST_tid
81 } tid_t;
83 /* The XDR datatypes (urn:schemas-microsoft-com:datatypes)
84 * These are actually valid for XSD schemas as well
85 * See datatypes.xsd
87 typedef enum _XDR_DT {
88 DT_INVALID = -1,
89 DT_BIN_BASE64,
90 DT_BIN_HEX,
91 DT_BOOLEAN,
92 DT_CHAR,
93 DT_DATE,
94 DT_DATE_TZ,
95 DT_DATETIME,
96 DT_DATETIME_TZ,
97 DT_ENTITY,
98 DT_ENTITIES,
99 DT_ENUMERATION,
100 DT_FIXED_14_4,
101 DT_FLOAT,
102 DT_I1,
103 DT_I2,
104 DT_I4,
105 DT_I8,
106 DT_ID,
107 DT_IDREF,
108 DT_IDREFS,
109 DT_INT,
110 DT_NMTOKEN,
111 DT_NMTOKENS,
112 DT_NOTATION,
113 DT_NUMBER,
114 DT_R4,
115 DT_R8,
116 DT_STRING,
117 DT_TIME,
118 DT_TIME_TZ,
119 DT_UI1,
120 DT_UI2,
121 DT_UI4,
122 DT_UI8,
123 DT_URI,
124 DT_UUID
125 } XDR_DT;
126 #define DT__N_TYPES (DT_UUID+1)
128 extern HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
129 extern void release_typelib(void) DECLSPEC_HIDDEN;
131 typedef struct dispex_data_t dispex_data_t;
132 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
134 typedef struct {
135 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
136 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*);
137 } dispex_static_data_vtbl_t;
139 typedef struct {
140 const dispex_static_data_vtbl_t *vtbl;
141 const tid_t disp_tid;
142 dispex_data_t *data;
143 const tid_t* const iface_tids;
144 } dispex_static_data_t;
146 typedef struct {
147 IDispatchEx IDispatchEx_iface;
149 IUnknown *outer;
151 dispex_static_data_t *data;
152 dispex_dynamic_data_t *dynamic_data;
153 } DispatchEx;
155 extern HINSTANCE MSXML_hInstance DECLSPEC_HIDDEN;
157 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*) DECLSPEC_HIDDEN;
158 void release_dispex(DispatchEx*) DECLSPEC_HIDDEN;
159 BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN;
160 const IID *get_riid_from_tid(enum tid_t tid) DECLSPEC_HIDDEN;
162 /* memory allocation functions */
164 static inline void *heap_alloc(size_t len)
166 return HeapAlloc(GetProcessHeap(), 0, len);
169 static inline void *heap_alloc_zero(size_t len)
171 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
174 static inline void *heap_realloc(void *mem, size_t len)
176 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
179 static inline BOOL heap_free(void *mem)
181 return HeapFree(GetProcessHeap(), 0, mem);
184 static inline LPWSTR heap_strdupW(LPCWSTR str)
186 LPWSTR ret = NULL;
188 if(str) {
189 DWORD size;
191 size = (strlenW(str)+1)*sizeof(WCHAR);
192 ret = heap_alloc(size);
193 memcpy(ret, str, size);
196 return ret;
199 static inline LPSTR heap_strdupWtoA(LPCWSTR str)
201 LPSTR ret = NULL;
203 if(str) {
204 DWORD len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
205 ret = heap_alloc(len+1);
206 if(!ret)
207 return NULL;
209 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len+1, NULL, NULL);
212 return ret;
215 #ifdef HAVE_LIBXML2
217 extern void schemasInit(void) DECLSPEC_HIDDEN;
218 extern void schemasCleanup(void) DECLSPEC_HIDDEN;
220 #ifndef HAVE_XMLFIRSTELEMENTCHILD
221 static inline xmlNodePtr wine_xmlFirstElementChild(xmlNodePtr parent)
223 xmlNodePtr child;
224 for (child = parent->children; child != NULL; child = child->next)
225 if (child->type == XML_ELEMENT_NODE)
226 break;
228 return child;
230 #define xmlFirstElementChild wine_xmlFirstElementChild
231 #endif
233 /* IXMLDOMNode Internal Structure */
234 typedef struct _xmlnode
236 DispatchEx dispex;
237 IXMLDOMNode *iface;
238 IXMLDOMNode *parent;
239 xmlNodePtr node;
240 } xmlnode;
242 /* IXMLDOMNamedNodeMap custom function table */
243 struct nodemap_funcs
245 HRESULT (*get_named_item)(const xmlNodePtr,BSTR,IXMLDOMNode**);
246 HRESULT (*set_named_item)(xmlNodePtr,IXMLDOMNode*,IXMLDOMNode**);
247 HRESULT (*remove_named_item)(xmlNodePtr,BSTR,IXMLDOMNode**);
248 HRESULT (*get_item)(xmlNodePtr,LONG,IXMLDOMNode**);
249 HRESULT (*get_length)(xmlNodePtr,LONG*);
250 HRESULT (*get_qualified_item)(const xmlNodePtr,BSTR,BSTR,IXMLDOMNode**);
251 HRESULT (*remove_qualified_item)(xmlNodePtr,BSTR,BSTR,IXMLDOMNode**);
252 HRESULT (*next_node)(const xmlNodePtr,LONG*,IXMLDOMNode**);
255 /* constructors */
256 extern IUnknown *create_domdoc( xmlNodePtr ) DECLSPEC_HIDDEN;
257 extern IUnknown *create_xmldoc( void ) DECLSPEC_HIDDEN;
258 extern IXMLDOMNode *create_node( xmlNodePtr ) DECLSPEC_HIDDEN;
259 extern IUnknown *create_element( xmlNodePtr ) DECLSPEC_HIDDEN;
260 extern IUnknown *create_attribute( xmlNodePtr ) DECLSPEC_HIDDEN;
261 extern IUnknown *create_text( xmlNodePtr ) DECLSPEC_HIDDEN;
262 extern IUnknown *create_pi( xmlNodePtr ) DECLSPEC_HIDDEN;
263 extern IUnknown *create_comment( xmlNodePtr ) DECLSPEC_HIDDEN;
264 extern IUnknown *create_cdata( xmlNodePtr ) DECLSPEC_HIDDEN;
265 extern IXMLDOMNodeList *create_children_nodelist( xmlNodePtr ) DECLSPEC_HIDDEN;
266 extern IXMLDOMNamedNodeMap *create_nodemap( xmlNodePtr, const struct nodemap_funcs* ) DECLSPEC_HIDDEN;
267 extern IUnknown *create_doc_Implementation(void) DECLSPEC_HIDDEN;
268 extern IUnknown *create_doc_fragment( xmlNodePtr ) DECLSPEC_HIDDEN;
269 extern IUnknown *create_doc_entity_ref( xmlNodePtr ) DECLSPEC_HIDDEN;
270 extern IUnknown *create_doc_type( xmlNodePtr ) DECLSPEC_HIDDEN;
271 extern HRESULT create_selection( xmlNodePtr, xmlChar*, IXMLDOMNodeList** ) DECLSPEC_HIDDEN;
273 /* data accessors */
274 xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type ) DECLSPEC_HIDDEN;
276 /* helpers */
277 extern xmlChar *xmlChar_from_wchar( LPCWSTR str ) DECLSPEC_HIDDEN;
279 extern void xmldoc_init( xmlDocPtr doc, MSXML_VERSION version ) DECLSPEC_HIDDEN;
280 extern LONG xmldoc_add_ref( xmlDocPtr doc ) DECLSPEC_HIDDEN;
281 extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN;
282 extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
283 extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
284 extern void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node) DECLSPEC_HIDDEN;
285 extern xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc) DECLSPEC_HIDDEN;
287 extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own ) DECLSPEC_HIDDEN;
289 extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg, va_list ap) DECLSPEC_HIDDEN;
290 extern void wineXmlCallbackError(char const* caller, xmlErrorPtr err) DECLSPEC_HIDDEN;
292 #define LIBXML2_LOG_CALLBACK __WINE_PRINTF_ATTR(2,3)
294 #define LIBXML2_CALLBACK_TRACE(caller, msg, ap) \
295 wineXmlCallbackLog(#caller, XML_ERR_NONE, msg, ap)
297 #define LIBXML2_CALLBACK_WARN(caller, msg, ap) \
298 wineXmlCallbackLog(#caller, XML_ERR_WARNING, msg, ap)
300 #define LIBXML2_CALLBACK_ERR(caller, msg, ap) \
301 wineXmlCallbackLog(#caller, XML_ERR_ERROR, msg, ap)
303 #define LIBXML2_CALLBACK_SERROR(caller, err) wineXmlCallbackError(#caller, err)
305 extern BOOL is_preserving_whitespace(xmlNodePtr node) DECLSPEC_HIDDEN;
306 extern BOOL is_xpathmode(const xmlDocPtr doc) DECLSPEC_HIDDEN;
307 extern void set_xpathmode(xmlDocPtr doc, BOOL xpath) DECLSPEC_HIDDEN;
309 extern void init_xmlnode(xmlnode*,xmlNodePtr,IXMLDOMNode*,dispex_static_data_t*) DECLSPEC_HIDDEN;
310 extern void destroy_xmlnode(xmlnode*) DECLSPEC_HIDDEN;
311 extern BOOL node_query_interface(xmlnode*,REFIID,void**) DECLSPEC_HIDDEN;
312 extern xmlnode *get_node_obj(IXMLDOMNode*) DECLSPEC_HIDDEN;
314 extern HRESULT node_append_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
315 extern HRESULT node_get_nodeName(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
316 extern HRESULT node_get_content(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
317 extern HRESULT node_set_content(xmlnode*,LPCWSTR) DECLSPEC_HIDDEN;
318 extern HRESULT node_put_value(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
319 extern HRESULT node_put_value_escaped(xmlnode*,VARIANT*) DECLSPEC_HIDDEN;
320 extern HRESULT node_get_parent(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
321 extern HRESULT node_get_child_nodes(xmlnode*,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
322 extern HRESULT node_get_first_child(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
323 extern HRESULT node_get_last_child(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
324 extern HRESULT node_get_previous_sibling(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
325 extern HRESULT node_get_next_sibling(xmlnode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
326 extern HRESULT node_insert_before(xmlnode*,IXMLDOMNode*,const VARIANT*,IXMLDOMNode**) DECLSPEC_HIDDEN;
327 extern HRESULT node_replace_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
328 extern HRESULT node_put_text(xmlnode*,BSTR) DECLSPEC_HIDDEN;
329 extern HRESULT node_get_xml(xmlnode*,BOOL,BOOL,BSTR*) DECLSPEC_HIDDEN;
330 extern HRESULT node_clone(xmlnode*,VARIANT_BOOL,IXMLDOMNode**) DECLSPEC_HIDDEN;
331 extern HRESULT node_get_prefix(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
332 extern HRESULT node_get_base_name(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
333 extern HRESULT node_get_namespaceURI(xmlnode*,BSTR*) DECLSPEC_HIDDEN;
334 extern HRESULT node_remove_child(xmlnode*,IXMLDOMNode*,IXMLDOMNode**) DECLSPEC_HIDDEN;
335 extern HRESULT node_has_childnodes(const xmlnode*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
336 extern HRESULT node_get_owner_doc(const xmlnode*,IXMLDOMDocument**) DECLSPEC_HIDDEN;
337 extern HRESULT node_get_text(const xmlnode*,BSTR*) DECLSPEC_HIDDEN;
338 extern HRESULT node_select_nodes(const xmlnode*,BSTR,IXMLDOMNodeList**) DECLSPEC_HIDDEN;
339 extern HRESULT node_select_singlenode(const xmlnode*,BSTR,IXMLDOMNode**) DECLSPEC_HIDDEN;
340 extern HRESULT node_transform_node(const xmlnode*,IXMLDOMNode*,BSTR*) DECLSPEC_HIDDEN;
341 extern HRESULT node_create_supporterrorinfo(const tid_t*,void**) DECLSPEC_HIDDEN;
343 extern HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document) DECLSPEC_HIDDEN;
345 extern HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2* iface, xmlNodePtr tree) DECLSPEC_HIDDEN;
346 extern XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node) DECLSPEC_HIDDEN;
348 extern XDR_DT str_to_dt(xmlChar const* str, int len /* calculated if -1 */) DECLSPEC_HIDDEN;
349 extern XDR_DT bstr_to_dt(OLECHAR const* bstr, int len /* calculated if -1 */) DECLSPEC_HIDDEN;
350 extern xmlChar const* dt_to_str(XDR_DT dt) DECLSPEC_HIDDEN;
351 extern const char* debugstr_dt(XDR_DT dt) DECLSPEC_HIDDEN;
352 extern OLECHAR const* dt_to_bstr(XDR_DT dt) DECLSPEC_HIDDEN;
353 extern HRESULT dt_validate(XDR_DT dt, xmlChar const* content) DECLSPEC_HIDDEN;
355 extern BSTR EnsureCorrectEOL(BSTR) DECLSPEC_HIDDEN;
357 extern xmlChar* tagName_to_XPath(const BSTR tagName) DECLSPEC_HIDDEN;
359 static inline BSTR bstr_from_xmlChar(const xmlChar *str)
361 BSTR ret = NULL;
363 if(str) {
364 DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0);
365 ret = SysAllocStringLen(NULL, len-1);
366 if(ret)
367 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len);
369 else
370 ret = SysAllocStringLen(NULL, 0);
372 return ret;
375 static inline HRESULT return_bstr(const WCHAR *value, BSTR *p)
377 if(!p)
378 return E_INVALIDARG;
380 if(value) {
381 *p = SysAllocString(value);
382 if(!*p)
383 return E_OUTOFMEMORY;
384 }else {
385 *p = NULL;
388 return S_OK;
391 static inline HRESULT return_null_node(IXMLDOMNode **p)
393 if(!p)
394 return E_INVALIDARG;
395 *p = NULL;
396 return S_FALSE;
399 static inline HRESULT return_null_ptr(void **p)
401 if(!p)
402 return E_INVALIDARG;
403 *p = NULL;
404 return S_FALSE;
407 static inline HRESULT return_null_var(VARIANT *p)
409 if(!p)
410 return E_INVALIDARG;
412 V_VT(p) = VT_NULL;
413 return S_FALSE;
416 static inline HRESULT return_null_bstr(BSTR *p)
418 if(!p)
419 return E_INVALIDARG;
421 *p = NULL;
422 return S_FALSE;
425 static inline xmlChar *xmlchar_from_wcharn(const WCHAR *str, int nchars)
427 xmlChar *xmlstr;
428 DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, nchars, NULL, 0, NULL, NULL );
430 xmlstr = heap_alloc( len+1 );
431 if ( xmlstr )
433 WideCharToMultiByte( CP_UTF8, 0, str, nchars, (LPSTR) xmlstr, len+1, NULL, NULL );
434 xmlstr[len] = 0;
436 return xmlstr;
439 static inline xmlChar *xmlchar_from_wchar( const WCHAR *str )
441 return xmlchar_from_wcharn(str, -1);
444 #endif
446 extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
447 LONG line, LONG linepos, LONG filepos ) DECLSPEC_HIDDEN;
448 extern HRESULT DOMDocument_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
449 extern HRESULT SchemaCache_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
450 extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN;
451 extern HRESULT SAXXMLReader_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
452 extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN;
453 extern HRESULT XSLTemplate_create(IUnknown*, void**) DECLSPEC_HIDDEN;
454 extern HRESULT MXWriter_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
455 extern HRESULT MXNamespaceManager_create(IUnknown*,void**) DECLSPEC_HIDDEN;
456 extern HRESULT XMLParser_create(IUnknown*,void**) DECLSPEC_HIDDEN;
458 static inline const CLSID* DOMDocument_version(MSXML_VERSION v)
460 switch (v)
462 default:
463 case MSXML_DEFAULT: return &CLSID_DOMDocument;
464 case MSXML3: return &CLSID_DOMDocument30;
465 case MSXML4: return &CLSID_DOMDocument40;
466 case MSXML6: return &CLSID_DOMDocument60;
470 static inline const CLSID* SchemaCache_version(MSXML_VERSION v)
472 switch (v)
474 default:
475 case MSXML_DEFAULT: return &CLSID_XMLSchemaCache;
476 case MSXML3: return &CLSID_XMLSchemaCache30;
477 case MSXML4: return &CLSID_XMLSchemaCache40;
478 case MSXML6: return &CLSID_XMLSchemaCache60;
482 typedef struct bsc_t bsc_t;
484 HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**) DECLSPEC_HIDDEN;
485 HRESULT detach_bsc(bsc_t*) DECLSPEC_HIDDEN;
487 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
489 /* Error Codes - not defined anywhere in the public headers */
490 #define E_XML_ELEMENT_UNDECLARED 0xC00CE00D
491 #define E_XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E
492 /* ... */
493 #define E_XML_EMPTY_NOT_ALLOWED 0xC00CE011
494 #define E_XML_ELEMENT_NOT_COMPLETE 0xC00CE012
495 #define E_XML_ROOT_NAME_MISMATCH 0xC00CE013
496 #define E_XML_INVALID_CONTENT 0xC00CE014
497 #define E_XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015
498 #define E_XML_ATTRIBUTE_FIXED 0xC00CE016
499 #define E_XML_ATTRIBUTE_VALUE 0xC00CE017
500 #define E_XML_ILLEGAL_TEXT 0xC00CE018
501 /* ... */
502 #define E_XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020
504 #endif /* __MSXML_PRIVATE__ */