Huw Davies : wineps: Add a helper to perform duplex lookup by name.
Alexandre Julliard
julliard at winehq.org
Wed May 16 14:22:39 CDT 2012
Module: wine
Branch: master
Commit: e6398a554483f454a23e21c85d6760af96cbdd41
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e6398a554483f454a23e21c85d6760af96cbdd41
Author: Huw Davies <huw at codeweavers.com>
Date: Wed May 16 13:15:18 2012 +0100
wineps: Add a helper to perform duplex lookup by name.
---
dlls/wineps.drv/ppd.c | 44 +++++++++++++++++++++++++-------------------
1 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c
index 42969df..dc598e8 100644
--- a/dlls/wineps.drv/ppd.c
+++ b/dlls/wineps.drv/ppd.c
@@ -481,6 +481,19 @@ static PAGESIZE *get_pagesize( PPD *ppd, char *name, BOOL create )
return page;
}
+static DUPLEX *get_duplex( PPD *ppd, const char *name )
+{
+ DUPLEX *duplex;
+
+ LIST_FOR_EACH_ENTRY( duplex, &ppd->Duplexes, DUPLEX, entry )
+ {
+ if (!strcmp( duplex->Name, name ))
+ return duplex;
+ }
+
+ return NULL;
+}
+
/**********************************************************************
*
* PSDRV_PPDGetWord
@@ -896,13 +909,13 @@ PPD *PSDRV_ParsePPD(char *fname)
list_add_tail( &ppd->Duplexes, &duplex->entry );
}
- else if(!strcmp("*DefaultDuplex", tuple.key)) {
- if(default_duplex) {
- WARN("Already set default duplex\n");
- } else {
+ else if (!strcmp("*DefaultDuplex", tuple.key))
+ {
+ if (!default_duplex)
+ {
default_duplex = tuple.value;
tuple.value = NULL;
- }
+ }
}
HeapFree(PSDRV_Heap, 0, tuple.key);
@@ -946,24 +959,17 @@ PPD *PSDRV_ParsePPD(char *fname)
ppd->DefaultDuplex = NULL;
if (default_duplex)
- {
- DUPLEX *duplex;
- LIST_FOR_EACH_ENTRY( duplex, &ppd->Duplexes, DUPLEX, entry )
- {
- if (!strcmp(duplex->Name, default_duplex))
- {
- ppd->DefaultDuplex = duplex;
- TRACE("DefaultDuplex: %s\n", duplex->Name);
- break;
- }
- }
- HeapFree(PSDRV_Heap, 0, default_duplex);
- }
+ ppd->DefaultDuplex = get_duplex( ppd, default_duplex );
+
if (!ppd->DefaultDuplex)
{
- ppd->DefaultDuplex = LIST_ENTRY( list_head( &ppd->Duplexes ), DUPLEX, entry );
+ struct list *head = list_head( &ppd->Duplexes );
+ if (head) ppd->DefaultDuplex = LIST_ENTRY( head, DUPLEX, entry );
TRACE("Setting DefaultDuplex to first in list\n");
}
+ TRACE( "DefaultDuplex: %s\n", ppd->DefaultDuplex ? ppd->DefaultDuplex->Name : "<not set>" );
+
+ HeapFree( PSDRV_Heap, 0, default_duplex );
{
More information about the wine-cvs
mailing list