Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmain.c
Go to the documentation of this file.
00001 /* 00002 * MSXML Class Factory 00003 * 00004 * Copyright 2002 Lionel Ulmer 00005 * Copyright 2005 Mike McCormack 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00020 */ 00021 00022 #include "config.h" 00023 #include "wine/port.h" 00024 00025 #define COBJMACROS 00026 00027 #include <stdarg.h> 00028 #include "windef.h" 00029 #include "winbase.h" 00030 #include "winuser.h" 00031 #include "ole2.h" 00032 #include "msxml.h" 00033 #include "msxml2.h" 00034 00035 #include "wine/unicode.h" 00036 #include "wine/debug.h" 00037 #include "wine/library.h" 00038 00039 #include "msxml_private.h" 00040 00041 WINE_DEFAULT_DEBUG_CHANNEL(msxml); 00042 00043 #ifdef HAVE_LIBXML2 00044 00045 /* Support for loading xml files from a Wine Windows drive */ 00046 static int wineXmlMatchCallback (char const * filename) 00047 { 00048 int nRet = 0; 00049 00050 TRACE("%s\n", filename); 00051 00052 /* 00053 * We will deal with loading XML files from the file system 00054 * We only care about files that linux cannot find. 00055 * e.g. C:,D: etc 00056 */ 00057 if(isalpha(filename[0]) && filename[1] == ':') 00058 nRet = 1; 00059 00060 return nRet; 00061 } 00062 00063 static void *wineXmlOpenCallback (char const * filename) 00064 { 00065 BSTR sFilename = bstr_from_xmlChar( (const xmlChar*)filename); 00066 HANDLE hFile; 00067 00068 TRACE("%s\n", debugstr_w(sFilename)); 00069 00070 hFile = CreateFileW(sFilename, GENERIC_READ,FILE_SHARE_READ, NULL, 00071 OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); 00072 if(hFile == INVALID_HANDLE_VALUE) hFile = 0; 00073 SysFreeString(sFilename); 00074 return hFile; 00075 } 00076 00077 static int wineXmlReadCallback(void * context, char * buffer, int len) 00078 { 00079 DWORD dwBytesRead; 00080 00081 TRACE("%p %s %d\n", context, buffer, len); 00082 00083 if ((context == NULL) || (buffer == NULL)) 00084 return(-1); 00085 00086 if(!ReadFile( context, buffer,len, &dwBytesRead, NULL)) 00087 { 00088 ERR("Failed to read file\n"); 00089 return -1; 00090 } 00091 00092 TRACE("Read %d\n", dwBytesRead); 00093 00094 return dwBytesRead; 00095 } 00096 00097 static int wineXmlFileCloseCallback (void * context) 00098 { 00099 return CloseHandle(context) ? 0 : -1; 00100 } 00101 00102 #endif 00103 00104 00105 HRESULT WINAPI DllCanUnloadNow(void) 00106 { 00107 return S_FALSE; 00108 } 00109 00110 00111 void* libxslt_handle = NULL; 00112 #ifdef SONAME_LIBXSLT 00113 # define DECL_FUNCPTR(f) typeof(f) * p##f = NULL 00114 DECL_FUNCPTR(xsltApplyStylesheet); 00115 DECL_FUNCPTR(xsltCleanupGlobals); 00116 DECL_FUNCPTR(xsltFreeStylesheet); 00117 DECL_FUNCPTR(xsltParseStylesheetDoc); 00118 # undef MAKE_FUNCPTR 00119 #endif 00120 00121 static void init_libxslt(void) 00122 { 00123 #ifdef SONAME_LIBXSLT 00124 void (*pxsltInit)(void); /* Missing in libxslt <= 1.1.14 */ 00125 00126 libxslt_handle = wine_dlopen(SONAME_LIBXSLT, RTLD_NOW, NULL, 0); 00127 if (!libxslt_handle) 00128 return; 00129 00130 #define LOAD_FUNCPTR(f, needed) if ((p##f = wine_dlsym(libxslt_handle, #f, NULL, 0)) == NULL && needed) { WARN("Can't find symbol %s\n", #f); goto sym_not_found; } 00131 LOAD_FUNCPTR(xsltInit, 0); 00132 LOAD_FUNCPTR(xsltApplyStylesheet, 1); 00133 LOAD_FUNCPTR(xsltCleanupGlobals, 1); 00134 LOAD_FUNCPTR(xsltFreeStylesheet, 1); 00135 LOAD_FUNCPTR(xsltParseStylesheetDoc, 1); 00136 #undef LOAD_FUNCPTR 00137 00138 if (pxsltInit) 00139 pxsltInit(); 00140 return; 00141 00142 sym_not_found: 00143 wine_dlclose(libxslt_handle, NULL, 0); 00144 libxslt_handle = NULL; 00145 #endif 00146 } 00147 00148 00149 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) 00150 { 00151 switch(fdwReason) 00152 { 00153 case DLL_PROCESS_ATTACH: 00154 #ifdef HAVE_LIBXML2 00155 xmlInitParser(); 00156 00157 /* Set the default indent character to a single tab, 00158 for this thread and as default for new threads */ 00159 xmlTreeIndentString = "\t"; 00160 xmlThrDefTreeIndentString("\t"); 00161 00162 /* Register callbacks for loading XML files */ 00163 if(xmlRegisterInputCallbacks(wineXmlMatchCallback, wineXmlOpenCallback, 00164 wineXmlReadCallback, wineXmlFileCloseCallback) == -1) 00165 WARN("Failed to register callbacks\n"); 00166 00167 #endif 00168 init_libxslt(); 00169 DisableThreadLibraryCalls(hInstDLL); 00170 break; 00171 case DLL_PROCESS_DETACH: 00172 #ifdef SONAME_LIBXSLT 00173 if (libxslt_handle) 00174 { 00175 pxsltCleanupGlobals(); 00176 wine_dlclose(libxslt_handle, NULL, 0); 00177 libxslt_handle = NULL; 00178 } 00179 #endif 00180 #ifdef HAVE_LIBXML2 00181 /* Restore default Callbacks */ 00182 xmlCleanupInputCallbacks(); 00183 xmlRegisterDefaultInputCallbacks(); 00184 00185 xmlCleanupParser(); 00186 #endif 00187 release_typelib(); 00188 break; 00189 } 00190 return TRUE; 00191 } Generated on Fri May 25 2012 04:15:05 for ReactOS by
1.7.6.1
|