#include "a:stdio.h" #define VERSION 10 /* version number x 10 */ /* side ways character definitions */ char swbit[][8]={ 0,0,0,0,0,0,0,0, 0,16,0,16,16,56,56,16, 0,0,0,0,0,36,36,36, 0,36,36,126,36,126,36,36, 0,24,124,2,60,64,62,24, 0,70,38,16,8,100,98,0, 0,118,136,136,86,48,72,48, 0,0,0,0,0,32,16,16, 0,16,32,64,64,64,32,16, 0,32,16,8,8,8,16,32, 0,0,68,56,254,56,68,0, 0,0,16,16,124,16,16,0, 32,16,16,0,0,0,0,0, 0,0,0,0,126,0,0,0, 0,16,16,0,0,0,0,0, 0,64,32,16,8,4,2,0, 0,60,98,82,74,70,66,60, 0,124,16,16,16,80,48,16, 0,126,66,48,12,2,66,60, 0,60,66,2,28,2,66,60, 0,28,8,254,72,40,24,8, 0,60,66,2,2,124,64,126, 0,60,66,66,124,64,32,28, 0,16,16,16,8,4,66,126, 0,60,66,66,60,66,66,60, 0,56,4,2,62,66,66,60, 0,16,16,0,0,16,16,0, 32,16,16,0,0,16,16,0, 0,8,16,32,64,32,16,8, 0,0,126,0,0,126,0,0, 0,16,8,4,2,4,8,16, 0,8,0,8,4,2,66,60, 0,60,64,94,82,94,66,60, 0,66,66,126,66,66,36,24, 0,124,34,34,60,34,34,124, 0,28,34,64,64,64,34,28, 0,120,36,34,34,34,36,120, 0,126,34,40,56,40,34,126, 0,112,32,40,56,40,34,126, 0,30,34,78,64,64,34,28, 0,66,66,66,126,66,66,66, 0,56,16,16,16,16,16,56, 0,56,68,68,4,4,4,14, 0,99,36,40,48,40,36,98, 0,126,34,32,32,32,32,112, 0,65,65,65,65,73,85,99, 0,66,66,66,70,74,82,98, 0,24,36,66,66,66,36,24, 0,112,32,32,60,34,34,124, 0,3,60,74,66,66,66,60, 0,114,36,40,60,34,34,124, 0,60,66,2,60,64,66,60, 0,28,8,8,8,8,73,127, 0,60,66,66,66,66,66,66, 0,8,20,34,65,65,65,65, 0,54,73,73,73,65,65,65, 0,65,34,20,8,20,34,65, 0,28,8,8,8,20,34,65, 0,127,33,16,8,4,66,127, 0,120,64,64,64,64,64,120, 0,2,4,8,16,32,64,128, 0,120,8,8,8,8,8,120, 0,0,0,0,130,68,40,16, 255,0,0,0,0,0,0,0, 0,0,0,0,0,8,16,16, 0,63,66,62,2,60,0,0, 0,46,49,49,46,32,32,96, 0,60,66,64,66,60,0,0, 0,59,70,70,58,2,2,6, 0,60,64,126,66,60,0,0, 0,56,16,16,56,16,18,12, 124,2,62,66,66,61,0,0, 0,98,34,34,50,44,32,96, 0,56,16,16,16,48,0,16, 60,66,66,2,2,6,0,2, 0,38,40,48,40,36,32,96, 0,56,16,16,16,16,16,48, 0,73,73,73,73,118,0,0, 0,66,66,66,98,92,0,0, 0,60,66,66,66,60,0,0, 112,32,44,50,50,108,0,0, 14,4,52,76,76,54,0,0, 0,112,32,34,50,108,0,0, 0,124,2,60,64,62,0,0, 0,12,18,16,16,124,16,16, 0,58,70,66,66,66,0,0, 0,8,20,34,65,65,0,0, 0,54,73,73,73,65,0,0, 0,68,40,16,40,68,0,0, 124,2,62,66,66,66,0,0, 0,124,32,16,8,124,0,0, 0,12,16,16,96,16,16,12, 0,16,16,16,0,16,16,16, 0,48,8,8,6,8,8,48, 0,0,0,0,0,0,76,50, 0,127,65,65,34,20,8,0 }; #define MAXLIN 48 #define MAXCOL 256 #define EPSON 0 #define GEMINI 1 char printer; /* printer type */ main(argc,argv) int argc; char *argv[]; { FILE *infile,*lstout; int columns; char pagebuf[MAXLIN][MAXCOL]; if (argc < 2) { printf("\ Usage: PDSW filespec [EPSON]\n"); printf("\ Where: filespec is the name of the file to be printed,\n"); printf("\ and [EPSON] indicates printer is an EPSON compatible\n"); printf("\ printer (default is GEMINI printer)\n"); exit(1); } else printf("PDSW version %d.%d - by Ray Rizzuto\n",VERSION/10,VERSION % 10); printer = GEMINI; if (argc >= 3) if (strcmp("EPSON",argv[2]) == 0) printer = EPSON; if ((infile = fopen(argv[1],"r")) == NULL) { printf("ERROR - can not open file %s\n",argv[1]); exit(1); } /* open "binary" so no character translation (i.e. lf ->crlf) occures */ if ((lstout = fopen("LST:","wb")) == NULL) { printf("ERROR - can not open LST: device"); exit(1); } do { columns = getpage(infile,pagebuf,MAXLIN,MAXCOL); fillpage(pagebuf,MAXLIN,columns); printpage(lstout,pagebuf,MAXLIN,columns); } while (!feof(infile)); exit(0); } /* note - this function uses a non-standard C function BDOS1 which may not be the same for all C compilers. In Q/C, bdos1 takes (c,de), where c, de are the registers that get passed to the bdos. BOTH must be there (use 0 if DE is not required by the bdos */ chkabt() { char c; c = bdos1(6,0xff); if (c == ('C'-0x40)) /* control-c? */ exit(1); } int getpage(infile,pagebuf,lines,cols) FILE *infile; char pagebuf[MAXLIN][MAXCOL]; int lines,cols; { register int i,j; int maxcols; char *eol; int character; register char *chptr; i = j = 0; maxcols = 0; chptr = &pagebuf[0][0]; do { character = getc(infile); if (character == '\n') /* test for end of line */ { *chptr = '\0'; if (j > maxcols) maxcols=j; j = 0; i++; chptr = &pagebuf[i][0]; } else if (character == EOF) /* test for end of file */ { *chptr = '\0'; if (j > maxcols) maxcols=j; j = 0; i++; chptr = &pagebuf[i][0]; break; } else if (character == '\014') /* test for form feed */ { *chptr = '\0'; if (j > maxcols) maxcols=j; j = 0; i++; chptr = &pagebuf[i][0]; break; } else if (character == '\011') /* test for tab */ while (j < cols) { *chptr++ = ' '; j++; if ((j % 8) == 0) break; } else { *chptr++ = character; j++; } if (!(j maxcols) maxcols=j; j=0; i++; chptr = &pagebuf[i][0]; } } while (i= 0; i--) { outchar = pagebuf[i][j]; swbit_ptr = &swbit[outchar-' '][0]; for (k = 0; k < 8; k++) putc(*swbit_ptr++,outfile); putc(0,outfile); /* spacing between lines */ putc(0,outfile); /* spacing between lines */ } nextline(outfile); } nextpage(outfile); } nextline(outfile) FILE *outfile; { chkabt(); switch (printer) { case GEMINI: fprintf(outfile,"\033J%c\r",16); break; case EPSON: fprintf(outfile,"\033J%c\r",24); break; } } nextpage(outfile) FILE *outfile; { putc('\014',outfile); }