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