1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 edit_mst_header: emh: proc;
18
19 dcl name_ptr ptr,
20 namel fixed bin(17),
21 name char(namel) based(name_ptr),
22 acinfo fixed bin(35),
23 code fixed bin(17),
24 dir char(168),
25 entry char(32),
26 leave label init(finish),
27 i fixed bin(17),
28 nposition fixed bin(17) init(1),
29 nptr ptr init(null),
30 nstring char(262144) based(nptr),
31 bc fixed bin(17),
32 estring char(einfo.end_of_data) based(einfo.segment_ptr),
33 ostring char(oinfo.end_of_data) based(oinfo.segment_ptr),
34 optr ptr,
35 eptr ptr,
36 okey char(40) aligned,
37 ekey char(40) aligned,
38 action fixed bin(17);
39
40 dcl nl char(1) internal static init("
41 ");
42
43 dcl 1 oinfo,
44 2 segment_ptr ptr init(null),
45 2 begin_section fixed bin(17),
46 2 position fixed bin(17) init(0),
47 2 finish fixed bin(17) init(0),
48 2 end_of_data fixed bin(17);
49
50 dcl 1 einfo,
51 2 segment_ptr ptr init(null),
52 2 begin_section fixed bin(17),
53 2 position fixed bin(17) init(0),
54 2 finish fixed bin(17) init(0),
55 2 end_of_data fixed bin(17);
56
57 dcl get_section internal entry(ptr,fixed bin(17),char(40) aligned);
58
59
60 dcl hcs_$terminate_noname ext entry(ptr,fixed bin(17)),
61 hcs_$fs_search_get_wdir ext entry(ptr,fixed bin(17)),
62 ti_$getseg ext entry,
63 ti_$findata ext entry(ptr,fixed bin(17),fixed bin(35),fixed bin(17)),
64 expand_path_ ext entry(ptr,fixed bin(17),ptr,ptr,fixed bin(17)),
65 cu_$arg_ptr ext entry(fixed bin(17),ptr,fixed bin(17),fixed bin(17)),
66 hcs_$initiate_count ext entry,
67 com_err_ ext entry;
68
69 dcl error_table_$entlong ext fixed bin(17);
70
71
72 call cu_$arg_ptr(2,name_ptr,namel,code);
73 if code ^= 0 then do;
74 dir = "";
75 error: call com_err_(code,"edit_mst_header",dir);
76 finish: if nptr ^= null then do;
77 substr(nstring,nposition,1) = nl;
78 call ti_$findata(nptr,9*nposition,acinfo,code);
79 end;
80 if einfo.segment_ptr ^= null then call hcs_$terminate_noname(einfo.segment_ptr,code);
81
82 if oinfo.segment_ptr ^= null then call hcs_$terminate_noname(oinfo.segment_ptr,code);
83
84 return;
85 end;
86 if name = "-hard" then do;
87 dir = ">library_dir_dir>hard>info";
88 entry = "hardcore.header";
89 end;
90 else if name = "-soft" then do;
91 dir = ">library_dir_dir>soft>info";
92 entry = "softcore.header";
93 end;
94 else do;
95 call expand_path_(name_ptr,namel,addr(dir),addr(entry),code);
96
97 if code ^= 0 then do;
98 dir = name;
99 go to error;
100 end;
101 do i = 32 by -1 to 1 while(substr(entry,i,1) = " ");
102 end;
103 if i < 1 | i > 25 then do;
104 code = error_table_$entlong;
105 dir = substr(entry,1,i)||".header";
106 go to error;
107 end;
108 substr(entry,i+1,7) = ".header";
109 end;
110 call hcs_$initiate_count(dir,entry,"",bc,1,oinfo.segment_ptr,code);
111
112 if oinfo.segment_ptr = null then do;
113 path_err: do i = 168 by -1 to 1 while(substr(dir,i,1) = " ");
114 end;
115 substr(dir,i+1,1) = ">";
116 substr(dir,i+2,min(32,167-i)) = entry;
117 go to error;
118 end;
119 oinfo.end_of_data = divide(bc,9,17,0);
120 call cu_$arg_ptr(1,name_ptr,namel,code);
121 if code ^= 0 then do;
122 dir = "";
123 go to error;
124 end;
125 call expand_path_(name_ptr,namel,addr(dir),addr(entry),code);
126 if code ^= 0 then do;
127 dir = name;
128 go to error;
129 end;
130 do i = 32 by -1 to 1 while(substr(entry,i,1) = " ");
131 end;
132 if i < 1 | i > 20 then do;
133 code = error_table_$entlong;
134 dir = substr(entry,1,i)||".edit_header";
135 go to error;
136 end;
137 substr(entry,i+1,12) = ".edit_header";
138 call hcs_$initiate_count(dir,entry,"",bc,1,einfo.segment_ptr,code);
139
140 if einfo.segment_ptr = null then go to path_err;
141 einfo.end_of_data = divide(bc,9,17,0);
142 call cu_$arg_ptr(3,name_ptr,namel,code);
143 if code ^= 0 then do;
144 substr(entry,i+1,32-i) = ".header";
145 call hcs_$fs_search_get_wdir(addr(dir),code);
146 end;
147 else do;
148 call expand_path_(name_ptr,namel,addr(dir),addr(entry),code);
149 if code ^= 0 then do;
150 dir = name;
151 go to error;
152 end;
153 do i = 32 by -1 to 1 while(substr(entry,i,1) = " ");
154 end;
155 if i < 1 | i > 25 then do;
156 code = error_table_$entlong;
157 dir = substr(entry,1,i)||".header";
158 go to error;
159 end;
160 substr(entry,i+1,7) = ".header";
161 end;
162 call ti_$getseg(dir,entry,nptr,acinfo,code);
163
164 if nptr = null then go to path_err;
165 optr = addr(oinfo);
166 eptr = addr(einfo);
167 call get_section(optr,i,okey);
168 next: call get_section(eptr,action,ekey);
169 if einfo.finish = 1 then go to finish;
170 if action > 3 then do;
171 do while(ekey ^= okey);
172 call get_section(optr,i,okey);
173 end;
174 if action = 5 then call get_section(optr,i,okey);
175
176 end;
177 else if action > 0 then do;
178 do while(ekey ^= okey);
179 i = oinfo.position-oinfo.begin_section+1;
180 substr(nstring,nposition,i) = substr(ostring,oinfo.begin_section,i);
181 nposition = nposition + i;
182 call get_section(optr,i,okey);
183 end;
184 if action = 2 then do;
185 i = oinfo.position-oinfo.begin_section+1;
186 substr(nstring,nposition,i) = substr(ostring,oinfo.begin_section,i);
187 nposition = nposition + i;
188 end;
189 if action < 3 then call get_section(optr,i,okey);
190
191 end;
192 if action < 2 then do;
193 i = einfo.position-einfo.begin_section+1;
194 substr(nstring,nposition,1) = nl;
195 substr(nstring,nposition+1,i) = substr(estring,einfo.begin_section,i);
196 nposition = nposition + i + 1;
197 end;
198 go to next;
199
200
201
202
203 get_section: proc(segptr,action,key);
204
205 dcl segptr ptr,
206 action fixed bin(17),
207 key char(40) aligned,
208 string char(stringl) based(string_ptr),
209 stringl fixed bin(17),
210 string_ptr ptr,
211 linespace char(40),
212 line char(ll) based(line_ptr),
213 line_ptr ptr init(addr(linespace)),
214 ll fixed bin(17);
215
216 dcl 1 info based(segptr),
217 2 seg_ptr ptr,
218 2 begin_sect fixed bin(17),
219 2 pos fixed bin(17),
220 2 fin fixed bin(17),
221 2 eod fixed bin(17);
222
223 dcl get_line internal entry;
224
225 stringl = eod;
226 string_ptr = seg_ptr;
227 if fin = 1 then do;
228 call com_err_(0,"edit_mst_header","Premature end of data reached on old header segment.
229 Current line is: ^a",ekey);
230 go to leave;
231 end;
232 begin_sect = pos + 1;
233 call get_line(0,":;");
234 if fin = 1 then if ll = 0 then return;
235 if line = "copy_to,replace:" then action = 1;
236 else if line = "copy_to,reload:" then action = 1;
237 else if line = "copy_to:" then action = 3;
238 else if line = "copy_thru:" then action = 2;
239 else if line = "skip_to:" then action = 4;
240 else if line = "skip_thru:" then action = 5;
241 else do;
242 action = 0;
243 go to skip;
244 end;
245 begin_sect = pos + 1;
246 call get_line(0,":;");
247 skip: if line = "collection:" then do;
248 call get_line(11,",;");
249 end;
250 else if line ^= "fini:" then do;
251 call get_line(ll,",;");
252 call get_line(ll,"");
253 end;
254 key = line;
255 if fin = 1 then do;
256 call com_err_(0,"edit_mst_header","Premature end of header section. ^a",substr(string,begin_sect,
257 eod-begin_sect+1));
258 go to leave;
259 end;
260 return;
261
262
263
264
265
266 get_line: proc(offset,breaks);
267
268 dcl offset fixed bin(17),
269 breaks char(*),
270 ch char(1),
271 i fixed bin(17),
272 end_flag fixed bin(17) init(0),
273 tab char(1) internal static init(" ");
274
275 if length(breaks) = 0 then end_flag = 1;
276 ll = offset;
277 do pos = pos + 1 to eod;
278 new_char: ch = substr(string,pos,1);
279 if ch = "/" then if eod-pos > 2 then if substr(string,pos+1,1) = "*" then do;
280
281 i = index(substr(string,pos+2,eod-pos-1),"*/");
282 if i = 0 then do;
283 call com_err_(0,"edit_mst_header","Unended comment. ^a",
284 substr(string,pos,eod-pos+1));
285 go to leave;
286 end;
287 pos = i + pos + 3;
288 go to new_char;
289 end;
290 if ch ^= " " then if ch ^= tab then if ch ^= nl then do;
291 if end_flag ^= 0 then do;
292 if ch = "e" then end_flag = 2;
293 else if end_flag ^= 1 then do;
294 if ch = "n" & end_flag = 2 then end_flag = 3;
295
296 else if ch = "d" & end_flag = 3 then end_flag = 4;
297
298 else if ch = ";" & end_flag = 4 then return;
299
300 else end_flag = 1;
301 end;
302 end;
303 else do;
304 ll = ll + 1;
305 if ll > 40 then do;
306 call com_err_(0,"edit_mst_header","Statement too long. ^a",line);
307 go to leave;
308 end;
309 do i = 1 to length(breaks);
310 if ch = substr(breaks,i,1) then do;
311 substr(linespace,ll,1) = substr(breaks,1,1);
312
313 return;
314 end;
315 end;
316 substr(linespace,ll,1) = ch;
317 end;
318 end;
319 end;
320 fin = 1;
321 end get_line;
322 end get_section;
323 end edit_mst_header;