1 add_epilogue: proc (cmnd_line);
2
3 dcl cmnd_line char (*);
4
5 dcl cu_$arg_count entry (fixed bin),
6 nargs fixed bin;
7 dcl add_epilogue_handler_ entry (entry, fixed bin (35));
8 dcl err fixed bin (35);
9 dcl ioa_$ioa_stream entry options (variable),
10 exec_com entry options (variable),
11 stream_name char (16) init ("add_epilogue.str") static internal options (constant),
12 stream_iocb ptr;
13 dcl iox_$attach_name entry (char (*), ptr, char (*), ptr, fixed bin (35)),
14 iox_$open entry (ptr, fixed bin, bit (1) aligned, fixed bin (35)),
15 iox_$close entry (ptr, fixed bin (35));
16 dcl (error_table_$noarg,
17 error_table_$not_detached,
18 error_table_$not_closed) fixed bin (35) static external;
19 dcl (attached_here, open_here) bit (1);
20 dcl com_err_ entry options (variable);
21 dcl get_pdir_ entry () returns (char (168)),
22 pdir_name char (168);
23
24 dcl prog char (12) init ("add_epilogue") static internal options (constant);
25 dcl (addr, null, rtrim) builtin;
26
27
28
29 call cu_$arg_count (nargs);
30 if nargs = 0 then do;
31 call com_err_ (error_table_$noarg, prog,
32 "Usage:^/ ^a Command-string^/ Command-string in quotes if it contains spaces",
33 prog);
34 return;
35 end;
36 else if nargs > 1 then do;
37 call com_err_ (0, prog, "excess arguments. put command line in quotes");
38 return;
39 end;
40
41 pdir_name = get_pdir_ ();
42
43 call iox_$attach_name (stream_name, stream_iocb,
44 "vfile_ " || rtrim (pdir_name) || ">dynamic_epilogue_.ec -extend",
45 null (), err);
46 if err = 0 then
47 attached_here = "1"b;
48 else if err = error_table_$not_detached then
49 attached_here = "0"b;
50 else do;
51 io_err: call com_err_ (err, prog, "^a>^a", pdir_name, stream_name);
52 return;
53 end;
54
55 call iox_$open (stream_iocb, 2, "0"b, err);
56 if err = 0 then
57 open_here = "1"b;
58 else if err = error_table_$not_closed then
59 open_here = "0"b;
60 else goto io_err;
61
62 if attached_here then
63 call ioa_$ioa_stream (stream_name, "&command_line off");
64 call ioa_$ioa_stream (stream_name, "^a", cmnd_line);
65
66 if open_here then do;
67 call iox_$close (stream_iocb, err);
68 if err ^= 0 then
69 call com_err_ (err, prog, stream_name);
70 end;
71
72 if attached_here then do;
73 call add_epilogue_handler_ (dynamic_epilogue_, err);
74 if err ^= 0 then
75 call com_err_ (err, prog, "dynamic_epilogue_");
76 end;
77
78 return;
79
80
81 dynamic_epilogue_: entry ();
82 pdir_name = get_pdir_ ();
83
84 call exec_com (rtrim (pdir_name) || ">dynamic_epilogue_");
85 return;
86
87 end add_epilogue;