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 atm:
45 attach_mowse:
46 proc ();
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 dcl open_descrip char (32);
76 dcl err_string char (512) var;
77 dcl iocb_ptr ptr;
78 dcl switch_name char (32);
79 dcl arg_count fixed bin;
80 dcl arg_list_ptr ptr;
81 dcl mowse_iocb_ptr ptr;
82 dcl syn_iocb_ptr ptr;
83 dcl code fixed bin (35);
84 dcl old_mask bit (36) aligned;
85 dcl new_mask bit (36) aligned;
86
87
88 dcl 01 term_info like terminal_info aligned automatic;
89 dcl 01 info like mowse_io_info automatic;
90
91
92 dcl iox_$open_file entry (ptr, fixed bin, char (*), bit (1) aligned, fixed bin (35));
93 dcl ioa_$ioa_switch entry () options (variable);
94 dcl hcs_$set_ips_mask entry (bit (36) aligned, bit (36) aligned);
95 dcl hcs_$reset_ips_mask entry (bit (36) aligned, bit (36) aligned);
96 dcl ioa_$rsnnl entry () options (variable);
97 dcl iox_$detach_iocb entry (ptr, fixed bin (35));
98 dcl iox_$destroy_iocb entry (ptr, fixed bin (35));
99 dcl iox_$look_iocb entry (char (*), ptr, fixed bin (35));
100 dcl cu_$arg_count entry (fixed bin, fixed bin (35));
101 dcl cu_$arg_list_ptr entry (ptr);
102 dcl iox_$control entry (ptr, char (*), ptr, fixed bin (35));
103 dcl com_err_ entry () options (variable);
104 dcl iox_$move_attach entry (ptr, ptr, fixed bin (35));
105 dcl iox_$find_iocb entry (char (*), ptr, fixed bin (35));
106 dcl iox_$attach_ptr entry (ptr, char (*), ptr, fixed bin (35));
107
108
109
110 dcl iox_$error_output ptr ext static;
111 dcl ws_error_$unsupported_ws_terminal
112 fixed bin (35) ext static;
113 dcl iox_$user_io ptr ext static;
114
115
116
117 dcl get_at_ entry (char (*), char (*), ptr, fixed bin (35));
118 dcl init_mowse_ entry (ptr, ptr, fixed bin (35));
119 dcl startup_parser_ entry (ptr, fixed bin, ptr, char (*) var,
120 fixed bin (35));
121
122
123
124
125
126
127 dcl addr builtin;
128 dcl length builtin;
129 dcl null builtin;
130 dcl index builtin;
131
132
133
134
135
136 dcl MY_NAME char (12) int static options (constant)
137 init ("attach_mowse");
138
139
140
141
142 open_struc_ptr = addr (open_descrip);
143 init_mowse_info_ptr = null;
144 new_mask = ""b;
145
146
147
148
149
150 call iox_$look_iocb ("mowse_i/o", iocb_ptr, code);
151 if iocb_ptr ^= null then do;
152 call ioa_$ioa_switch (iox_$error_output,
153 "^a: MOWSE has already been invoked.", MY_NAME);
154 return;
155 end;
156
157
158
159 call cu_$arg_list_ptr (arg_list_ptr);
160 call cu_$arg_count (arg_count, code);
161 if code ^= 0 then do;
162 call com_err_ (code, MY_NAME, "Getting arg count.");
163 return;
164 end;
165
166
167
168 call startup_parser_ (arg_list_ptr, arg_count, init_mowse_info_ptr,
169 err_string, code);
170 if code ^= 0 then do;
171 call com_err_ (code, MY_NAME, err_string);
172 call clean_up_init_mowse_info (init_mowse_info_ptr);
173 return;
174 end;
175
176
177
178 if ^init_mowse_info.flags.force_sw then do;
179 term_info.version = 1;
180 call iox_$control (iox_$user_io, "terminal_info",
181 addr (term_info), code);
182 if code ^= 0 then do;
183 call com_err_ (code, MY_NAME, "Getting terminal type.");
184 call clean_up_init_mowse_info (init_mowse_info_ptr);
185 return;
186 end;
187
188 if index (term_info.term_type, "MOWSE") = 0 then do;
189 call com_err_ (ws_error_$unsupported_ws_terminal,
190 MY_NAME, "Use MOWSE.");
191 call clean_up_init_mowse_info (init_mowse_info_ptr);
192 return;
193 end;
194 end;
195
196
197
198
199 if ^init_mowse_info.flags.io_switch_sw then do;
200 call get_at_ ("tty_", "", iocb_ptr, code);
201 if code ^= 0 then do;
202 call com_err_ (code, MY_NAME, "Finding tty_.");
203 call clean_up_init_mowse_info (init_mowse_info_ptr);
204 return;
205 end;
206 end;
207 else do;
208 switch_name = init_mowse_info.io_switch;
209 call iox_$look_iocb (switch_name, iocb_ptr, code);
210 if code ^= 0 then do;
211 call com_err_ (code, MY_NAME, "Finding ^a",
212 switch_name);
213 call clean_up_init_mowse_info (init_mowse_info_ptr);
214 return;
215 end;
216 end;
217
218
219
220 call iox_$find_iocb ("mowse_tty", mowse_iocb_ptr, code);
221 if code ^= 0 then do;
222 call com_err_ (code, MY_NAME, "Finding mowse_tty.");
223 call clean_up_init_mowse_info (init_mowse_info_ptr);
224 return;
225 end;
226
227
228
229 call iox_$find_iocb ("mowse_i/o", syn_iocb_ptr, code);
230 if code ^= 0 then do;
231 call iox_$destroy_iocb (mowse_iocb_ptr, (0));
232 call com_err_ (code, MY_NAME, "Finding mowse_i/o.");
233 call clean_up_init_mowse_info (init_mowse_info_ptr);
234 return;
235 end;
236
237
238
239 new_mask = ""b;
240 call hcs_$set_ips_mask (new_mask, old_mask);
241 call iox_$move_attach (iocb_ptr, syn_iocb_ptr, code);
242 if code ^= 0 then do;
243 call hcs_$reset_ips_mask (old_mask, new_mask);
244 call ioa_$rsnnl ("Moving ^a attachment to mowse_i/o.",
245 err_string, length (err_string), iocb_ptr -> iocb.name);
246 goto DESTROY_IOCB_SYN;
247 end;
248
249
250
251 call iox_$attach_ptr (iocb_ptr, "syn_ mowse_i/o", null, code);
252 if code ^= 0 then do;
253 call hcs_$reset_ips_mask (old_mask, new_mask);
254 call ioa_$rsnnl ("Attaching ^a to mowse_i/o.", err_string,
255 length (err_string), iocb_ptr -> iocb.name);
256 goto UNMOVE_ATTACH_SYN;
257 end;
258 call hcs_$reset_ips_mask (old_mask, new_mask);
259
260
261
262 new_mask = ""b;
263 call hcs_$set_ips_mask (new_mask, old_mask);
264 call iox_$move_attach (syn_iocb_ptr, mowse_iocb_ptr, code);
265 if code ^= 0 then do;
266 call hcs_$reset_ips_mask (old_mask, new_mask);
267 call ioa_$rsnnl ("Moving ^a attachment to mowse_i/o.",
268 err_string, length (err_string), syn_iocb_ptr -> iocb.name)
269 ;
270 goto DESTROY_IOCB;
271 end;
272
273
274
275 call iox_$attach_ptr (syn_iocb_ptr, "mowse_io_ mowse_tty", null,
276 code);
277 if code ^= 0 then do;
278 call hcs_$reset_ips_mask (old_mask, new_mask);
279 call ioa_$rsnnl ("Attaching ^a to mowse_tty.", err_string,
280 length (err_string), syn_iocb_ptr -> iocb.name);
281 goto UNMOVE_ATTACH;
282 end;
283 call hcs_$reset_ips_mask (old_mask, new_mask);
284
285
286
287 open_struc.flags.network_sw = "0"b;
288 open_struc.flags.escape_sw = "0"b;
289 if init_mowse_info.flags.escape_sw then do;
290 open_struc.flags.escape_sw = "1"b;
291 open_struc.escape.switches = init_mowse_info.escape.chars;
292 end;
293 if init_mowse_info.flags.network_sw then
294 open_struc.flags.network_sw = "1"b;
295
296 call iox_$open_file (syn_iocb_ptr, Stream_input_output,
297 open_descrip, "0"b, code);
298 if code ^= 0 then do;
299 err_string = "Opening mowse_tty.";
300 goto UNATTACH;
301 end;
302
303
304
305 info.version = mowse_io_info_version_1;
306 call iox_$control (syn_iocb_ptr, "get_mowse_info", addr (info),
307 code);
308 if code ^= 0 then do;
309 call com_err_ (code, MY_NAME, "Getting mowse mcb.");
310 call clean_up_init_mowse_info (init_mowse_info_ptr);
311 return;
312 end;
313
314
315
316 call init_mowse_ (info.mcb_ptr, init_mowse_info_ptr, code);
317 if code ^= 0 then do;
318 call com_err_ (code, MY_NAME, "Initializing mowse.");
319 call clean_up_init_mowse_info (init_mowse_info_ptr);
320 return;
321 end;
322
323 return;
324
325
326
327
328
329
330 UNATTACH:
331 call iox_$detach_iocb (syn_iocb_ptr, (0));
332
333 UNMOVE_ATTACH:
334 call iox_$move_attach (mowse_iocb_ptr, syn_iocb_ptr, (0));
335
336 DESTROY_IOCB:
337 call iox_$destroy_iocb (mowse_iocb_ptr, (0));
338
339 UNMOVE_ATTACH_SYN:
340 call iox_$detach_iocb (iocb_ptr, (0));
341 call iox_$move_attach (syn_iocb_ptr, iocb_ptr, (0));
342
343 DESTROY_IOCB_SYN:
344 call iox_$destroy_iocb (syn_iocb_ptr, (0));
345
346 call com_err_ (code, MY_NAME, err_string);
347 call clean_up_init_mowse_info (init_mowse_info_ptr);
348
349 return;
350
351
352
353
354
355
356
357 clean_up_init_mowse_info:
358 proc (p_info_ptr);
359
360
361
362
363
364
365
366 dcl p_info_ptr ptr parameter;
367
368
369
370 if p_info_ptr ^= null then
371 free p_info_ptr -> init_mowse_info;
372 p_info_ptr = null;
373
374 end clean_up_init_mowse_info;
375
376
377
378 %page;
379
380 %include iox_modes;
381 %include terminal_info;
382 %include mowse_info;
383 %include iocbv;
384 %include mowse_io_control_info;
385
386
387 end;