Category : Printer Utilities
Archive   : XPRT.ZIP
Filename : PRT_PKG.C

 
Output of file : PRT_PKG.C contained in archive : XPRT.ZIP
/*$ilib rtutil */

/*======================================================================*\
|| PRINTER STATUS PACKAGE ||
|| initprt() => 1 = up and online ||
|| 0 = user wants to terminate ||
|| chkprt() => values defined below as determined from the results ||
|| chkprt() => values defined below as determined ||
|| prtstatus()=> status values directly from the INT 17 (2) ||
|| ||
|| ||
\*======================================================================*/
#include "dos.h"

#define USER_TERM 0
#define ON_LINE 1
#define OFF_LINE 2
#define POW_DN 3
#define POW_UP 4
#define NOT_CON 5

static union REGS in, out;

/*===========================================================================*\
|| INITPRT returns 1 = printer up and ready ||
|| 0 = user abort ||
\*===========================================================================*/
int
initprt()
{
int i;
/*-------------------------------------------------------------------*\
| Initialize the printer |
\*-------------------------------------------------------------------*/
retry:
switch (i = chkprt())
{
case ON_LINE: /* powered & online */
return (1);
case OFF_LINE: /* powered & offline */
puts("Please place the printer ON-LINE ");
puts(" or press ANY key to terminate this program");
return (prt_or_kbd()); /* loop */
break;
case POW_UP: /* during power up */
while (chkprt() == POW_UP);
goto retry;
case POW_DN: /* powered down */
puts("Please TURN ON the printer and place ON-LINE ");
puts(" or press ANY key to terminate this program");
return (prt_or_kbd()); /* loop */
break;
case NOT_CON: /* not connected */
puts ("You have no printer connected to the system ??");
return (0);
break;
default :
printf("The printer is in an UNDETERMINED state (%d)\n",i);
printf("please correct the situation, or\n");
printf(" press ANY key to terminate\n");
return (prt_or_kbd()); /* loop */
}
}

/*===========================================================================*\
|| CHKPRT ||
|| determine status and return evaluated code, or full status if none ||
|| of the codes apply. ||
\*===========================================================================*/
int
chkprt()
{
switch (prtstatus())
{
case 144 : return (ON_LINE);
case 8 : return (OFF_LINE); /* HPLJ */
case 24 : return (OFF_LINE); /* EPSON */
case 192 : return (POW_UP);
case 200 : return (POW_DN); /* HPLJ */
case 136 : return (POW_DN); /* EPSON */
default : return ((int) out.h.ah);
};
}


/*===========================================================================*\
|| PRTSTATUS ||
|| return = ||
|| power & online = 144 1001 0000 ||
|| power & offline = 8 0000 1000 ||
|| during power up = 192 1100 0000 ||
|| no power = 200 1100 1000 ||
|| no power = 136 1000 1000 ||
|| not connected = 24 0001 1000 ||
|| ^^^^ ^-- i/o error ||
|| |||+---- printer selected ||
|| ||+----- out of paper ||
|| |+------ ack from printer ||
|| +------- 1=busy 0= not busy ||
\*===========================================================================*/
prtstatus()
{

/*-------------------------------------------------------------------*\
| now try interupt 17 (2) for status of the printer |
\*-------------------------------------------------------------------*/
in.h.ah = 2; /* STATUS */
in.x.dx = 0; /* printer 0 */
int86 (0x17,&in,&out); /* of PRINTER */
return (out.h.ah);
}


/*===========================================================================*\
|| clear printer or keyboard ||
|| check for either the printer comming on line (chkprt=1) or the ||
|| operator pressing a key (kbhit()=1). If keyboard, exit process. ||
|| ||
\*===========================================================================*/
static
prt_or_kbd ()
{
while ( (kbhit() == 0) && /* no key pressed */
(chkprt() != ON_LINE) ); /* printer not ready */
if (chkprt() == ON_LINE) return (ON_LINE);
else return (USER_TERM);

}


  3 Responses to “Category : Printer Utilities
Archive   : XPRT.ZIP
Filename : PRT_PKG.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/