1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 #include <dos.h>
57 #include <stdio.h>
58 #include <ws.h>
59 #include <alloc.h>
60 #include <cat.h>
61 #include <ws_fgb.h>
62 #include <ws_dcls.h>
63 #include <ws_buf.h>
64 #include <ws_msg.h>
65 #include <wsmincap.h>
66 #include <ws_error.h>
67 #include <ws_auto.h>
68
69 extern struct fgbstr *lcbfptr;
70 extern struct fgbstr *lcblptr;
71 extern struct bstruc fg_buf;
72 extern struct allocstr *lcaptr;
73
74 extern int bg_in_use;
75 extern int packetize_flag;
76 extern int mowse_terminating;
77 extern int load_list_pending;
78
79 extern char bg_sav_buf[];
80 extern char mysystem;
81
82 extern local_cat *sleepq;
83 extern local_cat l_CAT[];
84
85
86
87 rcvdata (p_dosflag)
88 int p_dosflag;
89 {
90 int loopflag;
91 int size;
92 int ecode;
93 int i;
94 int length;
95 int majorcap;
96 int inpl;
97
98 struct input_msg *ip;
99
100 struct fgbstr *bufp;
101 struct fgbstr *fgbp1;
102
103 local_cat *catp;
104
105 char *p1;
106 char *f1;
107
108 char *wsalloc();
109 int rcvfgdat();
110
111
112
113
114 receive_byte();
115
116
117
118 loopflag = 1;
119 while (loopflag) {
120 loopflag = 0;
121
122
123
124 if (fg_buf.bin == fg_buf.bout) {
125 length = getdat(FG,&fg_buf.bminor);
126 if (length > 0) {
127 loopflag = 1;
128 fg_buf.bout = fg_buf.bfirst;
129 fg_buf.bin = fg_buf.bfirst + length - 1;
130 }
131 }
132
133
134
135 if (!bg_in_use)
136 { bg_in_use = getdat(BG,&bg_sav_buf);
137 if (bg_in_use > 0)
138 { loopflag = 1;
139 bufp = (struct fgbstr *)wsalloc (lcaptr,bg_in_use + 1 + sizeof(struct fgbstr));
140 if (bufp != NULL)
141
142
143
144 { p1 = &bg_sav_buf[0];
145 f1 = &bufp -> fgb_char[0];
146 for (i = 0; i < bg_in_use; i++)
147 { *f1++ = *p1++;
148 }
149 *f1++ = '\0';
150 bufp -> fgb_length = bg_in_use;
151 bufp -> fgb_next = NULL;
152 bg_in_use = 0;
153
154
155
156 rcvmsg (bufp, &lcbfptr, &lcblptr);
157 }
158 }
159 }
160
161
162
163 if (fg_buf.bin != fg_buf.bout)
164 rcvfgdat (&fg_buf);
165
166
167
168 if (mowse_terminating && !p_dosflag)
169 { dtm_mowse ();
170 mowse_terminating = 0;
171 }
172
173
174
175
176 if (sleepq != NULL && !p_dosflag)
177 wakeup ();
178
179
180
181 if (!p_dosflag && load_list_pending && packetize_flag)
182 { load_list_pending = 0;
183 autoload ();
184 }
185
186
187
188 if ((lcbfptr != 0) && (!p_dosflag) ) {
189 bufp = lcbfptr;
190 inpl = bufp -> fgb_length;
191 ip = (struct input_msg *) &bufp -> fgb_char[0];
192
193
194
195
196 if (ip -> major == WSMAJCAP) {
197 internal_mowse(inpl,ip);
198 }
199
200
201
202 else {
203 majorcap = ((int) ip -> major) - MIN_CAPABILITY_NUMBER;
204
205
206
207
208 if ((majorcap < 0) || (majorcap > NUMBER_OF_CAT_ENTRIES))
209 message_error (ip -> source_system, ip -> source_major, FAIL_CAPABILITY);
210 else if (l_CAT[majorcap].mcb_ptr == NULL)
211 { if (ip -> minor == PARTIAL_MESSAGE)
212 message_error (ip -> source_major, ip -> msg_data[0], FAIL_CAPABILITY);
213 else if (ip -> minor == REQUEST_DISCONNECT)
214 message_error (ip -> source_system, ip -> source_major, RESPONSE_DISCONNECT);
215 else if (ip -> minor == GET_STATUS)
216 message_error (ip -> source_system, ip -> source_major, STATUS_REPLY);
217 else
218 message_error (ip -> source_system, ip -> source_major, FAIL_CAPABILITY);
219 }
220
221
222
223 else {
224 external_mowse (&l_CAT[majorcap],ip,inpl);
225 }
226 }
227 loopflag = 1;
228 lcbfptr = bufp -> fgb_next;
229 if (lcbfptr == NULL)
230 lcblptr = NULL;
231 wsfree (lcaptr,bufp);
232 }
233 }
234 }
235
236
237
238
239
240
241
242
243 message_error (p_system, p_major, p_minor)
244
245 char p_system;
246 char p_major;
247 char p_minor;
248 {
249 struct input_msg exerep;
250 char data;
251 struct putbg_struc status_msg;
252
253 exerep.system = p_system;
254 exerep.major = p_major;
255 exerep.minor = p_minor;
256 exerep.source_major = WSMAJCAP;
257 exerep.source_system = mysystem;
258
259
260
261 if (p_minor == RESPONSE_DISCONNECT)
262 { data = WSREJECT;
263 send_i_mess(&exerep.system, sizeof(exerep) - 1, &data, 1);
264 }
265
266
267
268 else if (p_minor == STATUS_REPLY)
269 { status_msg.type = STATUS_REPLY;
270 status_msg.sender_major = (mysystem << 8) | WSMAJCAP;
271 strcpy (status_msg.bgmsg, "Capability does not exist.");
272 status_msg.length = strlen (status_msg.bgmsg);
273
274 i_putbgm (&status_msg);
275 }
276
277
278
279 else
280 send_i_mess(&exerep.system, sizeof(exerep) - 1,NULL,0);
281 }
282 ^Z