File:  [Research Unix] / researchv9 / jtools / src / pads / x11 / host.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

#include "univ.h"
#define REMOTEBUFFER 64
unsigned char RemoteBuffer[REMOTEBUFFER];
int RemoteIndex;

FlushRemote()
{
	if( RemoteIndex ){
		sendnchars(RemoteIndex, RemoteBuffer);
		RemoteIndex = 0;
	}
}

GetRemote()
{
	register int c;

	while( (c = rcvchar() ) == -1 ){
		cursswitch(&Coffee);
		wait(RCV);
		cursswitch(Pcursor);
	}
	return c;
}

void PutRemote( c )
char c;
{
	if( RemoteIndex >= REMOTEBUFFER ) FlushRemote();
	RemoteBuffer[RemoteIndex++] = c;
}

ToHost( p, s )
Protocol p;
short s;
{
	extern Pad *Current;

	PutRemote( p );
	SendLong( HostParent );
	SendLong( HostObject );
	SendShort( s );
}
	
HostAction( i )
Index *i;			/* <text:action:opand> stored at host	*/
{
	ToHost( P_ACTION, *i );
}

HostNumeric( n )
long n;				/* always in short range ! */
{
	ToHost( P_NUMERIC, (short) n );
}

RCVServe()	/* poll the host */ 
{
	register Cursor *t = Pcursor;
	register int op;

	FlushRemote();
Again:
	if( P->state & RCV ){
		op = GetRemote();
		switch( op&0xF0 ){
		case (int)P_VERSION&0xF0:
			if( RcvLong() != PADS_VERSION )
			   ProtoErr( "host/term versions differ - regenerate. " );
			break;
		case (int)P_PICK&0xF0:
			PickOp();
			break;
		case (int)P_HOSTSTATE&0xF0:
			t = (op==(int)P_BUSY) ? &HostBusy : (Cursor*)0;
			goto Again;
		case (int)P_PADDEF&0xF0:
		case (int)P_PADOP&0xF0:	
			PadOp(op);
			break;
		case (int)P_CACHEOP&0xF0:
			CacheOp(op);
			break;
		case (int)P_HELPSTR&0xF0:
			HelpString();
			break;
		default:
			ProtoErr( "RCVServe(): " );
		}
	}
	if( t != Pcursor ) cursswitch( Pcursor = t );
}

HelpString()
{
	char s[256];

	RcvString(s);
	InvertKBDrect(s,"");
}

ProtoErr(s)
register char *s;
{
	extern char KBDStr[];
	register char *k = KBDStr, *p = "protocol: ";

	while( *s ) *k++ = *s++;
	while( *p ) *k++ = *p++;
	for(;;){
		PaintKBD();
		if( k<&KBDStr[64] ) *k++ = GetRemote()&0x7F;
		sleep(2);
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.