4 * Copyright 1994 Bob Amstadt
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(driver)
17 /***********************************************************************
20 INT16 WINAPI Escape16( HDC16 hdc, INT16 nEscape, INT16 cbInput,
21 SEGPTR lpszInData, SEGPTR lpvOutData )
23 DC * dc = DC_GetDCPtr( hdc );
24 if (!dc || !dc->funcs->pEscape) return 0;
25 if(nEscape == SETABORTPROC) SetAbortProc16(hdc, lpszInData);
26 return dc->funcs->pEscape( dc, nEscape, cbInput, lpszInData, lpvOutData );
29 /************************************************************************
32 INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
33 LPCSTR lpszInData, LPVOID lpvOutData )
37 DC * dc = DC_GetDCPtr( hdc );
38 if (!dc || !dc->funcs->pEscape) return 0;
40 segin = (SEGPTR)lpszInData;
41 segout = (SEGPTR)lpvOutData;
43 /* Escape(hdc,QUERYESCSUPPORT,LPINT,NULL) */
44 /* Escape(hdc,CLIP_TO_PATH,LPINT,NULL) */
48 LPINT16 x = (LPINT16)SEGPTR_NEW(INT16);
49 *x = *(INT*)lpszInData;
50 segin = SEGPTR_GET(x);
51 cbInput = sizeof(INT16);
55 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT32) */
56 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT32) */
57 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT32) */
59 case GETSCALINGFACTOR:
61 case GETPRINTINGOFFSET:
62 segout = SEGPTR_GET(SEGPTR_NEW(POINT16));
63 cbInput = sizeof(POINT16);
66 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT,LPDWORD) */
69 LPINT16 lpIndex = (LPINT16)SEGPTR_NEW(INT16);
70 LPDWORD lpCaps = (LPDWORD)SEGPTR_NEW(DWORD);
71 *lpIndex = *(INT*)lpszInData;
73 segin = SEGPTR_GET(lpIndex);
74 segout = SEGPTR_GET(lpCaps);
75 cbInput = sizeof(INT16);
79 /* Escape(hdc,SETLINECAP,LPINT,LPINT) */
84 LPINT16 new = (LPINT16)SEGPTR_NEW(INT16);
85 LPINT16 old = (LPINT16)SEGPTR_NEW(INT16);
86 *new = *(INT*)lpszInData;
87 segin = SEGPTR_GET(new);
88 segout = SEGPTR_GET(old);
89 cbInput = sizeof(INT16);
92 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
94 segout = SEGPTR_GET(SEGPTR_ALLOC(200)); /* enough I hope */
99 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
101 case ENABLEPAIRKERNING: {
102 LPINT16 enab = SEGPTR_NEW(INT16);
103 segout = SEGPTR_GET(SEGPTR_NEW(INT16));
104 segin = SEGPTR_GET(enab);
105 *enab = *(INT*)lpszInData;
106 cbInput = sizeof(INT16);
110 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
113 segout = SEGPTR_GET(SEGPTR_ALLOC(200));
117 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFOA);
118 * lpvOutData is actually a pointer to the DocInfo structure and used as
119 * a second input parameter
122 case STARTDOC: /* string may not be \0 terminated */
124 char *cp = SEGPTR_ALLOC(cbInput);
125 memcpy(cp, lpszInData, cbInput);
126 segin = SEGPTR_GET(cp);
131 DOCINFO16 *lpsegdoc = SEGPTR_NEW(DOCINFO16);
132 DOCINFOA *lpdoc = lpvOutData;
133 memset(lpsegdoc, 0, sizeof(*lpsegdoc));
134 lpsegdoc->cbSize = sizeof(*lpsegdoc);
135 lpsegdoc->lpszDocName = SEGPTR_GET(SEGPTR_STRDUP(lpdoc->lpszDocName));
136 lpsegdoc->lpszOutput = SEGPTR_GET(SEGPTR_STRDUP(lpdoc->lpszOutput));
137 lpsegdoc->lpszDatatype = SEGPTR_GET(SEGPTR_STRDUP(lpdoc->lpszDatatype));
138 lpsegdoc->fwType = lpdoc->fwType;
139 segout = SEGPTR_GET(lpsegdoc);
144 SetAbortProc(hdc, (ABORTPROC)lpszInData);
147 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
150 BYTE *p = SEGPTR_ALLOC(cbInput);
151 memcpy(p, lpszInData, cbInput);
152 segin = SEGPTR_GET(p);
161 ret = dc->funcs->pEscape( dc, nEscape, cbInput, segin, segout );
164 case QUERYESCSUPPORT:
166 TRACE("target DC implements Escape %d\n",nEscape);
167 SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
173 *(LPINT)lpvOutData = *(LPINT16)PTR_SEG_TO_LIN(segout);
174 SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
175 SEGPTR_FREE(PTR_SEG_TO_LIN(segout));
177 case GETSCALINGFACTOR:
178 case GETPRINTINGOFFSET:
179 case GETPHYSPAGESIZE: {
180 LPPOINT16 x = (LPPOINT16)PTR_SEG_TO_LIN(segout);
181 CONV_POINT16TO32(x,(LPPOINT)lpvOutData);
185 case EXT_DEVICE_CAPS:
186 *(LPDWORD)lpvOutData = *(LPDWORD)PTR_SEG_TO_LIN(segout);
187 SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
188 SEGPTR_FREE(PTR_SEG_TO_LIN(segout));
191 case GETTECHNOLOGY: {
192 LPSTR x=PTR_SEG_TO_LIN(segout);
193 lstrcpyA(lpvOutData,x);
197 case ENABLEPAIRKERNING: {
198 LPINT16 enab = (LPINT16)PTR_SEG_TO_LIN(segout);
200 *(LPINT)lpvOutData = *enab;
202 SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
206 LPSTR x = (LPSTR)PTR_SEG_TO_LIN(segout);
207 lstrcpyA(lpvOutData,x);
212 DOCINFO16 *doc = PTR_SEG_TO_LIN(segout);
213 SEGPTR_FREE(PTR_SEG_TO_LIN(doc->lpszDocName));
214 SEGPTR_FREE(PTR_SEG_TO_LIN(doc->lpszOutput));
215 SEGPTR_FREE(PTR_SEG_TO_LIN(doc->lpszDatatype));
217 SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
223 SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
232 /******************************************************************************
233 * ExtEscape [GDI32.95]
236 * hdc [I] Handle to device context
237 * nEscape [I] Escape function
238 * cbInput [I] Number of bytes in input structure
239 * lpszInData [I] Pointer to input structure
240 * cbOutput [I] Number of bytes in output structure
241 * lpszOutData [O] Pointer to output structure
248 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput,
249 LPCSTR lpszInData, INT cbOutput, LPSTR lpszOutData )
251 char *inBuf, *outBuf;
254 inBuf = SEGPTR_ALLOC(cbInput);
255 memcpy(inBuf, lpszInData, cbInput);
256 outBuf = cbOutput ? SEGPTR_ALLOC(cbOutput) : NULL;
257 ret = Escape16( hdc, nEscape, cbInput, SEGPTR_GET(inBuf),
258 SEGPTR_GET(outBuf) );
261 memcpy(lpszOutData, outBuf, cbOutput);
267 /*******************************************************************
268 * DrawEscape [GDI32.74]
272 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
274 FIXME("DrawEscape, stub\n");