From e6e42c8610edb9603d7054ad216087ce6b096d16 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 11 Apr 2012 12:36:16 +0100 Subject: [PATCH] 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 50fb59fe2b9..7ff117f4ce5 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 37c609412bd..508f141f800 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 27a2cc11e93..5db80f11d51 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 a240f4f28c3..e2d3c842083 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; -- 2.11.4.GIT