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      Looks for the switch attached to mowse_io_ rather than always to
 16      user_i/o.
 17   3) change(86-10-07,Flegel), approve(87-07-15,MCR7580),
 18      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 19      Removes the syn_ attached above mowse_io_. Change to find support new
 20      names for io switches, added call to flush both subchannels being
 21      transmitted.
 22   4) change(86-10-09,Flegel), approve(87-07-15,MCR7580),
 23      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 24      Masked around critical switch movements.
 25   5) change(86-10-10,Flegel), approve(87-07-15,MCR7580),
 26      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 27      Look for user_terminal_ as we cannot detach with the video system
 28      invoked.
 29   6) change(86-11-27,Flegel), approve(86-11-27,MCR7580),
 30      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 31      Approved.
 32   7) change(86-12-03,Flegel), approve(86-12-03,MCR7580),
 33      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 34      Removed flushing of background subchannel.
 35   8) change(86-12-11,Flegel), approve(86-12-11,MCR7580),
 36      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 37      Removed external static "interactive_initiated_disconnect" and replaced
 38      with a call iox_$close_file to mowse_i/o to tell mowse_io_ what kind of
 39      disconnect to perform with the PC.
 40                                                    END HISTORY COMMENTS */
 41 
 42 /* format: style4,indattr,ifthen,^indcomtxt,thendo,^indproc,^indblkcom,initcol1,declareind8,dclind4,struclvlind3,comcol55 */
 43 dtm:
 44 detach_mowse:
 45      proc ();
 46 
 47 /* : PROGRAM FUNCTION
 48 
 49 Detach the MOWSE environment.
 50 */
 51 
 52 /* : NOTES
 53 */
 54 
 55 /* MISC VARIABLES */
 56 dcl new_mask               bit (36) aligned;          /* IPS mask */
 57 dcl old_mask               bit (36) aligned;          /* IPS mask */
 58 dcl syn_iocb_ptr           ptr;                       /* The iocb attached to the syn_ for mowse_i/o */
 59 dcl iocb_ptr               ptr;                       /* The iocb attached before mowse_io_ */
 60 dcl mowse_iocb_ptr         ptr;
 61 dcl code                   fixed bin (35);
 62 
 63 /* STRUCTURES */
 64 dcl 01 fsc                 like mowse_io_flush_subchannel_info automatic;
 65 
 66 /* EXTERNAL STATIC */
 67 
 68 /* SYSTEM CALLS */
 69 dcl hcs_$set_ips_mask      entry (bit (36) aligned, bit (36) aligned);
 70 dcl hcs_$reset_ips_mask    entry (bit (36) aligned, bit (36) aligned);
 71 dcl iox_$control           entry (ptr, char (*), ptr, fixed bin (35));
 72 dcl terminate_process_     entry (char (*), ptr);
 73 dcl iox_$destroy_iocb      entry (ptr, fixed bin (35));
 74 dcl iox_$look_iocb         entry (char (*), ptr, fixed bin (35));
 75 dcl com_err_               entry () options (variable);
 76 dcl iox_$move_attach       entry (ptr, ptr, fixed bin (35));
 77 dcl iox_$detach_iocb       entry (ptr, fixed bin (35));
 78 dcl iox_$close             entry (ptr, fixed bin (35));
 79 dcl iox_$close_file        entry (ptr, char (*), fixed bin (35));
 80 
 81 
 82 /* SYSTEM CALL SUPPORT */
 83 dcl ws_error_$ws_video_invoked
 84                            fixed bin (35) ext static;
 85 dcl error_table_$unable_to_do_io
 86                            fixed bin (35) ext static;
 87 
 88 
 89 /* EXTERNAL CALLS */
 90 dcl get_at_                entry (char (*), char (*), ptr, fixed bin (35));
 91 
 92 
 93 /* EXTERNAL CALL SUPPORT */
 94 
 95 
 96 /* BUILTINS */
 97 dcl addr                   builtin;
 98 
 99 
