Commit 96508647 authored by Huw D M Davies's avatar Huw D M Davies Committed by Alexandre Julliard

Takes print spooler functions out of win16drv.

Allows the PostScript driver to go into libwine.
parent 8150b52c
......@@ -39,6 +39,7 @@ LIBSUBDIRS = \
files \
graphics \
graphics/metafiledrv \
graphics/psdrv \
ipc \
library \
loader \
......@@ -64,7 +65,6 @@ X11SUBDIRS = \
EMUSUBDIRS = \
debugger \
graphics/psdrv \
graphics/win16drv \
if1632 \
miscemu
......@@ -101,6 +101,7 @@ LIBOBJS = \
files/files.o \
graphics/graphics.o \
graphics/metafiledrv/metafiledrv.o \
graphics/psdrv/psdrv.o \
ipc/ipc.o \
loader/loader.o \
loader/ne/ne.o \
......@@ -125,7 +126,6 @@ X11OBJS = \
EMUOBJS = \
debugger/debugger.o \
graphics/psdrv/psdrv.o \
graphics/win16drv/win16drv.o \
if1632/if1632.o \
miscemu/miscemu.o
......
......@@ -5,13 +5,8 @@
* 1998 Huw Davies
*/
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "windows.h"
#include "win16drv.h"
#include "gdi.h"
......@@ -19,8 +14,8 @@
#include "heap.h"
#include "color.h"
#include "font.h"
#include "callback.h"
#include "options.h"
#include "xmalloc.h"
#include "debug.h"
#include "dc.h"
......@@ -201,7 +196,7 @@ BOOL32 WIN16DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device, LPCSTR output,
/* Now Get the device capabilities from the printer driver */
printerDevCaps = (DeviceCaps *) malloc(sizeof(DeviceCaps));
printerDevCaps = (DeviceCaps *) xmalloc(sizeof(DeviceCaps));
memset(printerDevCaps, 0, sizeof(DeviceCaps));
/* Get GDIINFO which is the same as a DeviceCaps structure */
......@@ -355,371 +350,3 @@ static INT32 WIN16DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
return nRet;
}
/**********************************************************************
* QueryAbort (GDI.155)
*
* Calls the app's AbortProc function if avail.
*
* RETURNS
* TRUE if no AbortProc avail or AbortProc wants to continue printing.
* FALSE if AbortProc wants to abort printing.
*/
BOOL16 WINAPI QueryAbort(HDC16 hdc, INT16 reserved)
{
DC *dc = DC_GetDCPtr( hdc );
if ((!dc) || (!dc->w.lpfnPrint))
return TRUE;
return Callbacks->CallDrvAbortProc(dc->w.lpfnPrint, hdc, 0);
}
/**********************************************************************
* SetAbortProc (GDI.381)
*
*/
INT16 WINAPI SetAbortProc(HDC16 hdc, FARPROC16 abrtprc)
{
DC *dc = DC_GetDCPtr( hdc );
if (dc) {
dc->w.lpfnPrint = abrtprc;
return 1;
}
return -1;
}
/****************** misc. printer related functions */
/*
* The following function should implement a queing system
*/
#ifndef HPQ
#define HPQ WORD
#endif
struct hpq
{
struct hpq *next;
int tag;
int key;
};
static struct hpq *hpqueue;
HPQ WINAPI CreatePQ(int size)
{
#if 0
HGLOBAL16 hpq = 0;
WORD tmp_size;
LPWORD pPQ;
tmp_size = size << 2;
if (!(hpq = GlobalAlloc16(GMEM_SHARE|GMEM_MOVEABLE, tmp_size + 8)))
return 0xffff;
pPQ = GlobalLock16(hpq);
*pPQ++ = 0;
*pPQ++ = tmp_size;
*pPQ++ = 0;
*pPQ++ = 0;
GlobalUnlock16(hpq);
return (HPQ)hpq;
#else
FIXME(win16drv, "(%d): stub\n",size);
return 1;
#endif
}
int WINAPI DeletePQ(HPQ hPQ)
{
return GlobalFree16((HGLOBAL16)hPQ);
}
int WINAPI ExtractPQ(HPQ hPQ)
{
struct hpq *queue, *prev, *current, *currentPrev;
int key = 0, tag = -1;
currentPrev = prev = NULL;
queue = current = hpqueue;
if (current)
key = current->key;
while (current)
{
currentPrev = current;
current = current->next;
if (current)
{
if (current->key < key)
{
queue = current;
prev = currentPrev;
}
}
}
if (queue)
{
tag = queue->tag;
if (prev)
prev->next = queue->next;
else
hpqueue = queue->next;
free(queue);
}
TRACE(win16drv, "%x got tag %d key %d\n", hPQ, tag, key);
return tag;
}
int WINAPI InsertPQ(HPQ hPQ, int tag, int key)
{
struct hpq *queueItem = malloc(sizeof(struct hpq));
queueItem->next = hpqueue;
hpqueue = queueItem;
queueItem->key = key;
queueItem->tag = tag;
FIXME(win16drv, "(%x %d %d): stub???\n", hPQ, tag, key);
return TRUE;
}
int WINAPI MinPQ(HPQ hPQ)
{
FIXME(win16drv, "(%x): stub\n", hPQ);
return 0;
}
int WINAPI SizePQ(HPQ hPQ, int sizechange)
{
FIXME(win16drv, "(%x %d): stub\n", hPQ, sizechange);
return -1;
}
/*
* The following functions implement part of the spooling process to
* print manager. I would like to see wine have a version of print managers
* that used LPR/LPD. For simplicity print jobs will be sent to a file for
* now.
*/
typedef struct PRINTJOB
{
char *pszOutput;
char *pszTitle;
HDC16 hDC;
HANDLE16 hHandle;
int nIndex;
int fd;
} PRINTJOB, *PPRINTJOB;
#define MAX_PRINT_JOBS 1
#define SP_OK 1
PPRINTJOB gPrintJobsTable[MAX_PRINT_JOBS];
static PPRINTJOB FindPrintJobFromHandle(HANDLE16 hHandle)
{
return gPrintJobsTable[0];
}
/* TTD Need to do some DOS->UNIX file conversion here */
static int CreateSpoolFile(LPSTR pszOutput)
{
int fd=-1;
char psCmd[1024];
char *psCmdP = psCmd;
/* TTD convert the 'output device' into a spool file name */
if (pszOutput == NULL || *pszOutput == '\0')
return -1;
PROFILE_GetWineIniString( "spooler", pszOutput, "", psCmd, sizeof(psCmd) );
TRACE(win16drv, "Got printerSpoolCommand '%s' for output device '%s'\n",
psCmd, pszOutput);
if (!*psCmd)
psCmdP = pszOutput;
else
{
while (*psCmdP && isspace(*psCmdP))
{
psCmdP++;
};
if (!*psCmdP)
return -1;
}
if (*psCmdP == '|')
{
int fds[2];
if (pipe(fds))
return -1;
if (fork() == 0)
{
psCmdP++;
TRACE(win16drv, "In child need to exec %s\n",psCmdP);
close(0);
dup2(fds[0],0);
close (fds[1]);
system(psCmdP);
exit(0);
}
close (fds[0]);
fd = fds[1];
TRACE(win16drv,"Need to execute a cmnd and pipe the output to it\n");
}
else
{
TRACE(win16drv, "Just assume its a file\n");
if ((fd = open(psCmdP, O_CREAT | O_TRUNC | O_WRONLY , 0600)) < 0)
{
ERR(win16drv, "Failed to create spool file %s, errno = %d\n",
psCmdP, errno);
}
}
return fd;
}
static int FreePrintJob(HANDLE16 hJob)
{
int nRet = SP_ERROR;
PPRINTJOB pPrintJob;
pPrintJob = FindPrintJobFromHandle(hJob);
if (pPrintJob != NULL)
{
gPrintJobsTable[pPrintJob->nIndex] = NULL;
free(pPrintJob->pszOutput);
free(pPrintJob->pszTitle);
if (pPrintJob->fd >= 0) close(pPrintJob->fd);
free(pPrintJob);
nRet = SP_OK;
}
return nRet;
}
HANDLE16 WINAPI OpenJob(LPSTR lpOutput, LPSTR lpTitle, HDC16 hDC)
{
HANDLE16 hHandle = (HANDLE16)SP_ERROR;
PPRINTJOB pPrintJob;
TRACE(win16drv, "'%s' '%s' %04x\n", lpOutput, lpTitle, hDC);
pPrintJob = gPrintJobsTable[0];
if (pPrintJob == NULL)
{
int fd;
/* Try an create a spool file */
fd = CreateSpoolFile(lpOutput);
if (fd >= 0)
{
hHandle = 1;
pPrintJob = malloc(sizeof(PRINTJOB));
memset(pPrintJob, 0, sizeof(PRINTJOB));
pPrintJob->pszOutput = strdup(lpOutput);
if(lpTitle)
pPrintJob->pszTitle = strdup(lpTitle);
pPrintJob->hDC = hDC;
pPrintJob->fd = fd;
pPrintJob->nIndex = 0;
pPrintJob->hHandle = hHandle;
gPrintJobsTable[pPrintJob->nIndex] = pPrintJob;
}
}
TRACE(win16drv, "return %04x\n", hHandle);
return hHandle;
}
int WINAPI CloseJob(HANDLE16 hJob)
{
int nRet = SP_ERROR;
PPRINTJOB pPrintJob = NULL;
TRACE(win16drv, "%04x\n", hJob);
pPrintJob = FindPrintJobFromHandle(hJob);
if (pPrintJob != NULL)
{
/* Close the spool file */
close(pPrintJob->fd);
FreePrintJob(hJob);
nRet = 1;
}
return nRet;
}
int WINAPI WriteSpool(HANDLE16 hJob, LPSTR lpData, WORD cch)
{
int nRet = SP_ERROR;
PPRINTJOB pPrintJob = NULL;
TRACE(win16drv, "%04x %08lx %04x\n", hJob, (DWORD)lpData, cch);
pPrintJob = FindPrintJobFromHandle(hJob);
if (pPrintJob != NULL && pPrintJob->fd >= 0 && cch)
{
if (write(pPrintJob->fd, lpData, cch) != cch)
nRet = SP_OUTOFDISK;
else
nRet = cch;
if (pPrintJob->hDC == 0) {
TRACE(print, "hDC == 0 so no QueryAbort\n");
}
else if (!(QueryAbort(pPrintJob->hDC, (nRet == SP_OUTOFDISK) ? nRet : 0 )))
{
CloseJob(hJob); /* printing aborted */
nRet = SP_APPABORT;
}
}
return nRet;
}
int WINAPI WriteDialog(HANDLE16 hJob, LPSTR lpMsg, WORD cchMsg)
{
int nRet = 0;
TRACE(win16drv, "%04x %04x '%s'\n", hJob, cchMsg, lpMsg);
nRet = MessageBox16(0, lpMsg, "Printing Error", MB_OKCANCEL);
return nRet;
}
int WINAPI DeleteJob(HANDLE16 hJob, WORD wNotUsed)
{
int nRet;
TRACE(win16drv, "%04x\n", hJob);
nRet = FreePrintJob(hJob);
return nRet;
}
/*
* The following two function would allow a page to be sent to the printer
* when it has been processed. For simplicity they havn't been implemented.
* This means a whole job has to be processed before it is sent to the printer.
*/
int WINAPI StartSpoolPage(HANDLE16 hJob)
{
FIXME(win16drv, "StartSpoolPage GDI.246 unimplemented\n");
return 1;
}
int WINAPI EndSpoolPage(HANDLE16 hJob)
{
FIXME(win16drv, "EndSpoolPage GDI.247 unimplemented\n");
return 1;
}
DWORD WINAPI GetSpoolJob(int nOption, LONG param)
{
DWORD retval = 0;
TRACE(win16drv, "In GetSpoolJob param 0x%lx noption %d\n",param, nOption);
return retval;
}
......@@ -41,7 +41,7 @@
#include "thread.h"
#include "task.h"
#include "debug.h"
#include "psdrv.h"
int __winelib = 1; /* Winelib run-time flag */
......@@ -158,7 +158,12 @@ BOOL32 WINAPI MAIN_GdiInit(HINSTANCE32 hinstDLL, DWORD fdwReason, LPVOID lpvRese
}
/* GDI initialisation */
return GDI_Init();
if(!GDI_Init()) return FALSE;
/* PSDRV initialization */
if(!PSDRV_Init()) return FALSE;
return TRUE;
}
/***********************************************************************
......
......@@ -24,6 +24,7 @@ C_SRCS = \
registry.c \
shell.c \
sound.c \
spooler.c \
spy.c \
stress.c \
system.c \
......
This diff is collapsed. Click to expand it.
......@@ -13,7 +13,6 @@
#include "options.h"
#include "process.h"
#include "win16drv.h"
#include "psdrv.h"
#include "thread.h"
#include "task.h"
#include "stackframe.h"
......@@ -39,9 +38,6 @@ BOOL32 MAIN_EmulatorInit(void)
/* Create the Win16 printer driver */
if (!WIN16DRV_Init()) return FALSE;
/* Create the Postscript printer driver (FIXME: should be in Winelib) */
if (!PSDRV_Init()) return FALSE;
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment