1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 */ 6 7 #ifndef lint 8 static char sccsid[] = "@(#)subr.c 5.1 (Berkeley) 05/07/85"; 9 #endif not lint 10 11 #include <sgtty.h> 12 #include "hp2648.h" 13 14 handshake() 15 { 16 int i; 17 char ch; 18 19 if( shakehands != TRUE ) 20 return; 21 ch = ' '; 22 putchar(ENQ); 23 fflush(stdout); 24 while(1){ 25 i = read(fildes, &ch, 1); 26 if(i < 0) 27 continue; 28 if(ch == ACK) 29 break; 30 putchar('Z'); 31 fflush(stdout); 32 stty(fildes, &sarg); 33 exit(0); 34 } 35 } 36 37 buffready(n) 38 int n; 39 { 40 buffcount = buffcount + n; 41 if(buffcount >= 80){ 42 handshake(); 43 putchar(ESC); 44 putchar(GRAPHIC); 45 putchar(PLOT); 46 putchar(BINARY); 47 buffcount = n+4; 48 } 49 } 50 51 itoa(num,byte1,byte2) 52 int num; 53 char *byte1,*byte2; 54 { 55 *byte1 = (num & 037) | 040; 56 *byte2 = ((num>>5) & 037) | 040; 57 } 58