133754Sjaap /*
233754Sjaap * lowest level io
333754Sjaap *
433754Sjaap * The Harris has a weird protocol, which wil be maintained by
533754Sjaap * a different programme (now called harprot, will be changed into
633754Sjaap * a typesetter spooler in near future).
733754Sjaap *
833754Sjaap * Due to thenature of the harris is a slight protocol to harprot
933754Sjaap * necessary as well:
1033754Sjaap * Operator messages are ruined if they aren't at the end of a buffer
1133754Sjaap *
1233754Sjaap * So to harprot we send a buffer with a header containing a bufferlenght
1333755Sjaap * and (for historical reasons, the amount of paper used.)
1433754Sjaap * The paper use will have to be counted by harprot in future.
1533754Sjaap *
16*33776Sjaap #if tahoe || sun
1733755Sjaap * For the sake of compbatibilty we will generate the same file format
1833755Sjaap * as on the vaxes
19*33776Sjaap #endif tahoe || sun
2033755Sjaap *
2133754Sjaap */
2233754Sjaap
2333755Sjaap #ifndef lint
24*33776Sjaap static char sccsid[] = "@(#)llio.c 1.3 (CWI) 88/03/23";
2533755Sjaap #endif
2633755Sjaap
2733754Sjaap #include <stdio.h>
2833754Sjaap #include "hcodes.h"
2933754Sjaap #include "llio.h"
3033754Sjaap
3133754Sjaap char obuf[BUFSIZE];
3233754Sjaap char *obufp = obuf;
3333754Sjaap char *eobufp = &obuf[BUFSIZE-1];
3433754Sjaap int typeset; /* if set, we are really typesetting */
3533754Sjaap
3633754Sjaap extern int fcut; /* if set, we have just cut the paper */
3733755Sjaap extern unsigned short papuse; /* used paper in feed */
3833754Sjaap extern int tf;
3933754Sjaap extern char harcode;
4033754Sjaap extern int eflag;
4133754Sjaap
4233754Sjaap
oput(c)4333754Sjaap oput( c )
4433754Sjaap char c;
4533754Sjaap {
4633754Sjaap typeset = 1;
4733754Sjaap
4833754Sjaap if( fcut ) { /* See harris manual, appendix D */
4933754Sjaap fcut = 0;
5033754Sjaap oput(VMV);
5133754Sjaap oput(0);
5233754Sjaap oput(0);
5333754Sjaap }
5433754Sjaap if( obufp > eobufp)
5533754Sjaap flusho();
5633754Sjaap *obufp++ = c & BMASK;
5733754Sjaap }
5833754Sjaap
flusho()5933754Sjaap flusho()
6033755Sjaap { unsigned short length;
6133755Sjaap int i;
6233754Sjaap if ( length = (int )(obufp - obuf )) {
6333754Sjaap if ( !papuse )
6433754Sjaap papuse++; /* account always at least 1 foot */
6533754Sjaap /* for testing only */
6633754Sjaap /*papuse = 1;*/
6733755Sjaap #ifdef vax
6833754Sjaap if ( write( tf, (char *)&length, 2) != 2 ||
6933754Sjaap write( tf, (char *)&papuse, 2) != 2 ||
7033755Sjaap (i = write( tf, obuf, length)) != length) {
7133754Sjaap printf("dhar: write error\n");
7233754Sjaap exit(1);
7333754Sjaap }
7433755Sjaap #endif vax
75*33776Sjaap #if tahoe || sun
7633755Sjaap { char c1, c2;
7733755Sjaap c1 = length & BMASK;
7833755Sjaap c2 = (length >> 8) & BMASK;
7933755Sjaap if( write(tf, &c1, 1) != 1 ||
8033755Sjaap write(tf, &c2, 1) != 1) {
8133755Sjaap printf("dhar: write error\n");
8233755Sjaap exit(1);
8333755Sjaap }
8433755Sjaap c1 = papuse & BMASK;
8533755Sjaap c2 = (papuse >> 8) & BMASK;
8633755Sjaap if( write(tf, &c1, 1) != 1 ||
8733755Sjaap write(tf, &c2, 1) != 1) {
8833755Sjaap printf("dhar: write error\n");
8933755Sjaap exit(1);
9033755Sjaap }
9133755Sjaap if((i = write( tf, obuf, length)) != length) {
9233755Sjaap printf("dhar: write error\n");
9333755Sjaap exit(1);
9433755Sjaap }
9533755Sjaap }
96*33776Sjaap #endif tahoe || sun
9733754Sjaap obufp = obuf;
9833754Sjaap }
9933754Sjaap }
10033754Sjaap
xflusho(nbytes)10133754Sjaap xflusho(nbytes)
10233754Sjaap int nbytes;
10333754Sjaap {
10433754Sjaap if ( obufp > &obuf[BUFSIZE - nbytes])
10533754Sjaap flusho();
10633754Sjaap }
10733754Sjaap
flushchar()10833754Sjaap flushchar()
10933754Sjaap {
11033754Sjaap if( harcode ) {
11133754Sjaap oput(harcode);
11233754Sjaap oput(0); oput(0);
11333754Sjaap harcode = 0;
11433754Sjaap }
11533754Sjaap }
11633754Sjaap
ex()11733754Sjaap ex()
11833754Sjaap { if(!typeset)
11933754Sjaap return;
12033754Sjaap if(!fcut)
12133754Sjaap cut();
12233754Sjaap fcut = 0;
12333754Sjaap oput(EOT);
12433754Sjaap oput(STP);
12533754Sjaap operator("End of job");
12633754Sjaap typeset = 0;
12733754Sjaap if(eflag) {
12833754Sjaap fprintf( stderr, "Don't forget to bring the machine");
12933754Sjaap fprintf( stderr, " back in a normal state\n");
13033754Sjaap eflag--;
13133754Sjaap }
13233754Sjaap }
13333754Sjaap
operator(s)13433754Sjaap operator( s )
13533754Sjaap char *s;
13633754Sjaap { register int i, j, n;
13733754Sjaap char buf[PANEL_SIZE];
13833754Sjaap n = 0;
13933754Sjaap while ( *s ) { /* ascii from harris, stupid fools */
14033754Sjaap if( *s >= 'a' && *s <= 'z')
14133754Sjaap *s += 'A' - 'a';
14233754Sjaap if(*s == '{')
14333754Sjaap *s = 0136;
14433754Sjaap if(*s == '}')
14533754Sjaap *s = 0137;
14633754Sjaap if( *s < 040 || *s > 0137) {
14733754Sjaap error( !FATAL, "illegal char %o to display", *s);
14833754Sjaap s++;
14933754Sjaap continue;
15033754Sjaap }
15133754Sjaap buf[n++] = *s++;
15233754Sjaap if( n >= PANEL_SIZE)
15333754Sjaap break;
15433754Sjaap }
15533754Sjaap /*
15633754Sjaap * now center the message and send it away
15733754Sjaap */
15833754Sjaap if( n <= PANEL_SIZE && n > 0) {
15933754Sjaap flusho(PANEL_SIZE + 1);
16033754Sjaap /*
16133754Sjaap * always flushing the buffer seems to be better
16233754Sjaap */
16333754Sjaap oput(OPR);
16433754Sjaap i = ( PANEL_SIZE - n ) / 2;
16533754Sjaap for( j = 0; j < i; j++)
16633754Sjaap oput(' ');
16733754Sjaap for( j = 0; j < n; j++)
16833754Sjaap oput(buf[j]);
16933754Sjaap for( j = i + n; j < PANEL_SIZE; j++)
17033754Sjaap oput(' ');
17133754Sjaap flusho();
17233754Sjaap }
17333754Sjaap }
174