1
2
3
4
5
6
7
8
9
10
11 execute_search_rules_: proc (rname, switches, dirname, ename, type, bit_count, code);
12
13
14
15 dcl rname char (32);
16 dcl switches bit (8) aligned;
17
18 dcl dirname char (168);
19 dcl ename char (32);
20 dcl type fixed bin (2);
21 dcl bit_count fixed bin (24);
22 dcl code fixed bin (35);
23
24
25
26
27 dcl get_default_wdir_ ext entry returns (char (168) aligned);
28 dcl get_pdir_ ext entry returns (char (168) aligned);
29 dcl get_wdir_ ext entry returns (char (168) aligned);
30 dcl get_system_free_area_ ext entry returns (ptr);
31
32 dcl cu_$stack_frame_ptr ext entry (ptr);
33 dcl hcs_$fs_get_seg_ptr ext entry (char (*), ptr, fixed bin (35));
34 dcl hcs_$fs_get_path_name ext entry (ptr, char (*), fixed bin, char (*), fixed bin (35));
35 dcl hcs_$initiate ext entry (char (*), char (*), char (*), fixed bin (1), fixed bin (2), ptr, fixed bin (35));
36 dcl hcs_$get_link_target ext entry (char (*), char (*), char (*), char (*), fixed bin (35));
37 dcl hcs_$terminate_noname ext entry (ptr, fixed bin (35));
38
39
40 dcl hcs_$get_search_rules ext entry (ptr);
41
42 dcl hcs_$status_long ext entry
43 (char (*), char (*), fixed bin (1), ptr, ptr, fixed bin (35));
44
45 dcl hcs_$status_minf ext entry (char (*), char (*), fixed bin (1), fixed bin (2), fixed bin (24),
46 fixed bin (35));
47 dcl ioa_ ext entry options (variable);
48 dcl com_err_ ext entry options (variable);
49
50
51
52 dcl error_table_$bad_string ext fixed bin (35);
53 dcl error_table_$name_not_found ext fixed bin (35);
54 dcl error_table_$no_s_permission ext fixed bin (35);
55 dcl error_table_$noentry ext fixed bin (35);
56 dcl error_table_$not_a_branch ext fixed bin (35);
57 dcl error_table_$segknown ext fixed bin (35);
58
59
60
61
62
63 dcl chase_sw bit (1) aligned;
64 dcl target_sw bit (1) aligned;
65 dcl priname_sw bit (1) aligned;
66 dcl known_sw bit (1) aligned;
67 dcl link_sw bit (1) aligned;
68 dcl error_sw bit (1) aligned;
69 dcl show_sw bit (1) aligned;
70 dcl noref_sw bit (1) aligned;
71
72 dcl chase fixed bin (1);
73
74 dcl search_rules_ptr ptr;
75 dcl 1 search_rules aligned based (search_rules_ptr),
76 2 number fixed bin,
77 2 names (21) char (168) aligned;
78
79 dcl 1 stack_search_rules like search_rules automatic;
80
81 dcl names_needed bit (1) aligned;
82 dcl no_s_permission bit (1) aligned;
83 dcl it_was_a_link bit (1) aligned;
84 dcl (i, j) fixed bin;
85 dcl ldn fixed bin;
86 dcl dummy_ename char (32);
87
88 dcl dummy_dirname char (168);
89 dcl dummy_segptr ptr;
90
91
92 dcl me char (24) aligned int static init ("execute_search_rules_");
93
94 dcl stack_ptr ptr;
95
96 dcl 1 stack_frame based (stack_ptr),
97 2 pad (16) bit (36),
98 2 back_ptr ptr,
99 2 next_ptr ptr,
100 2 return_ptr ptr,
101 2 entry_ptr ptr;
102
103
104 dcl 1 long_branch aligned,
105 (2 long_type bit (2),
106 2 nnames bit (16),
107 2 nrp bit (18)) unaligned,
108 2 pad (6) fixed bin (35),
109 (2 curlen bit (12),
110 2 long_bitcount bit (24)) unaligned,
111 2 pad2 (2) fixed bin (35);
112
113 dcl lg_type fixed bin (2);
114 dcl lg_bitcount fixed bin (24);
115 dcl lg_name char (32);
116 dcl lg_priname_sw bit (1) aligned;
117 dcl lg_chase fixed bin (1);
118
119 dcl names (fnames) char (32) aligned based (ep);
120
121 dcl fnames fixed bin;
122 dcl ep ptr;
123 dcl system_free_ptr ptr int static init (null);
124 dcl system_free_area area based (system_free_ptr);
125
126 dcl seg_ptr ptr;
127
128 dcl error_code fixed bin (35) init (0);
129 dcl error_dir char (168) aligned;
130 dcl unexpected_error bit (1) aligned;
131
132
133
134 dcl (addr, fixed, null, ptr, substr) builtin;
135
136 dcl cleanup condition;
137
138
139 search_rules_ptr = addr (stack_search_rules);
140 call hcs_$get_search_rules (search_rules_ptr);
141
142 start: ;
143
144
145
146 chase_sw = substr (switches, 1, 1);
147 target_sw = substr (switches, 2, 1);
148 priname_sw = substr (switches, 3, 1);
149 known_sw = substr (switches, 4, 1);
150 link_sw = substr (switches, 5, 1);
151 error_sw = substr (switches, 6, 1);
152 show_sw = substr (switches, 7, 1);
153 noref_sw = substr (switches, 8, 1);
154
155 if chase_sw & ^target_sw & ^link_sw then chase = 1;
156
157
158 ename = rname;
159
160
161
162 type, bit_count = -1;
163
164 search_loop: do i = 1 to search_rules.number;
165
166 unexpected_error, it_was_a_link, no_s_permission, names_needed = "0"b;
167
168 dirname = search_rules.names (i);
169
170 if show_sw then
171 call show (-3);
172
173 if dirname = "" then goto end_search_loop;
174
175
176
177
178 if dirname = "initiated_segments" then
179 check_init_segs: do;
180
181 call hcs_$fs_get_seg_ptr (ename, seg_ptr, code);
182
183 if code ^= 0 then
184 if show_sw then
185 call show (1);
186
187 if code ^= 0 then
188 if code ^= error_table_$name_not_found then do;
189
190 if ^error_sw then return;
191 error_dir = dirname;
192 error_code = code;
193 unexpected_error = "1"b;
194 end;
195
196 if seg_ptr ^= null then
197 it_was_init: do;
198
199 call hcs_$fs_get_path_name (seg_ptr, dirname, ldn, dummy_ename, code);
200
201 if code ^= 0 then do;
202
203 if show_sw then
204 call show (2);
205
206
207 if ^error_sw then return;
208 error_dir = dirname;
209 error_code = code;
210 unexpected_error = "1"b;
211 end;
212
213 else
214 got_pathname: do;
215
216 call hcs_$status_minf (dirname, dummy_ename, chase, type, bit_count, code);
217
218 if code ^= 0 then
219 if show_sw then
220 call show (3);
221
222
223
224 if code = 0 then
225 check_init_options: do;
226
227 if priname_sw then
228 ename = dummy_ename;
229 else
230 if ename ^= dummy_ename then
231 check_refname: do;
232
233 call hcs_$initiate (dirname, ename, "", 0, 0, dummy_segptr, code);
234
235 if seg_ptr ^= dummy_segptr
236 then ename = dummy_ename;
237
238 if dummy_segptr ^= null then
239 call hcs_$terminate_noname (dummy_segptr, code);
240
241 code = 0;
242
243 end check_refname;
244
245 if known_sw then
246 code = error_table_$segknown;
247
248 end check_init_options;
249
250
251 return;
252
253 end got_pathname;
254
255 end it_was_init;
256
257 end check_init_segs;
258
259 else
260 check_non_init: do;
261
262 if substr (dirname, 1, 1) ^= ">" then
263 interpret_rule: do;
264
265 if dirname = "referencing_dir" then
266 get_refdir: do;
267
268 if noref_sw then goto end_search_loop;
269
270 call cu_$stack_frame_ptr (stack_ptr);
271 stack_ptr = stack_frame.back_ptr;
272 seg_ptr = stack_frame.entry_ptr;
273
274 call hcs_$fs_get_path_name (seg_ptr, dirname, ldn, dummy_ename, code);
275
276
277
278 if code ^= 0 then do;
279 if show_sw then
280 call show (2);
281
282
283 if ^error_sw then return;
284 error_dir = dirname;
285 error_code = code;
286 unexpected_error = "1"b;
287 end;
288
289 end get_refdir;
290
291 else if dirname = "working_dir" then
292 dirname = get_wdir_ ();
293
294 else if dirname = "process_dir" then
295 dirname = get_pdir_ ();
296
297 else if dirname = "home_dir" then
298 dirname = get_default_wdir_ ();
299
300 else
301 bad_search_rule: do;
302 code = error_table_$bad_string;
303 if show_sw then
304 call show (0);
305
306 if ^error_sw then return;
307 error_code = code;
308 error_dir = dirname;
309 unexpected_error = "1"b;
310 end bad_search_rule;
311
312 end interpret_rule;
313
314 if show_sw then
315 if dirname ^= search_rules.names (i) then
316 call show (-2);
317
318 if ^unexpected_error then
319 try_status: do;
320
321 if priname_sw then do;
322 lg_priname_sw = "1"b;
323 lg_chase = chase;
324 call status_long_caller;
325 type = lg_type;
326 bit_count = lg_bitcount;
327 ename = lg_name;
328 end;
329
330 else do;
331 call hcs_$status_minf (dirname, ename, chase, type, bit_count, code);
332
333 if code ^= 0 then
334 if show_sw then
335 call show (3);
336 end;
337
338 if code = error_table_$no_s_permission then goto found_it;
339 if code = 0 then
340 found_it: do;
341
342 if type = 0 then
343 examine_link: do;
344
345 if link_sw then
346 it_was_a_link = "1"b;
347 if target_sw then
348 get_target: do;
349
350 call hcs_$get_link_target (dirname, ename, dummy_dirname, dummy_ename, code);
351
352 if code ^= 0 then do;
353
354 if show_sw then
355 call show (4);
356
357 if ^error_sw then return;
358
359 error_code = code;
360 error_dir = dirname;
361 unexpected_error = "1"b;
362 end;
363
364 end get_target;
365
366 if ^unexpected_error then
367 get_target_info: do;
368 if target_sw then
369 if dummy_ename ^= ename then
370 if ^priname_sw then
371 names_needed = "1"b;
372
373 if ^names_needed then if chase_sw then do;
374 call hcs_$status_minf (dirname, ename, 1, type, bit_count, code);
375 if code ^= 0 then do;
376 if show_sw then
377 call show (3);
378 if ^error_sw then return;
379 error_dir = dirname;
380 error_code = code;
381 unexpected_error = "1"b;
382 end;
383 end;
384
385 if names_needed then do;
386 lg_priname_sw = "0"b;
387 lg_chase = 1;
388 call status_long_caller;
389 if code = 0 then
390
391 dummy_ename = lg_name;
392 if chase_sw then do;
393 type = lg_type;
394 bit_count = lg_bitcount;
395 end;
396 end;
397
398 if target_sw then do;
399 dirname = dummy_dirname;
400 ename = dummy_ename;
401 end;
402
403 end get_target_info;
404
405
406 end examine_link;
407
408 if ^unexpected_error then do;
409 if it_was_a_link
410
411 then if code = 0
412 then code = error_table_$not_a_branch;
413 return;
414 end;
415
416 end found_it;
417
418 if code ^= error_table_$noentry then do;
419
420 if ^error_sw then return;
421
422 error_code = code;
423 error_dir = dirname;
424 end;
425
426 end try_status;
427
428 end check_non_init;
429
430 end_search_loop:
431 end search_loop;
432
433
434
435 if error_code ^= 0 then do;
436 code = error_code;
437 dirname = error_dir;
438 end;
439
440 else
441 code = error_table_$noentry;
442
443 if show_sw then
444 call show (-1);
445 return;
446
447
448
449
450
451
452
453 status_long_caller: proc;
454
455
456
457
458 nnames = (16)"0"b;
459 on condition (cleanup) begin;
460
461 if nnames ^= (16)"0"b then do;
462
463 ep = ptr (system_free_ptr, fixed (nrp));
464 free ep -> names in (system_free_area);
465 end;
466 end;
467
468 if system_free_ptr = null then
469 system_free_ptr = get_system_free_area_ ();
470
471 call hcs_$status_long (dirname, ename, lg_chase, addr (long_branch), system_free_ptr, code);
472
473 if code ^= 0 then do;
474 if show_sw then call show (5);
475 lg_name = ename;
476 if code = error_table_$no_s_permission then no_s_permission = "1"b;
477 else return;
478 end;
479
480 lg_type = fixed (long_type);
481 if lg_type = 0 then
482 lg_bitcount = 0;
483 else lg_bitcount = fixed (long_bitcount);
484
485 if no_s_permission then return;
486
487 fnames = fixed (nnames);
488 ep = ptr (system_free_ptr, fixed (nrp));
489
490 if lg_priname_sw then lg_name = names (1);
491
492 else do;
493
494 do j = 1 to fnames
495 while (names (j) ^= ename);
496 end;
497
498 if j > fnames then
499 lg_name = names (1);
500 else lg_name = ename;
501 end;
502 revert cleanup;
503
504
505 free ep -> names in (system_free_area);
506
507 return;
508
509 end status_long_caller;
510
511
512 show: proc (action_code);
513
514 dcl action_code fixed bin;
515
516 dcl message char (32) aligned;
517
518 dcl messages (5) char (32) int static aligned init (
519 "from hcs_$fs_get_seg_ptr",
520 "from hcs_$fs_get_path_name",
521 "from hcs_$status_minf",
522 "from hcs_$get_link_target",
523 "from hcs_$status_long");
524
525 if action_code > 0 then
526 positive: do;
527 if action_code > 5 then return;
528 message = messages (action_code);
529 end positive;
530
531 else
532 negative: do;
533 if action_code = -3 then do;
534 call ioa_ ("^/RULE: ^a", dirname);
535 return;
536 end;
537
538 if action_code = -2 then do;
539 call ioa_ (dirname);
540 return;
541 end;
542
543 else if action_code = -1 then
544 message = ename;
545 else if action_code = 0 then
546 message = "";
547 else return;
548
549 end negative;
550
551 call com_err_ (code, "execute_search_rules_", message);
552 return;
553 end show;
554
555
556
557
558
559 s_r_ptr: entry (rname, switches, sptr, dirname, ename, type, bit_count, code);
560
561
562
563
564 dcl sptr ptr;
565
566 search_rules_ptr = sptr;
567 goto start;
568
569
570
571
572 end execute_search_rules_;