Huw Davies : wineps: Move the input slot list to a standard list.

Alexandre Julliard julliard at winehq.org
Wed Apr 11 12:56:47 CDT 2012


Module: wine
Branch: master
Commit: e6e42c8610edb9603d7054ad216087ce6b096d16
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e6e42c8610edb9603d7054ad216087ce6b096d16

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Apr 11 12:36:16 2012 +0100

wineps: Move the input slot list to a standard list.

---

 dlls/wineps.drv/driver.c |   38 +++++++++++++++++++++++---------------
 dlls/wineps.drv/ppd.c    |   20 ++++++++------------
 dlls/wineps.drv/ps.c     |    2 +-
 dlls/wineps.drv/psdrv.h  |    7 ++++---
 4 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/dlls/wineps.drv/driver.c b/dlls/wineps.drv/driver.c
index 50fb59f..7ff117f 100644
--- a/dlls/wineps.drv/driver.c
+++ b/dlls/wineps.drv/driver.c
@@ -116,20 +116,21 @@ void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2,
 	TRACE("Changing Copies to %d\n", dm2->dmPublic.u1.s1.dmCopies);
     }
 
-    if(dm2->dmPublic.dmFields & DM_DEFAULTSOURCE) {
+    if (dm2->dmPublic.dmFields & DM_DEFAULTSOURCE)
+    {
         INPUTSLOT *slot;
 
-	for(slot = pi->ppd->InputSlots; slot; slot = slot->next) {
+        LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry )
 	    if(slot->WinBin == dm2->dmPublic.u1.s1.dmDefaultSource)
 	        break;
-	}
-	if(slot) {
+
+        if (&slot->entry != &pi->ppd->InputSlots)
+        {
 	    dm1->dmPublic.u1.s1.dmDefaultSource = dm2->dmPublic.u1.s1.dmDefaultSource;
 	    TRACE("Changing bin to '%s'\n", slot->FullName);
-	} else {
-	  TRACE("Trying to change to unsupported bin %d\n",
-		dm2->dmPublic.u1.s1.dmDefaultSource);
 	}
+        else
+            TRACE("Trying to change to unsupported bin %d\n", dm2->dmPublic.u1.s1.dmDefaultSource);
     }
 
    if (dm2->dmPublic.dmFields & DM_DEFAULTSOURCE )
@@ -512,9 +513,12 @@ DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszP
       WORD *wp = (WORD *)lpszOutput;
       int i = 0;
 
-      for(slot = pi->ppd->InputSlots; slot; slot = slot->next, i++)
-	if(lpszOutput != NULL)
-	  *wp++ = slot->WinBin;
+      LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry )
+      {
+          i++;
+          if (lpszOutput != NULL)
+              *wp++ = slot->WinBin;
+      }
       return i;
     }
 
@@ -524,11 +528,15 @@ DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszP
       char *cp = lpszOutput;
       int i = 0;
 
-      for(slot = pi->ppd->InputSlots; slot; slot = slot->next, i++)
-	if(lpszOutput != NULL) {
-	  lstrcpynA(cp, slot->FullName, 24);
-	  cp += 24;
-	}
+      LIST_FOR_EACH_ENTRY( slot, &pi->ppd->InputSlots, INPUTSLOT, entry )
+      {
+          i++;
+          if (lpszOutput != NULL)
+          {
+              lstrcpynA( cp, slot->FullName, 24 );
+              cp += 24;
+          }
+      }
       return i;
     }
 
diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c
index 37c6094..508f141 100644
--- a/dlls/wineps.drv/ppd.c
+++ b/dlls/wineps.drv/ppd.c
@@ -583,23 +583,19 @@ static BOOL parse_resolution(const char *str, SIZE *sz)
  *	PSDRV_AddSlot
  *
  */
