wineps: Add a helper to perform duplex lookup by name.

This commit is contained in:
Huw Davies 2012-05-16 13:15:18 +01:00 committed by Alexandre Julliard
parent cd770d907a
commit e6398a5544
1 changed files with 25 additions and 19 deletions

View File

@ -481,6 +481,19 @@ static PAGESIZE *get_pagesize( PPD *ppd, char *name, BOOL create )
return page; 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 * PSDRV_PPDGetWord
@ -896,13 +909,13 @@ PPD *PSDRV_ParsePPD(char *fname)
list_add_tail( &ppd->Duplexes, &duplex->entry ); list_add_tail( &ppd->Duplexes, &duplex->entry );
} }
else if(!strcmp("*DefaultDuplex", tuple.key)) { else if (!strcmp("*DefaultDuplex", tuple.key))
if(default_duplex) { {
WARN("Already set default duplex\n"); if (!default_duplex)
} else { {
default_duplex = tuple.value; default_duplex = tuple.value;
tuple.value = NULL; tuple.value = NULL;
} }
} }
HeapFree(PSDRV_Heap, 0, tuple.key); HeapFree(PSDRV_Heap, 0, tuple.key);
@ -946,24 +959,17 @@ PPD *PSDRV_ParsePPD(char *fname)
ppd->DefaultDuplex = NULL; ppd->DefaultDuplex = NULL;
if (default_duplex) if (default_duplex)
{ ppd->DefaultDuplex = get_duplex( ppd, 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);
}
if (!ppd->DefaultDuplex) 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("Setting DefaultDuplex to first in list\n");
} }
TRACE( "DefaultDuplex: %s\n", ppd->DefaultDuplex ? ppd->DefaultDuplex->Name : "<not set>" );
HeapFree( PSDRV_Heap, 0, default_duplex );
{ {