PATCH: make capi dynamic
Marcus Meissner
marcus at jet.franken.de
Thu Jan 6 14:31:51 CST 2005
Hi,
I got several complaints that wine hardrequirs libcapi20.so, so
here is the dynamic loading patch for it.
Untested, except that it compiles.
Ciao, Marcus
Changelog:
Load libcapi20.so.* dynamically on demand.
Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.331
diff -u -r1.331 configure.ac
--- configure.ac 5 Jan 2005 13:26:34 -0000 1.331
+++ configure.ac 6 Jan 2005 20:29:34 -0000
@@ -700,7 +700,6 @@
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 @@
WINE_GET_SONAME(ungif,DGifOpen)
WINE_GET_SONAME(gif,DGifOpen)
WINE_GET_SONAME(lcms,cmsOpenProfileFromFile)
+ WINE_GET_SONAME(capi20,capi20_isinstalled)
fi
Index: dlls/capi2032/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/capi2032/Makefile.in,v
retrieving revision 1.1
diff -u -r1.1 Makefile.in
--- dlls/capi2032/Makefile.in 6 Nov 2003 00:26:43 -0000 1.1
+++ dlls/capi2032/Makefile.in 6 Jan 2005 20:29:34 -0000
@@ -4,7 +4,6 @@
VPATH = @srcdir@
MODULE = capi2032.dll
IMPORTS = kernel32
-EXTRALIBS = @CAPI4LINUXLIBS@
C_SRCS = cap20wxx.c
Index: dlls/capi2032/cap20wxx.c
===================================================================
RCS file: /home/wine/wine/dlls/capi2032/cap20wxx.c,v
retrieving revision 1.4
diff -u -r1.4 cap20wxx.c
--- dlls/capi2032/cap20wxx.c 17 Aug 2004 22:08:43 -0000 1.4
+++ dlls/capi2032/cap20wxx.c 6 Jan 2005 20:29:34 -0000
@@ -36,18 +36,64 @@
#ifdef HAVE_CAPI20_H
# include <capi20.h>
#endif
+#include "wine/port.h"
+#include "wine/library.h"
#include "wine/debug.h"
#include "cap20wxx.h"
+#ifndef SONAME_LIBCAPI20
+#define SONAME_LIBCAPI20 "libcapi20.so"
+#endif
+
WINE_DEFAULT_DEBUG_CHANNEL(capi);
+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
+}
+
/*===========================================================================*\
\*===========================================================================*/
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 +107,12 @@
\*---------------------------------------------------------------------------*/
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 +124,12 @@
\*---------------------------------------------------------------------------*/
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 +141,12 @@
\*---------------------------------------------------------------------------*/
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 +159,12 @@
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 +174,13 @@
\*---------------------------------------------------------------------------*/
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 +196,12 @@
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 +218,12 @@
\*---------------------------------------------------------------------------*/
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 +235,13 @@
\*---------------------------------------------------------------------------*/
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 +253,12 @@
\*---------------------------------------------------------------------------*/
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
More information about the wine-patches
mailing list