1 #ifndef lint 2 static char sccsid[] = "@(#)subr.c 4.1 (Berkeley) 11/10/83"; 3 #endif 4 5 #include <sgtty.h> 6 #include "hp2648.h" 7 8 handshake() 9 { 10 int i; 11 char ch; 12 13 if( shakehands != TRUE ) 14 return; 15 ch = ' '; 16 putchar(ENQ); 17 fflush(stdout); 18 while(1){ 19 i = read(fildes, &ch, 1); 20 if(i < 0) 21 continue; 22 if(ch == ACK) 23 break; 24 putchar('Z'); 25 fflush(stdout); 26 stty(fildes, &sarg); 27 exit(0); 28 } 29 } 30 31 buffready(n) 32 int n; 33 { 34 buffcount = buffcount + n; 35 if(buffcount >= 80){ 36 handshake(); 37 putchar(ESC); 38 putchar(GRAPHIC); 39 putchar(PLOT); 40 putchar(BINARY); 41 buffcount = n+4; 42 } 43 } 44 45 itoa(num,byte1,byte2) 46 int num; 47 char *byte1,*byte2; 48 { 49 *byte1 = (num & 037) | 040; 50 *byte2 = ((num>>5) & 037) | 040; 51 } 52