|
|
1.1 ! root 1: /* D.L.Buck and Associates, Inc. - 8/27/84 ! 2: * ! 3: * COPYRIGHT NOTICE: ! 4: * Copyright c 8/27/84 - An unpublished work by ! 5: * D.L.Buck and Associates, Inc. ! 6: * ! 7: * PROPRIETARY RIGHTS NOTICE: ! 8: * All rights reserved. This document and program contains ! 9: * proprietary information of D.L.Buck and Associates,Inc. ! 10: * of San Jose, California, U.S.A., embodying confidential ! 11: * information, ideas, and expressions, no part of which ! 12: * may be reproduced, or transmitted in any form or by any ! 13: * means, electronic, mechanical, or otherwise, without ! 14: * the written permission of D.L.Buck and Associates, Inc. ! 15: * ! 16: * NAME ! 17: * emprtr ! 18: * ! 19: * SYNOPSIS ! 20: * emprtr() ! 21: * ! 22: * DESCRIPTION ! 23: * emprtr prints the contents of the received printer buffer. ! 24: */ ! 25: ! 26: #include "empr.h" ! 27: #include <signal.h> ! 28: ! 29: #define EM 0x19 ! 30: #define NL 0x0a ! 31: #define CR 0x0d ! 32: #define SI 0x0f ! 33: #define FF 0x0c ! 34: #define YES 1 ! 35: #define NO 0 ! 36: ! 37: #ifndef lint ! 38: static char sccsid[] = "@(#)emprtr.c 1.9 "; ! 39: #endif ! 40: extern int wflag; /* set if we wrote something to pipe; 0 if not */ ! 41: extern int maxlen; /* defined in emprbuf; line length from wcc */ ! 42: ! 43: extern int prtype; /* printer type- 4,6,7,8,9 (3284,3286,3287,3288,3289) */ ! 44: extern int buffered; /* 0=unbuffered printer; 1=buffered printer */ ! 45: extern int tprint; /* text print option for 3288; if 1, suppress index ! 46: works */ ! 47: extern int ctype; /* controller type- 1,5 (3271, 3275) */ ! 48: extern int linesperpage; /* # of lines allowed per page */ ! 49: ! 50: extern FILE *outfd; /* device, file, or pipe to write printer output to */ ! 51: extern char outtype; ! 52: ! 53: ! 54: char *scrnptr; /* points to character being processed now */ ! 55: char *lptr; /* pointer into line */ ! 56: char line[256]; /* construct lines here */ ! 57: emprtr() ! 58: { ! 59: register int lctr = 0; /* number of lines on page so far */ ! 60: register int dflag = 0; /* set if line `dirty' - non-white stuff*/ ! 61: register char *scrnend = &scrn_image[MAXSCREENSIZE]; ! 62: ! 63: scrnptr = scrn_image; ! 64: lptr = line; ! 65: cursaddr = 0; ! 66: curfield = scrn_xref[cursaddr]; ! 67: ! 68: while (scrnptr != scrnend) { /* build lines while not screen end */ ! 69: switch(*scrnptr) { ! 70: /* CR Order (3287, 3289 Printers): ref. pf 2-23 ! 71: * Executed only by 3287 and 3289 printers, in ! 72: * unformatted mode and in displayable/printable field. ! 73: * Otherwise print as space. ! 74: */ ! 75: case CR: /* Carriage Return */ ! 76: if ((prtype == 7 || prtype == 9) && ! 77: (maxlen == 132) && !invis_attr(fldattr[curfield])) { ! 78: *lptr++ = '\r'; ! 79: *lptr = '\0'; ! 80: if (dflag) ! 81: fputs (line,outfd); ! 82: lptr = line; ! 83: break; ! 84: } ! 85: /* Print as space */ ! 86: *lptr++ = ' '; ! 87: break; ! 88: ! 89: /* EM Order (All Printers): ref. pg 2-22. ! 90: * Executed only in unformatted (132 col mode) printout and ! 91: * when not in nondisplay/nonprint field. ! 92: * In nondisplay/nonprint field, it prints as blank. ! 93: * In formatted output, it "is printed by the 3284, 3286, ! 94: * 3287, and 3288 printers as the graphic `9,' and by the ! 95: * 3230, 3262, 3268, 3287, and 3289 printers as a space ! 96: * character." (sic) ! 97: * So, who knows what the 3287 really does ... ! 98: * we print a `9'. ! 99: */ ! 100: case EM: /* end of media */ ! 101: if (maxlen == 132 && ! 102: !invis_attr(fldattr[curfield])) { ! 103: if (lptr != line) { ! 104: *lptr++ = '\n'; ! 105: *lptr = '\0'; ! 106: fputs(line, outfd); ! 107: ++lctr; ! 108: } ! 109: goto way_out; ! 110: } ! 111: ! 112: if (invis_attr(fldattr[curfield]) || ! 113: (prtype == 9 && maxlen < 132)) ! 114: *lptr++ = ' '; ! 115: else if (prtype != 9) { ! 116: *lptr++ = '9'; ! 117: ++dflag; ! 118: } ! 119: break; ! 120: ! 121: /* FF Order (3287, 3288, 3289 Printers): ref. pg 2-22 ! 122: * Executed by the above printers during either ! 123: * formatted or unformatted operations, when at ! 124: * beginning of line. At other than beginning of ! 125: * line, it prints as "<" or blank on the 3288 printer ! 126: * depending on whether the field is printable or not. ! 127: * If the printer is at top-of-form on a 3287 or 3289 ! 128: * the skip is not performed. ! 129: */ ! 130: case FF: /* form feed */ ! 131: if (prtype < 7 || prtype > 9 || lptr != line) { ! 132: if (invis_attr(fldattr[curfield])) ! 133: *lptr++ = ' '; ! 134: else { ! 135: *lptr++ = '<'; ! 136: dflag = 1; ! 137: } ! 138: break; ! 139: } ! 140: ! 141: /* At beginning of line */ ! 142: if ((prtype == 7 || prtype == 9) && ! 143: (lctr == 0)) ! 144: break; /* Don't skip again */ ! 145: fputs("\f\r",outfd); ! 146: *lptr++ = ' '; ! 147: lctr = 0; ! 148: break; ! 149: ! 150: /* NL Order (All Printers): ref. pg 2-22 ! 151: * Executed only in unformatted print (132 col) mode, ! 152: * in displayable/printable field. ! 153: * When not executed, `it is printed by the 3284, 3286, ! 154: * 3287, and 3288 printers as the graphic "5", and by ! 155: * the 3230, 3262, 3268, 3287, and 3289 printers as a ! 156: * space character.' (sic) ! 157: * So, who knows what the 3287 really does ... ! 158: * we print a `5'. ! 159: */ ! 160: ! 161: case NL: ! 162: if (invis_attr(fldattr[curfield]) || maxlen != 132) { ! 163: if (invis_attr(fldattr[curfield]) || ! 164: prtype == 9) ! 165: *lptr++ = ' '; ! 166: else { ! 167: *lptr++ = '5'; ! 168: ++dflag; ! 169: } ! 170: break; ! 171: } ! 172: ! 173: *lptr++ = '\n'; ! 174: *lptr = '\0'; ! 175: fputs(line, outfd); ! 176: ++lctr; ! 177: dflag = 0; ! 178: lptr = line; ! 179: *lptr = '\0'; ! 180: break; ! 181: ! 182: /* SI -- suppress index; works like a carriage return, but only on ! 183: 3288 printers which have the text print option */ ! 184: case SI: ! 185: if (prtype != 8 || tprint == NO) break; ! 186: *lptr++ = '\r'; ! 187: *lptr = '\0'; ! 188: fputs(line, outfd); ! 189: lptr = line; ! 190: break; ! 191: ! 192: case ' ': ! 193: case '\0': ! 194: case (char)ATTRCODE: ! 195: *lptr++ = ' '; ! 196: break; ! 197: ! 198: default: ! 199: if (invis_attr(fldattr[curfield])) ! 200: *lptr++ = ' '; ! 201: else { ! 202: *lptr++ = *scrnptr; ! 203: ++dflag; ! 204: } ! 205: break; ! 206: }; /* End of SWITCH */ ! 207: ! 208: /* Check for end of line. */ ! 209: if ((lptr - line) >= maxlen) { ! 210: if (dflag) { /* Line is `dirty' */ ! 211: *lptr++ = '\n'; *lptr = '\0'; ! 212: fputs(line, outfd); ! 213: ++lctr; ! 214: } ! 215: dflag = 0; ! 216: lptr = line; ! 217: *lptr = '\0'; ! 218: } ! 219: ! 220: chk_eop: /* Check for end of page. */ ! 221: if (lctr >= linesperpage) { ! 222: fputs("\f\r",outfd); ! 223: lctr = 0; ! 224: } ! 225: ! 226: ++scrnptr; ! 227: if (++cursaddr >= MAXSCREENSIZE) ! 228: cursaddr = 0; ! 229: curfield = scrn_xref[cursaddr]; ! 230: } ! 231: ! 232: /* End of Screen Buffer ... Finish up */ ! 233: if (dflag) { /* Finish with last line */ ! 234: *lptr++ = '\n'; ! 235: *lptr = '\0'; ! 236: fputs(line,outfd); ! 237: if (++lctr >= linesperpage) { ! 238: fputs("\f\r",outfd); ! 239: lctr = 0; ! 240: } ! 241: } ! 242: way_out: ! 243: /* If writing to pipe, mark that we wrote to it */ ! 244: if (outtype == 'P') ! 245: ++wflag; ! 246: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.