100 /* CONDITIONS */
101 
102 
103 /* CONSTANTS */
104 dcl dtm_name               char (12) int static options (constant)
105                            init ("detach_mowse");
106 
107 /*^L*/
108 /* INITIALIZATION */
109 
110 
111 /* MAIN */
112 
113 /* : If mowse_i/o not found, return */
114 
115           call iox_$look_iocb ("mowse_tty", mowse_iocb_ptr, code);
116           if code ^= 0 then do;
117                call com_err_ (code, dtm_name, "While looking for mowse_tty.");
118                return;
119           end;
120 
121 /* : Find the mowse_i/o switch */
122 
123           call iox_$look_iocb ("mowse_i/o", syn_iocb_ptr, code);
124           if code ^= 0 then do;
125                call com_err_ (code, dtm_name, "While looking for mowse_i/o.");
126                return;
127           end;
128 
129 /* : Look for the user_terminal_ IOCB so that if it exists, the detachment
130      will fail */
131 
132           call iox_$look_iocb ("user_terminal_", iocb_ptr, code);
133           if code = 0 then do;
134                call com_err_ (ws_error_$ws_video_invoked, dtm_name,
135                     "MOWSE not detached.");
136                return;
137           end;
138 
139 /* : Flush both FG and BG subchannels */
140 
141           fsc.version = mowse_io_info_version_1;
142           fsc.subchannel = FG;
143           call iox_$control (syn_iocb_ptr, "flush_subchannel", addr (fsc),
144                (0));
145 
146 /* : Find the switch attached to mowse_io_ */
147 
148           call get_at_ ("syn_", "mowse_i/o", iocb_ptr, code);
149           if code ^= 0 then do;
150                call com_err_ (code, dtm_name,
151                     "Finding iocb attached to mowse_io_.");
152                return;
153           end;
154 
155 /* : Close MOWSE */
156 
157           call iox_$close_file (iocb_ptr, "confirmed_disconnect", code);
158 
159           if code ^= 0 then do;
160                call com_err_ (code, dtm_name,
161                     "While closing ^a.", iocb_ptr -> iocb.name);
162                return;
163           end;
164 
165 /* : Detach MOWSE */
166 
167           new_mask = ""b;
168           call hcs_$set_ips_mask (new_mask, old_mask);
169           call iox_$detach_iocb (iocb_ptr, code);
170           if code ^= 0 then do;
171                call hcs_$reset_ips_mask (old_mask, new_mask);
172                call fatal_return ();
173           end;
174 
175 /* : Attach the iocb above mowse_i/o to tty_ */
176 
177           call iox_$move_attach (mowse_iocb_ptr, iocb_ptr, code);
178           if code ^= 0 then do;
179                call hcs_$reset_ips_mask (old_mask, new_mask);
180                call fatal_return ();
181           end;
182           call hcs_$reset_ips_mask (old_mask, new_mask);
183 
184 /* : Destroy the iocb to mowse_tty (it is in limbo as the switches have been
185      moved around from foo_i/o to tty_) */
186 
187           call iox_$destroy_iocb (mowse_iocb_ptr, code);
188           if code ^= 0 then do;
189                call com_err_ (code, dtm_name, "Destroying ^a.",
190                     mowse_iocb_ptr -> iocb.name);
191                return;
192           end;
193 
194 /* : Close the mowse_i/o (It better be there or all of MOWSE would not have
195      been working properly) */
196 
197           call iox_$close (syn_iocb_ptr, (0));
198           call iox_$detach_iocb (syn_iocb_ptr, (0));
199           call iox_$destroy_iocb (syn_iocb_ptr, (0));
200 
201 /*^L*/
202 /* INTERNAL PROCEDURES */
203 
204 /* : *** fatal_return: Internal procedure for detach_mowse *** */
205 
206 fatal_return:
207      proc ();
208 
209 /* : PROCEDURE FUNCTION
210 
211 Invoke a call to terminate_process because something really bad has happened.
212 */
213 
214 /* STRUCTURES */
215 dcl 01 fatal_error_info    aligned,
216        02 version          fixed bin,                 /* Must be 0 */
217        02 status_code      fixed bin (35);            /* Error code to terminate_process_ */
218 
219 
220           fatal_error_info.version = 0;
221           fatal_error_info.status_code = error_table_$unable_to_do_io;
222           call terminate_process_ ("fatal_error", addr (fatal_error_info));
223 
224      end fatal_return;
225 
226 %page;
227 /* INCLUDE FILES */
228 %include iocbv;
229 %include mowse_messages;
230 %include mowse_io_control_info;
231 %include mowse;
232 
233 /* : END */
234      end;