Janitorial W->A dlls/gdi/printdrv.c (help!)

Tony Lambregts tony_lambregts at telusplanet.net
Sun Mar 23 14:47:39 CST 2003


I have been banging my head against this one for a while and need some 
feedback about a problem I am having. I have attached the patch to convert 
StartDocA to call StartDocW instead of the other way around. This patch 
results with StartDocW looking as follows

INT WINAPI StartDocW(HDC hdc, const DOCINFOW* doc)
{
     INT ret = 0;
     DC *dc = DC_GetDCPtr( hdc );

     TRACE("DocName = '%s' Output = '%s' Datatype = '%s'\n",
	  debugstr_w(doc->lpszDocName), debugstr_w(doc->lpszOutput),
	  debugstr_w(doc->lpszDatatype));

     if(!dc) return SP_ERROR;

     if (dc->funcs->pStartDoc) ret = dc->funcs->pStartDoc( dc->physDev, doc );
     GDI_ReleaseObj( hdc );
     return ret;
}

The problem I am having is with this line.

     if (dc->funcs->pStartDoc) ret = dc->funcs->pStartDoc( dc->physDev, doc );

With my patch in place I get the following error

printdrv.c: In function `StartDocW':
printdrv.c:82: warning: passing arg 2 of pointer to function from incompatible 
pointer type

so obviously dc->funcs->pStartDoc points to a function that expects DOCINFOA* 
as its second parameter but I am at a loss on what to do. I have tried to 
trace down where "DC_GetDCPtr( hdc )" gets this information but I just ended 
up confused. Please help!

-- 

Tony Lambregts
-------------- next part --------------
Index: printdrv.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/printdrv.c,v
retrieving revision 1.30
diff -u -u -r1.30 printdrv.c
--- printdrv.c	22 Nov 2002 22:16:53 -0000	1.30
+++ printdrv.c	23 Mar 2003 20:36:11 -0000
@@ -48,6 +48,7 @@
 #include "gdi.h"
 #include "heap.h"
 #include "file.h"
+#include "winternl.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(print);
 
@@ -58,7 +59,7 @@
 
 
 /******************************************************************
- *                  StartDocA  [GDI32.@]
+ *                  StartDocW  [GDI32.@]
  *
  * StartDoc calls the STARTDOC Escape with the input data pointing to DocName
  * and the output data (which is used as a second input parameter).pointing at
@@ -67,13 +68,14 @@
  *
  * Note: we now do it the other way, with the STARTDOC Escape calling StartDoc.
  */
-INT WINAPI StartDocA(HDC hdc, const DOCINFOA* doc)
+INT WINAPI StartDocW(HDC hdc, const DOCINFOW* doc)
 {
     INT ret = 0;
     DC *dc = DC_GetDCPtr( hdc );
 
     TRACE("DocName = '%s' Output = '%s' Datatype = '%s'\n",
-	  doc->lpszDocName, doc->lpszOutput, doc->lpszDatatype);
+	  debugstr_w(doc->lpszDocName), debugstr_w(doc->lpszOutput),
+	  debugstr_w(doc->lpszDatatype));
 
     if(!dc) return SP_ERROR;
 
@@ -83,32 +85,27 @@
 }
 
 /*************************************************************************
- *                  StartDocW [GDI32.@]
+ *                  StartDocA [GDI32.@]
  *
  */
-INT WINAPI StartDocW(HDC hdc, const DOCINFOW* doc)
+INT WINAPI StartDocA(HDC hdc, const DOCINFOA* doc)
 {
-    DOCINFOA docA;
-    INT ret;
-
-    docA.cbSize = doc->cbSize;
-    docA.lpszDocName = doc->lpszDocName ?
-      HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDocName ) : NULL;
-    docA.lpszOutput = doc->lpszOutput ?
-      HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszOutput ) : NULL;
-    docA.lpszDatatype = doc->lpszDatatype ?
-      HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDatatype ) : NULL;
-    docA.fwType = doc->fwType;
-
-    ret = StartDocA(hdc, &docA);
-
-    if(docA.lpszDocName)
-        HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDocName );
-    if(docA.lpszOutput)
-        HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszOutput );
-    if(docA.lpszDatatype)
-        HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDatatype );
-
+    DOCINFOW docW;
+    int ret;
+    UNICODE_STRING DocName, Output, Datatype;
+
+    docW.cbSize = doc->cbSize;
+    RtlCreateUnicodeStringFromAsciiz(&DocName, doc->lpszDocName);
+    RtlCreateUnicodeStringFromAsciiz(&Output, doc->lpszOutput );
+    RtlCreateUnicodeStringFromAsciiz(&Datatype, doc->lpszDatatype );
+    docW.lpszDocName = DocName.Buffer;
+    docW.lpszOutput = Output.Buffer;
+    docW.lpszDatatype = Datatype.Buffer;
+    docW.fwType = doc->fwType;
+    ret = StartDocW(hdc, &docW);
+    RtlFreeUnicodeString(&DocName);
+    RtlFreeUnicodeString(&Output);
+    RtlFreeUnicodeString(&Datatype);
     return ret;
 }
 


More information about the wine-devel mailing list