xref: /csrg-svn/lib/libplot/hp2648/subr.c (revision 48517)
1*48517Sbostic /*-
2*48517Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*48517Sbostic  * All rights reserved.
4*48517Sbostic  *
5*48517Sbostic  * %sccs.include.proprietary.c%
619975Sdist  */
719975Sdist 
815459Sralph #ifndef lint
9*48517Sbostic static char sccsid[] = "@(#)subr.c	5.2 (Berkeley) 04/22/91";
10*48517Sbostic #endif /* not lint */
1115459Sralph 
1215459Sralph #include <sgtty.h>
1315459Sralph #include "hp2648.h"
1415459Sralph 
1515459Sralph handshake()
1615459Sralph {
1715459Sralph 	int i;
1815459Sralph 	char ch;
1915459Sralph 
2015459Sralph 	if( shakehands != TRUE )
2115459Sralph 		return;
2215459Sralph 	ch = ' ';
2315459Sralph 	putchar(ENQ);
2415459Sralph 	fflush(stdout);
2515459Sralph 	while(1){
2615459Sralph 		i = read(fildes, &ch, 1);
2715459Sralph 		if(i < 0)
2815459Sralph 			continue;
2915459Sralph 		if(ch == ACK)
3015459Sralph 			break;
3115459Sralph 		putchar('Z');
3215459Sralph 		fflush(stdout);
3315459Sralph 		stty(fildes, &sarg);
3415459Sralph 		exit(0);
3515459Sralph 	}
3615459Sralph }
3715459Sralph 
3815459Sralph buffready(n)
3915459Sralph int n;
4015459Sralph {
4115459Sralph 	buffcount = buffcount + n;
4215459Sralph 	if(buffcount >= 80){
4315459Sralph 		handshake();
4415459Sralph 		putchar(ESC);
4515459Sralph 		putchar(GRAPHIC);
4615459Sralph 		putchar(PLOT);
4715459Sralph 		putchar(BINARY);
4815459Sralph 		buffcount = n+4;
4915459Sralph 	}
5015459Sralph }
5115459Sralph 
5215459Sralph itoa(num,byte1,byte2)
5315459Sralph int num;
5415459Sralph char *byte1,*byte2;
5515459Sralph {
5615459Sralph 	*byte1 = (num & 037) | 040;
5715459Sralph 	*byte2 = ((num>>5) & 037) | 040;
5815459Sralph }
59