4 * Copyright 1994 Bob Amstadt
12 #include "debugtools.h"
14 DEFAULT_DEBUG_CHANNEL(driver
);
16 /***********************************************************************
19 INT16 WINAPI
Escape16( HDC16 hdc
, INT16 nEscape
, INT16 cbInput
,
20 SEGPTR lpszInData
, SEGPTR lpvOutData
)
23 DC
* dc
= DC_GetDCPtr( hdc
);
26 if (dc
->funcs
->pEscape
)
28 if(nEscape
== SETABORTPROC
) SetAbortProc16(hdc
, lpszInData
);
29 ret
= dc
->funcs
->pEscape( dc
, nEscape
, cbInput
, lpszInData
, lpvOutData
);
31 GDI_ReleaseObj( hdc
);
36 /************************************************************************
39 INT WINAPI
Escape( HDC hdc
, INT nEscape
, INT cbInput
,
40 LPCSTR lpszInData
, LPVOID lpvOutData
)
44 DC
* dc
= DC_GetDCPtr( hdc
);
46 if (!dc
->funcs
->pEscape
) goto done
;
48 segin
= (SEGPTR
)lpszInData
;
49 segout
= (SEGPTR
)lpvOutData
;
51 /* Escape(hdc,QUERYESCSUPPORT,LPINT,NULL) */
52 /* Escape(hdc,CLIP_TO_PATH,LPINT,NULL) */
56 LPINT16 x
= (LPINT16
)SEGPTR_NEW(INT16
);
57 *x
= *(INT
*)lpszInData
;
58 segin
= SEGPTR_GET(x
);
59 cbInput
= sizeof(INT16
);
63 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT32) */
64 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT32) */
65 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT32) */
67 case GETSCALINGFACTOR
:
69 case GETPRINTINGOFFSET
:
70 segout
= SEGPTR_GET(SEGPTR_NEW(POINT16
));
71 cbInput
= sizeof(POINT16
);
74 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT,LPDWORD) */
77 LPINT16 lpIndex
= (LPINT16
)SEGPTR_NEW(INT16
);
78 LPDWORD lpCaps
= (LPDWORD
)SEGPTR_NEW(DWORD
);
79 *lpIndex
= *(INT
*)lpszInData
;
81 segin
= SEGPTR_GET(lpIndex
);
82 segout
= SEGPTR_GET(lpCaps
);
83 cbInput
= sizeof(INT16
);
87 /* Escape(hdc,SETLINECAP,LPINT,LPINT) */
92 LPINT16
new = (LPINT16
)SEGPTR_NEW(INT16
);
93 LPINT16 old
= (LPINT16
)SEGPTR_NEW(INT16
);
94 *new = *(INT
*)lpszInData
;
95 segin
= SEGPTR_GET(new);
96 segout
= SEGPTR_GET(old
);
97 cbInput
= sizeof(INT16
);
100 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
101 case GETTECHNOLOGY
: {
102 segout
= SEGPTR_GET(SEGPTR_ALLOC(200)); /* enough I hope */
107 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
109 case ENABLEPAIRKERNING
: {
110 LPINT16 enab
= SEGPTR_NEW(INT16
);
111 segout
= SEGPTR_GET(SEGPTR_NEW(INT16
));
112 segin
= SEGPTR_GET(enab
);
113 *enab
= *(INT
*)lpszInData
;
114 cbInput
= sizeof(INT16
);
118 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
121 segout
= SEGPTR_GET(SEGPTR_ALLOC(200));
125 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFOA);
126 * lpvOutData is actually a pointer to the DocInfo structure and used as
127 * a second input parameter
130 case STARTDOC
: /* string may not be \0 terminated */
132 char *cp
= SEGPTR_ALLOC(cbInput
);
133 memcpy(cp
, lpszInData
, cbInput
);
134 segin
= SEGPTR_GET(cp
);
139 DOCINFO16
*lpsegdoc
= SEGPTR_NEW(DOCINFO16
);
140 DOCINFOA
*lpdoc
= lpvOutData
;
141 memset(lpsegdoc
, 0, sizeof(*lpsegdoc
));
142 lpsegdoc
->cbSize
= sizeof(*lpsegdoc
);
143 lpsegdoc
->lpszDocName
= SEGPTR_GET(SEGPTR_STRDUP(lpdoc
->lpszDocName
));
144 lpsegdoc
->lpszOutput
= SEGPTR_GET(SEGPTR_STRDUP(lpdoc
->lpszOutput
));
145 lpsegdoc
->lpszDatatype
= SEGPTR_GET(SEGPTR_STRDUP(lpdoc
->lpszDatatype
));
146 lpsegdoc
->fwType
= lpdoc
->fwType
;
147 segout
= SEGPTR_GET(lpsegdoc
);
152 SetAbortProc(hdc
, (ABORTPROC
)lpszInData
);
155 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
158 BYTE
*p
= SEGPTR_ALLOC(cbInput
);
159 memcpy(p
, lpszInData
, cbInput
);
160 segin
= SEGPTR_GET(p
);
169 ret
= dc
->funcs
->pEscape( dc
, nEscape
, cbInput
, segin
, segout
);
172 case QUERYESCSUPPORT
:
174 TRACE("target DC implements Escape %d\n",nEscape
);
175 SEGPTR_FREE(MapSL(segin
));
181 *(LPINT
)lpvOutData
= *(LPINT16
)MapSL(segout
);
182 SEGPTR_FREE(MapSL(segin
));
183 SEGPTR_FREE(MapSL(segout
));
185 case GETSCALINGFACTOR
:
186 case GETPRINTINGOFFSET
:
187 case GETPHYSPAGESIZE
: {
188 LPPOINT16 x
= MapSL(segout
);
189 CONV_POINT16TO32(x
,(LPPOINT
)lpvOutData
);
193 case EXT_DEVICE_CAPS
:
194 *(LPDWORD
)lpvOutData
= *(LPDWORD
)MapSL(segout
);
195 SEGPTR_FREE(MapSL(segin
));
196 SEGPTR_FREE(MapSL(segout
));
199 case GETTECHNOLOGY
: {
200 LPSTR x
=MapSL(segout
);
201 strcpy(lpvOutData
,x
);
205 case ENABLEPAIRKERNING
: {
206 LPINT16 enab
= MapSL(segout
);
208 *(LPINT
)lpvOutData
= *enab
;
210 SEGPTR_FREE(MapSL(segin
));
214 LPSTR x
= (LPSTR
)MapSL(segout
);
215 strcpy(lpvOutData
,x
);
220 DOCINFO16
*doc
= MapSL(segout
);
221 SEGPTR_FREE(MapSL(doc
->lpszDocName
));
222 SEGPTR_FREE(MapSL(doc
->lpszOutput
));
223 SEGPTR_FREE(MapSL(doc
->lpszDatatype
));
225 SEGPTR_FREE(MapSL(segin
));
231 SEGPTR_FREE(MapSL(segin
));
238 GDI_ReleaseObj( hdc
);
242 /******************************************************************************
243 * ExtEscape [GDI32.@]
246 * hdc [I] Handle to device context
247 * nEscape [I] Escape function
248 * cbInput [I] Number of bytes in input structure
249 * lpszInData [I] Pointer to input structure
250 * cbOutput [I] Number of bytes in output structure
251 * lpszOutData [O] Pointer to output structure
258 INT WINAPI
ExtEscape( HDC hdc
, INT nEscape
, INT cbInput
,
259 LPCSTR lpszInData
, INT cbOutput
, LPSTR lpszOutData
)
261 char *inBuf
, *outBuf
;
264 inBuf
= SEGPTR_ALLOC(cbInput
);
265 memcpy(inBuf
, lpszInData
, cbInput
);
266 outBuf
= cbOutput
? SEGPTR_ALLOC(cbOutput
) : NULL
;
267 ret
= Escape16( hdc
, nEscape
, cbInput
, SEGPTR_GET(inBuf
),
268 SEGPTR_GET(outBuf
) );
271 memcpy(lpszOutData
, outBuf
, cbOutput
);
277 /*******************************************************************
278 * DrawEscape [GDI32.@]
282 INT WINAPI
DrawEscape(HDC hdc
, INT nEscape
, INT cbInput
, LPCSTR lpszInData
)
284 FIXME("DrawEscape, stub\n");