msxml3: Dynamically load libxslt.so and only call xsltInit() if present.

This commit is contained in:
Francois Gouget 2008-11-17 19:29:32 +01:00 committed by Alexandre Julliard
parent c38ce28af5
commit 3d384f172c
7 changed files with 103 additions and 162 deletions

142
configure vendored
View File

@ -682,7 +682,6 @@ sane_devel
GNUTLSINCL GNUTLSINCL
HALINCL HALINCL
XSLTINCL XSLTINCL
XSLTLIBS
XML2INCL XML2INCL
XML2LIBS XML2LIBS
NASLIBS NASLIBS
@ -12171,8 +12170,6 @@ XML2LIBS=""
XML2INCL="" XML2INCL=""
XSLTLIBS=""
XSLTINCL="" XSLTINCL=""
if test "x$with_xml" != "xno" if test "x$with_xml" != "xno"
@ -12654,14 +12651,14 @@ done
CPPFLAGS="$ac_save_CPPFLAGS" CPPFLAGS="$ac_save_CPPFLAGS"
if test "$ac_cv_header_libxslt_transform_h" = "yes" if test "$ac_cv_header_libxslt_transform_h" = "yes"
then then
{ $as_echo "$as_me:$LINENO: checking for xsltCompilePattern in -lxslt" >&5 { $as_echo "$as_me:$LINENO: checking for -lxslt" >&5
$as_echo_n "checking for xsltCompilePattern in -lxslt... " >&6; } $as_echo_n "checking for -lxslt... " >&6; }
if test "${ac_cv_lib_xslt_xsltCompilePattern+set}" = set; then if test "${ac_cv_lib_soname_xslt+set}" = set; then
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_soname_save_LIBS=$LIBS
LIBS="-lxslt $ac_xslt_libs $LIBS" LIBS="-lxslt $ac_xslt_libs $LIBS"
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */ /* confdefs.h. */
_ACEOF _ACEOF
cat confdefs.h >>conftest.$ac_ext cat confdefs.h >>conftest.$ac_ext
@ -12704,138 +12701,41 @@ $as_echo "$ac_try_echo") >&5
test "$cross_compiling" = yes || test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext $as_test_x conftest$ac_exeext
}; then }; then
ac_cv_lib_xslt_xsltCompilePattern=yes case "$LIBEXT" in
dll) ;;
dylib) ac_cv_lib_soname_xslt=`otool -L conftest$ac_exeext | grep "libxslt\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libxslt\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
*) ac_cv_lib_soname_xslt=`$ac_cv_path_LDD conftest$ac_exeext | grep "libxslt\\.$LIBEXT" | sed -e "s/^.*\(libxslt\.$LIBEXT[^ ]*\).*$/\1/"';2,$d'` ;;
esac
else else
$as_echo "$as_me: failed program was:" >&5 $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_xslt_xsltCompilePattern=no
fi fi
rm -rf conftest.dSYM rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_soname_save_LIBS
fi fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_xslt_xsltCompilePattern" >&5 if test "x$ac_cv_lib_soname_xslt" = "x"; then
$as_echo "$ac_cv_lib_xslt_xsltCompilePattern" >&6; } { $as_echo "$as_me:$LINENO: result: not found" >&5
if test "x$ac_cv_lib_xslt_xsltCompilePattern" = x""yes; then $as_echo "not found" >&6; }
cat >>confdefs.h <<\_ACEOF
#define HAVE_LIBXSLT 1
_ACEOF
XSLTLIBS="$ac_xslt_libs"
XSLTINCL="$ac_xslt_cflags"
ac_save_LIBS="$LIBS"
LIBS="$LIBS $ac_xslt_libs"
for ac_func in xsltInit
do
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
$as_echo_n "checking for $ac_func... " >&6; }
if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else else
cat >conftest.$ac_ext <<_ACEOF { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_soname_xslt" >&5
/* confdefs.h. */ $as_echo "$ac_cv_lib_soname_xslt" >&6; }
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes, cat >>confdefs.h <<_ACEOF
which can conflict with char $ac_func (); below. #define SONAME_LIBXSLT "$ac_cv_lib_soname_xslt"
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $ac_func
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$ac_func || defined __stub___$ac_func
choke me
#endif
int
main ()
{
return $ac_func ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
eval "$as_ac_var=yes"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
ac_res=`eval 'as_val=${'$as_ac_var'}
$as_echo "$as_val"'`
{ $as_echo "$as_me:$LINENO: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
as_val=`eval 'as_val=${'$as_ac_var'}
$as_echo "$as_val"'`
if test "x$as_val" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF _ACEOF
fi XSLTINCL="$ac_xslt_cflags"
done
LIBS="$ac_save_LIBS"
fi fi
fi fi
fi fi
if test "$ac_cv_lib_xslt_xsltCompilePattern" != "yes"; then if test "x$ac_cv_lib_soname_xslt" = "x"; then
case "x$with_xslt" in case "x$with_xslt" in
x) wine_warnings="$wine_warnings|libxslt ${notice_platform}development files not found, xslt won't be supported." ;; x) wine_warnings="$wine_warnings|libxslt ${notice_platform}development files not found, xslt won't be supported." ;;
xno) ;; xno) ;;

