Warning fixes for gcc 4.0.
[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, { 0, (DWORD)(__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
77 #define GET_FUNC(name) driver->funcs.p##name = (void*)GetProcAddress( module, #name )
78
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     /* add it to the list */
200     driver->prev = NULL;
201     if ((driver->next = first_driver)) driver->next->prev = driver;
202     first_driver = driver;
203     return driver;
204 }
205
206
207 /**********************************************************************
208  *           load_display_driver
209  *
210  * Special case for loading the display driver: get the name from the config file
211  */
212 static struct graphics_driver *load_display_driver(void)
213 {
214     char buffer[MAX_PATH], libname[32], *name, *next;
215     HMODULE module = 0;
216     HKEY hkey;
217
218     if (display_driver)  /* already loaded */
219     {
220         display_driver->count++;
221         return display_driver;
222     }
223
224     strcpy( buffer, "x11,tty" );  /* default value */
225     /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
226     if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
227     {
228         DWORD type, count = sizeof(buffer);
229         RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
230         RegCloseKey( hkey );
231     }
232
233     name = buffer;
234     while (name)
235     {
236         next = strchr( name, ',' );
237         if (next) *next++ = 0;
238
239         snprintf( libname, sizeof(libname), "wine%s.drv", name );
240         if ((module = LoadLibraryA( libname )) != 0) break;
241         name = next;
242     }
243     if (!module)
244     {
245         MESSAGE( "wine: Could not load graphics driver '%s'.\n", buffer );
246         if (!strcasecmp( buffer, "x11" ))
247             MESSAGE( "Make sure that your X server is running and that $DISPLAY is set correctly.\n" );
248         ExitProcess(1);
249     }
250
251     if (!(display_driver = create_driver( module )))
252     {
253         MESSAGE( "Could not create graphics driver '%s'\n", buffer );
254         FreeLibrary( module );
255         ExitProcess(1);
256     }
257
258     display_driver->count++;  /* we don't want to free it */
259     return display_driver;
260 }
261
262
263 /**********************************************************************
264  *           DRIVER_load_driver
265  */
266 const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
267 {
268     HMODULE module;
269     struct graphics_driver *driver;
270     static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
271
272     EnterCriticalSection( &driver_section );
273
274     /* display driver is a special case */
275     if (!strcmpiW( name, displayW ))
276     {
277         driver = load_display_driver();
278         LeaveCriticalSection( &driver_section );
279         return &driver->funcs;
280     }
281
282     if ((module = GetModuleHandleW( name )))
283     {
284         for (driver = first_driver; driver; driver = driver->next)
285         {
286             if (driver->module == module)
287             {
288                 driver->count++;
289                 LeaveCriticalSection( &driver_section );
290                 return &driver->funcs;
291             }
292         }
293     }
294
295     if (!(module = LoadLibraryW( name )))
296     {
297         LeaveCriticalSection( &driver_section );
298         return NULL;
299     }
300
301     if (!(driver = create_driver( module )))
302     {
303         FreeLibrary( module );
304         LeaveCriticalSection( &driver_section );
305         return NULL;
306     }
307
308     TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
309     LeaveCriticalSection( &driver_section );
310     return &driver->funcs;
311 }
312
313
314 /**********************************************************************
315  *           DRIVER_get_driver
316  *
317  * Get a new copy of an existing driver.
318  */
319 const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs )
320 {
321     struct graphics_driver *driver;
322
323     EnterCriticalSection( &driver_section );
324     for (driver = first_driver; driver; driver = driver->next)
325         if (&driver->funcs == funcs) break;
326     if (!driver) ERR( "driver not found, trouble ahead\n" );
327     driver->count++;
328     LeaveCriticalSection( &driver_section );
329     return funcs;
330 }
331
332
333 /**********************************************************************
334  *           DRIVER_release_driver
335  *
336  * Release a driver by decrementing ref count and freeing it if needed.
337  */
338 void DRIVER_release_driver( const DC_FUNCTIONS *funcs )
339 {
340     struct graphics_driver *driver;
341
342     EnterCriticalSection( &driver_section );
343
344     for (driver = first_driver; driver; driver = driver->next)
345         if (&driver->funcs == funcs) break;
346
347     if (!driver) goto done;
348     if (--driver->count) goto done;
349
350     /* removed last reference, free it */
351     if (driver->next) driver->next->prev = driver->prev;
352     if (driver->prev) driver->prev->next = driver->next;
353     else first_driver = driver->next;
354     if (driver == display_driver) display_driver = NULL;
355
356     FreeLibrary( driver->module );
357     HeapFree( GetProcessHeap(), 0, driver );
358  done:
359     LeaveCriticalSection( &driver_section );
360 }
361
362
363 /*****************************************************************************
364  *      DRIVER_GetDriverName
365  *
366  */
367 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
368 {
369     static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
370     static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
371     static const WCHAR empty_strW[] = { 0 };
372     WCHAR *p;
373
374     /* display is a special case */
375     if (!strcmpiW( device, displayW ))
376     {
377         lstrcpynW( driver, displayW, size );
378         return TRUE;
379     }
380
381     size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
382     if(!size) {
383         WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
384         return FALSE;
385     }
386     p = strchrW(driver, ',');
387     if(!p)
388     {
389         WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
390         return FALSE;
391     }
392     *p = 0;
393     TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
394     return TRUE;
395 }
396
397
398 /***********************************************************************
399  *           GdiConvertToDevmodeW    (GDI32.@)
400  */
401 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
402 {
403     DEVMODEW *dmW;
404     WORD dmW_size;
405
406     dmW_size = dmA->dmSize + CCHDEVICENAME;
407     if (dmA->dmSize >= (const char *)dmA->dmFormName - (const char *)dmA + CCHFORMNAME)
408         dmW_size += CCHFORMNAME;
409
410     dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
411     if (!dmW) return NULL;
412
413     MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME,
414                                    dmW->dmDeviceName, CCHDEVICENAME);
415     /* copy slightly more, to avoid long computations */
416     memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA->dmSize - CCHDEVICENAME);
417
418     if (dmA->dmSize >= (const char *)dmA->dmFormName - (const char *)dmA + CCHFORMNAME)
419     {
420         MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME,
421                                        dmW->dmFormName, CCHFORMNAME);
422         if (dmA->dmSize > (const char *)&dmA->dmLogPixels - (const char *)dmA)
423             memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA->dmSize - ((const char *)&dmA->dmLogPixels - (const char *)dmA));
424     }
425
426     if (dmA->dmDriverExtra)
427         memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA->dmSize, dmA->dmDriverExtra);
428
429     dmW->dmSize = dmW_size;
430
431     return dmW;
432 }
433
434
435 /*****************************************************************************
436  *      @ [GDI32.100]
437  *
438  * This should thunk to 16-bit and simply call the proc with the given args.
439  */
440 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
441                                  LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
442 {
443     FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
444     return -1;
445 }
446
447 /*****************************************************************************
448  *      @ [GDI32.101]
449  *
450  * This should load the correct driver for lpszDevice and calls this driver's
451  * ExtDeviceModePropSheet proc.
452  *
453  * Note: The driver calls a callback routine for each property sheet page; these
454  * pages are supposed to be filled into the structure pointed to by lpPropSheet.
455  * The layout of this structure is:
456  *
457  * struct
458  * {
459  *   DWORD  nPages;
460  *   DWORD  unknown;
461  *   HPROPSHEETPAGE  pages[10];
462  * };
463  */
464 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
465                                              LPCSTR lpszPort, LPVOID lpPropSheet )
466 {
467     FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
468     return -1;
469 }
470
471 /*****************************************************************************
472  *      @ [GDI32.102]
473  *
474  * This should load the correct driver for lpszDevice and calls this driver's
475  * ExtDeviceMode proc.
476  *
477  * FIXME: convert ExtDeviceMode to unicode in the driver interface
478  */
479 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
480                                     LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
481                                     LPSTR lpszPort, LPDEVMODEA lpdmInput,
482                                     LPSTR lpszProfile, DWORD fwMode )
483 {
484     WCHAR deviceW[300];
485     WCHAR bufW[300];
486     char buf[300];
487     HDC hdc;
488     DC *dc;
489     INT ret = -1;
490     INT (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,LPSTR,DWORD);
491
492     TRACE("(%p, %p, %s, %s, %p, %s, %ld)\n",
493           hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
494
495     if (!lpszDevice) return -1;
496     if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
497
498     if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
499
500     if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
501
502     if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
503
504     if ((dc = DC_GetDCPtr( hdc )))
505     {
506         pExtDeviceMode = dc->funcs->pExtDeviceMode;
507         GDI_ReleaseObj( hdc );
508         if (pExtDeviceMode)
509             ret = pExtDeviceMode(buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
510                                             lpdmInput, lpszProfile, fwMode);
511     }
512     DeleteDC( hdc );
513     return ret;
514 }
515
516 /****************************************************************************
517  *      @ [GDI32.103]
518  *
519  * This should load the correct driver for lpszDevice and calls this driver's
520  * AdvancedSetupDialog proc.
521  */
522 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
523                                           LPDEVMODEA devin, LPDEVMODEA devout )
524 {
525     TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
526     return -1;
527 }
528
529 /*****************************************************************************
530  *      @ [GDI32.104]
531  *
532  * This should load the correct driver for lpszDevice and calls this driver's
533  * DeviceCapabilities proc.
534  *
535  * FIXME: convert DeviceCapabilities to unicode in the driver interface
536  */
537 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
538                                            WORD fwCapability, LPSTR lpszOutput,
539                                            LPDEVMODEA lpdm )
540 {
541     WCHAR deviceW[300];
542     WCHAR bufW[300];
543     char buf[300];
544     HDC hdc;
545     DC *dc;
546     INT ret = -1;
547
548     TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
549
550     if (!lpszDevice) return -1;
551     if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
552
553     if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
554
555     if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
556
557     if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
558
559     if ((dc = DC_GetDCPtr( hdc )))
560     {
561         if (dc->funcs->pDeviceCapabilities)
562             ret = dc->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
563                                                   fwCapability, lpszOutput, lpdm );
564         GDI_ReleaseObj( hdc );
565     }
566     DeleteDC( hdc );
567     return ret;
568 }
569
570
571 /************************************************************************
572  *             Escape  [GDI32.@]
573  */
574 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
575 {
576     INT ret;
577     POINT *pt;
578
579     switch (escape)
580     {
581     case ABORTDOC:
582         return AbortDoc( hdc );
583
584     case ENDDOC:
585         return EndDoc( hdc );
586
587     case GETPHYSPAGESIZE:
588         pt = out_data;
589         pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
590         pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
591         return 1;
592
593     case GETPRINTINGOFFSET:
594         pt = out_data;
595         pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
596         pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
597         return 1;
598
599     case GETSCALINGFACTOR:
600         pt = out_data;
601         pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
602         pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
603         return 1;
604
605     case NEWFRAME:
606         return EndPage( hdc );
607
608     case SETABORTPROC:
609         return SetAbortProc( hdc, (ABORTPROC)in_data );
610
611     case STARTDOC:
612         {
613             DOCINFOA doc;
614             char *name = NULL;
615
616             /* in_data may not be 0 terminated so we must copy it */
617             if (in_data)
618             {
619                 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
620                 memcpy( name, in_data, in_count );
621                 name[in_count] = 0;
622             }
623             /* out_data is actually a pointer to the DocInfo structure and used as
624              * a second input parameter */
625             if (out_data) doc = *(DOCINFOA *)out_data;
626             else
627             {
628                 doc.cbSize = sizeof(doc);
629                 doc.lpszOutput = NULL;
630                 doc.lpszDatatype = NULL;
631                 doc.fwType = 0;
632             }
633             doc.lpszDocName = name;
634             ret = StartDocA( hdc, &doc );
635             HeapFree( GetProcessHeap(), 0, name );
636             if (ret > 0) ret = StartPage( hdc );
637             return ret;
638         }
639
640     case QUERYESCSUPPORT:
641         {
642             const INT *ptr = (const INT *)in_data;
643             if (in_count < sizeof(INT)) return 0;
644             switch(*ptr)
645             {
646             case ABORTDOC:
647             case ENDDOC:
648             case GETPHYSPAGESIZE:
649             case GETPRINTINGOFFSET:
650             case GETSCALINGFACTOR:
651             case NEWFRAME:
652             case QUERYESCSUPPORT:
653             case SETABORTPROC:
654             case STARTDOC:
655                 return TRUE;
656             }
657             break;
658         }
659     }
660
661     /* if not handled internally, pass it to the driver */
662     return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
663 }
664
665
666 /******************************************************************************
667  *              ExtEscape       [GDI32.@]
668  *
669  * PARAMS
670  *    hdc         [I] Handle to device context
671  *    nEscape     [I] Escape function
672  *    cbInput     [I] Number of bytes in input structure
673  *    lpszInData  [I] Pointer to input structure
674  *    cbOutput    [I] Number of bytes in output structure
675  *    lpszOutData [O] Pointer to output structure
676  *
677  * RETURNS
678  *    Success: >0
679  *    Not implemented: 0
680  *    Failure: <0
681  */
682 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
683                       INT cbOutput, LPSTR lpszOutData )
684 {
685     INT ret = 0;
686     DC * dc = DC_GetDCPtr( hdc );
687     if (dc)
688     {
689         if (dc->funcs->pExtEscape)
690             ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
691         GDI_ReleaseObj( hdc );
692     }
693     return ret;
694 }
695
696
697 /*******************************************************************
698  *      DrawEscape [GDI32.@]
699  *
700  *
701  */
702 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
703 {
704     FIXME("DrawEscape, stub\n");
705     return 0;
706 }