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
;
57 while (driver
&& name
)
59 if (!strcasecmp( driver
->name
, name
)) return driver
->funcs
;
60 driver
= driver
->next
;
62 return genericDriver
? genericDriver
->funcs
: NULL
;
66 /**********************************************************************
67 * DRIVER_UnregisterDriver
69 BOOL32
DRIVER_UnregisterDriver( LPCSTR name
)
73 GRAPHICS_DRIVER
**ppDriver
= &firstDriver
;
76 if (!strcasecmp( (*ppDriver
)->name
, name
))
78 GRAPHICS_DRIVER
*driver
= *ppDriver
;
79 (*ppDriver
) = driver
->next
;
80 HeapFree( SystemHeap
, 0, driver
->name
);
81 HeapFree( SystemHeap
, 0, driver
);
84 ppDriver
= &(*ppDriver
)->next
;
90 if (!genericDriver
) return FALSE
;
91 HeapFree( SystemHeap
, 0, genericDriver
);