Commit f061f767 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Do not link against -lcups directly, but dynamically load it if

present (just like freetype etc.)
parent bd4a385c
......@@ -362,17 +362,6 @@ then
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"],
wine_cv_warn_cups_h=yes)]
)
AC_SUBST(CUPSLIBS)
dnl **** Check for SANE ****
AC_CHECK_PROG(sane_devel,sane-config,sane-config,no)
if test "$sane_devel" = "no"
......@@ -856,6 +845,7 @@ then
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
......@@ -969,6 +959,7 @@ dnl **** Check for header files ****
AC_CHECK_HEADERS(\
arpa/inet.h \
arpa/nameser.h \
cups/cups.h \
direct.h \
elf.h \
float.h \
......@@ -1597,14 +1588,6 @@ then
echo "*** support before reporting bugs."
fi
if test "$wine_cv_warn_cups_h" = "yes"
then
echo
echo "*** Note: You have cups runtime libraries, but no development"
echo "*** libraries. Install the cups-devel package or whichever package"
echo "*** contains cups.h to enable CUPS support in Wine."
fi
if test "$wine_cv_msg_freetype" = "yes"
then
echo
......
......@@ -5,7 +5,6 @@ VPATH = @srcdir@
MODULE = wineps.dll
IMPORTS = user32 gdi32 winspool.drv advapi32 kernel32
ALTNAMES = wineps16.dll
EXTRALIBS = @CUPSLIBS@
EXTRAINCL = @FREETYPEINCL@
LDDLLFLAGS = @LDDLLFLAGS@
......
......@@ -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"
#ifdef HAVE_CUPS
# include <cups/cups.h>
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
#ifdef HAVE_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 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
HeapDestroy(PSDRV_Heap);
return FALSE;
}
#ifdef HAVE_CUPS_CUPS_H
/* 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_CUPS_H
if (cupshandle && (cupshandle != (void*)-1)) {
wine_dlclose(cupshandle, NULL, 0);
cupshandle = NULL;
}
#endif
break;
}
......@@ -491,24 +511,28 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
goto cleanup;
}
#ifdef HAVE_CUPS
{
ppd = cupsGetPPD(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);
#ifdef HAVE_CUPS_CUPS_H
if (cupshandle != (void*)-1) {
typeof(cupsGetPPD) * pcupsGetPPD = NULL;
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)) {
......
......@@ -5,7 +5,6 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winspool.drv
IMPORTS = advapi32 kernel32
EXTRALIBS = @CUPSLIBS@
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o
......
......@@ -23,14 +23,19 @@
*/
#include "config.h"
#include "wine/port.h"
#include "wine/library.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stddef.h>
#ifdef HAVE_CUPS
#ifdef HAVE_CUPS_CUPS_H
# include <cups/cups.h>
# ifndef CUPS_SONAME
# define CUPS_SONAME "libcups.so"
# endif
#endif
#include "winspool.h"
#include "winbase.h"
......@@ -115,21 +120,39 @@ WINSPOOL_SetDefaultPrinter(const char *devname, const char *name,BOOL force) {
}
}
#ifdef HAVE_CUPS
#ifdef HAVE_CUPS_CUPS_H
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 @@ CUPS_LoadPrinters(void) {
}
HeapFree(GetProcessHeap(),0,port);
}
wine_dlclose(cupshandle, NULL, 0);
return hadprinter;
}
#endif
......@@ -341,7 +365,7 @@ WINSPOOL_LoadSystemPrinters() {
ERR("Failed adding PS Driver (%ld)\n",GetLastError());
return;
}
#ifdef HAVE_CUPS
#ifdef HAVE_CUPS_CUPS_H
/* If we have any CUPS based printers, skip looking for printcap printers */
if (CUPS_LoadPrinters())
return;
......@@ -1827,7 +1851,7 @@ static BOOL WINSPOOL_GetPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
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 @@ BOOL WINAPI EnumJobsA(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
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 @@ BOOL WINAPI EnumJobsW(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
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;
}
/*****************************************************************************
......
......@@ -56,8 +56,8 @@
/* Define if we have linux/input.h AND it contains the INPUT event API */
#undef HAVE_CORRECT_LINUXINPUT_H
/* Define if we have CUPS */
#undef HAVE_CUPS
/* Define to 1 if you have the <cups/cups.h> header file. */
#undef HAVE_CUPS_CUPS_H
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
......@@ -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
......
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