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

 
Output of file : PRTSETUP.C contained in archive : XPRT.ZIP
/*$llib rtutil,lcm */
/*===========================================================================*\
|| XPRINT Printer Setup Rip Toren ||
|| POB 674 ||
|| Columbia, MD 21045 ||
|| ||
|| SET xp_lines=75 :data lines per page ||
|| ||
|| assume that the device is already OPEN ! ||
|| send initialization string, compute line spacing, and set vertical tabs ||
|| for 1st file line and the bottom page number. ||
|| ||
\*===========================================================================*/

#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "time.h"
#include "dos.h"

#define EPSON 0
#define HPLASER 1
#define PROPRINTER 2


static char *printer_control [] = {
/*------------------------------------------------------------------------*\
| Control string for EPSON (EPSON) mode |
\*------------------------------------------------------------------------*/
"\x1b0\x1b\x4d", /* 8 lpi elite */

/*------------------------------------------------------------------------*\
| Control string for HP laserjet |
\*------------------------------------------------------------------------*/
"\x1bE\x1b&l0O\x1b&l8D\x1b(8U\x1b(s0p16.66h8.5v0s-1b0T\x1b&a4L",
/* reset port 8 lpi Rmn 8 comp */

/*------------------------------------------------------------------------*\
| Control for IBM ProPrinter or EPSON 286 (ProPrinter mode) |
\*------------------------------------------------------------------------*/
"\x1b0\x1b\x3a" }; /* 8 LPI elite */


extern int
max_lines; /* from ENVIRONMENT or 75 */
static unsigned char
line_216, /* x 1/216 line spacing */
hp_line_48[8]; /* literal for HP spacing */
static char
*env_ptr;

/*===========================================================================*\
|| ||
\*===========================================================================*/
prtsetup (device, p_type, tofm, tofl, bofm)

FILE *device; /* where to send the setup */
int p_type; /* type of printer */
char *tofm, /* Top Of ForM string */
*tofl, /* Top Of FiLe string */
*bofm; /* Bottom Of ForM string */

{
/*------------------------------------------------------------------------*\
| Check for other ENVIRONMENT values |
\*------------------------------------------------------------------------*/
env_ptr = getenv("XP_LINES");
if (env_ptr == NULL) max_lines = 75;
else max_lines = atoi (env_ptr);
if (max_lines < 8) {
puts ("Not enough lines to print on !");
exit (-1);
}

switch (p_type) {
case EPSON:
case PROPRINTER:
fprintf (device,"%s",printer_control[p_type]);
/* page length = 88 lpp */
fprintf (device,"%s","\x1bC\x58");
/* Vert tab = 6,86 */
fprintf (device,"%s%c","\x1bB\x06\x56",0x00);

/* compute line spacing for file */
line_216 = 2106 / max_lines;
fprintf (device,"%s%c","\x1b3",line_216);
/*------------------------------------------------------------*\
| Now top of form value |
\*------------------------------------------------------------*/
/* FF 8lpi */
strcpy (tofm,"\x0c");
/*------------------------------------------------------------*\
| Now top of file data |
\*------------------------------------------------------------*/
/* VT n/216 lpi */
sprintf (tofl,"%s%c","\x0b\x1b3",line_216);
/*------------------------------------------------------------*\
| Now bottom of form |
\*------------------------------------------------------------*/
/* VT */
sprintf (bofm,"%s","\x1b0\x0b\x0d");
break;

case HPLASER:
fprintf (device,"%s",printer_control[p_type]);
/* compute line spacing for file */
/* 456 = 9.5 in * 48 */
line_216 = 456 / max_lines;
stci_d (hp_line_48,line_216,8);
/*------------------------------------------------------------*\
| Now top of form value |
\*------------------------------------------------------------*/
/* FF 8lpi */
strcpy (tofm,"\x0c\x1bl8D");
/*------------------------------------------------------------*\
| Now top of file data |
\*------------------------------------------------------------*/
/* goto .75 in from top left side */
/* set spacing 1/48th */
sprintf (tofl,"%s%s%s","\x1b&a540va0H\x1b&l",hp_line_48,"C");
/*------------------------------------------------------------*\
| Now bottom of form |
\*------------------------------------------------------------*/
/* goto 10.63 in fm top left side */
sprintf (tofl,"%s","\x1b&a7668va0H");
break;
default:
puts ("Unknown printer type!");
exit (-1);
}
}


  3 Responses to “Category : Printer Utilities
Archive   : XPRT.ZIP
Filename : PRTSETUP.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/