Added a few more Unicode digits from Unicode version 4.1.
[wine] / dlls / gdi / driver.c
1 /*
2  * Graphics driver management functions
3  *
4  * Copyright 1994 Bob Amstadt
5  * Copyright 1996, 2001 Alexandre Julliard
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23 #include "wine/port.h"
24
25 #include <stdarg.h>
26 #include <string.h>
27 #include <stdio.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31
32 #include "gdi.h"
33 #include "gdi_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(driver);
38
39 struct graphics_driver
40 {
41     struct graphics_driver *next;
42     struct graphics_driver *prev;
43     HMODULE                 module;  /* module handle */
44     unsigned int            count;   /* reference count */
45     DC_FUNCTIONS            funcs;
46 };
47
48 static struct graphics_driver *first_driver;
49 static struct graphics_driver *display_driver;
50
51 static CRITICAL_SECTION driver_section;
52 static CRITICAL_SECTION_DEBUG critsect_debug =
53 {
54     0, 0, &driver_section,
55     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
56       0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
57 };
58 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
59
60 /**********************************************************************
61  *           create_driver
62  *
63  * Allocate and fill the driver structure for a given module.
64  */
65 static struct graphics_driver *create_driver( HMODULE module )
66 {
67     struct graphics_driver *driver;
68
69     if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
70     driver->next   = NULL;
71     driver->prev   = NULL;
72     driver->module = module;
73     driver->count  = 1;
74
75     /* fill the function table */
76     if (module)
77     {
78 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
79         GET_FUNC(AbortDoc);
80         GET_FUNC(AbortPath);
81         GET_FUNC(AlphaBlend);
82         GET_FUNC(AngleArc);
83         GET_FUNC(Arc);
84         GET_FUNC(ArcTo);
85         GET_FUNC(BeginPath);
86         GET_FUNC(BitBlt);
87         GET_FUNC(ChoosePixelFormat);
88         GET_FUNC(Chord);
89         GET_FUNC(CloseFigure);
90         GET_FUNC(CreateBitmap);
91         GET_FUNC(CreateDC);
92         GET_FUNC(CreateDIBSection);
93         GET_FUNC(DeleteBitmap);
94         GET_FUNC(DeleteDC);
95         GET_FUNC(DescribePixelFormat);
96         GET_FUNC(DeviceCapabilities);
97         GET_FUNC(Ellipse);
98         GET_FUNC(EndDoc);
99         GET_FUNC(EndPage);
100         GET_FUNC(EndPath);
101         GET_FUNC(EnumDeviceFonts);
102         GET_FUNC(ExcludeClipRect);
103         GET_FUNC(ExtDeviceMode);
104         GET_FUNC(ExtEscape);
105         GET_FUNC(ExtFloodFill);
106         GET_FUNC(ExtSelectClipRgn);
107         GET_FUNC(ExtTextOut);
108         GET_FUNC(FillPath);
109         GET_FUNC(FillRgn);
110         GET_FUNC(FlattenPath);
111         GET_FUNC(FrameRgn);
112         GET_FUNC(GdiComment);
113         GET_FUNC(GetBitmapBits);
114         GET_FUNC(GetCharWidth);
115         GET_FUNC(GetDCOrgEx);
116         GET_FUNC(GetDIBColorTable);
117         GET_FUNC(GetDIBits);
118         GET_FUNC(GetDeviceCaps);
119         GET_FUNC(GetDeviceGammaRamp);
120         GET_FUNC(GetNearestColor);
121         GET_FUNC(GetPixel);
122         GET_FUNC(GetPixelFormat);
123         GET_FUNC(GetSystemPaletteEntries);
124         GET_FUNC(GetTextExtentPoint);
125         GET_FUNC(GetTextMetrics);
126         GET_FUNC(IntersectClipRect);
127         GET_FUNC(InvertRgn);
128         GET_FUNC(LineTo);
129         GET_FUNC(MoveTo);
130         GET_FUNC(ModifyWorldTransform);
131         GET_FUNC(OffsetClipRgn);
132         GET_FUNC(OffsetViewportOrg);
133         GET_FUNC(OffsetWindowOrg);
134         GET_FUNC(PaintRgn);
135         GET_FUNC(PatBlt);
136         GET_FUNC(Pie);
137         GET_FUNC(PolyBezier);
138         GET_FUNC(PolyBezierTo);
139         GET_FUNC(PolyDraw);
140         GET_FUNC(PolyPolygon);
141         GET_FUNC(PolyPolyline);
142         GET_FUNC(Polygon);
143         GET_FUNC(Polyline);
144         GET_FUNC(PolylineTo);
145         GET_FUNC(RealizeDefaultPalette);
146         GET_FUNC(RealizePalette);
147         GET_FUNC(Rectangle);
148         GET_FUNC(ResetDC);
149         GET_FUNC(RestoreDC);
150         GET_FUNC(RoundRect);
151         GET_FUNC(SaveDC);
152         GET_FUNC(ScaleViewportExt);
153         GET_FUNC(ScaleWindowExt);
154         GET_FUNC(SelectBitmap);
155         GET_FUNC(SelectBrush);
156         GET_FUNC(SelectClipPath);
157         GET_FUNC(SelectFont);
158         GET_FUNC(SelectPalette);
159         GET_FUNC(SelectPen);
160         GET_FUNC(SetArcDirection);
161         GET_FUNC(SetBitmapBits);
162         GET_FUNC(SetBkColor);
163         GET_FUNC(SetBkMode);
164         GET_FUNC(SetDCBrushColor);
165         GET_FUNC(SetDCOrg);
166         GET_FUNC(SetDCPenColor);
167         GET_FUNC(SetDIBColorTable);
168         GET_FUNC(SetDIBits);
169         GET_FUNC(SetDIBitsToDevice);
170         GET_FUNC(SetDeviceClipping);
171         GET_FUNC(SetDeviceGammaRamp);
172         GET_FUNC(SetMapMode);
173         GET_FUNC(SetMapperFlags);
174         GET_FUNC(SetPixel);
175         GET_FUNC(SetPixelFormat);
176         GET_FUNC(SetPolyFillMode);
177         GET_FUNC(SetROP2);
178         GET_FUNC(SetRelAbs);
179         GET_FUNC(SetStretchBltMode);
180         GET_FUNC(SetTextAlign);
181         GET_FUNC(SetTextCharacterExtra);
182         GET_FUNC(SetTextColor);
183         GET_FUNC(SetTextJustification);
184         GET_FUNC(SetViewportExt);
185         GET_FUNC(SetViewportOrg);
186         GET_FUNC(SetWindowExt);
187         GET_FUNC(SetWindowOrg);
188         GET_FUNC(SetWorldTransform);
189         GET_FUNC(StartDoc);
190         GET_FUNC(StartPage);
191         GET_FUNC(StretchBlt);
192         GET_FUNC(StretchDIBits);
193         GET_FUNC(StrokeAndFillPath);
194         GET_FUNC(StrokePath);
195         GET_FUNC(SwapBuffers);
196         GET_FUNC(WidenPath);
197 #undef GET_FUNC
198     }
199     else memset( &driver->funcs, 0, sizeof(driver->funcs) );
200
201     /* add it to the list */
202     driver->prev = NULL;
203     if ((driver->next = first_driver)) driver->next->prev = driver;
204     first_driver = driver;
205     return driver;
206 }
207
208
209 /**********************************************************************
210  *           load_display_driver
211  *
212  * Special case for loading the display driver: get the name from the config file
213  */
214 static struct graphics_driver *load_display_driver(void)
215 {
216     char buffer[MAX_PATH], libname[32], *name, *next;
217     HMODULE module = 0;
218     HKEY hkey;
219
220     if (display_driver)  /* already loaded */
221     {
222         display_driver->count++;
223         return display_driver;
224     }
225
226     strcpy( buffer, "x11" );  /* default value */
227     /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
228     if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
229     {
230         DWORD type, count = sizeof(buffer);
231         RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
232         RegCloseKey( hkey );
233     }
234
235     name = buffer;
236     while (name)
237     {
238         next = strchr( name, ',' );
239         if (next) *next++ = 0;
240
241         snprintf( libname, sizeof(libname), "wine%s.drv", name );
242         if ((module = LoadLibraryA( libname )) != 0) break;
243         name = next;
244     }
245
246     if (!(display_driver = create_driver( module )))
247     {
248         MESSAGE( "Could not create graphics driver '%s'\n", buffer );
249         FreeLibrary( module );
250         ExitProcess(1);
251     }
252
253     display_driver->count++;  /* we don't want to free it */
254     return display_driver;
255 }
256
257
258 /**********************************************************************
259  *           DRIVER_load_driver
260  */
261 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
262 {
263     HMODULE module;
264     struct graphics_driver *driver;
265     static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
266
267     EnterCriticalSection( &driver_section );
268
269     /* display driver is a special case */
270     if (!strcmpiW( name, displayW ))
271     {
272         driver = load_display_driver();
273         LeaveCriticalSection( &driver_section );
274         return &driver->funcs;
275     }
276
277     if ((module = GetModuleHandleW( name )))
278     {
279         for (driver = first_driver; driver; driver = driver->next)
280         {
281             if (driver->module == module)
282             {
283                 driver->count++;
284                 LeaveCriticalSection( &driver_section );
285                 return &driver->funcs;
286             }
287         }
288     }
289
290     if (!(module = LoadLibraryW( name )))
291     {
292         LeaveCriticalSection( &driver_section );
293         return NULL;
294     }
295
296     if (!(driver = create_driver( module )))
297     {
298         FreeLibrary( module );
299         LeaveCriticalSection( &driver_section );
300         return NULL;
301     }
302
303     TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
304     LeaveCriticalSection( &driver_section );
305     return &driver->funcs;
306 }
307
308
309 /**********************************************************************
310  *           DRIVER_get_driver
311  *
312  * Get a new copy of an existing driver.
313  */
314 const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs )
315 {
316     struct graphics_driver *driver;
317
318     EnterCriticalSection( &driver_section );
319     for (driver = first_driver; driver; driver = driver->next)
320         if (&driver->funcs == funcs) break;
321     if (!driver) ERR( "driver not found, trouble ahead\n" );
322     driver->count++;
323     LeaveCriticalSection( &driver_section );
324     return funcs;
325 }
326
327
328 /**********************************************************************
329  *           DRIVER_release_driver
330  *
331  * Release a driver by decrementing ref count and freeing it if needed.
332  */
333 void DRIVER_release_driver( const DC_FUNCTIONS *funcs )
334 {
335     struct graphics_driver *driver;
336
337     EnterCriticalSection( &driver_section );
338
339     for (driver = first_driver; driver; driver = driver->next)
340         if (&driver->funcs == funcs) break;
341
342     if (!driver) goto done;
343     if (--driver->count) goto done;
344
345     /* removed last reference, free it */
346     if (driver->next) driver->next->prev = driver->prev;
347     if (driver->prev) driver->prev->next = driver->next;
348     else first_driver = driver->next;
349     if (driver == display_driver) display_driver = NULL;
350
351     FreeLibrary( driver->module );
352     HeapFree( GetProcessHeap(), 0, driver );
353  done:
354     LeaveCriticalSection( &driver_section );
355 }
356
357
358 /*****************************************************************************
359  *      DRIVER_GetDriverName
360  *
361  */
362 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
363 {
364     static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
365     static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
366     static const WCHAR empty_strW[] = { 0 };
367     WCHAR *p;
368
369     /* display is a special case */
370     if (!strcmpiW( device, displayW ))
371     {
372         lstrcpynW( driver, displayW, size );
373         return TRUE;
374     }
375
376     size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
377     if(!size) {
378         WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
379         return FALSE;
380     }
381     p = strchrW(driver, ',');
382     if(!p)
383     {
384         WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
385         return FALSE;
386     }
387     *p = 0;
388     TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
389     return TRUE;
390 }
391
392
393 /***********************************************************************
394  *           GdiConvertToDevmodeW    (GDI32.@)
395  */
396 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
397 {
398     DEVMODEW *dmW;
399     WORD dmW_size;
400
401     dmW_size = dmA->dmSize + CCHDEVICENAME;
402     if (dmA->dmSize >= (const char *)dmA->dmFormName - (const char *)dmA + CCHFORMNAME)
403         dmW_size += CCHFORMNAME;
404
405     dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
406     if (!dmW) return NULL;
407
408     MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME,
409                                    dmW->dmDeviceName, CCHDEVICENAME);
410     /* copy slightly more, to avoid long computations */
411     memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA->dmSize - CCHDEVICENAME);
412
413     if (dmA->dmSize >= (const char *)dmA->dmFormName - (const char *)dmA + CCHFORMNAME)
414     {
415         MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME,
416                                        dmW->dmFormName, CCHFORMNAME);
417         if (dmA->dmSize > (const char *)&dmA->dmLogPixels - (const char *)dmA)
418             memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA->dmSize - ((const char *)&dmA->dmLogPixels - (const char *)dmA));
419     }
420
421     if (dmA->dmDriverExtra)
422         memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA->dmSize, dmA->dmDriverExtra);
423
424     dmW->dmSize = dmW_size;
425
426     return dmW;
427 }
428
429
430 /*****************************************************************************
431  *      @ [GDI32.100]
432  *
433  * This should thunk to 16-bit and simply call the proc with the given args.
434  */
435 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
436                                  LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
437 {
438     FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
439     return -1;
440 }
441
442 /*****************************************************************************
443  *      @ [GDI32.101]
444  *
445  * This should load the correct driver for lpszDevice and calls this driver's
446  * ExtDeviceModePropSheet proc.
447  *
448  * Note: The driver calls a callback routine for each property sheet page; these
449  * pages are supposed to be filled into the structure pointed to by lpPropSheet.
450  * The layout of this structure is:
451  *
452  * struct
453  * {
454  *   DWORD  nPages;
455  *   DWORD  unknown;
456  *   HPROPSHEETPAGE  pages[10];
457  * };
458  */
459 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
460                                              LPCSTR lpszPort, LPVOID lpPropSheet )
461 {
462     FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
463     return -1;
464 }
465
466 /*****************************************************************************
467  *      @ [GDI32.102]
468  *
469  * This should load the correct driver for lpszDevice and calls this driver's
470  * ExtDeviceMode proc.
471  *
472  * FIXME: convert ExtDeviceMode to unicode in the driver interface
473  */
474 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
475                                     LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
476                                     LPSTR lpszPort, LPDEVMODEA lpdmInput,
477                                     LPSTR lpszProfile, DWORD fwMode )
478 {
479     WCHAR deviceW[300];
480     WCHAR bufW[300];
481     char buf[300];
482     HDC hdc;
483     DC *dc;
484     INT ret = -1;
485     INT (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
486
487     TRACE("(%p, %p, %s, %s, %p, %s, %ld)\n",
488           hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
489
490     if (!lpszDevice) return -1;
491     if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
492
493     if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
494
495     if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
496
497     if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
498
499     if ((dc = DC_GetDCPtr( hdc )))
500     {
501         pExtDeviceMode = dc->funcs->pExtDeviceMode;
502         GDI_ReleaseObj( hdc );
503         if (pExtDeviceMode)
504             ret = pExtDeviceMode(buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
505                                             lpdmInput, lpszProfile, fwMode);
506     }
507     DeleteDC( hdc );
508     return ret;
509 }
510
511 /****************************************************************************
512  *      @ [GDI32.103]
513  *
514  * This should load the correct driver for lpszDevice and calls this driver's
515  * AdvancedSetupDialog proc.
516  */
517 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
518                                           LPDEVMODEA devin, LPDEVMODEA devout )
519 {
520     TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
521     return -1;
522 }
523
524 /*****************************************************************************
525  *      @ [GDI32.104]
526  *
527  * This should load the correct driver for lpszDevice and calls this driver's
528  * DeviceCapabilities proc.
529  *
530  * FIXME: convert DeviceCapabilities to unicode in the driver interface
531  */
532 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
533                                            WORD fwCapability, LPSTR lpszOutput,
534                                            LPDEVMODEA lpdm )
535 {
536     WCHAR deviceW[300];
537     WCHAR bufW[300];
538     char buf[300];
539     HDC hdc;
540     DC *dc;
541     INT ret = -1;
542
543     TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
544
545     if (!lpszDevice) return -1;
546     if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
547
548     if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
549
550     if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
551
552     if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
553
554     if ((dc = DC_GetDCPtr( hdc )))
555     {
556         if (dc->funcs->pDeviceCapabilities)
557             ret = dc->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
558                                                   fwCapability, lpszOutput, lpdm );
559         GDI_ReleaseObj( hdc );
560     }
561     DeleteDC( hdc );
562     return ret;
563 }
564
565
566 /************************************************************************
567  *             Escape  [GDI32.@]
568  */
569 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
570 {
571     INT ret;
572     POINT *pt;
573
574     switch (escape)
575     {
576     case ABORTDOC:
577         return AbortDoc( hdc );
578
579     case ENDDOC:
580         return EndDoc( hdc );
581
582     case GETPHYSPAGESIZE:
583         pt = out_data;
584         pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
585         pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
586         return 1;
587
588     case GETPRINTINGOFFSET:
589         pt = out_data;
590         pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
591         pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
592         return 1;
593
594     case GETSCALINGFACTOR:
595         pt = out_data;
596         pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
597         pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
598         return 1;
599
600     case NEWFRAME:
601         return EndPage( hdc );
602
603     case SETABORTPROC:
604         return SetAbortProc( hdc, (ABORTPROC)in_data );
605
606     case STARTDOC:
607         {
608             DOCINFOA doc;
609             char *name = NULL;
610
611             /* in_data may not be 0 terminated so we must copy it */
612             if (in_data)
613             {
614                 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
615                 memcpy( name, in_data, in_count );
616                 name[in_count] = 0;
617             }
618             /* out_data is actually a pointer to the DocInfo structure and used as
619              * a second input parameter */
620             if (out_data) doc = *(DOCINFOA *)out_data;
621             else
622             {
623                 doc.cbSize = sizeof(doc);
624                 doc.lpszOutput = NULL;
625                 doc.lpszDatatype = NULL;
626                 doc.fwType = 0;
627             }
628             doc.lpszDocName = name;
629             ret = StartDocA( hdc, &doc );
630             HeapFree( GetProcessHeap(), 0, name );
631             if (ret > 0) ret = StartPage( hdc );
632             return ret;
633         }
634
635     case QUERYESCSUPPORT:
636         {
637             const INT *ptr = (const INT *)in_data;
638             if (in_count < sizeof(INT)) return 0;
639             switch(*ptr)
640             {
641             case ABORTDOC:
642             case ENDDOC:
643             case GETPHYSPAGESIZE:
644             case GETPRINTINGOFFSET:
645             case GETSCALINGFACTOR:
646             case NEWFRAME:
647             case QUERYESCSUPPORT:
648             case SETABORTPROC:
649             case STARTDOC:
650                 return TRUE;
651             }
652             break;
653         }
654     }
655
656     /* if not handled internally, pass it to the driver */
657     return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
658 }
659
660
661 /******************************************************************************
662  *              ExtEscape       [GDI32.@]
663  *
664  * Access capabilities of a particular device that are not available through GDI.
665  *
666  * PARAMS
667  *    hdc         [I] Handle to device context
668  *    nEscape     [I] Escape function
669  *    cbInput     [I] Number of bytes in input structure
670  *    lpszInData  [I] Pointer to input structure
671  *    cbOutput    [I] Number of bytes in output structure
672  *    lpszOutData [O] Pointer to output structure
673  *
674  * RETURNS
675  *    Success: >0
676  *    Not implemented: 0
677  *    Failure: <0
678  */
679 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
680                       INT cbOutput, LPSTR lpszOutData )
681 {
682     INT ret = 0;
683     DC * dc = DC_GetDCPtr( hdc );
684     if (dc)
685     {
686         if (dc->funcs->pExtEscape)
687             ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
688         GDI_ReleaseObj( hdc );
689     }
690     return ret;
691 }
692
693
694 /*******************************************************************
695  *      DrawEscape [GDI32.@]
696  *
697  *
698  */
699 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
700 {
701     FIXME("DrawEscape, stub\n");
702     return 0;
703 }