winspool: Build with msvcrt.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-10-27 08:14:46 +01:00 committed by Alexandre Julliard
parent 8ecd220c8e
commit da0db2eb79
8 changed files with 121 additions and 124 deletions

1
configure vendored
View File

@ -16881,7 +16881,6 @@ ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $BUILTINFLAG" CFLAGS="$CFLAGS $BUILTINFLAG"
for ac_func in \ for ac_func in \
epoll_create \ epoll_create \
fork \
fstatfs \ fstatfs \
futimens \ futimens \
futimes \ futimes \

View File

@ -1941,7 +1941,6 @@ ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $BUILTINFLAG" CFLAGS="$CFLAGS $BUILTINFLAG"
AC_CHECK_FUNCS(\ AC_CHECK_FUNCS(\
epoll_create \ epoll_create \
fork \
fstatfs \ fstatfs \
futimens \ futimens \
futimes \ futimes \

View File

@ -1,12 +1,11 @@
EXTRADEFS = -D_SPOOL32_ EXTRADEFS = -D_SPOOL32_
MODULE = winspool.drv MODULE = winspool.drv
UNIXLIB = winspool.so
IMPORTLIB = winspool IMPORTLIB = winspool
IMPORTS = user32 gdi32 advapi32 IMPORTS = user32 gdi32 advapi32
EXTRAINCL = $(CUPS_CFLAGS) EXTRAINCL = $(CUPS_CFLAGS)
EXTRALIBS = $(APPLICATIONSERVICES_LIBS) EXTRALIBS = $(APPLICATIONSERVICES_LIBS)
EXTRADLLFLAGS = -mcygwin
C_SRCS = \ C_SRCS = \
cups.c \ cups.c \
info.c \ info.c \

View File

@ -17,8 +17,11 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#if 0
#pragma makedep unix
#endif
#include "config.h" #include "config.h"
#include "wine/port.h"
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
@ -26,12 +29,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <dlfcn.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
#endif
#ifdef HAVE_CUPS_CUPS_H #ifdef HAVE_CUPS_CUPS_H
#include <cups/cups.h> #include <cups/cups.h>
#endif #endif
@ -108,6 +110,7 @@
#include "ddk/winsplp.h" #include "ddk/winsplp.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/unixlib.h"
#include "wspool.h" #include "wspool.h"
@ -116,21 +119,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(winspool);
static const WCHAR CUPS_Port[] = { 'C','U','P','S',':',0 }; static const WCHAR CUPS_Port[] = { 'C','U','P','S',':',0 };
static const WCHAR LPR_Port[] = { 'L','P','R',':',0 }; static const WCHAR LPR_Port[] = { 'L','P','R',':',0 };
/* Temporary helpers until switch to unixlib */
#include "winnls.h"
#include "wine/heap.h"
#define malloc( sz ) heap_alloc( sz )
#define free( ptr ) heap_free( ptr )
static DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
{
return MultiByteToWideChar( CP_UNIXCP, 0, src, srclen, dst, dstlen );
}
static int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict )
{
/* FIXME: strict */
return WideCharToMultiByte( CP_UNIXCP, 0, src, srclen, dst, dstlen, NULL, NULL );
}
#ifdef SONAME_LIBCUPS #ifdef SONAME_LIBCUPS
static void *libcups_handle; static void *libcups_handle;
@ -159,7 +147,7 @@ static const char * (*pcupsLastErrorString)(void);
#endif /* SONAME_LIBCUPS */ #endif /* SONAME_LIBCUPS */
NTSTATUS unix_process_attach( void *arg ) static NTSTATUS process_attach( void *args )
{ {
#ifdef SONAME_LIBCUPS #ifdef SONAME_LIBCUPS
libcups_handle = dlopen( SONAME_LIBCUPS, RTLD_NOW ); libcups_handle = dlopen( SONAME_LIBCUPS, RTLD_NOW );
@ -347,7 +335,7 @@ static int get_cups_default_options( const char *printer, int num_options, cups_
} }
#endif /* SONAME_LIBCUPS */ #endif /* SONAME_LIBCUPS */
NTSTATUS unix_enum_printers( void *args ) static NTSTATUS enum_printers( void *args )
{ {
struct enum_printers_params *params = args; struct enum_printers_params *params = args;
#ifdef SONAME_LIBCUPS #ifdef SONAME_LIBCUPS
@ -417,7 +405,7 @@ NTSTATUS unix_enum_printers( void *args )
#endif /* SONAME_LIBCUPS */ #endif /* SONAME_LIBCUPS */
} }
NTSTATUS unix_get_ppd( void *args ) static NTSTATUS get_ppd( void *args )
{ {
struct get_ppd_params *params = args; struct get_ppd_params *params = args;
char *unix_ppd = get_unix_file_name( params->ppd ); char *unix_ppd = get_unix_file_name( params->ppd );
@ -458,7 +446,7 @@ NTSTATUS unix_get_ppd( void *args )
return status; return status;
} }
NTSTATUS unix_get_default_page_size( void *args ) static NTSTATUS get_default_page_size( void *args )
{ {
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H #ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
struct get_default_page_size_params *params = args; struct get_default_page_size_params *params = args;
@ -504,7 +492,6 @@ end:
*/ */
static BOOL schedule_pipe( const WCHAR *cmd, const WCHAR *filename ) static BOOL schedule_pipe( const WCHAR *cmd, const WCHAR *filename )
{ {
#ifdef HAVE_FORK
char *unixname, *cmdA; char *unixname, *cmdA;
DWORD len; DWORD len;
int fds[2] = { -1, -1 }, file_fd = -1, no_read; int fds[2] = { -1, -1 }, file_fd = -1, no_read;
@ -580,9 +567,6 @@ end:
free( cmdA ); free( cmdA );
free( unixname ); free( unixname );
return ret; return ret;
#else
return FALSE;
#endif
} }
/***************************************************************************** /*****************************************************************************
@ -677,7 +661,7 @@ static BOOL schedule_cups( const WCHAR *printer_name, const WCHAR *filename, con
} }
} }
BOOL unix_schedule_job( void *args ) static NTSTATUS schedule_job( void *args )
{ {
struct schedule_job_params *params = args; struct schedule_job_params *params = args;
@ -695,3 +679,12 @@ BOOL unix_schedule_job( void *args )
return FALSE; return FALSE;
} }
unixlib_entry_t __wine_unix_call_funcs[] =
{
process_attach,
enum_printers,
get_default_page_size,
get_ppd,
schedule_job,
};

View File

@ -23,9 +23,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -46,13 +43,13 @@
#include "wingdi.h" #include "wingdi.h"
#include "winspool.h" #include "winspool.h"
#include "winternl.h" #include "winternl.h"
#include "winnls.h"
#include "wine/windef16.h" #include "wine/windef16.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h" #include "wine/list.h"
#include "wine/rbtree.h" #include "wine/rbtree.h"
#include "wine/heap.h" #include "wine/heap.h"
#include "winnls.h" #include <wine/unixlib.h>
#include "ddk/winsplp.h" #include "ddk/winsplp.h"
#include "wspool.h" #include "wspool.h"
@ -289,7 +286,7 @@ static const printenv_t * validate_envW(LPCWSTR env)
{ {
for (i = 0; i < ARRAY_SIZE(all_printenv); i++) for (i = 0; i < ARRAY_SIZE(all_printenv); i++)
{ {
if (lstrcmpiW(env, all_printenv[i]->envname) == 0) if (!wcsicmp( env, all_printenv[i]->envname ))
{ {
result = all_printenv[i]; result = all_printenv[i];
break; break;
@ -332,7 +329,7 @@ static LPWSTR strdupW(LPCWSTR p)
DWORD len; DWORD len;
if(!p) return NULL; if(!p) return NULL;
len = (strlenW(p) + 1) * sizeof(WCHAR); len = (wcslen( p ) + 1) * sizeof(WCHAR);
ret = HeapAlloc(GetProcessHeap(), 0, len); ret = HeapAlloc(GetProcessHeap(), 0, len);
memcpy(ret, p, len); memcpy(ret, p, len);
return ret; return ret;
@ -389,7 +386,7 @@ static DEVMODEA *DEVMODEdupWtoA( const DEVMODEW *dmW )
static void packed_string_WtoA( WCHAR *strW ) static void packed_string_WtoA( WCHAR *strW )
{ {
DWORD len = strlenW( strW ), size = (len + 1) * sizeof(WCHAR), ret; DWORD len = wcslen( strW ), size = (len + 1) * sizeof(WCHAR), ret;
char *str; char *str;
if (!len) return; if (!len) return;
@ -458,19 +455,20 @@ static HKEY WINSPOOL_OpenDriverReg(const void *pEnvironment)
HKEY retval = NULL; HKEY retval = NULL;
LPWSTR buffer; LPWSTR buffer;
const printenv_t *env; const printenv_t *env;
unsigned int len;
TRACE("(%s)\n", debugstr_w(pEnvironment)); TRACE("(%s)\n", debugstr_w(pEnvironment));
env = validate_envW(pEnvironment); env = validate_envW(pEnvironment);
if (!env) return NULL; if (!env) return NULL;
buffer = HeapAlloc( GetProcessHeap(), 0, len = wcslen( DriversW ) + wcslen( env->envname ) + wcslen( env->versionregpath ) + 1;
(strlenW(DriversW) + strlenW(env->envname) + buffer = heap_alloc( len * sizeof(WCHAR) );
strlenW(env->versionregpath) + 1) * sizeof(WCHAR)); if (buffer)
if(buffer) { {
wsprintfW(buffer, DriversW, env->envname, env->versionregpath); swprintf( buffer, len, DriversW, env->envname, env->versionregpath );
RegCreateKeyW( HKEY_LOCAL_MACHINE, buffer, &retval ); RegCreateKeyW( HKEY_LOCAL_MACHINE, buffer, &retval );
HeapFree(GetProcessHeap(), 0, buffer); heap_free( buffer );
} }
return retval; return retval;
} }
@ -487,7 +485,7 @@ static CRITICAL_SECTION config_modules_cs = { &config_modules_cs_debug, -1, 0, 0
static int compare_config_modules(const void *key, const struct wine_rb_entry *entry) static int compare_config_modules(const void *key, const struct wine_rb_entry *entry)
{ {
config_module_t *module = WINE_RB_ENTRY_VALUE(entry, config_module_t, entry); config_module_t *module = WINE_RB_ENTRY_VALUE(entry, config_module_t, entry);
return lstrcmpiW(key, module->name); return wcsicmp( key, module->name );
} }
static struct wine_rb_tree config_modules = { compare_config_modules }; static struct wine_rb_tree config_modules = { compare_config_modules };
@ -549,7 +547,7 @@ static config_module_t *get_config_module(const WCHAR *device, BOOL grab)
goto ret; goto ret;
} }
len = lstrlenW(device); len = wcslen( device );
if (!(ret = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(config_module_t, name[len + 1])))) if (!(ret = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(config_module_t, name[len + 1]))))
goto ret; goto ret;
@ -557,7 +555,7 @@ static config_module_t *get_config_module(const WCHAR *device, BOOL grab)
ret->module = driver_module; ret->module = driver_module;
ret->pDrvDeviceCapabilities = (void *)GetProcAddress(driver_module, "DrvDeviceCapabilities"); ret->pDrvDeviceCapabilities = (void *)GetProcAddress(driver_module, "DrvDeviceCapabilities");
ret->pDrvDocumentProperties = (void *)GetProcAddress(driver_module, "DrvDocumentProperties"); ret->pDrvDocumentProperties = (void *)GetProcAddress(driver_module, "DrvDocumentProperties");
lstrcpyW(ret->name, device); wcscpy( ret->name, device );
wine_rb_put(&config_modules, ret->name, &ret->entry); wine_rb_put(&config_modules, ret->name, &ret->entry);
ret: ret:
@ -582,7 +580,7 @@ static int multi_sz_lenA(const char *str)
if(!str) return 0; if(!str) return 0;
do do
{ {
ptr += lstrlenA(ptr) + 1; ptr += strlen( ptr ) + 1;
} while(*ptr); } while(*ptr);
return ptr - str + 1; return ptr - str + 1;
@ -708,7 +706,7 @@ static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
{ {
static const WCHAR dot_ppd[] = {'.','p','p','d',0}; static const WCHAR dot_ppd[] = {'.','p','p','d',0};
static const WCHAR invalid_chars[] = {'*','?','<','>','|','"','/','\\',0}; static const WCHAR invalid_chars[] = {'*','?','<','>','|','"','/','\\',0};
int dir_len = strlenW( dir ), file_len = strlenW( file_name ); int dir_len = wcslen( dir ), file_len = wcslen( file_name );
int len = (dir_len + file_len + ARRAY_SIZE( dot_ppd )) * sizeof(WCHAR); int len = (dir_len + file_len + ARRAY_SIZE( dot_ppd )) * sizeof(WCHAR);
WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len ), *p; WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len ), *p;
@ -718,7 +716,7 @@ static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
memcpy( ppd + dir_len + file_len, dot_ppd, sizeof(dot_ppd) ); memcpy( ppd + dir_len + file_len, dot_ppd, sizeof(dot_ppd) );
p = ppd + dir_len; p = ppd + dir_len;
while ((p = strpbrkW( p, invalid_chars ))) *p++ = '_'; while ((p = wcspbrk( p, invalid_chars ))) *p++ = '_';
return ppd; return ppd;
} }
@ -850,9 +848,9 @@ static BOOL init_unix_printers( void )
if (!ppd_dir && !(ppd_dir = get_ppd_dir())) break; if (!ppd_dir && !(ppd_dir = get_ppd_dir())) break;
if (!add_printer_driver( printer->name, ppd_dir )) continue; if (!add_printer_driver( printer->name, ppd_dir )) continue;
port = heap_alloc( sizeof(CUPS_Port) + lstrlenW( printer->name ) * sizeof(WCHAR) ); port = heap_alloc( sizeof(CUPS_Port) + wcslen( printer->name ) * sizeof(WCHAR) );
lstrcpyW( port, CUPS_Port ); wcscpy( port, CUPS_Port );
lstrcatW( port, printer->name ); wcscat( port, printer->name );
memset( &pi2, 0, sizeof(PRINTER_INFO_2W) ); memset( &pi2, 0, sizeof(PRINTER_INFO_2W) );
pi2.pPrinterName = printer->name; pi2.pPrinterName = printer->name;
@ -934,7 +932,7 @@ static inline DWORD set_reg_szW(HKEY hkey, const WCHAR *keyname, const WCHAR *va
{ {
if (value) if (value)
return RegSetValueExW(hkey, keyname, 0, REG_SZ, (const BYTE*)value, return RegSetValueExW(hkey, keyname, 0, REG_SZ, (const BYTE*)value,
(lstrlenW(value) + 1) * sizeof(WCHAR)); (wcslen( value ) + 1) * sizeof(WCHAR));
else else
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
} }
@ -979,14 +977,16 @@ static LPWSTR get_servername_from_name(LPCWSTR name)
if (server == NULL) return NULL; if (server == NULL) return NULL;
/* strip '\' and the printername */ /* strip '\' and the printername */
ptr = strchrW(server, '\\'); ptr = wcschr( server, '\\' );
if (ptr) ptr[0] = '\0'; if (ptr) ptr[0] = '\0';
TRACE("found %s\n", debugstr_w(server)); TRACE("found %s\n", debugstr_w(server));
len = ARRAY_SIZE(buffer); len = ARRAY_SIZE(buffer);
if (GetComputerNameW(buffer, &len)) { if (GetComputerNameW(buffer, &len))
if (lstrcmpW(buffer, server) == 0) { {
if (!wcscmp( buffer, server ))
{
/* The requested Servername is our computername */ /* The requested Servername is our computername */
HeapFree(GetProcessHeap(), 0, server); HeapFree(GetProcessHeap(), 0, server);
return NULL; return NULL;
@ -1004,10 +1004,12 @@ static LPWSTR get_servername_from_name(LPCWSTR name)
static LPCWSTR get_basename_from_name(LPCWSTR name) static LPCWSTR get_basename_from_name(LPCWSTR name)
{ {
if (name == NULL) return NULL; if (name == NULL) return NULL;
if ((name[0] == '\\') && (name[1] == '\\')) { if ((name[0] == '\\') && (name[1] == '\\'))
{
/* skip over the servername and search for the following '\' */ /* skip over the servername and search for the following '\' */
name = strchrW(&name[2], '\\'); name = wcschr( &name[2], '\\' );
if ((name) && (name[1])) { if ((name) && (name[1]))
{
/* found a separator ('\') followed by a name: /* found a separator ('\') followed by a name:
skip over the separator and return the rest */ skip over the separator and return the rest */
name++; name++;
@ -1075,7 +1077,7 @@ static HANDLE get_opened_printer_entry(LPWSTR name, LPPRINTER_DEFAULTSW pDefault
} }
else else
{ {
if(!queue && (name) && !lstrcmpW(name, printer_handles[i]->name)) if(!queue && (name) && !wcscmp( name, printer_handles[i]->name ))
queue = printer_handles[i]->queue; queue = printer_handles[i]->queue;
} }
} }
@ -1167,8 +1169,8 @@ static void old_printer_check( BOOL delete_phase )
{ {
if (!pi[i].pPortName) continue; if (!pi[i].pPortName) continue;
if (strncmpW( pi[i].pPortName, CUPS_Port, strlenW(CUPS_Port) ) && if (wcsncmp( pi[i].pPortName, CUPS_Port, wcslen( CUPS_Port ) ) &&
strncmpW( pi[i].pPortName, LPR_Port, strlenW(LPR_Port) )) wcsncmp( pi[i].pPortName, LPR_Port, wcslen( LPR_Port ) ))
continue; continue;
if (open_printer_reg_key( pi[i].pPrinterName, &key )) continue; if (open_printer_reg_key( pi[i].pPrinterName, &key )) continue;
@ -2541,9 +2543,9 @@ BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPD
if(path[len - 1] != '\\') if(path[len - 1] != '\\')
path[len++] = '\\'; path[len++] = '\\';
memcpy( path + len, spool_path, sizeof(spool_path) ); memcpy( path + len, spool_path, sizeof(spool_path) );
sprintfW(filename, fmtW, path, job->job_id); swprintf( filename, ARRAY_SIZE(filename), fmtW, path, job->job_id );
len = strlenW(filename); len = wcslen( filename );
job->filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); job->filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
memcpy(job->filename, filename, (len + 1) * sizeof(WCHAR)); memcpy(job->filename, filename, (len + 1) * sizeof(WCHAR));
job->portname = NULL; job->portname = NULL;
@ -2680,7 +2682,7 @@ BOOL WINAPI GetPrintProcessorDirectoryW(LPWSTR server, LPWSTR env,
*/ */
static void set_devices_and_printerports(PRINTER_INFO_2W *pi) static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
{ {
DWORD portlen = lstrlenW(pi->pPortName) * sizeof(WCHAR); DWORD portlen = wcslen( pi->pPortName ) * sizeof(WCHAR);
WCHAR *devline; WCHAR *devline;
HKEY hkey; HKEY hkey;
@ -2688,22 +2690,23 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
/* FIXME: the driver must change to "winspool" */ /* FIXME: the driver must change to "winspool" */
devline = HeapAlloc(GetProcessHeap(), 0, sizeof(driver_nt) + portlen + sizeof(timeout_15_45)); devline = HeapAlloc(GetProcessHeap(), 0, sizeof(driver_nt) + portlen + sizeof(timeout_15_45));
if (devline) { if (devline)
lstrcpyW(devline, driver_nt); {
lstrcatW(devline, commaW); wcscpy( devline, driver_nt );
lstrcatW(devline, pi->pPortName); wcscat( devline, commaW );
wcscat( devline, pi->pPortName );
TRACE("using %s\n", debugstr_w(devline)); TRACE("using %s\n", debugstr_w(devline));
if (!RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey)) { if (!RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey)) {
RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline, RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
(lstrlenW(devline) + 1) * sizeof(WCHAR)); (wcslen( devline ) + 1) * sizeof(WCHAR));
RegCloseKey(hkey); RegCloseKey(hkey);
} }
lstrcatW(devline, timeout_15_45); wcscat( devline, timeout_15_45 );
if (!RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey)) { if (!RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey)) {
RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline, RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
(lstrlenW(devline) + 1) * sizeof(WCHAR)); (wcslen( devline ) + 1) * sizeof(WCHAR));
RegCloseKey(hkey); RegCloseKey(hkey);
} }
HeapFree(GetProcessHeap(), 0, devline); HeapFree(GetProcessHeap(), 0, devline);
@ -2768,7 +2771,8 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
RegCloseKey(hkeyDriver); RegCloseKey(hkeyDriver);
RegCloseKey(hkeyDrivers); RegCloseKey(hkeyDrivers);
if(lstrcmpiW(pi->pPrintProcessor, WinPrintW)) { /* FIXME */ if(wcsicmp( pi->pPrintProcessor, WinPrintW ))
{
FIXME("Can't find processor %s\n", debugstr_w(pi->pPrintProcessor)); FIXME("Can't find processor %s\n", debugstr_w(pi->pPrintProcessor));
SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR); SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR);
RegCloseKey(hkeyPrinters); RegCloseKey(hkeyPrinters);
@ -2825,8 +2829,9 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
} }
else else
{ {
/* set devmode to printer name */ unsigned int len = min( ARRAY_SIZE( dm->dmDeviceName ) - 1, wcslen( pi->pPrinterName ) );
lstrcpynW( dm->dmDeviceName, pi->pPrinterName, CCHDEVICENAME ); memcpy( dm->dmDeviceName, pi->pPrinterName, len * sizeof(WCHAR) );
dm->dmDeviceName[len] = '\0';
} }
} }
@ -2985,7 +2990,7 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
RegCloseKey(hkey); RegCloseKey(hkey);
} }
if (GetDefaultPrinterW( def, &size ) && !strcmpW( def, lpNameW )) if (GetDefaultPrinterW( def, &size ) && !wcscmp( def, lpNameW ))
{ {
if (!RegCreateKeyW( HKEY_CURRENT_USER, user_default_reg_key, &hkey )) if (!RegCreateKeyW( HKEY_CURRENT_USER, user_default_reg_key, &hkey ))
{ {
@ -3554,7 +3559,7 @@ static BOOL get_filename_from_reg(HKEY hkey, LPCWSTR driverdir, DWORD dirlen, LP
/* we must build the full Path */ /* we must build the full Path */
*needed += dirlen; *needed += dirlen;
if ((out) && (outlen > dirlen)) { if ((out) && (outlen > dirlen)) {
lstrcpyW((LPWSTR)out, driverdir); wcscpy( (WCHAR *)out, driverdir );
out += dirlen; out += dirlen;
outlen -= dirlen; outlen -= dirlen;
} }
@ -3563,16 +3568,16 @@ static BOOL get_filename_from_reg(HKEY hkey, LPCWSTR driverdir, DWORD dirlen, LP
} }
/* write the filename */ /* write the filename */
size = (lstrlenW(ptr) + 1) * sizeof(WCHAR); size = (wcslen( ptr ) + 1) * sizeof(WCHAR);
if ((out) && (outlen >= size)) { if ((out) && (outlen >= size)) {
lstrcpyW((LPWSTR)out, ptr); wcscpy( (WCHAR *)out, ptr );
out += size; out += size;
outlen -= size; outlen -= size;
} }
else else
out = NULL; out = NULL;
*needed += size; *needed += size;
ptr += lstrlenW(ptr)+1; ptr += wcslen( ptr ) + 1;
if ((type != REG_MULTI_SZ) || (!ptr[0])) ptr = NULL; if ((type != REG_MULTI_SZ) || (!ptr[0])) ptr = NULL;
} }
@ -3634,7 +3639,7 @@ static void WINSPOOL_GetDefaultDevMode(LPBYTE ptr, DWORD buflen, DWORD *needed)
/* the driver will update registry with real values */ /* the driver will update registry with real values */
memset(dm, 0, sizeof(*dm)); memset(dm, 0, sizeof(*dm));
dm->dmSize = sizeof(*dm); dm->dmSize = sizeof(*dm);
lstrcpyW(dm->dmDeviceName, winepsW); wcscpy( dm->dmDeviceName, winepsW );
} }
*needed = sizeof(DEVMODEW); *needed = sizeof(DEVMODEW);
} }
@ -4487,9 +4492,9 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
if (di) ZeroMemory(di, di_sizeof[Level]); if (di) ZeroMemory(di, di_sizeof[Level]);
*pcbNeeded = (lstrlenW(DriverName) + 1) * sizeof(WCHAR); *pcbNeeded = (wcslen( DriverName ) + 1) * sizeof(WCHAR);
if (*pcbNeeded <= cbBuf) if (*pcbNeeded <= cbBuf)
strcpyW((LPWSTR)strPtr, DriverName); wcscpy( (WCHAR *)strPtr, DriverName );
/* pName for level 1 has a different offset! */ /* pName for level 1 has a different offset! */
if (Level == 1) { if (Level == 1) {
@ -4510,11 +4515,11 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
/* Should never Fail */ /* Should never Fail */
return FALSE; return FALSE;
} }
lstrcatW(driverdir, env->versionsubdir); wcscat( driverdir, env->versionsubdir );
lstrcatW(driverdir, backslashW); wcscat( driverdir, backslashW );
/* dirlen must not include the terminating zero */ /* dirlen must not include the terminating zero */
dirlen = lstrlenW(driverdir) * sizeof(WCHAR); dirlen = wcslen( driverdir ) * sizeof(WCHAR);
if (!DriverName[0] || RegOpenKeyW(hkeyDrivers, DriverName, &hkeyDriver) != ERROR_SUCCESS) { if (!DriverName[0] || RegOpenKeyW(hkeyDrivers, DriverName, &hkeyDriver) != ERROR_SUCCESS) {
ERR("Can't find driver %s in registry\n", debugstr_w(DriverName)); ERR("Can't find driver %s in registry\n", debugstr_w(DriverName));
@ -4523,11 +4528,11 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
} }
/* pEnvironment */ /* pEnvironment */
size = (lstrlenW(env->envname) + 1) * sizeof(WCHAR); size = (wcslen( env->envname ) + 1) * sizeof(WCHAR);
*pcbNeeded += size; *pcbNeeded += size;
if (*pcbNeeded <= cbBuf) { if (*pcbNeeded <= cbBuf) {
lstrcpyW((LPWSTR)strPtr, env->envname); wcscpy( (WCHAR *)strPtr, env->envname );
if (di) di->pEnvironment = (LPWSTR)strPtr; if (di) di->pEnvironment = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL; strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
} }
@ -5210,7 +5215,7 @@ BOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level,
memset( pDriverInfo, 0, cbBuf); memset( pDriverInfo, 0, cbBuf);
/* Exception: pull all printers */ /* Exception: pull all printers */
if (pEnvironment && !strcmpW(pEnvironment, allW)) if (pEnvironment && !wcscmp( pEnvironment, allW ))
{ {
DWORD i, needed, bufsize = cbBuf; DWORD i, needed, bufsize = cbBuf;
DWORD total_found = 0; DWORD total_found = 0;
@ -5501,7 +5506,7 @@ BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
} }
TRACE("%s\n", debugstr_w(buffer)); TRACE("%s\n", debugstr_w(buffer));
if ((ptr = strchrW(buffer, ',')) == NULL) if ((ptr = wcschr( buffer, ',' )) == NULL)
{ {
SetLastError(ERROR_INVALID_NAME); SetLastError(ERROR_INVALID_NAME);
retval = FALSE; retval = FALSE;
@ -5509,14 +5514,14 @@ BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
} }
*ptr = 0; *ptr = 0;
*namesize = strlenW(buffer) + 1; *namesize = wcslen( buffer ) + 1;
if(!name || (*namesize > insize)) if(!name || (*namesize > insize))
{ {
SetLastError(ERROR_INSUFFICIENT_BUFFER); SetLastError(ERROR_INSUFFICIENT_BUFFER);
retval = FALSE; retval = FALSE;
goto end; goto end;
} }
strcpyW(name, buffer); wcscpy( name, buffer );
end: end:
HeapFree( GetProcessHeap(), 0, buffer); HeapFree( GetProcessHeap(), 0, buffer);
@ -5624,7 +5629,7 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
} }
/* "pszPrinter" is never empty or NULL here. */ /* "pszPrinter" is never empty or NULL here. */
namelen = lstrlenW(pszPrinter); namelen = wcslen( pszPrinter );
size = namelen + (MAX_PATH * 2) + 3; /* printer,driver,port and a 0 */ size = namelen + (MAX_PATH * 2) + 3; /* printer,driver,port and a 0 */
buffer = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); buffer = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
if (!buffer || if (!buffer ||
@ -5647,7 +5652,7 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
if (!RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hdev)) if (!RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hdev))
{ {
RegSetValueExW(hdev, deviceW, 0, REG_SZ, (BYTE *)buffer, (lstrlenW(buffer) + 1) * sizeof(WCHAR)); RegSetValueExW(hdev, deviceW, 0, REG_SZ, (BYTE *)buffer, (wcslen( buffer ) + 1) * sizeof(WCHAR));
RegCloseKey(hdev); RegCloseKey(hdev);
} }
} }
@ -7525,7 +7530,7 @@ static BOOL string_to_buf(LPCWSTR str, LPBYTE ptr, DWORD cb, DWORD *size, BOOL u
if(unicode) if(unicode)
{ {
*size = (strlenW(str) + 1) * sizeof(WCHAR); *size = (wcslen( str ) + 1) * sizeof(WCHAR);
if(*size <= cb) if(*size <= cb)
{ {
memcpy(ptr, str, *size); memcpy(ptr, str, *size);
@ -7904,7 +7909,7 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
TRACE("need to schedule job %d filename %s to port %s\n", job->job_id, debugstr_w(job->filename), TRACE("need to schedule job %d filename %s to port %s\n", job->job_id, debugstr_w(job->filename),
debugstr_w(portname)); debugstr_w(portname));
if (!strncmpW( portname, FILE_Port, strlenW( FILE_Port ) )) if (!wcsncmp( portname, FILE_Port, wcslen( FILE_Port ) ))
{ {
ret = schedule_file( job->filename ); ret = schedule_file( job->filename );
} }
@ -8024,7 +8029,7 @@ LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
return NULL; return NULL;
pi5 = HeapAlloc(GetProcessHeap(), 0, len); pi5 = HeapAlloc(GetProcessHeap(), 0, len);
GetPrinterW(hPrinter, 5, (LPBYTE)pi5, len, &len); GetPrinterW(hPrinter, 5, (LPBYTE)pi5, len, &len);
if(!pi5->pPortName || strcmpW(pi5->pPortName, FILE_Port)) if(!pi5->pPortName || wcscmp( pi5->pPortName, FILE_Port ))
{ {
HeapFree(GetProcessHeap(), 0, pi5); HeapFree(GetProcessHeap(), 0, pi5);
return NULL; return NULL;
@ -8032,7 +8037,7 @@ LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
HeapFree(GetProcessHeap(), 0, pi5); HeapFree(GetProcessHeap(), 0, pi5);
} }
if(doc->lpszOutput == NULL || !strcmpW(doc->lpszOutput, FILE_Port)) if(doc->lpszOutput == NULL || !wcscmp( doc->lpszOutput, FILE_Port ))
{ {
LPWSTR name; LPWSTR name;

View File

@ -18,19 +18,17 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdarg.h> #include <stdarg.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winspool.h" #include "winspool.h"
#include "winreg.h" #include "winreg.h"
#include "winternl.h"
#include "ddk/winsplp.h" #include "ddk/winsplp.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unixlib.h"
#include "wspool.h" #include "wspool.h"
@ -50,10 +48,10 @@ static CRITICAL_SECTION backend_cs = { &backend_cs_debug, -1, 0, 0, 0, 0 };
/* ############################### */ /* ############################### */
HINSTANCE WINSPOOL_hInstance = NULL; HINSTANCE WINSPOOL_hInstance = NULL;
unixlib_handle_t winspool_handle = 0;
static HMODULE hlocalspl = NULL; static HMODULE hlocalspl;
static BOOL (WINAPI *pInitializePrintProvidor)(LPPRINTPROVIDOR, DWORD, LPWSTR); static BOOL (WINAPI *pInitializePrintProvidor)(LPPRINTPROVIDOR, DWORD, LPWSTR);
PRINTPROVIDOR *backend = NULL; PRINTPROVIDOR *backend = NULL;
/****************************************************************************** /******************************************************************************
@ -117,6 +115,8 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
WINSPOOL_hInstance = instance; WINSPOOL_hInstance = instance;
DisableThreadLibraryCalls( instance ); DisableThreadLibraryCalls( instance );
if (!NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
&winspool_handle, sizeof(winspool_handle), NULL ))
UNIX_CALL( process_attach, NULL ); UNIX_CALL( process_attach, NULL );
WINSPOOL_LoadSystemPrinters(); WINSPOOL_LoadSystemPrinters();
break; break;

View File

@ -72,10 +72,15 @@ struct schedule_job_params
const WCHAR *wine_port; const WCHAR *wine_port;
}; };
#define UNIX_CALL( func, params ) unix_ ## func( params ) extern unixlib_handle_t winspool_handle DECLSPEC_HIDDEN;
NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN; #define UNIX_CALL( func, params ) __wine_unix_call( winspool_handle, unix_ ## func, params )
NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN;
NTSTATUS unix_get_default_page_size( void * ) DECLSPEC_HIDDEN; enum cups_funcs
NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN; {
NTSTATUS unix_schedule_job( void * ) DECLSPEC_HIDDEN; unix_process_attach,
unix_enum_printers,
unix_get_default_page_size,
unix_get_ppd,
unix_schedule_job,
};

View File

@ -74,9 +74,6 @@
/* Define to 1 if you have the <fontconfig/fontconfig.h> header file. */ /* Define to 1 if you have the <fontconfig/fontconfig.h> header file. */
#undef HAVE_FONTCONFIG_FONTCONFIG_H #undef HAVE_FONTCONFIG_FONTCONFIG_H
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
/* Define if FreeType 2 is installed */ /* Define if FreeType 2 is installed */
#undef HAVE_FREETYPE #undef HAVE_FREETYPE