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