1
2
3
4
5
6
7 detach_audit:
8 dta:
9 proc;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 dcl nargs fixed bin;
27 dcl tc fixed bin;
28 dcl tp ptr;
29 dcl blkptr ptr;
30 dcl old_iocb ptr;
31 dcl new_iocb ptr;
32 dcl code fixed bin (35);
33
34
35
36 dcl targ char (tc) based (tp);
37
38
39
40 dcl MYNAME char (12) init ("detach_audit") internal static options (constant);
41
42
43
44 dcl audit_$audit_close entry;
45 dcl cu_$arg_count entry (fixed bin);
46 dcl cu_$arg_ptr entry (fixed bin, ptr, fixed bin, fixed bin (35));
47 dcl ioa_$ioa_switch entry options (variable);
48 dcl iox_$look_iocb entry (char (*), ptr, fixed bin (35));
49 dcl iox_$move_attach entry (ptr, ptr, fixed bin (35));
50 dcl iox_$detach_iocb entry (ptr, fixed bin (35));
51 dcl iox_$destroy_iocb entry (ptr, fixed bin (35));
52 dcl iox_$close entry (ptr, fixed bin (35));
53 dcl com_err_ entry options (variable);
54
55
56
57 dcl error_table_$badopt fixed bin (35) ext;
58 ^L
59 call cu_$arg_count (nargs);
60 if nargs > 1
61 then
62 do;
63 call com_err_ (error_table_$badopt, MYNAME, "Too many arguments.^/Usage: detach_audit {switchname}");
64 return;
65 end;
66 else if nargs = 1
67 then call cu_$arg_ptr (1, tp, tc, code);
68 else
69 do;
70 tc = 8;
71 alloc targ;
72 targ = "user_i/o";
73 end;
74 call iox_$look_iocb ((targ), old_iocb, code);
75 if code ^= 0
76 then
77 do;
78 call com_err_ (code, MYNAME, "while looking for ^a", targ);
79 return;
80 end;
81
82 if old_iocb -> iocb.close ^= audit_$audit_close
83 then
84 do;
85 call com_err_ (0, MYNAME, "^a not attached via audit_", targ);
86 return;
87 end;
88
89 blkptr = old_iocb -> iocb.attach_data_ptr;
90 new_iocb = blkptr -> blk.auditing_iocb;
91
92 call iox_$close (old_iocb, code);
93 if code ^= 0
94 then
95 do;
96 call com_err_ (code, MYNAME, "while closing ^a switch", targ);
97 return;
98 end;
99
100 call iox_$detach_iocb (old_iocb, code);
101 if code ^= 0
102 then
103 do;
104 call ioa_$ioa_switch (new_iocb, "Couldn't detach ^a", targ);
105 return;
106 end;
107
108
109 call iox_$move_attach (new_iocb, old_iocb, code);
110 if code ^= 0
111 then
112 do;
113 call com_err_ (code, MYNAME, "while moving attachment from ^a to ^a", new_iocb -> iocb.name, targ);
114 return;
115 end;
116
117 call iox_$destroy_iocb (new_iocb, code);
118 if code ^= 0
119 then
120 do;
121 call com_err_ (code, MYNAME, "Unable to destroy the auditing iocb. Auditing was successfully
122 detached for switch ""^a"", however.", targ);
123 end;
124
125 return;
126
127
128
129 %include iocb;
130 %include audit_block;
131
132 end;