1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/* prnspool.c 12-22-91 Robert Mashlan, public domain */
/* DOS print spooler interface functions */
#include <stdio.h>
#include <dos.h>
#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;
}
}
|