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 dtm:
44 detach_mowse:
45 proc ();
46
47
48
49
50
51
52
53
54
55
56 dcl new_mask bit (36) aligned;
57 dcl old_mask bit (36) aligned;
58 dcl syn_iocb_ptr ptr;
59 dcl iocb_ptr ptr;
60 dcl mowse_iocb_ptr ptr;
61 dcl code fixed bin (35);
62
63
64 dcl 01 fsc like mowse_io_flush_subchannel_info automatic;
65
66
67
68
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
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
90 dcl get_at_ entry (char (*), char (*), ptr, fixed bin (35));
91
92
93
94
95
96
97 dcl addr builtin;
98
99
100
101
102
103
104 dcl dtm_name char (12) int static options (constant)
105 init ("detach_mowse");
106
107
108
109
110
111
112
113
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
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
130
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
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
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
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
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
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
185
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
195
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
202
203
204
205
206 fatal_return:
207 proc ();
208
209
210
211
212
213
214
215 dcl 01 fatal_error_info aligned,
216 02 version fixed bin,
217 02 status_code fixed bin (35);
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
228 %include iocbv;
229 %include mowse_messages;
230 %include mowse_io_control_info;
231 %include mowse;
232
233
234 end;