Release 970804
[wine/multimedia.git] / graphics / win16drv / init.c
blob9fc20860f8941f348783f0d7bb2204ed8267774e
1 /*
2 * Windows Device Context initialisation functions
4 * Copyright 1996 John Harvey
5 */
7 #include <stdlib.h>
8 #include <string.h>
9 #include <sys/types.h>
10 #include <ctype.h>
11 #include <fcntl.h>
12 #include <unistd.h>
13 #include <errno.h>
14 #include "windows.h"
15 #include "module.h"
16 #include "win16drv.h"
17 #include "gdi.h"
18 #include "bitmap.h"
19 #include "heap.h"
20 #include "color.h"
21 #include "font.h"
22 #include "callback.h"
23 #include "stddebug.h"
24 #include "debug.h"
26 #define SUPPORT_REALIZED_FONTS 1
27 #pragma pack(1)
28 typedef struct
30 SHORT nSize;
31 SEGPTR lpindata;
32 SEGPTR lpFont;
33 SEGPTR lpXForm;
34 SEGPTR lpDrawMode;
35 } EXTTEXTDATA, *LPEXTTEXTDATA;
36 #pragma pack(4)
38 SEGPTR win16drv_SegPtr_TextXForm;
39 LPTEXTXFORM16 win16drv_TextXFormP;
40 SEGPTR win16drv_SegPtr_DrawMode;
41 LPDRAWMODE win16drv_DrawModeP;
44 static BOOL32 WIN16DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
45 LPCSTR output, const DEVMODE16* initData );
46 static INT32 WIN16DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
47 SEGPTR lpInData, SEGPTR lpOutData );
49 static const DC_FUNCTIONS WIN16DRV_Funcs =
51 NULL, /* pArc */
52 NULL, /* pBitBlt */
53 NULL, /* pChord */
54 WIN16DRV_CreateDC, /* pCreateDC */
55 NULL, /* pDeleteDC */
56 NULL, /* pDeleteObject */
57 NULL, /* pEllipse */
58 NULL, /* pEnumDeviceFonts */
59 WIN16DRV_Escape, /* pEscape */
60 NULL, /* pExcludeClipRect */
61 NULL, /* pExcludeVisRect */
62 NULL, /* pExtFloodFill */
63 WIN16DRV_ExtTextOut, /* pExtTextOut */
64 WIN16DRV_GetCharWidth, /* pGetCharWidth */
65 NULL, /* pGetPixel */
66 WIN16DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
67 WIN16DRV_GetTextMetrics, /* pGetTextMetrics */
68 NULL, /* pIntersectClipRect */
69 NULL, /* pIntersectVisRect */
70 NULL, /* pLineTo */
71 NULL, /* pMoveToEx */
72 NULL, /* pOffsetClipRgn */
73 NULL, /* pOffsetViewportOrgEx */
74 NULL, /* pOffsetWindowOrgEx */
75 NULL, /* pPaintRgn */
76 WIN16DRV_PatBlt, /* pPatBlt */
77 NULL, /* pPie */
78 NULL, /* pPolyPolygon */
79 NULL, /* pPolygon */
80 NULL, /* pPolyline */
81 NULL, /* pRealizePalette */
82 NULL, /* pRectangle */
83 NULL, /* pRestoreDC */
84 NULL, /* pRoundRect */
85 NULL, /* pSaveDC */
86 NULL, /* pScaleViewportExtEx */
87 NULL, /* pScaleWindowExtEx */
88 NULL, /* pSelectClipRgn */
89 WIN16DRV_SelectObject, /* pSelectObject */
90 NULL, /* pSelectPalette */
91 NULL, /* pSetBkColor */
92 NULL, /* pSetBkMode */
93 NULL, /* pSetDeviceClipping */
94 NULL, /* pSetDIBitsToDevice */
95 NULL, /* pSetMapMode */
96 NULL, /* pSetMapperFlags */
97 NULL, /* pSetPixel */
98 NULL, /* pSetPolyFillMode */
99 NULL, /* pSetROP2 */
100 NULL, /* pSetRelAbs */
101 NULL, /* pSetStretchBltMode */
102 NULL, /* pSetTextAlign */
103 NULL, /* pSetTextCharacterExtra */
104 NULL, /* pSetTextColor */
105 NULL, /* pSetTextJustification */
106 NULL, /* pSetViewportExtEx */
107 NULL, /* pSetViewportOrgEx */
108 NULL, /* pSetWindowExtEx */
109 NULL, /* pSetWindowOrgEx */
110 NULL, /* pStretchBlt */
111 NULL /* pStretchDIBits */
118 /**********************************************************************
119 * WIN16DRV_Init
121 BOOL32 WIN16DRV_Init(void)
123 return DRIVER_RegisterDriver( NULL /* generic driver */, &WIN16DRV_Funcs );
127 /* Tempory functions, for initialising structures */
128 /* These values should be calculated, not hardcoded */
129 void InitTextXForm(LPTEXTXFORM16 lpTextXForm)
131 lpTextXForm->txfHeight = 0x0001;
132 lpTextXForm->txfWidth = 0x000c;
133 lpTextXForm->txfEscapement = 0x0000;
134 lpTextXForm->txfOrientation = 0x0000;
135 lpTextXForm->txfWeight = 0x0190;
136 lpTextXForm->txfItalic = 0x00;
137 lpTextXForm->txfUnderline = 0x00;
138 lpTextXForm->txfStrikeOut = 0x00;
139 lpTextXForm->txfOutPrecision = 0x02;
140 lpTextXForm->txfClipPrecision = 0x01;
141 lpTextXForm->txfAccelerator = 0x0001;
142 lpTextXForm->txfOverhang = 0x0000;
146 void InitDrawMode(LPDRAWMODE lpDrawMode)
148 lpDrawMode->Rop2 = 0x000d;
149 lpDrawMode->bkMode = 0x0001;
150 lpDrawMode->bkColor = 0x3fffffff;
151 lpDrawMode->TextColor = 0x20000000;
152 lpDrawMode->TBreakExtra = 0x0000;
153 lpDrawMode->BreakExtra = 0x0000;
154 lpDrawMode->BreakErr = 0x0000;
155 lpDrawMode->BreakRem = 0x0000;
156 lpDrawMode->BreakCount = 0x0000;
157 lpDrawMode->CharExtra = 0x0000;
158 lpDrawMode->LbkColor = 0x00ffffff;
159 lpDrawMode->LTextColor = 0x00000000;
163 * EnumCallback (GDI.158)
165 * This is the callback function used when EnumDFonts is called.
166 * (The printer drivers uses it to pass info on available fonts).
168 * lpvClientData is the pointer passed to EnumDFonts, which points to a WEPFC
169 * structure (WEPFC = WINE_ENUM_PRINTER_FONT_CALLBACK). This structure
170 * contains infomation on how to store the data passed .
172 * There are two modes:
173 * 1) Just count the number of fonts available.
174 * 2) Store all font data passed.
176 WORD WineEnumDFontCallback(LPLOGFONT16 lpLogFont, LPTEXTMETRIC16 lpTextMetrics,
177 WORD wFontType, LONG lpvClientData)
179 int wRet = 0;
180 WEPFC *pWEPFC = (WEPFC *)lpvClientData;
182 /* Make sure we have the right structure */
183 if (pWEPFC != NULL )
185 dprintf_win16drv(stddeb, "mode is 0x%x\n",pWEPFC->nMode);
187 switch (pWEPFC->nMode)
189 /* Count how many fonts */
190 case 1:
191 pWEPFC->nCount++;
192 break;
194 /* Store the fonts in the printer driver structure */
195 case 2:
197 PRINTER_FONTS_INFO *pPFI;
199 dprintf_win16drv(stddeb, "WineEnumDFontCallback: Found %s %x\n",
200 lpLogFont->lfFaceName, wFontType);
202 pPFI = &pWEPFC->pLPD->paPrinterFonts[pWEPFC->nCount];
203 memcpy(&(pPFI->lf), lpLogFont, sizeof(LOGFONT16));
204 memcpy(&(pPFI->tm), lpTextMetrics, sizeof(TEXTMETRIC16));
205 pWEPFC->nCount++;
208 break;
210 wRet = 1;
212 dprintf_win16drv(stddeb, "WineEnumDFontCallback: returnd %d\n", wRet);
213 return wRet;
216 BOOL32 WIN16DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device, LPCSTR output,
217 const DEVMODE16* initData )
219 LOADED_PRINTER_DRIVER *pLPD;
220 WORD wRet;
221 DeviceCaps *printerDevCaps;
222 FARPROC16 pfnCallback;
223 int nPDEVICEsize;
224 PDEVICE_HEADER *pPDH;
225 WIN16DRV_PDEVICE *physDev;
226 int numFonts;
227 /* Realizing fonts */
228 int nSize;
229 char printerEnabled[20];
230 PROFILE_GetWineIniString( "wine", "printer", "off",
231 printerEnabled, sizeof(printerEnabled) );
232 if (lstrcmpi32A(printerEnabled,"on"))
234 printf("WIN16DRV_CreateDC disabled in wine.conf file\n");
235 return FALSE;
238 dprintf_win16drv(stddeb, "In creatdc for (%s,%s,%s) initData 0x%p\n",driver, device, output, initData);
240 physDev = (WIN16DRV_PDEVICE *)HeapAlloc( SystemHeap, 0, sizeof(*physDev) );
241 if (!physDev) return FALSE;
242 dc->physDev = physDev;
244 pLPD = LoadPrinterDriver(driver);
245 if (pLPD == NULL)
247 dprintf_win16drv(stddeb, "LPGDI_CreateDC: Failed to find printer driver\n");
248 HeapFree( SystemHeap, 0, physDev );
249 return FALSE;
251 dprintf_win16drv(stddeb, "windevCreateDC pLPD 0x%p\n", pLPD);
253 /* Now Get the device capabilities from the printer driver */
255 printerDevCaps = (DeviceCaps *) malloc(sizeof(DeviceCaps));
256 memset(printerDevCaps, 0, sizeof(DeviceCaps));
258 /* Get GDIINFO which is the same as a DeviceCaps structure */
259 wRet = PRTDRV_Enable(printerDevCaps, GETGDIINFO, device, driver, output,NULL);
261 /* Add this to the DC */
262 dc->w.devCaps = printerDevCaps;
263 dc->w.hVisRgn = CreateRectRgn32(0, 0, dc->w.devCaps->horzRes, dc->w.devCaps->vertRes);
264 dc->w.bitsPerPixel = dc->w.devCaps->bitsPixel;
266 printf("Got devcaps width %d height %d bits %d planes %d\n",
267 dc->w.devCaps->horzRes,
268 dc->w.devCaps->vertRes,
269 dc->w.devCaps->bitsPixel,
270 dc->w.devCaps->planes);
272 /* Now we allocate enough memory for the PDEVICE structure */
273 /* The size of this varies between printer drivers */
274 /* This PDEVICE is used by the printer DRIVER not by the GDI so must */
275 /* be accessable from 16 bit code */
276 nPDEVICEsize = dc->w.devCaps->pdeviceSize + sizeof(PDEVICE_HEADER);
278 /* TTD Shouldn't really do pointer arithmetic on segment points */
279 physDev->segptrPDEVICE = WIN16_GlobalLock16(GlobalAlloc16(GHND, nPDEVICEsize))+sizeof(PDEVICE_HEADER);
280 *(BYTE *)(PTR_SEG_TO_LIN(physDev->segptrPDEVICE)+0) = 'N';
281 *(BYTE *)(PTR_SEG_TO_LIN(physDev->segptrPDEVICE)+1) = 'B';
283 /* Set up the header */
284 pPDH = (PDEVICE_HEADER *)(PTR_SEG_TO_LIN(physDev->segptrPDEVICE) - sizeof(PDEVICE_HEADER));
285 pPDH->pLPD = pLPD;
287 dprintf_win16drv(stddeb, "PRTDRV_Enable: PDEVICE allocated %08lx\n",(DWORD)(physDev->segptrPDEVICE));
289 /* Now get the printer driver to initialise this data */
290 wRet = PRTDRV_Enable((LPVOID)physDev->segptrPDEVICE, INITPDEVICE, device, driver, output, NULL);
292 /* Now enumerate the fonts supported by the printer driver*/
293 /* GDI.158 is EnumCallback, which is called by the 16bit printer driver */
294 /* passing information on the available fonts */
295 if (pLPD->paPrinterFonts == NULL)
297 pfnCallback = MODULE_GetEntryPoint( GetModuleHandle16("GDI"), 158 );
299 if (pfnCallback != NULL)
301 WEPFC wepfc;
303 wepfc.nMode = 1;
304 wepfc.nCount = 0;
305 wepfc.pLPD = pLPD;
307 /* First count the number of fonts */
309 PRTDRV_EnumDFonts(physDev->segptrPDEVICE, NULL, pfnCallback,
310 (void *)&wepfc);
312 /* Allocate a buffer to store all of the fonts */
313 pLPD->nPrinterFonts = wepfc.nCount;
314 dprintf_win16drv(stddeb, "Got %d fonts\n",wepfc.nCount);
316 if (wepfc.nCount > 0)
319 pLPD->paPrinterFonts = malloc(sizeof(PRINTER_FONTS_INFO) * wepfc.nCount);
321 /* Now get all of the fonts */
322 wepfc.nMode = 2;
323 wepfc.nCount = 0;
324 PRTDRV_EnumDFonts(physDev->segptrPDEVICE, NULL, pfnCallback,
325 (void *)&wepfc);
326 numFonts = wepfc.nCount;
331 /* Select the first font into the DC */
332 /* Set up the logfont */
333 memcpy(&physDev->lf,
334 &pLPD->paPrinterFonts[0].lf,
335 sizeof(LOGFONT16));
337 /* Set up the textmetrics */
338 memcpy(&physDev->tm,
339 &pLPD->paPrinterFonts[0].tm,
340 sizeof(TEXTMETRIC16));
342 win16drv_SegPtr_TextXForm = WIN16_GlobalLock16(GlobalAlloc16(GHND, sizeof(TEXTXFORM16)));
343 win16drv_TextXFormP = PTR_SEG_TO_LIN(win16drv_SegPtr_TextXForm);
345 InitTextXForm(win16drv_TextXFormP);
346 #ifdef SUPPORT_REALIZED_FONTS
347 /* TTD should calculate this */
349 /* First get the size of the realized font */
350 nSize = PRTDRV_RealizeObject(physDev->segptrPDEVICE, OBJ_FONT,
351 &pLPD->paPrinterFonts[0], NULL,
354 physDev->segptrFontInfo = WIN16_GlobalLock16(GlobalAlloc16(GHND, nSize));
355 /* Realize the font */
356 PRTDRV_RealizeObject(physDev->segptrPDEVICE, OBJ_FONT,
357 &pLPD->paPrinterFonts[0],
358 (LPVOID)physDev->segptrFontInfo,
359 win16drv_SegPtr_TextXForm);
360 /* Quick look at structure */
361 if (physDev->segptrFontInfo)
363 FONTINFO16 *p = (FONTINFO16 *)PTR_SEG_TO_LIN(physDev->segptrFontInfo);
365 dprintf_win16drv(stddeb, "T:%d VR:%d HR:%d, F:%d L:%d\n",
366 p->dfType,
367 p->dfVertRes, p->dfHorizRes,
368 p->dfFirstCHAR, p->dfLastCHAR
372 #endif
373 /* TTD Lots more to do here */
374 win16drv_SegPtr_DrawMode = WIN16_GlobalLock16(GlobalAlloc16(GHND, sizeof(DRAWMODE)));
375 win16drv_DrawModeP = PTR_SEG_TO_LIN(win16drv_SegPtr_DrawMode);
377 InitDrawMode(win16drv_DrawModeP);
379 return TRUE;
382 extern BOOL32 WIN16DRV_PatBlt( struct tagDC *dc, INT32 left, INT32 top,
383 INT32 width, INT32 height, DWORD rop )
385 printf("In WIN16DRV_PatBlt\n");
386 return FALSE;
389 * Escape (GDI.38)
391 static INT32 WIN16DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
392 SEGPTR lpInData, SEGPTR lpOutData )
394 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
395 int nRet = 0;
397 /* We should really process the nEscape parameter, but for now just
398 pass it all to the driver */
399 if (dc != NULL && physDev->segptrPDEVICE != 0)
401 switch(nEscape)
403 case SETABORTPROC:
404 printf("Escape: SetAbortProc ignored should be stored in dc somewhere\n");
405 /* Make calling application believe this worked */
406 nRet = 1;
407 break;
409 case NEXTBAND:
411 SEGPTR newInData = WIN16_GlobalLock16(GlobalAlloc16(GHND, sizeof(POINT16)));
412 nRet = PRTDRV_Control(physDev->segptrPDEVICE, nEscape,
413 newInData, lpOutData);
414 GlobalFree16(newInData);
415 break;
418 case GETEXTENDEDTEXTMETRICS:
420 SEGPTR newInData = WIN16_GlobalLock16(GlobalAlloc16(GHND, sizeof(EXTTEXTDATA)));
421 EXTTEXTDATA *textData = (EXTTEXTDATA *)(PTR_SEG_TO_LIN(newInData));
423 textData->nSize = cbInput;
424 textData->lpindata = lpInData;
425 textData->lpFont = physDev->segptrFontInfo;
426 textData->lpXForm = win16drv_SegPtr_TextXForm;
427 textData->lpDrawMode = win16drv_SegPtr_DrawMode;
428 nRet = PRTDRV_Control(physDev->segptrPDEVICE, nEscape,
429 newInData, lpOutData);
430 GlobalFree16(newInData);
433 break;
434 case STARTDOC:
435 nRet = PRTDRV_Control(physDev->segptrPDEVICE, nEscape,
436 lpInData, lpOutData);
437 if (nRet != -1)
439 SEGPTR newInData = WIN16_GlobalLock16(GlobalAlloc16(GHND, sizeof(HDC32)));
440 #define SETPRINTERDC SETABORTPROC
441 HDC32 *tmpHdc = (HDC32 *)(PTR_SEG_TO_LIN(newInData));
442 *tmpHdc = dc->hSelf;
443 PRTDRV_Control(physDev->segptrPDEVICE, SETPRINTERDC,
444 newInData, (SEGPTR)NULL);
445 GlobalFree16(newInData);
447 break;
448 default:
449 nRet = PRTDRV_Control(physDev->segptrPDEVICE, nEscape,
450 lpInData, lpOutData);
451 break;
454 else
455 fprintf(stderr, "Escape(nEscape = %04x)\n", nEscape);
456 return nRet;
462 /****************** misc. printer releated functions */
465 * The following function should implement a queing system
467 #ifndef HPQ
468 #define HPQ WORD
469 #endif
470 struct hpq
472 struct hpq *next;
473 int tag;
474 int key;
477 static struct hpq *hpqueue;
479 HPQ
480 CreatePQ(int size)
482 printf("CreatePQ: %d\n",size);
483 return 1;
485 int
486 DeletePQ(HPQ hPQ)
488 printf("DeletePQ: %x\n", hPQ);
489 return 0;
491 int
492 ExtractPQ(HPQ hPQ)
494 struct hpq *queue, *prev, *current, *currentPrev;
495 int key = 0, tag = -1;
496 currentPrev = prev = NULL;
497 queue = current = hpqueue;
498 if (current)
499 key = current->key;
501 while (current)
503 currentPrev = current;
504 current = current->next;
505 if (current)
507 if (current->key < key)
509 queue = current;
510 prev = currentPrev;
514 if (queue)
516 tag = queue->tag;
518 if (prev)
519 prev->next = queue->next;
520 else
521 hpqueue = queue->next;
522 free(queue);
525 printf("ExtractPQ: %x got tag %d key %d\n", hPQ, tag, key);
527 return tag;
530 int
531 InsertPQ(HPQ hPQ, int tag, int key)
533 struct hpq *queueItem = malloc(sizeof(struct hpq));
534 queueItem->next = hpqueue;
535 hpqueue = queueItem;
536 queueItem->key = key;
537 queueItem->tag = tag;
539 printf("InsertPQ: %x %d %d\n", hPQ, tag, key);
540 return TRUE;
543 MinPQ(HPQ hPQ)
545 printf("MinPQ: %x\n", hPQ);
546 return 0;
549 SizePQ(HPQ hPQ, int sizechange)
551 printf("SizePQ: %x %d\n", hPQ, sizechange);
552 return -1;
556 * The following functions implement part of the spooling process to
557 * print manager. I would like to see wine have a version of print managers
558 * that used LPR/LPD. For simplicity print jobs will be sent to a file for
559 * now.
561 typedef struct PRINTJOB
563 char *pszOutput;
564 char *pszTitle;
565 HDC16 hDC;
566 HANDLE16 hHandle;
567 int nIndex;
568 int fd;
569 } PRINTJOB, *PPRINTJOB;
571 #define MAX_PRINT_JOBS 1
572 #define SP_OK 1
574 PPRINTJOB gPrintJobsTable[MAX_PRINT_JOBS];
577 static PPRINTJOB FindPrintJobFromHandle(HANDLE16 hHandle)
579 return gPrintJobsTable[0];
582 /* TTD Need to do some DOS->UNIX file conversion here */
583 static int CreateSpoolFile(LPSTR pszOutput)
585 int fd=-1;
586 char psCmd[1024];
587 char *psCmdP = psCmd;
589 /* TTD convert the 'output device' into a spool file name */
591 if (pszOutput == NULL || *pszOutput == '\0')
592 return -1;
594 PROFILE_GetWineIniString( "spooler", pszOutput, "",
595 psCmd, sizeof(psCmd) );
596 printf("Got printerSpoolCOmmand \"%s\"\n",psCmd);
597 if (!*psCmd)
598 psCmdP = pszOutput;
599 else
601 while (*psCmdP && isspace(*psCmdP))
603 psCmdP++;
605 if (!*psCmdP)
606 return -1;
608 if (*psCmdP == '|')
610 int fds[2];
611 if (pipe(fds))
612 return -1;
613 if (fork() == 0)
615 psCmdP++;
617 printf("In child need to exec %s\n",psCmdP);
618 close(0);
619 dup2(fds[0],0);
620 close (fds[1]);
621 system(psCmdP);
622 exit(0);
625 close (fds[0]);
626 fd = fds[1];
627 printf("Need to execut a command and pipe the output to it\n");
629 else
631 printf("Just assume its a file\n");
633 if ((fd = open(psCmdP, O_CREAT | O_TRUNC | O_WRONLY , 0600)) < 0)
635 printf("Failed to create spool file %s, errno = %d\n", psCmdP, errno);
638 return fd;
641 static int FreePrintJob(HANDLE16 hJob)
643 int nRet = SP_ERROR;
644 PPRINTJOB pPrintJob;
646 pPrintJob = FindPrintJobFromHandle(hJob);
647 if (pPrintJob != NULL)
649 gPrintJobsTable[pPrintJob->nIndex] = NULL;
650 free(pPrintJob->pszOutput);
651 free(pPrintJob->pszTitle);
652 if (pPrintJob->fd >= 0) close(pPrintJob->fd);
653 free(pPrintJob);
654 nRet = SP_OK;
656 return nRet;
659 HANDLE16 OpenJob(LPSTR lpOutput, LPSTR lpTitle, HDC16 hDC)
661 HANDLE16 hHandle = SP_ERROR;
662 PPRINTJOB pPrintJob;
664 dprintf_win16drv(stddeb, "OpenJob: \"%s\" \"%s\" %04x\n", lpOutput, lpTitle, hDC);
666 pPrintJob = gPrintJobsTable[0];
667 if (pPrintJob == NULL)
669 int fd;
671 /* Try an create a spool file */
672 fd = CreateSpoolFile(lpOutput);
673 if (fd >= 0)
675 hHandle = 1;
677 pPrintJob = malloc(sizeof(PRINTJOB));
678 memset(pPrintJob, 0, sizeof(PRINTJOB));
680 pPrintJob->pszOutput = strdup(lpOutput);
681 pPrintJob->pszTitle = strdup(lpTitle);
682 pPrintJob->hDC = hDC;
683 pPrintJob->fd = fd;
684 pPrintJob->nIndex = 0;
685 pPrintJob->hHandle = hHandle;
686 gPrintJobsTable[pPrintJob->nIndex] = pPrintJob;
689 dprintf_win16drv(stddeb, "OpenJob: return %04x\n", hHandle);
690 return hHandle;
693 int CloseJob(HANDLE16 hJob)
695 int nRet = SP_ERROR;
696 PPRINTJOB pPrintJob = NULL;
698 dprintf_win16drv(stddeb, "CloseJob: %04x\n", hJob);
700 pPrintJob = FindPrintJobFromHandle(hJob);
701 if (pPrintJob != NULL)
703 /* Close the spool file */
704 close(pPrintJob->fd);
705 FreePrintJob(hJob);
706 nRet = 1;
708 return nRet;
711 int WriteSpool(HANDLE16 hJob, LPSTR lpData, WORD cch)
713 int nRet = SP_ERROR;
714 PPRINTJOB pPrintJob = NULL;
716 dprintf_win16drv(stddeb, "WriteSpool: %04x %08lx %04x\n", hJob, (DWORD)lpData, cch);
718 pPrintJob = FindPrintJobFromHandle(hJob);
719 if (pPrintJob != NULL && pPrintJob->fd >= 0 && cch)
721 if (write(pPrintJob->fd, lpData, cch) != cch)
722 nRet = SP_OUTOFDISK;
723 else
724 nRet = cch;
726 return nRet;
729 int WriteDialog(HANDLE16 hJob, LPSTR lpMsg, WORD cchMsg)
731 int nRet = 0;
733 dprintf_win16drv(stddeb, "WriteDialog: %04x %04x \"%s\"\n", hJob, cchMsg, lpMsg);
735 nRet = MessageBox16(0, lpMsg, "Printing Error", MB_OKCANCEL);
736 return nRet;
739 int DeleteJob(HANDLE16 hJob, WORD wNotUsed)
741 int nRet;
743 dprintf_win16drv(stddeb, "DeleteJob: %04x\n", hJob);
745 nRet = FreePrintJob(hJob);
746 return nRet;
750 * The following two function would allow a page to be sent to the printer
751 * when it has been processed. For simplicity they havn't been implemented.
752 * This means a whole job has to be processed before it is sent to the printer.
754 int StartSpoolPage(HANDLE16 hJob)
756 dprintf_win16drv(stddeb, "StartSpoolPage GDI.246 unimplemented\n");
757 return 1;
760 int EndSpoolPage(HANDLE16 hJob)
762 dprintf_win16drv(stddeb, "EndSpoolPage GDI.247 unimplemented\n");
763 return 1;
767 DWORD GetSpoolJob(int nOption, LONG param)
769 DWORD retval = 0;
770 dprintf_win16drv(stddeb, "In GetSpoolJob param 0x%lx noption %d\n",param, nOption);
771 return retval;