Only return valid file system names from RenderFILENAMEA/W() by using
[wine/wine64.git] / graphics / escape.c
blobaf504cb8c7c064bcbcd7cef6b9b082f148717fd8
1 /*
2 * Escape() function.
4 * Copyright 1994 Bob Amstadt
5 * Copyright 2001 Alexandre Julliard
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.
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.
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
22 #include <stdarg.h>
23 #include <string.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "gdi.h"
28 #include "gdi_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(driver);
34 /************************************************************************
35 * Escape [GDI32.@]
37 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
39 INT ret;
40 POINT *pt;
42 switch (escape)
44 case ABORTDOC:
45 return AbortDoc( hdc );
47 case ENDDOC:
48 return EndDoc( hdc );
50 case GETPHYSPAGESIZE:
51 pt = out_data;
52 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
53 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
54 return 1;
56 case GETPRINTINGOFFSET:
57 pt = out_data;
58 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
59 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
60 return 1;
62 case GETSCALINGFACTOR:
63 pt = out_data;
64 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
65 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
66 return 1;
68 case NEWFRAME:
69 return EndPage( hdc );
71 case SETABORTPROC:
72 return SetAbortProc( hdc, (ABORTPROC)in_data );
74 case STARTDOC:
76 DOCINFOA doc;
77 char *name = NULL;
79 /* in_data may not be 0 terminated so we must copy it */
80 if (in_data)
82 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
83 memcpy( name, in_data, in_count );
84 name[in_count] = 0;
86 /* out_data is actually a pointer to the DocInfo structure and used as
87 * a second input parameter */
88 if (out_data) doc = *(DOCINFOA *)out_data;
89 else
91 doc.cbSize = sizeof(doc);
92 doc.lpszOutput = NULL;
93 doc.lpszDatatype = NULL;
94 doc.fwType = 0;
96 doc.lpszDocName = name;
97 ret = StartDocA( hdc, &doc );
98 if (name) HeapFree( GetProcessHeap(), 0, name );
99 if (ret > 0) ret = StartPage( hdc );
100 return ret;
103 case QUERYESCSUPPORT:
105 INT *ptr = (INT *)in_data;
106 if (in_count < sizeof(INT)) return 0;
107 switch(*ptr)
109 case ABORTDOC:
110 case ENDDOC:
111 case GETPHYSPAGESIZE:
112 case GETPRINTINGOFFSET:
113 case GETSCALINGFACTOR:
114 case NEWFRAME:
115 case QUERYESCSUPPORT:
116 case SETABORTPROC:
117 case STARTDOC:
118 return TRUE;
120 break;
124 /* if not handled internally, pass it to the driver */
125 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
129 /******************************************************************************
130 * ExtEscape [GDI32.@]
132 * PARAMS
133 * hdc [I] Handle to device context
134 * nEscape [I] Escape function
135 * cbInput [I] Number of bytes in input structure
136 * lpszInData [I] Pointer to input structure
137 * cbOutput [I] Number of bytes in output structure
138 * lpszOutData [O] Pointer to output structure
140 * RETURNS
141 * Success: >0
142 * Not implemented: 0
143 * Failure: <0
145 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
146 INT cbOutput, LPSTR lpszOutData )
148 INT ret = 0;
149 DC * dc = DC_GetDCPtr( hdc );
150 if (dc)
152 if (dc->funcs->pExtEscape)
153 ret = dc->funcs->pExtEscape( dc->physDev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
154 GDI_ReleaseObj( hdc );
156 return ret;
160 /*******************************************************************
161 * DrawEscape [GDI32.@]
165 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
167 FIXME("DrawEscape, stub\n");
168 return 0;