1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 linus_open:
27 proc (sci_ptr, lcb_ptr);
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 ^L
96 %include linus_lcb;
97 %page;
98 %include linus_char_argl;
99 %page;
100 %include linus_ready_data;
101 %page;
102 %include linus_ready_table;
103 %page;
104 %include linus_scal_fn_info;
105 %page;
106 %include linus_set_fn_info;
107 %page;
108 %include mrds_model_relations;
109 %page;
110 %include mrds_opening_modes_;
111 %page;
112 %include mrds_security_info;
113 ^L
114 dcl sci_ptr ptr;
115 dcl (
116 db_version,
117 i,
118 j,
119 open_mode,
120 retrieval_mode init (2)
121 ) fixed bin;
122
123 dcl code fixed bin (35);
124
125 dcl error_codes (2) fixed bin (35);
126
127 dcl initial_mrds_vclock float bin (63);
128
129 dcl cleanup condition;
130 dcl cleanup_has_been_signalled bit (1) aligned;
131
132 dcl (
133 data_model_ptr init (null),
134 free_setfi_ptr init (null),
135 last_setfi_ptr init (null)
136 ) ptr;
137
138 dcl mode char (char_argl.arg.arg_len (2)) based (char_argl.arg.arg_ptr (2));
139
140 dcl open_mode_value (9) fixed bin int static options (constant) init (
141
142 1, 1, 2, 2, 3, 3, 4, 4, 5);
143 dcl opened_mode char (20);
144 dcl path_name char (char_argl.arg.arg_len (1))
145 based (char_argl.arg.arg_ptr (1));
146
147 dcl (
148 db_path_name,
149 out_path_name
150 ) char (168);
151
152 dcl valid_open_mode (8) char (19) int static options (constant) init (
153
154 "r", "retrieval", "u", "update", "er", "exclusive_retrieval", "eu",
155 "exclusive_update");
156
157 dcl active_request_flag bit (1) aligned;
158 dcl return_value char (return_value_length) varying based (return_value_ptr);
159 dcl return_value_length fixed bin (21);
160 dcl return_value_ptr ptr;
161
162 dcl (addr, fixed, hbound, null, rel, vclock) builtin;
163
164 dcl (
165 linus_error_$cant_ref_fun,
166 linus_error_$inv_mode,
167 linus_error_$no_input_arg,
168 linus_error_$too_few_args,
169 linus_error_$too_many_dbs,
170 mrds_error_$db_busy,
171 mrds_error_$quiesced_db,
172 sys_info$max_seg_size
173 ) ext fixed bin (35);
174
175 dcl error_table_$too_many_args fixed bin(35) ext static;
176 dcl dsl_$close entry() options(variable);
177 dcl dsl_$declare entry options (variable);
178 dcl dsl_$get_db_version
179 entry (char (168), char (168), fixed bin, fixed bin (35));
180 dcl dsl_$get_rslt_rels entry (fixed bin (35), ptr, ptr, fixed bin (35));
181 dcl dsl_$get_pn entry (fixed bin (35), char (168), char (20), fixed bin (35));
182 dcl dsl_$get_security_info entry (fixed bin (35), ptr, ptr, fixed bin (35));
183 dcl dsl_$open entry options (variable);
184 dcl linus_stifle_mrds_sub_error entry ((*) fixed bin(35));
185 dcl ssu_$abort_line entry options (variable);
186 dcl ssu_$return_arg entry (ptr, fixed bin, bit(1) aligned, ptr, fixed bin(21));
187 dcl ssu_$arg_ptr entry (ptr, fixed bin, ptr, fixed bin (21));
188 dcl ssu_$print_message entry() options(variable);
189 dcl sub_error_ condition;
190 dcl USAGE char (36) internal static options (constant) init (
191 "^/Usage: open pathname opening_mode");
192
193 ^L
194 ca_ptr = null;
195 mr_ptr = null;
196
197 on cleanup begin;
198 cleanup_has_been_signalled = "1"b;
199 call clean_up;
200 end;
201
202 lcb.trans_id, rd_nfiles_init = 0;
203 call ssu_$return_arg (sci_ptr, nargs_init,
204 active_request_flag, return_value_ptr, return_value_length);
205 if active_request_flag
206 then return_value = "false";
207 if lcb.db_index ^= 0 then
208 call ssu_$abort_line (sci_ptr, linus_error_$too_many_dbs);
209
210 if nargs_init = 0 then
211 call ssu_$abort_line (sci_ptr, linus_error_$no_input_arg, USAGE);
212
213 if nargs_init < 2 then
214 call ssu_$abort_line (sci_ptr, linus_error_$too_few_args, USAGE);
215 if nargs_init > 2 then
216 call ssu_$abort_line (sci_ptr, error_table_$too_many_args, USAGE);
217 allocate char_argl in (lcb.static_area);
218 do i = 1 to 2;
219 call ssu_$arg_ptr (sci_ptr, i, char_argl.arg.arg_ptr (i), char_argl.arg.arg_len (i));
220 end;
221 do i = 1 to 8 while (mode ^= valid_open_mode (i));
222 end;
223 if i > hbound (valid_open_mode, 1) then
224 call
225 ssu_$abort_line (sci_ptr, linus_error_$inv_mode,
226 "Unrecognizable opening mode ^a.^a", mode, USAGE);
227 open_mode = open_mode_value (i);
228 if active_request_flag
229 then do;
230 error_codes (1) = mrds_error_$db_busy;
231 error_codes (2) = mrds_error_$quiesced_db;
232 on sub_error_ call linus_stifle_mrds_sub_error (error_codes);
233 end;
234 if lcb.timing_mode then
235 initial_mrds_vclock = vclock;
236 call dsl_$open (path_name, lcb.db_index, open_mode, code);
237
238 if lcb.timing_mode then
239 lcb.mrds_time = lcb.mrds_time + (vclock - initial_mrds_vclock);
240 if active_request_flag
241 then revert sub_error_;
242 if code ^= 0
243 then if active_request_flag & (code = mrds_error_$db_busy | code = mrds_error_$quiesced_db)
244 then do;
245 call clean_up;
246 return;
247 end;
248 else call ssu_$abort_line (sci_ptr, code);
249 else if active_request_flag
250 then return_value = "true";
251 else;
252
253 if lcb.timing_mode then
254 initial_mrds_vclock = vclock;
255 call dsl_$get_pn (lcb.db_index, db_path_name, opened_mode, code);
256 if lcb.timing_mode then
257 lcb.mrds_time = lcb.mrds_time + (vclock - initial_mrds_vclock);
258 if code ^= 0 then
259 call ssu_$abort_line (sci_ptr, code);
260
261 if lcb.timing_mode then
262 initial_mrds_vclock = vclock;
263 call dsl_$get_db_version (db_path_name, out_path_name, db_version, code);
264 if lcb.timing_mode then
265 lcb.mrds_time = lcb.mrds_time + (vclock - initial_mrds_vclock);
266 if code ^= 0 then
267 call ssu_$abort_line (sci_ptr, code);
268 if db_version > 3 then
269 lcb.new_version = "1"b;
270 else lcb.new_version = "0"b;
271
272 if lcb.timing_mode then
273 initial_mrds_vclock = vclock;
274 call
275 dsl_$get_security_info (lcb.db_index, lcb.linus_area_ptr,
276 mrds_security_info_ptr, code);
277 if lcb.timing_mode then
278 lcb.mrds_time = lcb.mrds_time + (vclock - initial_mrds_vclock);
279 if code ^= 0 then
280 call ssu_$abort_line (sci_ptr, code);
281 lcb.administrator = mrds_security_info.administrator;
282 lcb.secured_db = mrds_security_info.db_secure;
283
284 if lcb.sclfi_ptr ^= null then do;
285 sclfi_ptr = lcb.sclfi_ptr;
286 do while (sclfi_ptr ^= null);
287 if lcb.timing_mode then
288 initial_mrds_vclock = vclock;
289 call dsl_$declare (lcb.db_index, scal_fn_info.name, code);
290 if lcb.timing_mode then
291 lcb.mrds_time = lcb.mrds_time + (vclock - initial_mrds_vclock);
292 if code ^= 0 then
293 call ssu_$abort_line (sci_ptr, code);
294 sclfi_ptr = scal_fn_info.fwd_ptr;
295 end;
296 end;
297
298 if lcb.setfi_ptr ^= null then do;
299 free_setfi_ptr = null;
300 last_setfi_ptr = lcb.setfi_ptr;
301 linus_set_fn_info_ptr = lcb.setfi_ptr;
302 do linus_set_fn_info_ptr = lcb.setfi_ptr
303 repeat linus_set_fn_info.fwd_ptr
304 while (linus_set_fn_info.fwd_ptr ^= null);
305 if ^linus_set_fn_info.init_entry_set then do;
306 call
307 ssu_$print_message (linus_error_$cant_ref_fun, "open",
308 "^/The set function ^a does not have an ""_init"" entry ^/point and has been removed from the declared set functions list."
309 , linus_set_fn_info.name);
310 if lcb.setfi_ptr = last_setfi_ptr then do;
311 lcb.setfi_ptr = linus_set_fn_info.fwd_ptr;
312 last_setfi_ptr = linus_set_fn_info.fwd_ptr;
313 end;
314 linus_set_fn_info.fwd_ptr = free_setfi_ptr;
315 free_setfi_ptr = linus_set_fn_info_ptr;
316 end;
317 else last_setfi_ptr = linus_set_fn_info_ptr;
318 end;
319 do linus_set_fn_info_ptr = free_setfi_ptr repeat free_setfi_ptr
320 while (free_setfi_ptr ^= null);
321 free_setfi_ptr = linus_set_fn_info.fwd_ptr;
322 free linus_set_fn_info;
323 end;
324 end;
325
326 lcb.rt_ptr, lcb.rd_ptr = null;
327
328 if lcb.timing_mode then
329 initial_mrds_vclock = vclock;
330 call dsl_$get_rslt_rels (lcb.db_index, lcb.linus_area_ptr, mr_ptr, code);
331 if lcb.timing_mode then
332 lcb.mrds_time = lcb.mrds_time + (vclock - initial_mrds_vclock);
333 if code ^= 0 then
334 call ssu_$abort_line (sci_ptr, code);
335
336 call init_ready_data;
337 call init_ready_table;
338
339 return;
340 ^L
341 init_ready_data:
342 proc;
343
344
345
346 rd_nfiles_init = model_relations.nrels;
347 allocate ready_data in (lcb.static_area);
348 lcb.rd_ptr = rd_ptr;
349 ready_data.mode = RETRIEVAL;
350
351 do j = 1 to model_relations.nrels;
352 ready_data.file.name (j) = model_relations.relation_name (j);
353 ready_data.file.active (j) = "0"b;
354 end;
355
356
357 end init_ready_data;
358 ^L
359 init_ready_table:
360 proc;
361
362 ntabs_init = model_relations.nrels;
363 allocate ready_table in (lcb.static_area);
364 lcb.rt_ptr = rt_ptr;
365 do i = 1 to ntabs_init;
366 ready_table.tab.name (i) = model_relations.relation_name (i);
367 ready_table.tab.active (i) = "0"b;
368 end;
369 mr_ptr = null;
370
371 end init_ready_table;
372 ^L
373 clean_up:
374 proc;
375
376 if ca_ptr ^= null
377 then free char_argl;
378 if lcb.db_index ^= 0 & cleanup_has_been_signalled
379 then call dsl_$close (lcb.db_index, code);
380
381 end clean_up;
382
383
384 end linus_open;