winspool: Store generic.ppd in a resource instead of depending on an external file.

This commit is contained in:
Alexandre Julliard 2013-10-05 12:54:38 +02:00
parent aedb86a46f
commit 8c959d6c56
6 changed files with 33 additions and 36 deletions

5
configure vendored
View File

@ -16598,8 +16598,6 @@ Makefile: Makefile.in Make.vars.in Make.rules config.status
ac_config_links="$ac_config_links dlls/shell32/AUTHORS:AUTHORS"
wine_fn_config_symlink -d dlls/shell32 dlls/shell32/AUTHORS
ac_config_links="$ac_config_links dlls/wineps.drv/generic.ppd:dlls/wineps.drv/generic.ppd"
test "$srcdir" = "." || wine_fn_config_symlink dlls/wineps.drv/generic.ppd
if test "x$enable_fonts" != xno; then
ac_config_links="$ac_config_links fonts/marlett.ttf:fonts/marlett.ttf"
ac_config_links="$ac_config_links fonts/symbol.ttf:fonts/symbol.ttf"
@ -17228,7 +17226,7 @@ wine_fn_config_dll winemac.drv enable_winemac_drv
wine_fn_config_dll winemapi enable_winemapi
wine_fn_config_dll winemp3.acm enable_winemp3_acm
wine_fn_config_dll wineoss.drv enable_wineoss_drv
wine_fn_config_dll wineps.drv enable_wineps_drv install-lib,po
wine_fn_config_dll wineps.drv enable_wineps_drv po
wine_fn_config_dll wineps16.drv16 enable_win16
wine_fn_config_dll wineqtdecoder enable_wineqtdecoder
wine_fn_config_dll winex11.drv enable_winex11_drv
@ -18217,7 +18215,6 @@ do
"include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
"include/stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS include/stamp-h" ;;
"dlls/shell32/AUTHORS") CONFIG_LINKS="$CONFIG_LINKS dlls/shell32/AUTHORS:AUTHORS" ;;
"dlls/wineps.drv/generic.ppd") CONFIG_LINKS="$CONFIG_LINKS dlls/wineps.drv/generic.ppd:dlls/wineps.drv/generic.ppd" ;;
"fonts/marlett.ttf") CONFIG_LINKS="$CONFIG_LINKS fonts/marlett.ttf:fonts/marlett.ttf" ;;
"fonts/symbol.ttf") CONFIG_LINKS="$CONFIG_LINKS fonts/symbol.ttf:fonts/symbol.ttf" ;;
"fonts/tahoma.ttf") CONFIG_LINKS="$CONFIG_LINKS fonts/tahoma.ttf:fonts/tahoma.ttf" ;;

View File

@ -2617,7 +2617,6 @@ Makefile: Makefile.in Make.vars.in Make.rules config.status
@./config.status Make.tmp Makefile])
WINE_CONFIG_SYMLINK(dlls/shell32,,[AUTHORS])
WINE_CONFIG_SYMLINK(dlls/wineps.drv,dlls/wineps.drv,[generic.ppd])
WINE_CONFIG_SYMLINK(fonts,fonts,[marlett.ttf,symbol.ttf,tahoma.ttf,tahomabd.ttf],enable_fonts)
WINE_CONFIG_SYMLINK(loader,loader,[l_intl.nls])
WINE_CONFIG_SYMLINK(po,po,[LINGUAS])
@ -3198,7 +3197,7 @@ WINE_CONFIG_DLL(winemac.drv)
WINE_CONFIG_DLL(winemapi)
WINE_CONFIG_DLL(winemp3.acm)
WINE_CONFIG_DLL(wineoss.drv)
WINE_CONFIG_DLL(wineps.drv,,[install-lib,po])
WINE_CONFIG_DLL(wineps.drv,,[po])
WINE_CONFIG_DLL(wineps16.drv16,enable_win16)
WINE_CONFIG_DLL(wineqtdecoder)
WINE_CONFIG_DLL(winex11.drv)

View File

@ -67,13 +67,3 @@ RC_SRCS = wineps.rc
EXTRASUBDIRS = data
@MAKE_DLL_RULES@
install-ppd:: $(DESTDIR)$(datadir)/wine dummy
$(INSTALL_DATA) $(srcdir)/generic.ppd $(DESTDIR)$(datadir)/wine/generic.ppd
.PHONY: install-ppd
@WOW64_DISABLE@ install install-lib:: install-ppd
uninstall::
$(RM) $(DESTDIR)$(datadir)/wine/generic.ppd

View File

@ -646,7 +646,6 @@ static char *get_fallback_ppd_name( const char *printer_name )
HKEY hkey;
DWORD needed, type;
char *ret = NULL;
const char *data_dir, *filename;
if (RegOpenKeyW( HKEY_CURRENT_USER, ppds_key, &hkey ) == ERROR_SUCCESS )
{
@ -666,22 +665,7 @@ static char *get_fallback_ppd_name( const char *printer_name )
RegCloseKey( hkey );
if (ret) return expand_env_string( ret, type );
}
if ((data_dir = wine_get_data_dir())) filename = "/generic.ppd";
else if ((data_dir = wine_get_build_dir())) filename = "/dlls/wineps.drv/generic.ppd";
else
{
ERR( "Error getting PPD file name for printer '%s'\n", debugstr_a(printer_name) );
return NULL;
}
ret = HeapAlloc( GetProcessHeap(), 0, strlen(data_dir) + strlen(filename) + 1 );
if (ret)
{
strcpy( ret, data_dir );
strcat( ret, filename );
}
return ret;
return NULL;
}
static BOOL copy_file( const char *src, const char *dst )
@ -707,15 +691,39 @@ fail:
return ret;
}
static BOOL get_internal_fallback_ppd( const WCHAR *ppd )
{
static const WCHAR typeW[] = {'P','P','D','F','I','L','E',0};
char *ptr, *end;
DWORD size, written;
HANDLE file;
BOOL ret;
HRSRC res = FindResourceW( WINSPOOL_hInstance, MAKEINTRESOURCEW(1), typeW );
if (!res || !(ptr = LoadResource( WINSPOOL_hInstance, res ))) return FALSE;
size = SizeofResource( WINSPOOL_hInstance, res );
end = memchr( ptr, 0, size ); /* resource file may contain additional nulls */
if (end) size = end - ptr;
file = CreateFileW( ppd, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0 );
if (file == INVALID_HANDLE_VALUE) return FALSE;
ret = WriteFile( file, ptr, size, &written, NULL ) && written == size;
CloseHandle( file );
if (ret) TRACE( "using internal fallback for %s\n", debugstr_w( ppd ));
else DeleteFileW( ppd );
return ret;
}
static BOOL get_fallback_ppd( const char *printer_name, const WCHAR *ppd )
{
char *src = get_fallback_ppd_name( printer_name );
char *dst = wine_get_unix_file_name( ppd );
char *dst, *src = get_fallback_ppd_name( printer_name );
BOOL ret = FALSE;
if (!src) return get_internal_fallback_ppd( ppd );
TRACE( "(%s %s) found %s\n", debugstr_a(printer_name), debugstr_w(ppd), debugstr_a(src) );
if (!src || !dst) goto fail;
if (!(dst = wine_get_unix_file_name( ppd ))) goto fail;
if (symlink( src, dst ) == -1)
if (errno != ENOSYS || !copy_file( src, dst ))

View File

@ -42,6 +42,9 @@ END
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
/* @makedep: generic.ppd */
1 PPDFILE generic.ppd
#define WINE_FILENAME_STR "winspool.drv"
#define WINE_FILEDESCRIPTION_STR "Wine core printer driver"