|
|
1.1 root 1: #include "univ.h"
2: #define REMOTEBUFFER 64
3: unsigned char RemoteBuffer[REMOTEBUFFER];
4: int RemoteIndex;
5:
6: FlushRemote()
7: {
8: if( RemoteIndex ){
9: sendnchars(RemoteIndex, RemoteBuffer);
10: RemoteIndex = 0;
11: }
12: }
13:
14: GetRemote()
15: {
16: register int c;
17:
18: while( (c = rcvchar() ) == -1 ){
19: cursswitch(&Coffee);
20: wait(RCV);
21: cursswitch(Pcursor);
22: }
23: return c;
24: }
25:
26: void PutRemote( c )
27: char c;
28: {
29: if( RemoteIndex >= REMOTEBUFFER ) FlushRemote();
30: RemoteBuffer[RemoteIndex++] = c;
31: }
32:
33: ToHost( p, s )
34: Protocol p;
35: short s;
36: {
37: extern Pad *Current;
38:
39: PutRemote( p );
40: SendLong( HostParent );
41: SendLong( HostObject );
42: SendShort( s );
43: }
44:
45: HostAction( i )
46: Index *i; /* <text:action:opand> stored at host */
47: {
48: ToHost( P_ACTION, *i );
49: }
50:
51: HostNumeric( n )
52: long n; /* always in short range ! */
53: {
54: ToHost( P_NUMERIC, (short) n );
55: }
56:
57: RCVServe() /* poll the host */
58: {
59: register Cursor *t = Pcursor;
60: register int op;
61:
62: FlushRemote();
63: Again:
64: if( P->state & RCV ){
65: op = GetRemote();
66: switch( op&0xF0 ){
67: case (int)P_VERSION&0xF0:
68: if( RcvLong() != PADS_VERSION )
69: ProtoErr( "host/term versions differ - regenerate. " );
70: break;
71: case (int)P_PICK&0xF0:
72: PickOp();
73: break;
74: case (int)P_HOSTSTATE&0xF0:
75: t = (op==(int)P_BUSY) ? &HostBusy : (Cursor*)0;
76: goto Again;
77: case (int)P_PADDEF&0xF0:
78: case (int)P_PADOP&0xF0:
79: PadOp(op);
80: break;
81: case (int)P_CACHEOP&0xF0:
82: CacheOp(op);
83: break;
84: case (int)P_HELPSTR&0xF0:
85: HelpString();
86: break;
87: default:
88: ProtoErr( "RCVServe(): " );
89: }
90: }
91: if( t != Pcursor ) cursswitch( Pcursor = t );
92: }
93:
94: HelpString()
95: {
96: char s[256];
97:
98: RcvString(s);
99: InvertKBDrect(s,"");
100: }
101:
102: ProtoErr(s)
103: register char *s;
104: {
105: extern char KBDStr[];
106: register char *k = KBDStr, *p = "protocol: ";
107:
108: while( *s ) *k++ = *s++;
109: while( *p ) *k++ = *p++;
110: for(;;){
111: PaintKBD();
112: if( k<&KBDStr[64] ) *k++ = GetRemote()&0x7F;
113: sleep(2);
114: }
115: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.