1
2
3
4
5
6
7
8
9
10
11
12
13 bk_retrieve: proc;
14
15
16
17
18
19
20
21
22
23
24
25
26
27 dcl (i, j, k, l, n, htype) fixed bin,
28 path_name char (168),
29 old_dname char (168) init (""),
30 code fixed bin (35);
31
32
33 dcl line char (300) static,
34 line_pointer ptr static,
35 hp ptr static,
36 a_hp ptr;
37
38 dcl nl char (1) static;
39
40 dcl rname char (168) aligned,
41 rdname char (168) static aligned,
42 rename char (32) aligned static,
43 (rsize, rbc) fixed bin;
44
45 dcl (rptr, reqptr) ptr static;
46
47 dcl (parsed, next, stop, terminate, reported, checked) fixed bin static;
48
49 dcl label_index fixed bin;
50
51 dcl (rlines, rfin, rcomp,
52 rcurr, ncurr) fixed bin static,
53 grt_count fixed bin;
54
55 dcl 1 req based (reqptr) aligned,
56 2 path_copy char (168),
57 2 opt (1000),
58 3 (rename,
59 exact,
60 synonym,
61 found,
62 finished,
63 spare) bit (1) unaligned,
64 2 srch (1000),
65 3 (len,
66 grt,
67 control_index,
68 renamo) fixed bin,
69 3 name char (168),
70 2 newn (200),
71 3 (ndlen, nelen, ngrt) fixed bin,
72 3 ndname char (168);
73
74 dcl (rscan (1000000) char (1), rmove char (1000000)) based,
75 rset bit (6) based;
76
77 dcl (error_table_$badcall, error_table_$bad_string,
78 error_table_$smallarg, error_table_$badpath, error_table_$noentry,
79 error_table_$no_dir, error_table_$no_s_permission,
80 error_table_$moderr, error_table_$no_info,
81 error_table_$arg_ignored, error_table_$segknown) external fixed bin (35);
82
83 dcl (addr, baseptr, divide, fixed, index, length, reverse, rtrim, substr, unspec, verify) builtin;
84
85 dcl backup_map_$fs_error_line entry (fixed bin (35), char (*) aligned, char (*) aligned, char (*) aligned),
86 backup_map_$on_line entry (ptr, fixed bin),
87 backup_util$get_real_name entry (ptr, ptr, fixed bin, fixed bin (35)),
88 expand_pathname_ entry (char (*) aligned, char (*) aligned, char (*) aligned, fixed bin (35));
89
90 dcl hcs_$make_seg entry (char (*), char (*), char (*), fixed bin (5), ptr, fixed bin (35)),
91 hcs_$terminate_noname entry (ptr, fixed bin (35)),
92 hcs_$truncate_seg entry (ptr, fixed bin, fixed bin (35)),
93 hcs_$initiate_count entry (char (*) aligned, char (*) aligned, char (*), fixed bin, fixed bin (2), ptr, fixed bin (35));
94
95 dcl (com_err_, ioa_, ioa_$rsnnl) ext entry options (variable);
96
97
98
99 %include bk_ss_;
100 %page;
101 %include backup_control;
102 %page;
103 %include backup_preamble_header;
104 %page;
105 %include backup_record_types;
106
107
108
109
110
111 check_retrieval: entry (label_index);
112
113 if rfin = rcomp then do;
114 call ioa_$rsnnl ("^a: all requests satisfied.", line, n, bk_ss_$myname);
115 call backup_map_$on_line (line_pointer, n);
116 label_index = stop;
117 go to exit;
118 end;
119
120 htype = hp -> h.record_type;
121 hp -> h.dlen = length (rtrim (hp -> h.dname));
122 path_name = substr (hp -> h.dname, 1, hp -> h.dlen) || ">";
123 n = hp -> h.dlen + 1;
124 if hp -> h.elen ^= 0 then do;
125 hp -> h.elen = length (rtrim (hp -> h.ename));
126 substr (path_name, n + 1) = substr (hp -> h.ename, 1, hp -> h.elen) || ">";
127 n = n + hp -> h.elen + 1;
128 end;
129 if rcurr ^= 0 then do;
130 i = rcurr;
131 req.path_copy = req.srch.name (i);
132 if substr (path_name, 1, req.srch.len (i)) = req.path_copy then
133 go to match;
134 if bk_ss_$onlysw & req.opt.found (i) then do;
135 req.opt.finished (i) = "1"b;
136 if req.opt.synonym (i) then req.opt.finished (req.srch.renamo (i)) = "1"b;
137 rfin = rfin + 1;
138 end;
139 end;
140 do i = 1 to rlines;
141 if i = rcurr then go to next_test;
142 if req.opt.finished (i) then go to next_test;
143 if req.opt.exact (i) then do;
144 if n = req.srch.len (i) & substr (path_name, 1, n) = req.srch.name (i) then
145 go to match;
146 end;
147 else do;
148 req.path_copy = req.srch.name (i);
149 if substr (path_name, 1, req.srch.len (i)) = req.path_copy then
150 go to match;
151 end;
152 next_test: end;
153 rcurr = 0;
154 label_index = next;
155 go to exit;
156
157 match: bk_ss_$retrieval_index = i;
158 if bk_ss_$sub_entry then bk_ss_$path_index = req.srch.control_index (i);
159 if htype ^= ndc_directory & htype ^= sec_dir then do;
160 req.opt.found (i) = "1"b;
161 if req.opt.synonym (i) then req.opt.found (req.srch.renamo (i)) = "1"b;
162 if bk_ss_$sub_entry then
163 bk_ss_$control_ptr -> backup_control.found (bk_ss_$path_index) = "1"b;
164 end;
165 if bk_ss_$onlysw then do;
166 if req.opt.exact (i) then do;
167 if htype ^= ndc_directory & htype ^= sec_dir then do;
168 req.opt.finished (i) = "1"b;
169 if req.opt.synonym (i) then req.opt.finished (req.srch.renamo (i)) = "1"b;
170 rfin = rfin + 1;
171 end;
172 end;
173 if rcurr ^= 0 then
174 if req.opt.finished (rcurr) then rcurr = 0;
175 end;
176 if ^req.opt.exact (i) then rcurr = i;
177 if req.opt.rename (i) then do;
178 bk_ss_$cross_retrievesw = "1"b;
179 ncurr = req.srch.renamo (i);
180 if req.opt.synonym (i) then ncurr = req.srch.renamo (ncurr);
181 grt_count = req.srch.grt (i);
182 j = 0;
183 if req.newn.ndlen (ncurr) = 0 then do;
184 if (htype = ndc_directory_list) then do;
185 do i = 1 to hp -> h.dlen;
186 if addr (hp -> h.dname) -> rscan (i) = ">" then do;
187 j = j + 1;
188 if j = grt_count then do;
189 hp -> h.dname = substr (hp -> h.dname, 1, i) ||
190 substr (req.newn.ndname (ncurr), 1, req.newn.nelen (ncurr));
191 hp -> h.dlen = i + req.newn.nelen (ncurr);
192 go to renamed;
193 end;
194 end;
195 end;
196 go to renamed;
197 end;
198 hp -> h.ename = req.newn.ndname (ncurr);
199 hp -> h.elen = req.newn.nelen (ncurr);
200 go to renamed;
201 end;
202 if (htype = ndc_directory_list) then do;
203 do i = 1 to hp -> h.dlen;
204 if addr (hp -> h.dname) -> rscan (i) = ">" then do;
205 j = j + 1;
206 if j = grt_count + 1 then do;
207 partial: hp -> h.dname = substr (req.newn.ndname (ncurr), 1, req.newn.ndlen (ncurr))
208 || substr (hp -> h.dname, i, hp -> h.dlen - i + 1);
209 hp -> h.dlen = hp -> h.dlen - i + 1 + req.newn.ndlen (ncurr);
210 go to renamed;
211 end;
212 end;
213 end;
214 dironly: hp -> h.dlen = req.newn.ndlen (ncurr);
215 hp -> h.dname = substr (req.newn.ndname (ncurr), 1, hp -> h.dlen);
216 go to renamed;
217 end;
218 do i = 1 to hp -> h.dlen;
219 if addr (hp -> h.dname) -> rscan (i) = ">" then do;
220 j = j + 1;
221 if j = grt_count then do;
222 k = index (substr (hp -> h.dname, i + 1), ">");
223 if k = 0 then go to dironly;
224 i = i + k;
225 go to partial;
226 end;
227 end;
228 end;
229 hp -> h.dlen = req.newn.ndlen (ncurr) - req.newn.nelen (ncurr) - 1;
230 hp -> h.dname = substr (req.newn.ndname (ncurr), 1, hp -> h.dlen);
231 hp -> h.elen = req.newn.nelen (ncurr);
232 hp -> h.ename = substr (req.newn.ndname (ncurr), hp -> h.dlen + 2, hp -> h.elen);
233 renamed: end;
234 else bk_ss_$cross_retrievesw = "0"b;
235 label_index = checked;
236 go to exit;
237
238
239
240
241
242 flag_msf: entry (A_index);
243
244 dcl A_index fixed bin;
245
246 rcurr = A_index;
247
248 req.opt.exact (A_index) = "0"b;
249 if req.opt.synonym (A_index) then req.opt.exact (req.srch.renamo (A_index)) = "0"b;
250
251 return;
252
253
254
255
256
257
258
259 parse_retrieval_control: entry (rname, rsize, a_hp, label_index);
260
261 if bk_ss_$sub_entry then do;
262 call backup_map_$fs_error_line (error_table_$badcall, "bk_retrieve$parse_retrieval_control",
263 "^/This entry point must be called via backup_load, reload or retrieve", "");
264 label_index = terminate;
265 end;
266 go to COMMON;
267
268 parse_structure: entry (a_hp, label_index);
269
270 if ^bk_ss_$sub_entry then do;
271 call backup_map_$fs_error_line (error_table_$badcall, "bk_retrieve$parse_structure",
272 "^/This entry point must be called via backup_load_", "");
273 label_index = terminate;
274 end;
275
276 COMMON: hp = a_hp;
277 unspec (nl) = "000001010"b;
278 rfin, rlines = 0;
279 parsed = 1;
280 next = 2;
281 stop = 3;
282 terminate = 4;
283 reported = 5;
284 checked = 6;
285 if ^bk_ss_$sub_entry then do;
286 line_pointer = addr (line);
287
288 call expand_pathname_ (substr (rname, 1, rsize), rdname, rename, code);
289 if code ^= 0 then do;
290 call com_err_ (code, bk_ss_$myname, rname);
291 go to reported_exit;
292 end;
293
294 call hcs_$initiate_count (rdname, rename, "", rbc, 1, rptr, code);
295 if code ^= 0 & code ^= error_table_$segknown then do;
296 call com_err_ (code, bk_ss_$myname, "^a>^a", rdname, rename);
297 go to reported_exit;
298 end;
299 end;
300
301 call hcs_$make_seg ("", "retrieval_control", "", 01011b, reqptr, code);
302 if code ^= 0 & code ^= error_table_$segknown then do;
303 call com_err_ (code, bk_ss_$myname, "retrieval_control");
304 reported_exit: label_index = reported;
305 go to exit;
306 end;
307 call hcs_$truncate_seg (reqptr, 0, 0);
308
309 ncurr, rcurr, i = 1;
310
311 if bk_ss_$sub_entry then do;
312 rlines, rcomp = bk_ss_$control_ptr -> backup_control.request_count;
313 if rlines > 500 then go to parsed_enough;
314 do rcurr = 1 to rlines;
315 line = bk_ss_$control_ptr -> backup_control.path (rcurr);
316 if substr (line, 1, 1) ^= ">" then do;
317 bk_ss_$control_ptr -> backup_control.status_code (rcurr) = error_table_$badpath;
318 label_index = terminate;
319 go to exit;
320 end;
321 req.srch.control_index (rcurr) = rcurr;
322 req.srch.name (rcurr) = line;
323 req.srch.len (rcurr) = length (line) + 1 - verify (reverse (line), " ");
324 if bk_ss_$control_ptr -> backup_control.new_path (rcurr) ^= "" then do;
325 req.opt.rename (rcurr) = "1"b;
326 req.srch.renamo (rcurr) = ncurr;
327 j = 0;
328 do k = 1 to req.srch.len (rcurr);
329 if addr (req.srch.name (rcurr)) -> rscan (k) = ">" then j = j + 1;
330 end;
331 req.srch.grt (rcurr) = j;
332 line = bk_ss_$control_ptr -> backup_control.new_path (rcurr);
333 n = length (rtrim (line));
334 bk_ss_$no_primary = bk_ss_$control_ptr -> backup_control.no_primary_sw (rcurr);
335 j = 0;
336 call count_grts;
337 ncurr = ncurr + 1;
338 n = req.srch.len (rcurr);
339 end;
340 else req.opt.rename (rcurr) = "0"b;
341 req.opt.exact (rcurr) = "0"b;
342 end;
343 end;
344
345 else do;
346 rbc = divide (rbc, 9, 17, 0);
347 do while (i < rbc);
348 if rlines > 500 then go to parsed_enough;
349 do j = i by 1 to rbc while (rptr -> rscan (j) ^= nl);
350 end;
351 n = j - i;
352 k = i;
353 i = j + 1;
354 if n = 0 then go to parse_next;
355 line = substr (rptr -> rmove, k, n);
356 if substr (line, 1, 1) ^= ">" then do;
357 call com_err_ (error_table_$badpath, bk_ss_$myname, "search arg of ^a", line);
358 go to bad_p;
359 end;
360 j = index (line, "=");
361 if j = 0 then do;
362 req.opt.rename (rcurr) = ""b;
363 req.srch.name (rcurr) = substr (line, 1, n);
364 req.srch.len (rcurr) = n;
365 end;
366 else do;
367 if j = n then do;
368 call com_err_ (error_table_$bad_string, bk_ss_$myname, "no new name in ^a", line);
369 go to bad_p;
370 end;
371 req.opt.rename (rcurr) = "1"b;
372 req.srch.name (rcurr) = substr (line, 1, j - 1);
373 req.srch.len (rcurr) = j - 1;
374 req.srch.renamo (rcurr) = ncurr;
375 call count_grts;
376 ncurr = ncurr + 1;
377 n = j - 1;
378 end;
379 call see_stars;
380 j = 0;
381 do k = 1 to req.srch.len (rcurr);
382 if addr (req.srch.name (rcurr)) -> rscan (k) = ">" then j = j + 1;
383 end;
384 req.srch.grt (rcurr) = j;
385 rcurr = rcurr + 1;
386 rlines = rlines + 1;
387 parse_next: end;
388 call hcs_$terminate_noname (rptr, code);
389 if code ^= 0 then
390 call backup_map_$fs_error_line (code, "terminate_noname", rname, "");
391 rcomp = rlines;
392 end;
393 do i = 1 to rlines;
394 if bk_ss_$sub_entry then
395 bk_ss_$no_primary = bk_ss_$control_ptr -> backup_control.no_primary_sw (i);
396 if ^bk_ss_$no_primary then do;
397 call backup_util$get_real_name
398 (addr (req.srch.name (i)), addr (req.srch.name (rcurr)), req.srch.len (rcurr), code);
399 if code > 1 & code ^= error_table_$noentry & code ^= error_table_$no_dir &
400 code ^= error_table_$no_s_permission & code ^= error_table_$moderr &
401 code ^= error_table_$no_info then do;
402 bk_ss_$path_index = i;
403 call backup_map_$fs_error_line (code, (bk_ss_$myname),
404 "get_real_name for "||req.srch.name (i), "");
405 go to bad_p;
406 end;
407 else if code = 1 then do;
408 req.opt (rcurr) = req.opt (i);
409 req.opt.synonym (rcurr) = "1"b;
410 req.srch.renamo (rcurr) = i;
411 req.srch.control_index (rcurr) = req.srch.control_index (i);
412
413 req.srch.grt (rcurr) = req.srch.grt (i);
414 req.srch.name (rcurr) = substr (req.srch.name (rcurr), 1, req.srch.len (rcurr)) || ">";
415 req.srch.len (rcurr) = req.srch.len (rcurr) + 1;
416 rcurr = rcurr + 1;
417 rlines = rlines + 1;
418 end;
419 end;
420 else code = 0;
421 req.srch.name (i) = substr (req.srch.name (i), 1, req.srch.len (i)) || ">";
422 req.srch.len (i) = req.srch.len (i) + 1;
423 end;
424 rcurr = 0;
425 label_index = parsed;
426 go to exit;
427
428 parsed_enough: call ioa_$rsnnl
429 ("^a: over 500 retrieval requests. Reload ended.", line, n, bk_ss_$myname);
430 call backup_map_$on_line (line_pointer, n);
431 bad_p: call hcs_$terminate_noname (rptr, code);
432 code = error_table_$arg_ignored;
433 rlines = 0;
434 label_index = terminate;
435
436 return;
437
438
439 count_grts: proc;
440
441 req.newn.ngrt (ncurr) = 0;
442 if substr (line, j + 1, 1) = ">" then do;
443 req.newn.ndname (ncurr) = substr (line, j + 1, n - j);
444 req.newn.ndlen (ncurr) = n - j;
445 if ^bk_ss_$no_primary then call backup_util$get_real_name
446 (addr (req.newn.ndname (ncurr)), addr (req.newn.ndname (ncurr)), req.newn.ndlen (ncurr), code);
447 else code = 0;
448 do k = 1 to req.newn.ndlen (ncurr);
449 if addr (req.newn.ndname (ncurr)) -> rscan (k) = ">" then do;
450 req.newn.ngrt (ncurr) = req.newn.ngrt (ncurr) + 1;
451 l = k;
452 end;
453 end;
454 req.newn.nelen (ncurr) = req.newn.ndlen (ncurr) - l;
455 end;
456 else do;
457 req.newn.ndlen (ncurr) = 0;
458 req.newn.ndname (ncurr) = substr (line, j + 1, n - j);
459 req.newn.nelen (ncurr) = n - j;
460 end;
461
462 end count_grts;
463
464
465 see_stars: proc;
466
467 if substr (req.srch.name (rcurr), n - 2, 3) = ">**" then do;
468 req.opt.exact (rcurr) = ""b;
469 substr (req.srch.name (rcurr), n - 2, 3) = "";
470 req.srch.len (rcurr) = n - 3;
471 if req.opt.rename (rcurr) then do;
472 l = 1;
473 do k = 2 to req.srch.len (rcurr);
474 if addr (req.srch.name (rcurr)) -> rscan (k) = ">" then l = l + 1;
475 end;
476 end;
477 end;
478 else req.opt.exact (rcurr) = "1"b;
479 req.opt.found (rcurr), req.opt.finished (rcurr), req.opt.synonym (rcurr) = ""b;
480
481 end see_stars;
482
483
484
485
486
487
488 report_retrieval: entry;
489
490 dcl unsatisfied bit (1) aligned;
491
492 if rlines = 0 then go to exit;
493 if bk_ss_$sub_entry then go to reportend;
494 call hcs_$initiate_count (rdname, rename, "", rbc, 1, rptr, code);
495 if code ^= 0 & code ^= error_table_$segknown then do;
496 call backup_map_$fs_error_line (code, "initiate", rdname, rename);
497 go to reportend;
498 end;
499 rbc = divide (rbc, 9, 17, 0);
500 i, k = 1;
501 unsatisfied = ""b;
502
503 next_req: n = index (substr (rptr -> rmove, i, rbc), nl);
504 if n ^= 0 then
505 if ^req.opt (k).found then do;
506 if ^unsatisfied then do;
507 call ioa_ ("The following requests were not satisfied:");
508 unsatisfied = "1"b;
509 end;
510
511 call ioa_ ("^a^/ Search name: ^a",
512 substr (rptr -> rmove, i, n-1),
513 substr (req.srch (k).name, 1, req.srch (k).len));
514 end;
515
516 i = i + n;
517 k = k + 1;
518
519 if i < rbc then go to next_req;
520
521 call hcs_$terminate_noname (rptr, code);
522 reportend: call hcs_$truncate_seg (reqptr, 0, code);
523 exit: return;
524 end;