File: prtstat.c

package info (click to toggle)
c-cpp-reference 2.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 8,012 kB
  • ctags: 4,612
  • sloc: ansic: 26,960; sh: 11,014; perl: 1,854; cpp: 1,324; asm: 1,239; python: 258; makefile: 115; java: 77; awk: 34; csh: 9
file content (68 lines) | stat: -rwxr-xr-x 1,257 bytes parent folder | download | duplicates (5)
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
/*
**  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 <dos.h>

#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, &regs, &regs);
      return regs.h.ah;
}

#ifdef TEST

#include <stdio.h>

#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