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