-static INT PSDRV_AddSlot(PPD *ppd, LPCSTR szName, LPCSTR szFullName,
+static BOOL PSDRV_AddSlot(PPD *ppd, LPCSTR szName, LPCSTR szFullName,
 	LPSTR szInvocationString, WORD wWinBin)
 {
-    INPUTSLOT	*slot, **insert = &ppd->InputSlots;
-
-    while (*insert)
-	insert = &((*insert)->next);
-
-    slot = *insert = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(INPUTSLOT));
-    if (!slot) return 1;
+    INPUTSLOT *slot = HeapAlloc( PSDRV_Heap, 0, sizeof(INPUTSLOT) );
+    if (!slot) return FALSE;
 
     slot->Name = szName;
     slot->FullName = szFullName;
     slot->InvocationString = szInvocationString;
     slot->WinBin = wWinBin;
 
-    return 0;
+    list_add_tail( &ppd->InputSlots, &slot->entry );
+    return TRUE;
 }
 
 /***********************************************************************
@@ -635,13 +631,13 @@ PPD *PSDRV_ParsePPD(char *fname)
     list_init( &ppd->InstalledFonts );
     list_init( &ppd->PageSizes );
     list_init( &ppd->Constraints );
+    list_init( &ppd->InputSlots );
 
     /*
      *	The Windows PostScript drivers create the following "virtual bin" for
      *	every PostScript printer
      */
-    if (PSDRV_AddSlot(ppd, NULL, "Automatically Select", NULL,
-	    DMBIN_FORMSOURCE))
+    if (!PSDRV_AddSlot( ppd, NULL, "Automatically Select", NULL, DMBIN_FORMSOURCE ))
     {
 	HeapFree (PSDRV_Heap, 0, ppd);
 	fclose(fp);
@@ -1002,7 +998,7 @@ PPD *PSDRV_ParsePPD(char *fname)
 		      optionEntry->FullName, optionEntry->InvocationString);
 	}
 
-	for(slot = ppd->InputSlots; slot; slot = slot->next)
+        LIST_FOR_EACH_ENTRY( slot, &ppd->InputSlots, INPUTSLOT, entry )
 	    TRACE("INPUTSLOTS '%s' Name '%s' (%d) Invocation '%s'\n",
 		  debugstr_a(slot->Name), slot->FullName, slot->WinBin,
 		  debugstr_a(slot->InvocationString));
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c
index 27a2cc1..5db80f1 100644
--- a/dlls/wineps.drv/ps.c
+++ b/dlls/wineps.drv/ps.c
@@ -350,7 +350,7 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
         write_spool(dev, copies_buf, strlen(copies_buf));
     }
 
-    for(slot = physDev->pi->ppd->InputSlots; slot; slot = slot->next) {
+    LIST_FOR_EACH_ENTRY( slot, &physDev->pi->ppd->InputSlots, INPUTSLOT, entry ) {
         if(slot->WinBin == physDev->Devmode->dmPublic.u1.s1.dmDefaultSource) {
 	    if(slot->InvocationString) {
 	        PSDRV_WriteFeature(dev, "*InputSlot", slot->Name,
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index a240f4f..e2d3c84 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -177,12 +177,13 @@ typedef struct
     char			*Value2;
 } CONSTRAINT;
 
-typedef struct _tagINPUTSLOT {
+typedef struct
+{
+    struct list                 entry;
     const char			*Name;
     const char			*FullName;
     char			*InvocationString;
     WORD			WinBin; /* eg DMBIN_LOWER */
-    struct _tagINPUTSLOT	*next;
 } INPUTSLOT;
 
 typedef enum _RASTERIZEROPTION
@@ -220,7 +221,7 @@ typedef struct {
     PAGESIZE            *DefaultPageSize;
     OPTION		*InstalledOptions;
     struct list         Constraints;
-    INPUTSLOT		*InputSlots;
+    struct list         InputSlots;
     RASTERIZEROPTION    TTRasterizer;
     DUPLEX              *Duplexes;
     DUPLEX              *DefaultDuplex;




More information about the wine-cvs mailing list