2 * Graphics driver management functions
4 * Copyright 1996 Alexandre Julliard
12 typedef struct tagGRAPHICS_DRIVER
14 struct tagGRAPHICS_DRIVER
*next
;
16 const DC_FUNCTIONS
*funcs
;
19 static GRAPHICS_DRIVER
*firstDriver
= NULL
;
20 static GRAPHICS_DRIVER
*genericDriver
= NULL
;
22 /**********************************************************************
23 * DRIVER_RegisterDriver
25 BOOL32
DRIVER_RegisterDriver( LPCSTR name
, const DC_FUNCTIONS
*funcs
)
27 GRAPHICS_DRIVER
*driver
= HeapAlloc( SystemHeap
, 0, sizeof(*driver
) );
28 if (!driver
) return FALSE
;
29 driver
->funcs
= funcs
;
32 driver
->name
= HEAP_strdupA( SystemHeap
, 0, name
);
33 driver
->next
= firstDriver
;
37 /* No name -> it's the generic driver */
40 WARN(driver
, " already a generic driver\n" );
41 HeapFree( SystemHeap
, 0, driver
);
45 genericDriver
= driver
;
50 /**********************************************************************
53 const DC_FUNCTIONS
*DRIVER_FindDriver( LPCSTR name
)
55 GRAPHICS_DRIVER
*driver
= firstDriver
;
58 if (!strcasecmp( driver
->name
, name
)) return driver
->funcs
;
59 driver
= driver
->next
;
61 return genericDriver
? genericDriver
->funcs
: NULL
;
65 /**********************************************************************
66 * DRIVER_UnregisterDriver
68 BOOL32
DRIVER_UnregisterDriver( LPCSTR name
)
72 GRAPHICS_DRIVER
**ppDriver
= &firstDriver
;
75 if (!strcasecmp( (*ppDriver
)->name
, name
))
77 GRAPHICS_DRIVER
*driver
= *ppDriver
;
78 (*ppDriver
) = driver
->next
;
79 HeapFree( SystemHeap
, 0, driver
->name
);
80 HeapFree( SystemHeap
, 0, driver
);
83 ppDriver
= &(*ppDriver
)->next
;
89 if (!genericDriver
) return FALSE
;
90 HeapFree( SystemHeap
, 0, genericDriver
);