2 * Graphics driver management functions
4 * Copyright 1996 Alexandre Julliard
11 typedef struct tagGRAPHICS_DRIVER
13 struct tagGRAPHICS_DRIVER
*next
;
15 const DC_FUNCTIONS
*funcs
;
18 static GRAPHICS_DRIVER
*firstDriver
= NULL
;
19 static GRAPHICS_DRIVER
*genericDriver
= NULL
;
21 /**********************************************************************
22 * DRIVER_RegisterDriver
24 BOOL32
DRIVER_RegisterDriver( LPCSTR name
, const DC_FUNCTIONS
*funcs
)
26 GRAPHICS_DRIVER
*driver
= HeapAlloc( SystemHeap
, 0, sizeof(*driver
) );
27 if (!driver
) return FALSE
;
28 driver
->funcs
= funcs
;
31 driver
->name
= HEAP_strdupA( SystemHeap
, 0, name
);
32 driver
->next
= firstDriver
;
36 /* No name -> it's the generic driver */
39 fprintf( stderr
, "DRIVER_RegisterDriver: already a generic driver\n" );
40 HeapFree( SystemHeap
, 0, driver
);
44 genericDriver
= driver
;
49 /**********************************************************************
52 const DC_FUNCTIONS
*DRIVER_FindDriver( LPCSTR name
)
54 GRAPHICS_DRIVER
*driver
= firstDriver
;
57 if (!lstrcmpi32A( driver
->name
, name
)) return driver
->funcs
;
58 driver
= driver
->next
;
60 return genericDriver
? genericDriver
->funcs
: NULL
;
64 /**********************************************************************
65 * DRIVER_UnregisterDriver
67 BOOL32
DRIVER_UnregisterDriver( LPCSTR name
)
71 GRAPHICS_DRIVER
**ppDriver
= &firstDriver
;
74 if (!lstrcmpi32A( (*ppDriver
)->name
, name
))
76 GRAPHICS_DRIVER
*driver
= *ppDriver
;
77 (*ppDriver
) = driver
->next
;
78 HeapFree( SystemHeap
, 0, driver
->name
);
79 HeapFree( SystemHeap
, 0, driver
);
82 ppDriver
= &(*ppDriver
)->next
;
88 if (!genericDriver
) return FALSE
;
89 HeapFree( SystemHeap
, 0, genericDriver
);