Commit 67d3afb0 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Load libcapi20.so.* dynamically on demand.

parent 346188b7
......@@ -311,7 +311,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS WIN16_FILES WIN16_INSTALL DLLDEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPPBIN ac_ct_CPPBIN TOOLSDIR CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LEX LEXLIB LEX_OUTPUT_ROOT XLEX BISON AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN EGREP LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS DB2HTML DB2PDF DB2PS DB2TXT FONTFORGE LIBPTHREAD XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS GLUT_LIBS GLUT32FILES NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPELIBS FREETYPEINCL FONTSSUBDIRS ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS CAPI4LINUXLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLLFLAGS LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS LDLIBWINEFLAGS COREFOUNDATIONLIB IOKITLIB CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS SOCKETLIBS WINE_BINARIES MAIN_BINARY LDD ALLOCA LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS WIN16_FILES WIN16_INSTALL DLLDEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPPBIN ac_ct_CPPBIN TOOLSDIR CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LEX LEXLIB LEX_OUTPUT_ROOT XLEX BISON AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN EGREP LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS DB2HTML DB2PDF DB2PS DB2TXT FONTFORGE LIBPTHREAD XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS GLUT_LIBS GLUT32FILES NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPELIBS FREETYPEINCL FONTSSUBDIRS ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLLFLAGS LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS LDLIBWINEFLAGS COREFOUNDATIONLIB IOKITLIB CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS SOCKETLIBS WINE_BINARIES MAIN_BINARY LDD ALLOCA LIBOBJS LTLIBOBJS'
ac_subst_files='MAKE_RULES MAKE_DLL_RULES MAKE_TEST_RULES MAKE_LIB_RULES MAKE_PROG_RULES'
# Initialize some variables set by options.
......@@ -12050,8 +12050,6 @@ cat >>confdefs.h <<\_ACEOF
#define HAVE_CAPI4LINUX 1
_ACEOF
CAPI4LINUXLIBS="-lcapi20"
fi
......@@ -15776,6 +15774,80 @@ cat >>confdefs.h <<_ACEOF
#define SONAME_LIBLCMS "$ac_cv_lib_soname_lcms"
_ACEOF
fi
echo "$as_me:$LINENO: checking for -lcapi20 soname" >&5
echo $ECHO_N "checking for -lcapi20 soname... $ECHO_C" >&6
if test "${ac_cv_lib_soname_capi20+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_get_soname_save_LIBS=$LIBS
LIBS="-lcapi20 $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char capi20_isinstalled ();
int
main ()
{
capi20_isinstalled ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_soname_capi20=`$ac_cv_path_LDD conftest$ac_exeext | grep libcapi20\\.$LIBEXT | sed "s/^.*\(libcapi20\.$LIBEXT[^ ]*\).*$/\1/"`
if test "x$ac_cv_lib_soname_capi20" = "x"
then
ac_cv_lib_soname_capi20="libcapi20.$LIBEXT"
fi
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_soname_capi20="libcapi20.$LIBEXT"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_get_soname_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_soname_capi20" >&5
echo "${ECHO_T}$ac_cv_lib_soname_capi20" >&6
if test "x$ac_cv_lib_soname_capi20" != xNONE
then
cat >>confdefs.h <<_ACEOF
#define SONAME_LIBCAPI20 "$ac_cv_lib_soname_capi20"
_ACEOF
fi
fi
......@@ -20835,7 +20907,6 @@ s,@ARTSLIBS@,$ARTSLIBS,;t t
s,@ARTSINCL@,$ARTSINCL,;t t
s,@ALSALIBS@,$ALSALIBS,;t t
s,@AUDIOIOLIBS@,$AUDIOIOLIBS,;t t
s,@CAPI4LINUXLIBS@,$CAPI4LINUXLIBS,;t t
s,@EXTRACFLAGS@,$EXTRACFLAGS,;t t
s,@DLLEXT@,$DLLEXT,;t t
s,@DLLFLAGS@,$DLLFLAGS,;t t
......
......@@ -700,7 +700,6 @@ AC_CHECK_HEADERS(capi20.h,[
AC_CHECK_HEADERS(linux/capi.h,[
AC_CHECK_LIB(capi20,capi20_register,[
AC_DEFINE(HAVE_CAPI4LINUX,1,[Define if you have capi4linux libs and headers])
AC_SUBST(CAPI4LINUXLIBS,"-lcapi20")
])
])
])
......@@ -1106,6 +1105,7 @@ then
WINE_GET_SONAME(ungif,DGifOpen)
WINE_GET_SONAME(gif,DGifOpen)
WINE_GET_SONAME(lcms,cmsOpenProfileFromFile)
WINE_GET_SONAME(capi20,capi20_isinstalled)
fi
......
......@@ -4,7 +4,6 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = capi2032.dll
IMPORTS = kernel32
EXTRALIBS = @CAPI4LINUXLIBS@
C_SRCS = cap20wxx.c
......
......@@ -22,6 +22,7 @@
#define __NO_CAPIUTILS__
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <sys/types.h>
......@@ -36,18 +37,67 @@
#ifdef HAVE_CAPI20_H
# include <capi20.h>
#endif
#include "wine/library.h"
#include "wine/debug.h"
#include "cap20wxx.h"
WINE_DEFAULT_DEBUG_CHANNEL(capi);
#ifdef HAVE_CAPI4LINUX
#ifndef SONAME_LIBCAPI20
#define SONAME_LIBCAPI20 "libcapi20.so"
#endif
static unsigned (*pcapi20_register)(unsigned, unsigned, unsigned, unsigned *) = NULL;
static unsigned (*pcapi20_release)(unsigned) = NULL;
static unsigned (*pcapi20_put_message)(unsigned, unsigned char *) = NULL;
static unsigned (*pcapi20_get_message)(unsigned, unsigned char **) = NULL;
static unsigned (*pcapi20_waitformessage)(unsigned, struct timeval *) = NULL;
static unsigned (*pcapi20_isinstalled)() = NULL;
static unsigned (*pcapi20_get_profile)(unsigned, unsigned char *) = NULL;
static unsigned char *(*pcapi20_get_manufacturer)(unsigned, unsigned char *) = NULL;
static unsigned char *(*pcapi20_get_serial_number)(unsigned, unsigned char *) = NULL;
static unsigned char *(*pcapi20_get_version)(unsigned, unsigned char *) = NULL;
static void load_functions() {
void *capi_handle = NULL;
if (pcapi20_register) /* loaded already */
return;
capi_handle = wine_dlopen(SONAME_LIBCAPI20, RTLD_NOW, NULL, 0);
if(!capi_handle) {
FIXME("Wine cannot find the library %s, capi2032.dll not working.\n", SONAME_LIBCAPI20);
return;
}
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(capi_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); return;}
LOAD_FUNCPTR(capi20_register);
LOAD_FUNCPTR(capi20_release);
LOAD_FUNCPTR(capi20_put_message);
LOAD_FUNCPTR(capi20_get_message);
LOAD_FUNCPTR(capi20_waitformessage);
LOAD_FUNCPTR(capi20_isinstalled);
LOAD_FUNCPTR(capi20_get_profile);
LOAD_FUNCPTR(capi20_get_manufacturer);
LOAD_FUNCPTR(capi20_get_serial_number);
LOAD_FUNCPTR(capi20_get_version);
#undef LOAD_FUNCPTR
}
#endif
/*===========================================================================*\
\*===========================================================================*/
DWORD WINAPI wrapCAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnection, DWORD maxBDataBlocks, DWORD maxBDataLen, DWORD *pApplID) {
#ifdef HAVE_CAPI4LINUX
unsigned aid = 0;
DWORD fret = capi20_register (maxLogicalConnection, maxBDataBlocks, maxBDataLen, &aid);
DWORD fret;
load_functions();
if (!pcapi20_register)
return 0x1009;
fret = pcapi20_register (maxLogicalConnection, maxBDataBlocks, maxBDataLen, &aid);
*pApplID = aid;
TRACE ( "(%lx) -> %lx\n", *pApplID, fret);
return fret;
......@@ -61,7 +111,12 @@ DWORD WINAPI wrapCAPI_REGISTER (DWORD MessageBufferSize, DWORD maxLogicalConnect
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_RELEASE (DWORD ApplID) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = capi20_release (ApplID);
DWORD fret;
load_functions();
if (!pcapi20_release)
return 0x1109;
fret = pcapi20_release (ApplID);
TRACE ("(%lx) -> %lx\n", ApplID, fret);
return fret;
#else
......@@ -73,7 +128,12 @@ DWORD WINAPI wrapCAPI_RELEASE (DWORD ApplID) {
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = capi20_put_message (ApplID, pCAPIMessage);
DWORD fret;
load_functions();
if (!pcapi20_put_message)
return 0x1109;
fret = pcapi20_put_message (ApplID, pCAPIMessage);
TRACE ("(%lx) -> %lx\n", ApplID, fret);
return fret;
#else
......@@ -85,7 +145,12 @@ DWORD WINAPI wrapCAPI_PUT_MESSAGE (DWORD ApplID, PVOID pCAPIMessage) {
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = capi20_get_message (ApplID, (unsigned char **)ppCAPIMessage);
DWORD fret;
load_functions();
if (!pcapi20_get_message)
return 0x1109;
fret = pcapi20_get_message (ApplID, (unsigned char **)ppCAPIMessage);
TRACE ("(%lx) -> %lx\n", ApplID, fret);
return fret;
#else
......@@ -98,7 +163,12 @@ DWORD WINAPI wrapCAPI_GET_MESSAGE (DWORD ApplID, PVOID *ppCAPIMessage) {
DWORD WINAPI wrapCAPI_WAIT_FOR_SIGNAL (DWORD ApplID) {
#ifdef HAVE_CAPI4LINUX
TRACE ("(%lx)\n", ApplID);
return capi20_waitformessage (ApplID, NULL);
load_functions();
if (!pcapi20_waitformessage)
return 0x1109;
return pcapi20_waitformessage (ApplID, NULL);
#else
return 0x1109;
#endif
......@@ -108,7 +178,13 @@ DWORD WINAPI wrapCAPI_WAIT_FOR_SIGNAL (DWORD ApplID) {
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = (capi20_get_manufacturer (0, SzBuffer) != 0) ? 0 : 0x1108;
DWORD fret;
load_functions();
if (!pcapi20_get_manufacturer)
return 0x1109;
fret = (pcapi20_get_manufacturer (0, SzBuffer) != 0) ? 0 : 0x1108;
if (!strncmp (SzBuffer, "AVM", 3)) {
strcpy (SzBuffer, "AVM-GmbH");
}
......@@ -124,7 +200,12 @@ DWORD WINAPI wrapCAPI_GET_MANUFACTURER (char *SzBuffer) {
DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *pManufacturerMajor, DWORD *pManufacturerMinor) {
#ifdef HAVE_CAPI4LINUX
unsigned char version[4 * sizeof (unsigned)];
DWORD fret = (capi20_get_version (0, version) != 0) ? 0 : 0x1108;
DWORD fret;
load_functions();
if (!pcapi20_get_version)
return 0x1109;
fret = (pcapi20_get_version (0, version) != 0) ? 0 : 0x1108;
*pCAPIMajor = *(unsigned *)(version + 0 * sizeof (unsigned));
*pCAPIMinor = *(unsigned *)(version + 1 * sizeof (unsigned));
*pManufacturerMajor = *(unsigned *)(version + 2 * sizeof (unsigned));
......@@ -141,7 +222,12 @@ DWORD WINAPI wrapCAPI_GET_VERSION (DWORD *pCAPIMajor, DWORD *pCAPIMinor, DWORD *
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_SERIAL_NUMBER (char *SzBuffer) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = (capi20_get_serial_number (0, SzBuffer) != 0) ? 0 : 0x1108;
DWORD fret;
load_functions();
if (!pcapi20_get_serial_number)
return 0x1109;
fret = (pcapi20_get_serial_number (0, SzBuffer) != 0) ? 0 : 0x1108;
TRACE ("(%s) -> %lx\n", SzBuffer, fret);
return fret;
#else
......@@ -153,7 +239,13 @@ DWORD WINAPI wrapCAPI_GET_SERIAL_NUMBER (char *SzBuffer) {
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = capi20_get_profile (CtlrNr, SzBuffer);
DWORD fret;
load_functions();
if (!pcapi20_get_profile)
return 0x1109;
fret = pcapi20_get_profile (CtlrNr, SzBuffer);
TRACE ("(%lx,%x) -> %lx\n", CtlrNr, *(unsigned short *)SzBuffer, fret);
return fret;
#else
......@@ -165,7 +257,12 @@ DWORD WINAPI wrapCAPI_GET_PROFILE (PVOID SzBuffer, DWORD CtlrNr) {
\*---------------------------------------------------------------------------*/
DWORD WINAPI wrapCAPI_INSTALLED (void) {
#ifdef HAVE_CAPI4LINUX
DWORD fret = capi20_isinstalled();
DWORD fret;
load_functions();
if (!pcapi20_isinstalled)
return 0x1109;
fret = pcapi20_isinstalled();
TRACE ("() -> %lx\n", fret);
return fret;
#else
......
......@@ -833,6 +833,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to the soname of the libcapi20 library. */
#undef SONAME_LIBCAPI20
/* Define to the soname of the libcrypto library. */
#undef SONAME_LIBCRYPTO
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment