1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 firmware_util_: proc;
16 return;
17
18
19
20 dcl fwptr ptr;
21 dcl code fixed bin (35);
22 dcl ident char (6);
23 dcl name char (4);
24 dcl segp ptr;
25 dcl seglen fixed bin (18);
26
27
28
29 dcl dir char (168);
30 dcl ename char (32);
31 dcl v_ename char (32) varying;
32 dcl segname char (32);
33 dcl ac_code fixed bin;
34 dcl head_ptr ptr;
35 dcl temp_ptr ptr;
36 dcl star_sw bit (1);
37 dcl bit_count fixed bin (24);
38
39
40
41 dcl get_wdir_ entry returns (char (168));
42 dcl hcs_$initiate entry (char (*), char (*), char (*), fixed bin (1), fixed bin (2), ptr, fixed bin (35));
43 dcl hcs_$terminate_noname entry (ptr, fixed bin (35));
44 dcl archive_util_$first_element entry (ptr, fixed bin);
45 dcl archive_util_$first_disected entry (ptr, ptr, char (32), fixed bin (24), fixed bin);
46 dcl archive_util_$disected_element entry (ptr, ptr, char (32), fixed bin (24), fixed bin);
47 dcl match_star_name_ entry (char (*), char (*), fixed bin (35));
48
49 dcl error_table_$noentry ext fixed bin (35);
50 dcl error_table_$archive_fmt_err ext fixed bin (35);
51 dcl error_table_$zero_length_seg ext fixed bin (35);
52
53 dcl (divide, index, null, substr) builtin;
54
55
56
57
58 init: entry (fwptr, code);
59
60 dir = get_wdir_ ();
61 call hcs_$initiate (dir, "firmware.archive", "", 0, 0, fwptr, code);
62 if fwptr = null then do;
63 call hcs_$initiate (">firmware", "firmware.archive", "", 0, 0, fwptr, code);
64 if fwptr = null then return;
65 end;
66 call archive_util_$first_element (fwptr, ac_code);
67 if ac_code = 0 then do;
68 code = 0;
69 return;
70 end;
71 call hcs_$terminate_noname (fwptr, code);
72 if ac_code = 1 then code = error_table_$zero_length_seg;
73 else code = error_table_$archive_fmt_err;
74 return;
75
76
77
78
79 find: entry (fwptr, ident, name, segp, seglen, code);
80
81
82
83 star_sw = "0"b;
84 v_ename = "fw.";
85 v_ename = v_ename || cvt_name (ident);
86 v_ename = v_ename || ".";
87 v_ename = v_ename || cvt_name (name);
88 ename = v_ename;
89
90
91
92 head_ptr = fwptr;
93 call archive_util_$first_disected (head_ptr, temp_ptr, segname, bit_count, ac_code);
94 if ac_code ^= 0 then do;
95 if ac_code = 1 then code = error_table_$zero_length_seg;
96 else code = error_table_$archive_fmt_err;
97 segp = null;
98 seglen = 0;
99 return;
100 end;
101
102
103
104 check: if star_sw then do;
105 call match_star_name_ (segname, ename, code);
106 if code = 0 then go to hit;
107 end;
108 else if segname = ename then go to hit;
109
110
111
112 call archive_util_$disected_element (head_ptr, temp_ptr, segname, bit_count, ac_code);
113 if ac_code = 0 then go to check;
114 if ac_code = 1 then code = error_table_$noentry;
115 else code = error_table_$archive_fmt_err;
116 segp = null;
117 seglen = 0;
118 return;
119
120
121
122 hit: segp = temp_ptr;
123 seglen = divide (bit_count, 36, 18, 0);
124 code = 0;
125 return;
126
127
128
129 cvt_name: proc (string) returns (char (6) var);
130
131 dcl string char (*);
132 dcl temp char (6);
133 dcl i fixed bin;
134
135 temp = string;
136 loop: if temp = "" | temp = "*" then do;
137 star_sw = "1"b;
138 return ("*");
139 end;
140 i = index (temp, " ");
141 if i = 0 then return (temp);
142 if i = 1 then do;
143 temp = substr (temp, 2);
144 go to loop;
145 end;
146 return (substr (temp, 1, i-1));
147
148 end cvt_name;
149
150
151
152
153
154 end firmware_util_;