Category : Files from Magazines
Archive   : DDJ8605.ZIP
Filename : LETTERS.MAY

 
Output of file : LETTERS.MAY contained in archive : DDJ8605.ZIP
/**
**
** LJ.C -- A printing utility for the HP LaserJet
**
** This program prints a series of files on the LaserJet
** printer. The files are printed in a ``landscape'' font at
** 17 characters to the inch. To take advantage of this
** density, two ``pages'' of information from the file are
** printed on each piece of paper (left and right halves).
**
** Usage is: LJ file1 file2 file3 ...
**
** Where file# is a valid MS-DOS filename, included on the
** command line. This program is compatible with Lattice C
** on the IBM PC and the HP Touchscreen computers.
**
** Joe Barnhart original version May 5, 1985
** Ray Duncan date and time stamping May 22, 1985
** Joe Barnhart revised date stamping June 6, 1985
** Ray Moon modified for CI86 December 13, 1985
** & revised EOF test
**
**/

#define CI86 1 /* Remove this #define => Lattice C version */

#ifdef CI86
#include
#else
#include
#endif
#define MAXLINE 56 /* maximum lines per page */
#define Page `/f' /* for compilers without `/f' */
#define TAB 8 /* width of one tab stop */

#ifdef CI86
typedef struct {
unsigned short ax,bx,cx,dx,si,di,ds,es;
} REGSET;
#else
typedef struct {
int ax, bx, cx, dx, si, di;
} REGSET;
#endif

main(argc, argv)
int argc;
char *argv[];
{
int filenum;
FILE *fp, *prn, *fopen();

if( (prn = fopen(``PRN:'', ``w'') ) == NULL )
printf(``Error opening printer as file.\n'');
else {
/* initialize the LaserJet for landscape printing */
fprintf(prn, ``\033E\033&l1o\033(s17H\033&l8d6E'' );
for(filenum=1; filenum < argc; filenum++) {
fp = fopen(argv[filenum], ``r'');
if (fp == NULL)
printf(``file %s doesn't exist.\n'', argv [filenum])
else {
printf(``Now printing %s\n'', argv[filenum]);
printfile(fp, prn, argv[filenum]);
fclose(fp);
}
}
fprintf(prn, ``\015\033E''); /* clear LaserJet */
}
}

printfile(fp,prn,filename)
FILE *fp,*prn;
char *filename;
{
int pagenum = 1;

while( !feof(fp)) {
fprintf(prn, ``\033&a0r85m5L\015''); /* set left half */
printpage(fp,prn); /* print page */
if( !feof(fp)) { /*if more .. */
fprintf(prn, ``\033&a0r171m91L''); /*set right half */
printpage(fp,prn); /* print another */

}
stamp(prn, filename, pagenum++); /* title */
fputc(PAGE, prn); /* kick paper */
}
}

printpage(fp,prn)
FILE *fp, *prn;
{
int c,line,col;

line = col = 0;
while(line < MAXLINE)
switch(c = fgetc(fp)) {
case `\n': /* newline found */
col = 0; /* zero column */
line++; /* adv line cnt */
fputc(`\n',prn);
break;
case `\t`: /* TAB found */
do
fputc(`\040',prn);
while ((++col % TAB) != 0);
break;
case PAGE: /* page break or */
case EOF: /* EOF found */
line = MAXLINE; /* force terminate */
break;
default: /* no special case */
fputc(c,prn); /* print character */
col++;
break;
}
}

stamp(prn, filename,pagenum)
FILE *prn;
char *filename;
int pagenum;
{
char datestr[10], timestr[10];

fprintf(prn, ``\033&a5l171M''); /* widen margins */
fprintf(prn, ``\015\033&a58R''); /* move to row 58 */
fprintf(prn, ``File: %-113s'', filename);
fprintf(prn, ``Page %-3d'', pagenum);
timestamp(timestr);
datestamp(datestr);
fprintf(prn, `` %s %s'', datestr, timestr);
}

datestamp(datestr)
char *datestr;
{
REGSET regs;
int month, day, year;

regs.ax = 0x2a00;
#ifdef CI86
sysint21(®s,®s);
#else
int86(0x21,®s,®s);
#endif
month = (regs.dx >> 8) & 255;
day = regs.dx & 255;
year = regs.cx - 1900;
sprintf(datestr, ``%02d/%02d/%02d'', month, day, year);
}

timestamp(timestr)
char *timestr;
{
REGSET regs;
int hours,mins;

regs.ax = 0x2c00;
#ifdef CI86
sysint21(®s,®s);
#else
int86(0x21,®s,®s);
#endif
hours = (regs.cx >> 8) & 255;
mins = regs.cx & 255;
sprintf(timestr, ``%02d:%02d'', hours, mins);
}
[EOF]


  3 Responses to “Category : Files from Magazines
Archive   : DDJ8605.ZIP
Filename : LETTERS.MAY

  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/