1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6         *                                                         *
  7         *********************************************************** */
  8 
  9 /****^  HISTORY COMMENTS:
 10   1) change(86-08-14,Flegel), approve(87-07-15,MCR7580),
 11      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 12      Created.
 13   2) change(86-08-28,Flegel), approve(87-07-15,MCR7580),
 14      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 15      Extracted get_at_ to separate module.
 16   3) change(86-10-07,Flegel), approve(87-07-15,MCR7580),
 17      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 18      Added syn_mowse_i/o to allow easy location of the switch attached to
 19      mowse_io_ module.
 20   4) change(86-10-08,Flegel), approve(87-07-15,MCR7580),
 21      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 22      Renamed attachments.
 23   5) change(86-10-09,Flegel), approve(87-07-15,MCR7580),
 24      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 25      Masked around critical switch movements.
 26   6) change(86-11-27,Flegel), approve(86-11-27,MCR7580),
 27      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 28      Approved.
 29   7) change(87-01-19,Flegel), approve(87-01-19,MCR7580),
 30      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 31      Added check for WSTERM terminal type before attaching MOWSE.
 32   8) change(87-02-25,Flegel), approve(87-02-25,MCR7580),
 33      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 34      Corrected terminal type setting test, installed the
 35      clean_up_init_mowse_info routine, and added the force request to the
 36      command.
 37   9) change(87-03-24,Flegel), approve(87-03-24,MCR7580),
 38      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 39      Changed call to iox_$open_file in order to pass escape and EOP character
 40      information to mowse_io_.
 41                                                    END HISTORY COMMENTS */
 42 
 43 /* format: style4,indattr,ifthen,^indcomtxt,thendo,^indproc,^indblkcom,initcol1,declareind8,dclind4,struclvlind3,comcol55 */
 44 atm:
 45 attach_mowse:
 46      proc ();
 47 
 48 /* : PROGRAM FUNCTION
 49 
 50 Attach the MOWSE environment to the user's process.
 51 */
 52 
 53 /* : NOTES
 54 
 55 The MOWSE environment is to be used only by the user when (s)he has logged
 56 into Multics through the MOWSE environment on a Personal Computer.  Failure to
 57 do so will result in a "hung" terminal.
 58 
 59 MOWSE will be attached before tty_.  If tty_ does not exist, then attachment
 60 will fail.
 61 
 62 Below is a before/after look of the io switch attachments:
 63 
 64   --|
 65   --+--...--<foo_i/o>-- tty_
 66   --|
 67 
 68   --|
 69   --+--...--<foo_i/o>-- syn_ --<mowse_i/o>-- mowse_io_ --<mowse_tty>-- tty_
 70   --|
 71 */
 72 
 73 
 74 /* MISC VARIABLES */
 75 dcl open_descrip           char (32);                 /* Open description arguments */
 76 dcl err_string             char (512) var;
 77 dcl iocb_ptr               ptr;
 78 dcl switch_name            char (32);                 /* Switch name to attach to */
 79 dcl arg_count              fixed bin;                 /* Number of arguments */
 80 dcl arg_list_ptr           ptr;                       /* Pointer to argument list */
 81 dcl mowse_iocb_ptr         ptr;                       /* Pointer to Mowse control block */
 82 dcl syn_iocb_ptr           ptr;                       /* Pointer to Syn Mowse control block */
 83 dcl code                   fixed bin (35);            /* Error code */
 84 dcl old_mask               bit (36) aligned;          /* IPS mask */
 85 dcl new_mask               bit (36) aligned;          /* IPS mask */
 86 
 87 /* STRUCTURES */
 88 dcl 01 term_info           like terminal_info aligned automatic;
 89 dcl 01 info                like mowse_io_info automatic;
 90 
 91 /* SYSTEM CALLS */
 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 /* SYSTEM CALL SUPPORT */
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;            /* User_i/o IOCB */
114 
115 
116 /* EXTERNAL CALLS */
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 /* EXTERNAL CALL SUPPORT */
124 
125 
126 /* BUILTINS */
127 dcl addr                   builtin;
128 dcl length                 builtin;
129 dcl null                   builtin;
130 dcl index                  builtin;
131 
132 /* CONDITIONS */
133 
134 
135 /* CONSTANTS */
136 dcl MY_NAME                char (12) int static options (constant)
137                            init ("attach_mowse");
138 
139 
140 /*^L*/
141 /* INITIALIZATION */
142           open_struc_ptr = addr (open_descrip);
143           init_mowse_info_ptr = null;
144           new_mask = ""b;
145 
146 /* MAIN */
147 
148 /* : MOWSE already attached? */
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 /* : Parse the arglist */
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 /* : Call arg_list parser routine */
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 /* : See if we are on an acceptable terminal type */
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 /* : Find the iocb of the switch (if specified) under which to attach,
197      otherwise next to tty_ */
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 /* : Create mowse_tty control block */
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 /* : Create mowse_i/o control block */
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 /* : Move mowse_i/o onto the iocb above tty_ */
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 /* : Attach the syn_ */
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 /* : Move mowse_i/o to mowse_io_ */
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 /* : Attach mowse_io_ to tty_ */
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 /* : Open mowse_io_ */
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 /* : Initialization of mowse */
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 /* : Set up the mowse_info_ structure */
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 /*^L*/
326 
327 /* : Label entries to transfer control to when a failure occurs during the
328      attachment / movement of the iocbs */
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 /*^L*/
352 
353 /* INTERNAL PROCEDURES */
354 
355 /* : *** Procedure clean_up_init_mowse_ptr: internal procedure for atm *** */
356 
357 clean_up_init_mowse_info:
358      proc (p_info_ptr);
359 
360 /* : PROCEDURE FUNCTION
361 
362 Free the init_mowse_info structure if the pointer is not null.
363 */
364 
365 /* INPUT PARAMETERS */
366 dcl p_info_ptr             ptr parameter;
367 
368 /* INITIALIZATION */
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 /*^L*/
377 
378 %page;
379 /* INCLUDE FILES */
380 %include iox_modes;
381 %include terminal_info;
382 %include mowse_info;
383 %include iocbv;
384 %include mowse_io_control_info;
385 
386 /* : END */
387      end;