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/prtstat.c | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/prtstat.c (limited to 'reference/C/CONTRIB/SNIP/prtstat.c') diff --git a/reference/C/CONTRIB/SNIP/prtstat.c b/reference/C/CONTRIB/SNIP/prtstat.c new file mode 100755 index 0000000..e541939 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/prtstat.c @@ -0,0 +1,68 @@ +/* +** PRTSTAT.H - Header file for PRTSTAT.C +*/ + +#ifndef PRTSTAT_H + #define PRTSTAT_H + +struct PrStatus { + unsigned int timeout : 1; + unsigned int unused : 2; + unsigned int IOerror : 1; + unsigned int selected : 1; + unsigned int paperout : 1; + unsigned int ack : 1; + unsigned int notbusy : 1; +}; + +int prtstat(unsigned int); + +#endif + +/*** End of PRTSTAT.H *******************************************************/ + +/* +** PRTSTAT.C - Determine printer status +** +** public domain by Bob Stout +*/ + +#include + +#ifndef PRTSTAT_H + #include "prtstat.h" +#endif + +/* +** prtstat() - Call with printer number (0 = LPT1, 1 = LPT2, 2 = LPT3) +** +** Returns status which can be mapped to a PrStatus struct +*/ + +int prtstat(unsigned int printer_no) +{ + union REGS regs; + + regs.h.ah = 2; + regs.x.dx = printer_no; + int86(0x17, ®s, ®s); + return regs.h.ah; +} + +#ifdef TEST + +#include + +#define show(x) printf(#x" is %strue (LPT1)\n", mystat.x ? "" : "not "); + +void main(void) +{ + struct PrStatus mystat; + + *((int *)&mystat) = prtstat(0); + show(notbusy); + show(selected); + show(paperout); +} + +#endif -- cgit v1.2.3-54-g00ecf