Huw Davies : wineps: Use the unicode version of StartDocPrinter.
Alexandre Julliard
julliard at winehq.org
Mon Apr 2 13:14:51 CDT 2012
Module: wine
Branch: master
Commit: d963a8f864a495f7230dc6fe717d71e61ae51d67
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d963a8f864a495f7230dc6fe717d71e61ae51d67
Author: Huw Davies <huw at codeweavers.com>
Date: Mon Apr 2 14:14:08 2012 +0100
wineps: Use the unicode version of StartDocPrinter.
---
dlls/wineps.drv/escape.c | 68 ++++++++-------------------------------------
dlls/wineps.drv/init.c | 18 +++++++++---
dlls/wineps.drv/psdrv.h | 2 +-
3 files changed, 26 insertions(+), 62 deletions(-)
diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c
index eff7500..66a1a89 100644
--- a/dlls/wineps.drv/escape.c
+++ b/dlls/wineps.drv/escape.c
@@ -409,15 +409,15 @@ INT PSDRV_EndPage( PHYSDEV dev )
/************************************************************************
- * PSDRV_StartDocA
+ * PSDRV_StartDoc
*/
-static INT PSDRV_StartDocA( PHYSDEV dev, const DOCINFOA *doc )
+INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
- DOC_INFO_1A di;
+ DOC_INFO_1W di;
- TRACE("(%p, %p) => %s, %s, %s\n", physDev, doc, debugstr_a(doc->lpszDocName),
- debugstr_a(doc->lpszOutput), debugstr_a(doc->lpszDatatype));
+ TRACE("(%p, %p) => %s, %s, %s\n", physDev, doc, debugstr_w(doc->lpszDocName),
+ debugstr_w(doc->lpszOutput), debugstr_w(doc->lpszDatatype));
if(physDev->job.id) {
FIXME("hJob != 0. Now what?\n");
@@ -431,21 +431,21 @@ static INT PSDRV_StartDocA( PHYSDEV dev, const DOCINFOA *doc )
return 0;
}
- di.pDocName = (LPSTR) doc->lpszDocName;
+ di.pDocName = (LPWSTR) doc->lpszDocName;
di.pDatatype = NULL;
if(doc->lpszOutput)
- di.pOutputFile = (LPSTR) doc->lpszOutput;
+ di.pOutputFile = (LPWSTR) doc->lpszOutput;
else if(physDev->job.output)
di.pOutputFile = physDev->job.output;
else
di.pOutputFile = NULL;
- TRACE("using output: %s\n", debugstr_a(di.pOutputFile));
+ TRACE("using output: %s\n", debugstr_w(di.pOutputFile));
/* redirection located in HKCU\Software\Wine\Printing\Spooler
is done during winspool.drv,ScheduleJob */
- physDev->job.id = StartDocPrinterA(physDev->job.hprinter, 1, (LPBYTE) &di);
+ physDev->job.id = StartDocPrinterW(physDev->job.hprinter, 1, (LPBYTE) &di);
if(!physDev->job.id) {
WARN("StartDocPrinter() failed: %d\n", GetLastError());
ClosePrinter(physDev->job.hprinter);
@@ -458,8 +458,9 @@ static INT PSDRV_StartDocA( PHYSDEV dev, const DOCINFOA *doc )
physDev->job.in_passthrough = FALSE;
physDev->job.had_passthrough_rect = FALSE;
if(doc->lpszDocName) {
- physDev->job.DocName = HeapAlloc(GetProcessHeap(), 0, strlen(doc->lpszDocName)+1);
- strcpy(physDev->job.DocName, doc->lpszDocName);
+ INT len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, NULL, 0, NULL, NULL );
+ physDev->job.DocName = HeapAlloc( GetProcessHeap(), 0, len );
+ WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, physDev->job.DocName, len, NULL, NULL );
} else
physDev->job.DocName = NULL;
@@ -467,51 +468,6 @@ static INT PSDRV_StartDocA( PHYSDEV dev, const DOCINFOA *doc )
}
/************************************************************************
- * PSDRV_StartDoc
- */
-INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc )
-{
- DOCINFOA docA;
- INT ret, len;
- LPSTR docname = NULL, output = NULL, datatype = NULL;
-
- TRACE("(%p, %p) => %d,%s,%s,%s\n", dev, doc, doc->cbSize, debugstr_w(doc->lpszDocName),
- debugstr_w(doc->lpszOutput), debugstr_w(doc->lpszDatatype));
-
- docA.cbSize = doc->cbSize;
- if (doc->lpszDocName)
- {
- len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, NULL, 0, NULL, NULL );
- if ((docname = HeapAlloc( GetProcessHeap(), 0, len )))
- WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, docname, len, NULL, NULL );
- }
- if (doc->lpszOutput)
- {
- len = WideCharToMultiByte( CP_ACP, 0, doc->lpszOutput, -1, NULL, 0, NULL, NULL );
- if ((output = HeapAlloc( GetProcessHeap(), 0, len )))
- WideCharToMultiByte( CP_ACP, 0, doc->lpszOutput, -1, output, len, NULL, NULL );
- }
- if (doc->lpszDatatype)
- {
- len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDatatype, -1, NULL, 0, NULL, NULL );
- if ((datatype = HeapAlloc( GetProcessHeap(), 0, len )))
- WideCharToMultiByte( CP_ACP, 0, doc->lpszDatatype, -1, datatype, len, NULL, NULL );
- }
- docA.lpszDocName = docname;
- docA.lpszOutput = output;
- docA.lpszDatatype = datatype;
- docA.fwType = doc->fwType;
-
- ret = PSDRV_StartDocA(dev, &docA);
-
- HeapFree( GetProcessHeap(), 0, docname );
- HeapFree( GetProcessHeap(), 0, output );
- HeapFree( GetProcessHeap(), 0, datatype );
-
- return ret;
-}
-
-/************************************************************************
* PSDRV_EndDoc
*/
INT PSDRV_EndDoc( PHYSDEV dev )
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c
index fa47573..c6a4488 100644
--- a/dlls/wineps.drv/init.c
+++ b/dlls/wineps.drv/init.c
@@ -41,6 +41,7 @@
#include "winnls.h"
#include "psdrv.h"
#include "winspool.h"
+#include "wine/unicode.h"
#include "wine/library.h"
#include "wine/debug.h"
@@ -171,6 +172,17 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
return TRUE;
}
+static inline WCHAR *strdupW( const WCHAR *str )
+{
+ int size;
+ WCHAR *ret;
+
+ if (!str) return NULL;
+ size = (strlenW( str ) + 1) * sizeof(WCHAR);
+ ret = HeapAlloc( GetProcessHeap(), 0, size );
+ if (ret) memcpy( ret, str, size );
+ return ret;
+}
static void PSDRV_UpdateDevCaps( PSDRV_PDEVICE *physDev )
{
@@ -355,11 +367,7 @@ static BOOL PSDRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
if (!(physDev = create_psdrv_physdev( pi ))) return FALSE;
- if (output && *output) {
- INT len = WideCharToMultiByte( CP_ACP, 0, output, -1, NULL, 0, NULL, NULL );
- if ((physDev->job.output = HeapAlloc( PSDRV_Heap, 0, len )))
- WideCharToMultiByte( CP_ACP, 0, output, -1, physDev->job.output, len, NULL, NULL );
- }
+ if (output && *output) physDev->job.output = strdupW( output );
if(initData) {
DEVMODEA *devmodeA = DEVMODEdupWtoA(PSDRV_Heap, initData);
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index 3bcad2c..fd82bd5 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -346,7 +346,7 @@ typedef struct {
typedef struct {
DWORD id; /* Job id */
HANDLE hprinter; /* Printer handle */
- LPSTR output; /* Output file/port */
+ LPWSTR output; /* Output file/port */
LPSTR DocName; /* Document Name */
BOOL banding; /* Have we received a NEXTBAND */
BOOL OutOfPage; /* Page header not sent yet */
More information about the wine-cvs
mailing list