From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/prnspool.c | 151 ++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/prnspool.c (limited to 'reference/C/CONTRIB/SNIP/prnspool.c') diff --git a/reference/C/CONTRIB/SNIP/prnspool.c b/reference/C/CONTRIB/SNIP/prnspool.c new file mode 100755 index 0000000..f842800 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/prnspool.c @@ -0,0 +1,151 @@ +/* prnspool.c 12-22-91 Robert Mashlan, public domain */ +/* DOS print spooler interface functions */ + +#include +#include +#include "prnspool.h" + +int printspool_errno = 0; + +char *printspool_errlist[] = { + "No error", + "Function Invalid", + "File not found", + "Path not found", + "Too many open files", + "Access denied", + "", + "", + "Queue full", + "Spooler busy", + "", + "", + "Name too long", + "", + "Drive invalid" + }; + +/* returns -1 if printspooler installed */ +/* 0 otherwise */ + +int printspool_installed(void) +{ + union REGS r; + + r.x.ax = 0x0100; + int86(0x2f, &r, &r); + if(r.h.al==0xff) + { + printspool_errno=0; + return -1; + } + else + { + printspool_errno=1; + return 0; + } +} + +/* submits a file name to be printed */ +/* returns error code */ + +int printspool_submit( const char *pathname ) +{ + struct PACKET packet; + union REGS r; + struct SREGS s; + + packet.level = 0; + packet.pathname = (char far *)pathname; + s.ds = FP_SEG(&packet); + r.x.dx = FP_OFF(&packet); + r.x.ax = 0x0101; + int86x(0x2f, &r, &r, &s); + if(!r.x.cflag) + return printspool_errno = 0; + else return printspool_errno = r.x.ax; +} + +/* removes a file from the print queue */ + +int printspool_remove( const char far *fname ) +{ + union REGS r; + struct SREGS s; + + s.ds = FP_SEG(fname); + r.x.dx = FP_OFF(fname); + r.x.ax = 0x0102; + int86x(0x2f, &r, &r, &s); + if(!r.x.cflag) + return printspool_errno = 0; + else return printspool_errno=r.x.ax; +} + +/* cancels all files in the print queue */ + +int printspool_cancel(void) +{ + union REGS r; + + r.x.ax = 0x0103; + int86(0x2f, &r, &r); + if(!r.x.cflag) + return printspool_errno = 0; + else return printspool_errno = r.x.ax; +} + +/* ends hold state after a call to printspool_qetqueue */ +/* or printspool_errorcount */ + +void printspool_endhold(void) +{ + union REGS r; + + r.x.ax = 0x0105; + int86(0x2f, &r, &r); +} + +/* returns a far pointer to the printspooler queue, */ +/* an array of 64 char asciiz strings */ + +char far *printspool_getqueue(void) +{ + char far *result; + union REGS r; + struct SREGS s; + + r.x.ax = 0x0104; + int86x(0x2f, &r, &r, &s); + result = MK_FP(s.ds,r.x.si); + if (!r.x.cflag) + { + printspool_errno = 0; + return result; + } + else + { + printspool_errno = r.x.ax; + return NULL; + } +} + +/* returns the error count from the printspooler */ + +int printspool_errorcount(void) +{ + union REGS r; + + r.x.ax = 0x0104; + int86(0x2f, &r, &r); + if (!r.x.cflag) + { + printspool_errno = 0; + return r.x.dx; /* return the number of errors */ + } + else + { + printspool_errno = r.x.ax; + return r.x.dx; + } +} -- cgit v1.2.3-54-g00ecf