1 /* 2 * lowest level io 3 * 4 * The Harris has a weird protocol, which wil be maintained by 5 * a different programme (now called harprot, will be changed into 6 * a typesetter spooler in near future). 7 * 8 * Due to thenature of the harris is a slight protocol to harprot 9 * necessary as well: 10 * Operator messages are ruined if they aren't at the end of a buffer 11 * 12 * So to harprot we send a buffer with a header containing a bufferlenght 13 * and (for historical reasons, the amount of paper used.) 14 * The paper use will have to be counted by harprot in future. 15 * 16 #if tahoe || sun 17 * For the sake of compbatibilty we will generate the same file format 18 * as on the vaxes 19 #endif tahoe || sun 20 * 21 */ 22 23 #ifndef lint 24 static char sccsid[] = "@(#)llio.c 1.3 (CWI) 88/03/23"; 25 #endif 26 27 #include <stdio.h> 28 #include "hcodes.h" 29 #include "llio.h" 30 31 char obuf[BUFSIZE]; 32 char *obufp = obuf; 33 char *eobufp = &obuf[BUFSIZE-1]; 34 int typeset; /* if set, we are really typesetting */ 35 36 extern int fcut; /* if set, we have just cut the paper */ 37 extern unsigned short papuse; /* used paper in feed */ 38 extern int tf; 39 extern char harcode; 40 extern int eflag; 41 42 43 oput( c ) 44 char c; 45 { 46 typeset = 1; 47 48 if( fcut ) { /* See harris manual, appendix D */ 49 fcut = 0; 50 oput(VMV); 51 oput(0); 52 oput(0); 53 } 54 if( obufp > eobufp) 55 flusho(); 56 *obufp++ = c & BMASK; 57 } 58 59 flusho() 60 { unsigned short length; 61 int i; 62 if ( length = (int )(obufp - obuf )) { 63 if ( !papuse ) 64 papuse++; /* account always at least 1 foot */ 65 /* for testing only */ 66 /*papuse = 1;*/ 67 #ifdef vax 68 if ( write( tf, (char *)&length, 2) != 2 || 69 write( tf, (char *)&papuse, 2) != 2 || 70 (i = write( tf, obuf, length)) != length) { 71 printf("dhar: write error\n"); 72 exit(1); 73 } 74 #endif vax 75 #if tahoe || sun 76 { char c1, c2; 77 c1 = length & BMASK; 78 c2 = (length >> 8) & BMASK; 79 if( write(tf, &c1, 1) != 1 || 80 write(tf, &c2, 1) != 1) { 81 printf("dhar: write error\n"); 82 exit(1); 83 } 84 c1 = papuse & BMASK; 85 c2 = (papuse >> 8) & BMASK; 86 if( write(tf, &c1, 1) != 1 || 87 write(tf, &c2, 1) != 1) { 88 printf("dhar: write error\n"); 89 exit(1); 90 } 91 if((i = write( tf, obuf, length)) != length) { 92 printf("dhar: write error\n"); 93 exit(1); 94 } 95 } 96 #endif tahoe || sun 97 obufp = obuf; 98 } 99 } 100 101 xflusho(nbytes) 102 int nbytes; 103 { 104 if ( obufp > &obuf[BUFSIZE - nbytes]) 105 flusho(); 106 } 107 108 flushchar() 109 { 110 if( harcode ) { 111 oput(harcode); 112 oput(0); oput(0); 113 harcode = 0; 114 } 115 } 116 117 ex() 118 { if(!typeset) 119 return; 120 if(!fcut) 121 cut(); 122 fcut = 0; 123 oput(EOT); 124 oput(STP); 125 operator("End of job"); 126 typeset = 0; 127 if(eflag) { 128 fprintf( stderr, "Don't forget to bring the machine"); 129 fprintf( stderr, " back in a normal state\n"); 130 eflag--; 131 } 132 } 133 134 operator( s ) 135 char *s; 136 { register int i, j, n; 137 char buf[PANEL_SIZE]; 138 n = 0; 139 while ( *s ) { /* ascii from harris, stupid fools */ 140 if( *s >= 'a' && *s <= 'z') 141 *s += 'A' - 'a'; 142 if(*s == '{') 143 *s = 0136; 144 if(*s == '}') 145 *s = 0137; 146 if( *s < 040 || *s > 0137) { 147 error( !FATAL, "illegal char %o to display", *s); 148 s++; 149 continue; 150 } 151 buf[n++] = *s++; 152 if( n >= PANEL_SIZE) 153 break; 154 } 155 /* 156 * now center the message and send it away 157 */ 158 if( n <= PANEL_SIZE && n > 0) { 159 flusho(PANEL_SIZE + 1); 160 /* 161 * always flushing the buffer seems to be better 162 */ 163 oput(OPR); 164 i = ( PANEL_SIZE - n ) / 2; 165 for( j = 0; j < i; j++) 166 oput(' '); 167 for( j = 0; j < n; j++) 168 oput(buf[j]); 169 for( j = i + n; j < PANEL_SIZE; j++) 170 oput(' '); 171 flusho(); 172 } 173 } 174