View File

@ -833,7 +833,6 @@ dnl **** Check for libxml2 ****
AC_SUBST(XML2LIBS,"") AC_SUBST(XML2LIBS,"")
AC_SUBST(XML2INCL,"") AC_SUBST(XML2INCL,"")
AC_SUBST(XSLTLIBS,"")
AC_SUBST(XSLTINCL,"") AC_SUBST(XSLTINCL,"")
if test "x$with_xml" != "xno" if test "x$with_xml" != "xno"
then then
@ -881,17 +880,11 @@ then
CPPFLAGS="$ac_save_CPPFLAGS" CPPFLAGS="$ac_save_CPPFLAGS"
if test "$ac_cv_header_libxslt_transform_h" = "yes" if test "$ac_cv_header_libxslt_transform_h" = "yes"
then then
AC_CHECK_LIB(xslt, xsltCompilePattern, WINE_CHECK_SONAME(xslt,xsltCompilePattern,
[AC_DEFINE(HAVE_LIBXSLT, 1, [Define if you have the libxslt library]) [XSLTINCL="$ac_xslt_cflags"],,[$ac_xslt_libs])
XSLTLIBS="$ac_xslt_libs"
XSLTINCL="$ac_xslt_cflags"
ac_save_LIBS="$LIBS"
LIBS="$LIBS $ac_xslt_libs"
AC_CHECK_FUNCS(xsltInit)
LIBS="$ac_save_LIBS"],,$ac_xslt_libs)
fi fi
fi fi
WINE_WARNING_WITH(xslt,[test "$ac_cv_lib_xslt_xsltCompilePattern" != "yes"], WINE_WARNING_WITH(xslt,[test "x$ac_cv_lib_soname_xslt" = "x"],
[libxslt ${notice_platform}development files not found, xslt won't be supported.]) [libxslt ${notice_platform}development files not found, xslt won't be supported.])
dnl **** Check for libhal **** dnl **** Check for libhal ****

View File

@ -5,7 +5,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = msxml3.dll MODULE = msxml3.dll
IMPORTS = uuid urlmon shlwapi oleaut32 ole32 user32 advapi32 kernel32 IMPORTS = uuid urlmon shlwapi oleaut32 ole32 user32 advapi32 kernel32
EXTRALIBS = @XML2LIBS@ @XSLTLIBS@ EXTRALIBS = @XML2LIBS@
EXTRAINCL = @XML2INCL@ @XSLTINCL@ EXTRAINCL = @XML2INCL@ @XSLTINCL@
C_SRCS = \ C_SRCS = \

View File

@ -20,6 +20,7 @@
*/ */
#include "config.h" #include "config.h"
#include "wine/port.h"
#define COBJMACROS #define COBJMACROS
@ -32,13 +33,10 @@
#include "msxml2.h" #include "msxml2.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/library.h"
#include "msxml_private.h" #include "msxml_private.h"
#ifdef HAVE_LIBXSLT
#include <libxslt/xslt.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL(msxml); WINE_DEFAULT_DEBUG_CHANNEL(msxml);
HRESULT WINAPI DllCanUnloadNow(void) HRESULT WINAPI DllCanUnloadNow(void)
@ -47,6 +45,44 @@ HRESULT WINAPI DllCanUnloadNow(void)
return S_FALSE; return S_FALSE;
} }
void* libxslt_handle = NULL;
#ifdef SONAME_LIBXSLT
# define DECL_FUNCPTR(f) typeof(f) * p##f = NULL
DECL_FUNCPTR(xsltInit);
DECL_FUNCPTR(xsltApplyStylesheet);
DECL_FUNCPTR(xsltCleanupGlobals);
DECL_FUNCPTR(xsltFreeStylesheet);
DECL_FUNCPTR(xsltParseStylesheetDoc);
# undef MAKE_FUNCPTR
#endif
static void init_libxslt(void)
{
#ifdef SONAME_LIBXSLT
libxslt_handle = wine_dlopen(SONAME_LIBXSLT, RTLD_NOW, NULL, 0);
if (!libxslt_handle)
return;
#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; }
LOAD_FUNCPTR(xsltInit, 0);
LOAD_FUNCPTR(xsltApplyStylesheet, 1);
LOAD_FUNCPTR(xsltCleanupGlobals, 1);
LOAD_FUNCPTR(xsltFreeStylesheet, 1);
LOAD_FUNCPTR(xsltParseStylesheetDoc, 1);
#undef LOAD_FUNCPTR
if (pxsltInit)
pxsltInit();
return;
sym_not_found:
wine_dlclose(libxslt_handle, NULL, 0);
libxslt_handle = NULL;
#endif
}
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{ {
switch(fdwReason) switch(fdwReason)
@ -60,14 +96,17 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
xmlTreeIndentString = "\t"; xmlTreeIndentString = "\t";
xmlThrDefTreeIndentString("\t"); xmlThrDefTreeIndentString("\t");
#endif #endif
#ifdef HAVE_XSLTINIT init_libxslt();
xsltInit();
#endif
DisableThreadLibraryCalls(hInstDLL); DisableThreadLibraryCalls(hInstDLL);
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
#ifdef HAVE_LIBXSLT #ifdef SONAME_LIBXSLT
xsltCleanupGlobals(); if (libxslt_handle)
{
pxsltCleanupGlobals();
wine_dlclose(libxslt_handle, NULL, 0);
libxslt_handle = NULL;
}
#endif #endif
#ifdef HAVE_LIBXML2 #ifdef HAVE_LIBXML2
xmlCleanupParser(); xmlCleanupParser();

View File

@ -92,6 +92,27 @@ extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2
#endif #endif
void* libxslt_handle;
#ifdef SONAME_LIBXSLT
# ifdef HAVE_LIBXSLT_PATTERN_H
# include <libxslt/pattern.h>
# endif
# ifdef HAVE_LIBXSLT_TRANSFORM_H
# include <libxslt/transform.h>
# endif
# include <libxslt/xsltutils.h>
# include <libxslt/xsltInternals.h>
# include <libxslt/xslt.h>
# define MAKE_FUNCPTR(f) extern typeof(f) * p##f
MAKE_FUNCPTR(xsltInit);
MAKE_FUNCPTR(xsltApplyStylesheet);
MAKE_FUNCPTR(xsltCleanupGlobals);
MAKE_FUNCPTR(xsltFreeStylesheet);
MAKE_FUNCPTR(xsltParseStylesheetDoc);
# undef MAKE_FUNCPTR
#endif
extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText, extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
LONG line, LONG linepos, LONG filepos ); LONG line, LONG linepos, LONG filepos );
extern HRESULT DOMDocument_create( IUnknown *pUnkOuter, LPVOID *ppObj ); extern HRESULT DOMDocument_create( IUnknown *pUnkOuter, LPVOID *ppObj );

