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 #include <dos.h>
33 #include <stdio.h>
34 #include <ws.h>
35 #include <ws_msg.h>
36 #include <ws_error.h>
37 #include <wsmincap.h>
38 #include <cat.h>
39
40 #define HEADER_LENGTH 5
41
42 extern remote_cat r_CAT[];
43 extern local_cat l_CAT[];
44
45 internal_mowse(length,mowse_msgp)
46
47 int length;
48 struct input_msg *mowse_msgp;
49 {
50 int err_code;
51 int i;
52 int cap_index;
53 char return_status;
54 char capname[33];
55 int capname_length;
56 int cap_num;
57 int connect_request_len;
58 char connect_request_string[WSPAKSIZ];
59
60 struct alter_cat_msg *acp;
61 struct null_msg connect_response_msg;
62 struct null_msg mowse_message;
63
64
65
66 switch(mowse_msgp -> minor)
67 {
68
69
70
71 case WS_EXECUTE_COMMAND :
72
73 EXECUTE_COMMAND(length,mowse_msgp);
74 break;
75
76
77
78 case WS_ADD_TO_RAT:
79
80 acp = (struct alter_cat_msg *) mowse_msgp;
81 return (add_to_remote_cat(acp -> source_system,acp -> rat_major,&acp -> major_name[0]));
82
83
84
85 case WS_DELETE_FROM_RAT:
86
87 acp = (struct alter_cat_msg *) mowse_msgp;
88 if (acp -> source_system == WSIBMPC)
89 return(WSINVSYS);
90 cap_index = acp -> rat_major - MIN_CAPABILITY_NUMBER;
91 if ((cap_index < 0) || (cap_index > NUMBER_OF_CAT_ENTRIES))
92 return(WSINVNUM);
93 r_CAT[cap_index].major_capability = 0;
94 r_CAT[cap_index].system_id = 0;
95 r_CAT[cap_index].flags = 0;
96 i = 0;
97 while (r_CAT[cap_index].capability_name[i] != 0)
98 r_CAT[cap_index].capability_name[i++] = 0;
99 return(0);
100
101
102
103
104 case WS_SET_SLEEP_FLAG:
105
106 cap_index = (int)mowse_msgp -> source_major - MIN_CAPABILITY_NUMBER;
107 if ((cap_index < 0) || (cap_index > NUMBER_OF_CAT_ENTRIES))
108 return (0);
109 r_CAT[cap_index].flags |= SLEEPING_BIT;
110 return (0);
111
112
113
114
115 case WS_RESET_SLEEP_FLAG:
116
117 cap_index = (int)mowse_msgp -> source_major - MIN_CAPABILITY_NUMBER;
118 if ((cap_index < 0) || (cap_index > NUMBER_OF_CAT_ENTRIES))
119 return (0);
120 r_CAT[cap_index].flags &= ~SLEEPING_BIT;
121 return (0);
122
123
124
125
126
127 case RESET_REPLY:
128
129 cap_index = mowse_msgp -> source_major - MIN_CAPABILITY_NUMBER;
130 if ((cap_index < 0) || (cap_index > NUMBER_OF_CAT_ENTRIES))
131 return (0);
132 r_CAT[cap_index].flags &= ~RESET_BIT;
133 return (0);
134
135
136
137
138 case REQUEST_CONNECT:
139
140 capname_length = min(length - HEADER_LENGTH, CAPABILITY_NAME_LENGTH);
141 for (i=0; i < capname_length && mowse_msgp -> msg_data[i] != ' '; i++)
142 capname[i] = mowse_msgp -> msg_data[i];
143 capname[i] = '\0';
144
145 connect_request_len = min(length-HEADER_LENGTH,WSPAKSIZ);
146
147 for (i=0; i < connect_request_len; i++)
148 connect_request_string[i] = mowse_msgp -> msg_data[i];
149 connect_request_string[i] = '\0';
150
151
152
153
154 cap_num = find_local_capability(capname);
155 err_code = 0;
156 if (cap_num == 0) {
157 set_dta();
158 set_trap();
159 err_code = system(connect_request_string);
160 rst_trap();
161 rst_dta();
162 cap_num = find_local_capability(capname);
163 }
164
165
166
167
168
169 if ((cap_num == 0) || (err_code != 0)) {
170 connect_response_msg.system = mowse_msgp -> source_system;
171 connect_response_msg.major = mowse_msgp -> source_major;
172 connect_response_msg.minor = RESPONSE_CONNECT;
173 connect_response_msg.source_system = WSIBMPC;
174 connect_response_msg.source_major = WSMAJCAP;
175 return_status = WSREJECT;
176 return (send_i_mess(&connect_response_msg,HEADER_LENGTH,&return_status,1));
177 }
178
179
180
181
182 mowse_message.system = WSIBMPC;
183 mowse_message.major = cap_num & 0xff;
184 mowse_message.minor = REQUEST_CONNECT;
185 mowse_message.source_system = mowse_msgp -> source_system;
186 mowse_message.source_major = mowse_msgp -> source_major;
187 return (send_i_mess(&mowse_message,HEADER_LENGTH,NULL,0));
188
189
190
191
192 case SET_SUSPEND:
193
194 cap_index = mowse_msgp -> source_major - MIN_CAPABILITY_NUMBER;
195 if ((cap_index < 0) || (cap_index > NUMBER_OF_CAT_ENTRIES))
196 return (0);
197 r_CAT[cap_index].flags |= SUSPENDED_BIT;
198 return (0);
199
200
201
202
203 case RESET_SUSPEND:
204
205 cap_index = mowse_msgp -> source_major - MIN_CAPABILITY_NUMBER;
206 if ((cap_index < 0) || (cap_index > NUMBER_OF_CAT_ENTRIES))
207 return (0);
208 r_CAT[cap_index].flags &= ~SUSPENDED_BIT;
209 return (0);
210
211
212
213
214 case FAIL_CAPABILITY:
215
216 return (0);
217
218
219
220 default:
221
222 if (mowse_msgp -> source_major == WSMAJCAP)
223 return (0);
224 mowse_message.system = mowse_msgp -> source_system;
225 mowse_message.major = mowse_msgp -> source_major;
226 mowse_message.minor = FAIL_CAPABILITY;
227 mowse_message.source_system = WSIBMPC;
228 mowse_message.source_major = WSMAJCAP;
229 return (send_i_mess(&mowse_message,HEADER_LENGTH,NULL,0));
230 }
231 return(0);
232 }
233 ^Z