Use Win32 file handles instead of Unix ones.
[wine/multimedia.git] / graphics / driver.c
blob08df15efe169eb6f617cebf8331d57486aa3d1f5
1 /*
2 * Graphics driver management functions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #include "gdi.h"
8 #include "heap.h"
9 #include "debug.h"
10 #include <string.h>
12 typedef struct tagGRAPHICS_DRIVER
14 struct tagGRAPHICS_DRIVER *next;
15 LPSTR name;
16 const DC_FUNCTIONS *funcs;
17 } GRAPHICS_DRIVER;
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;
30 if (name)
32 driver->name = HEAP_strdupA( SystemHeap, 0, name );
33 driver->next = firstDriver;
34 firstDriver = driver;
35 return TRUE;
37 /* No name -> it's the generic driver */
38 if (genericDriver)
40 WARN(driver, " already a generic driver\n" );
41 HeapFree( SystemHeap, 0, driver );
42 return FALSE;
44 driver->name = NULL;
45 genericDriver = driver;
46 return TRUE;
50 /**********************************************************************
51 * DRIVER_FindDriver
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 )
71 if (name)
73 GRAPHICS_DRIVER **ppDriver = &firstDriver;
74 while (*ppDriver)
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 );
82 return TRUE;
84 ppDriver = &(*ppDriver)->next;
86 return FALSE;
88 else
90 if (!genericDriver) return FALSE;
91 HeapFree( SystemHeap, 0, genericDriver );
92 genericDriver = NULL;
93 return TRUE;