View File

@ -33,17 +33,6 @@
#include "msxml_private.h" #include "msxml_private.h"
#ifdef HAVE_LIBXSLT
# ifdef HAVE_LIBXSLT_PATTERN_H
# include <libxslt/pattern.h>
# endif
# ifdef HAVE_LIBXSLT_TRANSFORM_H
# include <libxslt/transform.h>
# endif
# include <libxslt/xsltutils.h>
# include <libxslt/xsltInternals.h>
#endif
#ifdef HAVE_LIBXML2 #ifdef HAVE_LIBXML2
# include <libxml/HTMLtree.h> # include <libxml/HTMLtree.h>
#endif #endif
@ -1278,7 +1267,7 @@ static HRESULT WINAPI xmlnode_transformNode(
IXMLDOMNode* styleSheet, IXMLDOMNode* styleSheet,
BSTR* xmlString) BSTR* xmlString)
{ {
#ifdef HAVE_LIBXSLT #ifdef SONAME_LIBXSLT
xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlnode *This = impl_from_IXMLDOMNode( iface );
xmlnode *pStyleSheet = NULL; xmlnode *pStyleSheet = NULL;
xsltStylesheetPtr xsltSS = NULL; xsltStylesheetPtr xsltSS = NULL;
@ -1287,6 +1276,8 @@ static HRESULT WINAPI xmlnode_transformNode(
TRACE("%p %p %p\n", This, styleSheet, xmlString); TRACE("%p %p %p\n", This, styleSheet, xmlString);
if (!libxslt_handle)
return E_NOTIMPL;
if(!styleSheet || !xmlString) if(!styleSheet || !xmlString)
return E_INVALIDARG; return E_INVALIDARG;
@ -1296,10 +1287,10 @@ static HRESULT WINAPI xmlnode_transformNode(
{ {
pStyleSheet = impl_from_IXMLDOMNode( ssNew ); pStyleSheet = impl_from_IXMLDOMNode( ssNew );
xsltSS = xsltParseStylesheetDoc( pStyleSheet->node->doc); xsltSS = pxsltParseStylesheetDoc( pStyleSheet->node->doc);
if(xsltSS) if(xsltSS)
{ {
result = xsltApplyStylesheet(xsltSS, This->node->doc, NULL); result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
if(result) if(result)
{ {
const xmlChar *pContent; const xmlChar *pContent;
@ -1337,7 +1328,7 @@ static HRESULT WINAPI xmlnode_transformNode(
/* libxslt "helpfully" frees the XML document the stylesheet was /* libxslt "helpfully" frees the XML document the stylesheet was
generated from, too */ generated from, too */
xsltSS->doc = NULL; xsltSS->doc = NULL;
xsltFreeStylesheet(xsltSS); pxsltFreeStylesheet(xsltSS);
} }
IXMLDOMNode_Release(ssNew); IXMLDOMNode_Release(ssNew);

View File

@ -333,9 +333,6 @@
/* Define if you have the X Shape extension */ /* Define if you have the X Shape extension */
#undef HAVE_LIBXSHAPE #undef HAVE_LIBXSHAPE
/* Define if you have the libxslt library */
#undef HAVE_LIBXSLT
/* Define to 1 if you have the <libxslt/pattern.h> header file. */ /* Define to 1 if you have the <libxslt/pattern.h> header file. */
#undef HAVE_LIBXSLT_PATTERN_H #undef HAVE_LIBXSLT_PATTERN_H
@ -1002,9 +999,6 @@
/* Define if Xrender has the XRenderSetPictureTransform function */ /* Define if Xrender has the XRenderSetPictureTransform function */
#undef HAVE_XRENDERSETPICTURETRANSFORM #undef HAVE_XRENDERSETPICTURETRANSFORM
/* Define to 1 if you have the `xsltInit' function. */
#undef HAVE_XSLTINIT
/* Define to 1 if you have the `_pclose' function. */ /* Define to 1 if you have the `_pclose' function. */
#undef HAVE__PCLOSE #undef HAVE__PCLOSE
@ -1128,6 +1122,9 @@
/* Define to the soname of the libXrender library. */ /* Define to the soname of the libXrender library. */
#undef SONAME_LIBXRENDER #undef SONAME_LIBXRENDER
/* Define to the soname of the libxslt library. */
#undef SONAME_LIBXSLT
/* Define to the soname of the libXxf86vm library. */ /* Define to the soname of the libXxf86vm library. */
#undef SONAME_LIBXXF86VM #undef SONAME_LIBXXF86VM