Hi, This removes the explicit dependency to CUPS from winspool and wineps and makes it a dynamical one. This is using the same trick as we do for Freetype. Tested against Word 2000. Ciao, Marcus License: LGPL Changelog: Do not link against -lcups directly, but dynamically load it if present. (just like freetype etc.) Index: configure.ac =================================================================== RCS file: /home/wine/wine/configure.ac,v retrieving revision 1.90 diff -u -r1.90 configure.ac --- configure.ac 8 Nov 2002 19:34:52 -0000 1.90 +++ configure.ac 10 Nov 2002 18:54:42 -0000 @@ -362,16 +362,13 @@ fi AC_SUBST(CURSESLIBS) -CUPSLIBS="" dnl **** Check for CUPS **** wine_cv_warn_cups_h=no AC_CHECK_LIB(cups,cupsGetPPD, [AC_CHECK_HEADER(cups/cups.h, - [AC_DEFINE(HAVE_CUPS, 1, [Define if we have CUPS]) - CUPSLIBS="-lcups"], + [AC_DEFINE(HAVE_CUPS, 1, [Define if we have CUPS])], wine_cv_warn_cups_h=yes)] ) -AC_SUBST(CUPSLIBS) dnl **** Check for SANE **** AC_CHECK_PROG(sane_devel,sane-config,sane-config,no) @@ -856,6 +853,7 @@ WINE_GET_SONAME(Xext,XextCreateExtension,[$X_LIBS -lX11 $X_EXTRA_LIBS]) WINE_GET_SONAME(Xrender,XRenderQueryExtension,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS]) WINE_GET_SONAME(freetype,FT_Init_FreeType,[$X_LIBS]) + WINE_GET_SONAME(cups,cupsGetDefault) fi Index: dlls/wineps/Makefile.in =================================================================== RCS file: /home/wine/wine/dlls/wineps/Makefile.in,v retrieving revision 1.21 diff -u -r1.21 Makefile.in --- dlls/wineps/Makefile.in 24 Jun 2002 23:44:18 -0000 1.21 +++ dlls/wineps/Makefile.in 10 Nov 2002 18:54:50 -0000 @@ -5,7 +5,6 @@ MODULE = wineps.dll IMPORTS = user32 gdi32 winspool.drv advapi32 kernel32 ALTNAMES = wineps16.dll -EXTRALIBS = @CUPSLIBS@ EXTRAINCL = @FREETYPEINCL@ LDDLLFLAGS = @LDDLLFLAGS@ Index: dlls/wineps/init.c =================================================================== RCS file: /home/wine/wine/dlls/wineps/init.c,v retrieving revision 1.41 diff -u -r1.41 init.c --- dlls/wineps/init.c 4 Nov 2002 23:53:43 -0000 1.41 +++ dlls/wineps/init.c 10 Nov 2002 18:54:50 -0000 @@ -20,6 +20,7 @@ */ #include "config.h" +#include "wine/port.h" #include <string.h> #ifdef HAVE_UNISTD_H @@ -33,11 +34,17 @@ #include "winspool.h" #include "winerror.h" +WINE_DEFAULT_DEBUG_CHANNEL(psdrv); + #ifdef HAVE_CUPS -# include <cups/cups.h> +#include <cups/cups.h> + +#ifndef CUPS_SONAME +#define CUPS_SONAME "libcups.so" #endif -WINE_DEFAULT_DEBUG_CHANNEL(psdrv); +static void *cupshandle = NULL; +#endif static PSDRV_DEVMODEA DefaultDevmode = { @@ -127,12 +134,25 @@ HeapDestroy(PSDRV_Heap); return FALSE; } +#ifdef HAVE_CUPS + /* dynamically load CUPS if not yet loaded */ + if (!cupshandle) { + cupshandle = wine_dlopen(CUPS_SONAME, RTLD_NOW, NULL, 0); + if (!cupshandle) cupshandle = (void*)-1; + } +#endif break; case DLL_PROCESS_DETACH: DeleteObject( PSDRV_DefaultFont ); HeapDestroy( PSDRV_Heap ); +#ifdef HAVE_CUPS + if (cupshandle && (cupshandle != (void*)-1)) { + wine_dlclose(cupshandle, NULL, 0); + cupshandle = NULL; + } +#endif break; } @@ -492,23 +511,27 @@ } #ifdef HAVE_CUPS - { - ppd = cupsGetPPD(name); + if (cupshandle != (void*)-1) { + typeof(cupsGetPPD) * pcupsGetPPD = NULL; - if (ppd) { - needed=strlen(ppd)+1; - ppdFileName=HeapAlloc(PSDRV_Heap, 0, needed); - memcpy(ppdFileName, ppd, needed); - ppdType=REG_SZ; - res = ERROR_SUCCESS; - /* we should unlink() that file later */ - } else { - res = ERROR_FILE_NOT_FOUND; - WARN("Did not find ppd for %s\n",name); + pcupsGetPPD = wine_dlsym(cupshandle, "cupsGetPPD", NULL, 0); + if (pcupsGetPPD) { + ppd = pcupsGetPPD(name); + + if (ppd) { + needed=strlen(ppd)+1; + ppdFileName=HeapAlloc(PSDRV_Heap, 0, needed); + memcpy(ppdFileName, ppd, needed); + ppdType=REG_SZ; + res = ERROR_SUCCESS; + /* we should unlink() that file later */ + } else { + res = ERROR_FILE_NOT_FOUND; + WARN("Did not find ppd for %s\n",name); + } } } #endif - if (!ppdFileName) { res = GetPrinterDataA(hPrinter, "PPD File", NULL, NULL, 0, &needed); if ((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA)) { Index: dlls/winspool/Makefile.in =================================================================== RCS file: /home/wine/wine/dlls/winspool/Makefile.in,v retrieving revision 1.21 diff -u -r1.21 Makefile.in --- dlls/winspool/Makefile.in 22 Oct 2002 00:47:33 -0000 1.21 +++ dlls/winspool/Makefile.in 10 Nov 2002 18:54:50 -0000 @@ -5,7 +5,6 @@ VPATH = @srcdir@ MODULE = winspool.drv IMPORTS = advapi32 kernel32 -EXTRALIBS = @CUPSLIBS@ LDDLLFLAGS = @LDDLLFLAGS@ SYMBOLFILE = $(MODULE).tmp.o Index: dlls/winspool/info.c =================================================================== RCS file: /home/wine/wine/dlls/winspool/info.c,v retrieving revision 1.60 diff -u -r1.60 info.c --- dlls/winspool/info.c 22 Oct 2002 00:47:33 -0000 1.60 +++ dlls/winspool/info.c 10 Nov 2002 18:54:51 -0000 @@ -23,6 +23,8 @@ */ #include "config.h" +#include "wine/port.h" +#include "wine/library.h" #include <stdio.h> #include <stdlib.h> @@ -31,6 +33,9 @@ #include <stddef.h> #ifdef HAVE_CUPS # include <cups/cups.h> +# ifndef CUPS_SONAME +# define CUPS_SONAME "libcups.so.2" +# endif #endif #include "winspool.h" #include "winbase.h" @@ -118,18 +123,36 @@ #ifdef HAVE_CUPS BOOL CUPS_LoadPrinters(void) { + typeof(cupsGetPrinters) *pcupsGetPrinters = NULL; + typeof(cupsGetDefault) *pcupsGetDefault = NULL; + typeof(cupsGetPPD) *pcupsGetPPD = NULL; char **printers; int i,nrofdests,hadprinter = FALSE; PRINTER_INFO_2A pinfo2a; - const char* def = cupsGetDefault(); + const char* def; + void *cupshandle = NULL; - nrofdests = cupsGetPrinters(&printers); + cupshandle = wine_dlopen(CUPS_SONAME, RTLD_NOW, NULL, 0); + if (!cupshandle) + return FALSE; + +#define DYNCUPS(x) \ + p##x = wine_dlsym(cupshandle, #x, NULL,0); \ + if (!p##x) return FALSE; + + DYNCUPS(cupsGetDefault); + DYNCUPS(cupsGetPPD); + DYNCUPS(cupsGetPrinters); +#undef DYNCUPS + + def = pcupsGetDefault(); if (def && !strcmp(def,"none")) /* CUPS has "none" for no default printer */ def = NULL; + nrofdests = pcupsGetPrinters(&printers); for (i=0;i<nrofdests;i++) { - const char *ppd = cupsGetPPD(printers[i]); + const char *ppd = pcupsGetPPD(printers[i]); char *port,*devline; if (!ppd) { @@ -180,6 +203,7 @@ } HeapFree(GetProcessHeap(),0,port); } + wine_dlclose(cupshandle, NULL, 0); return hadprinter; } #endif @@ -1827,7 +1851,7 @@ RegCloseKey(hkeyPrinter); RegCloseKey(hkeyPrinters); - TRACE("returing %d needed = %ld\n", ret, needed); + TRACE("returning %d needed = %ld\n", ret, needed); if(pcbNeeded) *pcbNeeded = needed; if(!ret) SetLastError(ERROR_INSUFFICIENT_BUFFER); @@ -2544,10 +2568,12 @@ DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) { - FIXME("stub\n"); + FIXME("(%p,first=%ld,no=%ld,level=%ld,job=%p,cb=%ld,%p,%p), stub!\n", + hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned + ); if(pcbNeeded) *pcbNeeded = 0; if(pcReturned) *pcReturned = 0; - return TRUE; + return FALSE; } @@ -2559,10 +2585,12 @@ DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned) { - FIXME("stub\n"); + FIXME("(%p,first=%ld,no=%ld,level=%ld,job=%p,cb=%ld,%p,%p), stub!\n", + hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned + ); if(pcbNeeded) *pcbNeeded = 0; if(pcReturned) *pcReturned = 0; - return TRUE; + return FALSE; } /***************************************************************************** Index: include/config.h.in =================================================================== RCS file: /home/wine/wine/include/config.h.in,v retrieving revision 1.131 diff -u -r1.131 config.h.in --- include/config.h.in 31 Oct 2002 03:41:57 -0000 1.131 +++ include/config.h.in 10 Nov 2002 18:54:52 -0000 @@ -686,6 +686,9 @@ /* The size of a `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG +/* Define to the soname of the libcups library. */ +#undef SONAME_LIBCUPS + /* Define to the soname of the libfreetype library. */ #undef SONAME_LIBFREETYPE