4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2005 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/debug.h"
36 #include "msxml_private.h"
39 #include <libxslt/xslt.h>
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44 static HINSTANCE hInstance;
45 static ITypeLib *typelib;
46 static ITypeInfo *typeinfos[LAST_tid];
48 static REFIID tid_ids[] = {
49 &IID_IXMLDOMAttribute,
50 &IID_IXMLDOMCDATASection,
52 &IID_IXMLDOMDocument2,
53 &IID_IXMLDOMDocumentFragment,
55 &IID_IXMLDOMEntityReference,
56 &IID_IXMLDOMImplementation,
57 &IID_IXMLDOMNamedNodeMap,
60 &IID_IXMLDOMParseError,
61 &IID_IXMLDOMProcessingInstruction,
62 &IID_IXMLDOMSchemaCollection,
66 &IID_IVBSAXAttributes,
67 &IID_IVBSAXContentHandler,
68 &IID_IVBSAXDeclHandler,
69 &IID_IVBSAXDTDHandler,
70 &IID_IVBSAXEntityResolver,
71 &IID_IVBSAXErrorHandler,
72 &IID_IVBSAXLexicalHandler,
77 &IID_IMXReaderControl,
81 HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
88 hres = LoadRegTypeLib(&LIBID_MSXML2, 3, 0, LOCALE_SYSTEM_DEFAULT, &tl);
90 ERR("LoadRegTypeLib failed: %08x\n", hres);
94 if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
101 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
103 ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
107 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
108 ITypeInfo_Release(typeinfo);
111 *typeinfo = typeinfos[tid];
113 ITypeInfo_AddRef(typeinfos[tid]);
117 static CRITICAL_SECTION MSXML3_typelib_cs;
118 static CRITICAL_SECTION_DEBUG MSXML3_typelib_cs_debug =
120 0, 0, &MSXML3_typelib_cs,
121 { &MSXML3_typelib_cs_debug.ProcessLocksList,
122 &MSXML3_typelib_cs_debug.ProcessLocksList },
123 0, 0, { (DWORD_PTR)(__FILE__ ": MSXML3_typelib_cs") }
125 static CRITICAL_SECTION MSXML3_typelib_cs = { &MSXML3_typelib_cs_debug, -1, 0, 0, 0, 0 };
127 ITypeLib *get_msxml3_typelib( LPWSTR *path )
129 static WCHAR msxml3_path[MAX_PATH];
131 EnterCriticalSection( &MSXML3_typelib_cs );
135 TRACE("loading typelib\n");
137 if (GetModuleFileNameW( hInstance, msxml3_path, MAX_PATH ))
138 LoadTypeLib( msxml3_path, &typelib );
141 LeaveCriticalSection( &MSXML3_typelib_cs );
147 ITypeLib_AddRef( typelib );
152 static void process_detach(void)
157 for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
159 ITypeInfo_Release(typeinfos[i]);
161 ITypeLib_Release(typelib);
165 HRESULT WINAPI DllCanUnloadNow(void)
171 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
175 case DLL_PROCESS_ATTACH:
182 hInstance = hInstDLL;
183 DisableThreadLibraryCalls(hInstDLL);
185 case DLL_PROCESS_DETACH:
187 xsltCleanupGlobals();