1 /* zzekbs02.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* Table of constant values */
9
10 static integer c__3 = 3;
11 static integer c__1 = 1;
12 static integer c__256 = 256;
13 static integer c__11 = 11;
14
15 /* $Procedure ZZEKBS02 ( EK, begin segment, type 1 ) */
zzekbs02_(integer * handle,char * tabnam,integer * ncols,char * cnames,integer * cdscrs,integer * segno,ftnlen tabnam_len,ftnlen cnames_len)16 /* Subroutine */ int zzekbs02_(integer *handle, char *tabnam, integer *ncols,
17 char *cnames, integer *cdscrs, integer *segno, ftnlen tabnam_len,
18 ftnlen cnames_len)
19 {
20 /* System generated locals */
21 integer i__1, i__2;
22
23 /* Builtin functions */
24 /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
25 integer s_rnge(char *, integer, char *, integer);
26
27 /* Local variables */
28 integer base, room;
29 extern /* Subroutine */ int zzekpgch_(integer *, char *, ftnlen),
30 zzekpgan_(integer *, integer *, integer *, integer *), zzekpgbs_(
31 integer *, integer *, integer *), zzekpgwc_(integer *, integer *,
32 char *, ftnlen), zzekpgwi_(integer *, integer *, integer *),
33 zzektrap_(integer *, integer *, integer *, integer *), zzektrit_(
34 integer *, integer *);
35 integer i__, cbase;
36 char cpage[1024];
37 integer p, ipage[256];
38 extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
39 ftnlen, ftnlen), movei_(integer *, integer *, integer *);
40 integer p1;
41 extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
42 integer p1base, cp;
43 extern logical failed_(void);
44 extern integer eknseg_(integer *);
45 extern logical return_(void);
46 char tmpcnm[32], tmptnm[64];
47 integer cp1, cpagno, dscbas, ipagno, metasz, nambas, ncpage, nipage,
48 sgtree;
49 extern /* Subroutine */ int chkout_(char *, ftnlen), cleari_(integer *,
50 integer *), dasrdi_(integer *, integer *, integer *, integer *);
51 integer cpt, dpt, ipt;
52
53 /* $ Abstract */
54
55 /* Start a new type 2 segment in an E-kernel. */
56
57 /* $ Disclaimer */
58
59 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
60 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
61 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
62 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
63 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
64 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
65 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
66 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
67 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
68 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
69
70 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
71 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
72 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
73 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
74 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
75 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
76
77 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
78 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
79 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
80 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
81
82 /* $ Required_Reading */
83
84 /* EK */
85
86 /* $ Keywords */
87
88 /* EK */
89
90 /* $ Declarations */
91 /* $ Disclaimer */
92
93 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
94 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
95 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
96 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
97 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
98 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
99 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
100 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
101 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
102 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
103
104 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
105 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
106 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
107 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
108 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
109 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
110
111 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
112 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
113 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
114 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
115
116
117 /* Include Section: EK Boolean Enumerated Type */
118
119
120 /* ekbool.inc Version 1 21-DEC-1994 (NJB) */
121
122
123 /* Within the EK system, boolean values sometimes must be */
124 /* represented by integer or character codes. The codes and their */
125 /* meanings are listed below. */
126
127 /* Integer code indicating `true': */
128
129
130 /* Integer code indicating `false': */
131
132
133 /* Character code indicating `true': */
134
135
136 /* Character code indicating `false': */
137
138
139 /* End Include Section: EK Boolean Enumerated Type */
140
141 /* $ Disclaimer */
142
143 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
144 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
145 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
146 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
147 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
148 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
149 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
150 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
151 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
152 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
153
154 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
155 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
156 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
157 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
158 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
159 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
160
161 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
162 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
163 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
164 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
165
166
167 /* Include Section: EK Column Descriptor Parameters */
168
169 /* ekcoldsc.inc Version 6 23-AUG-1995 (NJB) */
170
171
172 /* Note: The column descriptor size parameter CDSCSZ is */
173 /* declared separately in the include section CDSIZE$INC.FOR. */
174
175 /* Offset of column descriptors, relative to start of segment */
176 /* integer address range. This number, when added to the last */
177 /* integer address preceding the segment, yields the DAS integer */
178 /* base address of the first column descriptor. Currently, this */
179 /* offset is exactly the size of a segment descriptor. The */
180 /* parameter SDSCSZ, which defines the size of a segment descriptor, */
181 /* is declared in the include file eksegdsc.inc. */
182
183
184 /* Size of column descriptor */
185
186
187 /* Indices of various pieces of column descriptors: */
188
189
190 /* CLSIDX is the index of the column's class code. (We use the */
191 /* word `class' to distinguish this item from the column's data */
192 /* type.) */
193
194
195 /* TYPIDX is the index of the column's data type code (CHR, INT, DP, */
196 /* or TIME). The type is actually implied by the class, but it */
197 /* will frequently be convenient to look up the type directly. */
198
199
200
201 /* LENIDX is the index of the column's string length value, if the */
202 /* column has character type. A value of IFALSE in this element of */
203 /* the descriptor indicates that the strings have variable length. */
204
205
206 /* SIZIDX is the index of the column's element size value. This */
207 /* descriptor element is meaningful for columns with fixed-size */
208 /* entries. For variable-sized columns, this value is IFALSE. */
209
210
211 /* NAMIDX is the index of the base address of the column's name. */
212
213
214 /* IXTIDX is the data type of the column's index. IXTIDX */
215 /* contains a type value only if the column is indexed. For columns */
216 /* that are not indexed, the location IXTIDX contains the boolean */
217 /* value IFALSE. */
218
219
220 /* IXPIDX is a pointer to the column's index. IXTPDX contains a */
221 /* meaningful value only if the column is indexed. The */
222 /* interpretation of the pointer depends on the data type of the */
223 /* index. */
224
225
226 /* NFLIDX is the index of a flag indicating whether nulls are */
227 /* permitted in the column. The value at location NFLIDX is */
228 /* ITRUE if nulls are permitted and IFALSE otherwise. */
229
230
231 /* ORDIDX is the index of the column's ordinal position in the */
232 /* list of columns belonging to the column's parent segment. */
233
234
235 /* METIDX is the index of the column's integer metadata pointer. */
236 /* This pointer is a DAS integer address. */
237
238
239 /* The last position in the column descriptor is reserved. No */
240 /* parameter is defined to point to this location. */
241
242
243 /* End Include Section: EK Column Descriptor Parameters */
244
245 /* $ Disclaimer */
246
247 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
248 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
249 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
250 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
251 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
252 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
253 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
254 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
255 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
256 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
257
258 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
259 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
260 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
261 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
262 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
263 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
264
265 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
266 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
267 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
268 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
269
270
271 /* Include Section: EK Column Name Size */
272
273 /* ekcnamsz.inc Version 1 17-JAN-1995 (NJB) */
274
275
276 /* Size of column name, in characters. */
277
278
279 /* End Include Section: EK Column Name Size */
280
281 /* $ Disclaimer */
282
283 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
284 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
285 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
286 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
287 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
288 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
289 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
290 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
291 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
292 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
293
294 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
295 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
296 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
297 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
298 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
299 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
300
301 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
302 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
303 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
304 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
305
306
307 /* Include Section: EK Data Page Parameters */
308
309 /* ekfilpar.inc Version 1 03-APR-1995 (NJB) */
310
311 /* These parameters apply to EK files using architecture 4. */
312 /* These files use a paged DAS file as their underlying file */
313 /* structure. */
314
315 /* In paged DAS EK files, data pages are structured: they contain */
316 /* metadata as well as data. The metadata is located in the last */
317 /* few addresses of each page, so as to interfere as little as */
318 /* possible with calculation of data addresses. */
319
320 /* Each data page belongs to exactly one segment. Some bookkeeping */
321 /* information, such as record pointers, is also stored in data */
322 /* pages. */
323
324 /* Each page contains a forward pointer that allows rapid lookup */
325 /* of data items that span multiple pages. Each page also keeps */
326 /* track of the current number of links from its parent segment */
327 /* to the page. Link counts enable pages to `know' when they */
328 /* are no longer in use by a segment; unused pages are deallocated */
329 /* and returned to the free list. */
330
331 /* The parameters in this include file depend on the parameters */
332 /* declared in the include file ekpage.inc. If those parameters */
333 /* change, this file must be updated. The specified parameter */
334 /* declarations we need from that file are: */
335
336 /* INTEGER PGSIZC */
337 /* PARAMETER ( PGSIZC = 1024 ) */
338
339 /* INTEGER PGSIZD */
340 /* PARAMETER ( PGSIZD = 128 ) */
341
342 /* INTEGER PGSIZI */
343 /* PARAMETER ( PGSIZI = 256 ) */
344
345
346
347 /* Character pages use an encoding mechanism to represent integer */
348 /* metadata. Each integer is encoded in five consecutive */
349 /* characters. */
350
351
352 /* Character data page parameters: */
353
354
355 /* Size of encoded integer: */
356
357
358 /* Usable page size: */
359
360
361 /* Location of character forward pointer: */
362
363
364 /* Location of character link count: */
365
366
367 /* Double precision data page parameters: */
368
369 /* Usable page size: */
370
371
372 /* Location of d.p. forward pointer: */
373
374
375 /* Location of d.p. link count: */
376
377
378 /* Integer data page parameters: */
379
380 /* Usable page size: */
381
382
383 /* Location of integer forward pointer: */
384
385
386 /* Location of integer link count: */
387
388
389 /* End Include Section: EK Data Page Parameters */
390
391 /* $ Disclaimer */
392
393 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
394 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
395 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
396 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
397 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
398 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
399 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
400 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
401 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
402 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
403
404 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
405 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
406 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
407 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
408 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
409 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
410
411 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
412 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
413 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
414 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
415
416
417 /* Include Section: EK File Metadata Parameters */
418
419 /* ekfilpar.inc Version 1 28-MAR-1995 (NJB) */
420
421 /* These parameters apply to EK files using architecture 4. */
422 /* These files use a paged DAS file as their underlying file */
423 /* structure. */
424
425 /* The metadata for an architecture 4 EK file is very simple: it */
426 /* consists of a single integer, which is a pointer to a tree */
427 /* that in turn points to the segments in the EK. However, in the */
428 /* interest of upward compatibility, one integer page is reserved */
429 /* for the file's metadata. */
430
431
432 /* Size of file parameter block: */
433
434
435 /* All offsets shown below are relative to the beginning of the */
436 /* first integer page in the EK. */
437
438
439 /* Index of the segment pointer tree---this location contains the */
440 /* root page number of the tree: */
441
442
443 /* End Include Section: EK File Metadata Parameters */
444
445 /* $ Disclaimer */
446
447 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
448 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
449 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
450 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
451 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
452 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
453 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
454 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
455 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
456 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
457
458 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
459 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
460 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
461 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
462 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
463 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
464
465 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
466 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
467 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
468 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
469
470
471 /* Include Section: EK General Limit Parameters */
472
473 /* ekglimit.inc Version 1 21-MAY-1995 (NJB) */
474
475
476 /* This file contains general limits for the EK system. */
477
478 /* MXCLSG is the maximum number of columns allowed in a segment. */
479 /* This limit applies to logical tables as well, since all segments */
480 /* in a logical table must have the same column definitions. */
481
482
483 /* End Include Section: EK General Limit Parameters */
484
485 /* $ Disclaimer */
486
487 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
488 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
489 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
490 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
491 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
492 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
493 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
494 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
495 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
496 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
497
498 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
499 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
500 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
501 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
502 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
503 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
504
505 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
506 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
507 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
508 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
509
510
511 /* Include Section: EK Das Paging Parameters */
512
513 /* ekpage.inc Version 4 25-AUG-1995 (NJB) */
514
515
516
517 /* The EK DAS paging system makes use of the integer portion */
518 /* of an EK file's DAS address space to store the few numbers */
519 /* required to describe the system's state. The allocation */
520 /* of DAS integer addresses is shown below. */
521
522
523 /* DAS integer array */
524
525 /* +--------------------------------------------+ */
526 /* | EK architecture code | Address = 1 */
527 /* +--------------------------------------------+ */
528 /* | Character page size (in DAS words) | */
529 /* +--------------------------------------------+ */
530 /* | Character page base address | */
531 /* +--------------------------------------------+ */
532 /* | Number of character pages in file | */
533 /* +--------------------------------------------+ */
534 /* | Number of character pages on free list | */
535 /* +--------------------------------------------+ */
536 /* | Character free list head pointer | Address = 6 */
537 /* +--------------------------------------------+ */
538 /* | | Addresses = */
539 /* | Metadata for d.p. pages | 7--11 */
540 /* | | */
541 /* +--------------------------------------------+ */
542 /* | | Addresses = */
543 /* | Metadata for integer pages | 12--16 */
544 /* | | */
545 /* +--------------------------------------------+ */
546 /* . */
547 /* . */
548 /* . */
549 /* +--------------------------------------------+ */
550 /* | | End Address = */
551 /* | Unused space | integer page */
552 /* | | end */
553 /* +--------------------------------------------+ */
554 /* | | Start Address = */
555 /* | First integer page | integer page */
556 /* | | base */
557 /* +--------------------------------------------+ */
558 /* . */
559 /* . */
560 /* . */
561 /* +--------------------------------------------+ */
562 /* | | */
563 /* | Last integer page | */
564 /* | | */
565 /* +--------------------------------------------+ */
566
567 /* The following parameters indicate positions of elements in the */
568 /* paging system metadata array: */
569
570
571
572 /* Number of metadata items per data type: */
573
574
575 /* Character metadata indices: */
576
577
578 /* Double precision metadata indices: */
579
580
581 /* Integer metadata indices: */
582
583
584 /* Size of metadata area: */
585
586
587 /* Page sizes, in units of DAS words of the appropriate type: */
588
589
590 /* Default page base addresses: */
591
592
593 /* End Include Section: EK Das Paging Parameters */
594
595 /* $ Disclaimer */
596
597 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
598 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
599 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
600 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
601 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
602 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
603 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
604 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
605 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
606 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
607
608 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
609 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
610 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
611 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
612 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
613 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
614
615 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
616 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
617 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
618 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
619
620
621 /* Include Section: EK Record Pointer Parameters */
622
623 /* ekrecptr.inc Version 2 18-JUL-1995 (NJB) */
624
625
626 /* This file declares parameters used in EK record pointers. */
627 /* Each segment references data in a given record via two levels */
628 /* of indirection: a record number points to a record pointer, */
629 /* which is a structured array of metadata and data pointers. */
630
631 /* Record pointers always occupy contiguous ranges of integer */
632 /* addresses. */
633
634 /* The parameter declarations in this file depend on the assumption */
635 /* that integer pages contain 256 DAS integer words and that the */
636 /* maximum number of columns in a segment is 100. Record pointers */
637 /* are stored in integer data pages, so they must fit within the */
638 /* usable data area afforded by these pages. The size of the usable */
639 /* data area is given by the parameter IPSIZE which is declared in */
640 /* ekdatpag.inc. The assumed value of IPSIZE is 254. */
641
642
643 /* The first element of each record pointer is a status indicator. */
644 /* The meanings of status indicators depend on whether the parent EK */
645 /* is shadowed or not. For shadowed EKs, allowed status values and */
646 /* their meanings are: */
647
648 /* OLD The record has not been modified since */
649 /* the EK containing the record was opened. */
650
651 /* UPDATE The record is an update of a previously existing */
652 /* record. The original record is now on the */
653 /* modified record list. */
654
655 /* NEW The record has been added since the EK containing the */
656 /* record was opened. The record is not an update */
657 /* of a previously existing record. */
658
659 /* DELOLD This status applies only to a backup record. */
660 /* DELOLD status indicates that the record corresponds */
661 /* to a deleted OLD record in the source segment. */
662
663 /* DELNEW This status applies only to a backup record. */
664 /* DELNEW status indicates that the record corresponds */
665 /* to a deleted NEW record in the source segment. */
666
667 /* DELUPD This status applies only to a backup record. */
668 /* DELUPD status indicates that the record corresponds */
669 /* to a deleted UPDATEd record in the source segment. */
670
671 /* In EKs that are not shadowed, all records have status OLD. */
672
673
674
675 /* The following parameters refer to indices within the record */
676 /* pointer structure: */
677
678 /* Index of status indicator: */
679
680
681 /* Each record pointer contains a pointer to its companion: for a */
682 /* record belonging to a shadowed EK, this is the backup counterpart, */
683 /* or if the parent EK is itself a backup EK, a pointer to the */
684 /* record's source record. The pointer is UNINIT (see below) if the */
685 /* record is unmodified. */
686
687 /* Record companion pointers contain record numbers, not record */
688 /* base addresses. */
689
690 /* Index of record's companion pointer: */
691
692
693 /* Each data item is referenced by an integer. The meaning of */
694 /* this integer depends on the representation of data in the */
695 /* column to which the data item belongs. Actual lookup of a */
696 /* data item must be done by subroutines appropriate to the class of */
697 /* the column to which the item belongs. Note that data items don't */
698 /* necessarily occupy contiguous ranges of DAS addresses. */
699
700 /* Base address of data pointers: */
701
702
703 /* Maximum record pointer size: */
704
705
706 /* Data pointers are given the value UNINIT to start with; this */
707 /* indicates that the data item is uninitialized. UNINIT is */
708 /* distinct from the value NULL. NOBACK indicates an uninitialized */
709 /* backup column entry. */
710
711
712 /* End Include Section: EK Record Pointer Parameters */
713
714 /* $ Disclaimer */
715
716 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
717 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
718 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
719 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
720 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
721 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
722 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
723 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
724 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
725 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
726
727 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
728 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
729 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
730 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
731 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
732 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
733
734 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
735 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
736 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
737 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
738
739
740 /* Include Section: EK Segment Descriptor Parameters */
741
742 /* eksegdsc.inc Version 8 06-NOV-1995 (NJB) */
743
744
745 /* All `base addresses' referred to below are the addresses */
746 /* *preceding* the item the base applies to. This convention */
747 /* enables simplied address calculations in many cases. */
748
749 /* Size of segment descriptor. Note: the include file ekcoldsc.inc */
750 /* must be updated if this parameter is changed. The parameter */
751 /* CDOFF in that file should be kept equal to SDSCSZ. */
752
753
754 /* Index of the segment type code: */
755
756
757 /* Index of the segment's number. This number is the segment's */
758 /* index in the list of segments contained in the EK to which */
759 /* the segment belongs. */
760
761
762 /* Index of the DAS integer base address of the segment's integer */
763 /* meta-data: */
764
765
766 /* Index of the DAS character base address of the table name: */
767
768
769 /* Index of the segment's column count: */
770
771
772 /* Index of the segment's record count: */
773
774
775 /* Index of the root page number of the record tree: */
776
777
778 /* Index of the root page number of the character data page tree: */
779
780
781 /* Index of the root page number of the double precision data page */
782 /* tree: */
783
784
785 /* Index of the root page number of the integer data page tree: */
786
787
788 /* Index of the `modified' flag: */
789
790
791 /* Index of the `initialized' flag: */
792
793
794 /* Index of the shadowing flag: */
795
796
797 /* Index of the companion file handle: */
798
799
800 /* Index of the companion segment number: */
801
802
803 /* The next three items are, respectively, the page numbers of the */
804 /* last character, d.p., and integer data pages allocated by the */
805 /* segment: */
806
807
808 /* The next three items are, respectively, the page-relative */
809 /* indices of the last DAS word in use in the segment's */
810 /* last character, d.p., and integer data pages: */
811
812
813 /* Index of the DAS character base address of the column name list: */
814
815
816 /* The last descriptor element is reserved for future use. No */
817 /* parameter is defined to point to this location. */
818
819
820 /* End Include Section: EK Segment Descriptor Parameters */
821
822 /* $ Disclaimer */
823
824 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
825 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
826 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
827 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
828 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
829 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
830 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
831 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
832 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
833 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
834
835 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
836 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
837 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
838 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
839 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
840 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
841
842 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
843 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
844 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
845 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
846
847
848 /* Include Section: EK Table Name Size */
849
850 /* ektnamsz.inc Version 1 17-JAN-1995 (NJB) */
851
852
853 /* Size of table name, in characters. */
854
855
856 /* End Include Section: EK Table Name Size */
857
858 /* $ Disclaimer */
859
860 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
861 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
862 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
863 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
864 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
865 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
866 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
867 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
868 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
869 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
870
871 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
872 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
873 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
874 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
875 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
876 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
877
878 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
879 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
880 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
881 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
882
883
884 /* Include Section: EK Data Types */
885
886 /* ektype.inc Version 1 27-DEC-1994 (NJB) */
887
888
889 /* Within the EK system, data types of EK column contents are */
890 /* represented by integer codes. The codes and their meanings */
891 /* are listed below. */
892
893 /* Integer codes are also used within the DAS system to indicate */
894 /* data types; the EK system makes no assumptions about compatibility */
895 /* between the codes used here and those used in the DAS system. */
896
897
898 /* Character type: */
899
900
901 /* Double precision type: */
902
903
904 /* Integer type: */
905
906
907 /* `Time' type: */
908
909 /* Within the EK system, time values are represented as ephemeris */
910 /* seconds past J2000 (TDB), and double precision numbers are used */
911 /* to store these values. However, since time values require special */
912 /* treatment both on input and output, and since the `TIME' column */
913 /* has a special role in the EK specification and code, time values */
914 /* are identified as a type distinct from double precision numbers. */
915
916
917 /* End Include Section: EK Data Types */
918
919 /* $ Brief_I/O */
920
921 /* Variable I/O Description */
922 /* -------- --- -------------------------------------------------- */
923 /* HANDLE I File handle. */
924 /* TABNAM I Table name. */
925 /* NCOLS I Number of columns in the segment. */
926 /* CNAMES I Names of columns. */
927 /* CDSCRS I-O Descriptors of columns. */
928 /* SEGNO O Segment number. */
929
930 /* $ Detailed_Input */
931
932 /* HANDLE the handle of an EK file that is open for writing. */
933
934 /* TABNAM is the name of the EK table to which the current */
935 /* segment belongs. All segments in the EK file */
936 /* designated by HANDLE must have identical column */
937 /* attributes. TABNAM must not exceed 32 characters */
938 /* in length. Case is not significant. Table names */
939 /* must start with a letter and contain only */
940 /* characters from the set {A-Z,a-z,0-9,$,_}. */
941
942 /* NCOLS is the number of columns in a new segment. */
943
944 /* CNAMES, */
945 /* CDSCRS are, respectively, and array of column names and */
946 /* their corresponding descriptors: the Ith element */
947 /* of CNAMES and the Ith descriptor apply to */
948 /* the Ith column in the segment. */
949
950
951 /* $ Detailed_Output */
952
953 /* CDSCRS are the input column descriptors, with their name */
954 /* base and ordinal position elements filled in. */
955
956 /* SEGNO is the number of the segment created by this */
957 /* routine. Segment numbers are used as unique */
958 /* identifiers by other EK access routines. */
959
960 /* $ Parameters */
961
962 /* None. */
963
964 /* $ Exceptions */
965
966 /* 1) If HANDLE is invalid, the error will be diagnosed by routines */
967 /* called by this routine. */
968
969 /* 2) If an I/O error occurs while reading or writing the indicated */
970 /* file, the error will be diagnosed by routines called by this */
971 /* routine. */
972
973 /* $ Files */
974
975 /* See the EK Required Reading for a discussion of the EK file */
976 /* format. */
977
978 /* $ Particulars */
979
980 /* This routine operates by side effects: it prepares an EK for */
981 /* the addition of a new type 2 segment. Type 2 segments have */
982 /* fixed record counts: they do not support record insertion, */
983 /* or deletion operations. They do not support arbitrary column */
984 /* entry update operations either, since some updates change the */
985 /* size of the affected entries. */
986
987 /* Type 2 segments may contains columns of class 7 through 9. */
988
989 /* By way of contrast, type 1 segments support variable record */
990 /* counts. */
991
992 /* $ Examples */
993
994 /* See EKBSEG. */
995
996 /* $ Restrictions */
997
998 /* None. */
999
1000 /* $ Literature_References */
1001
1002 /* None. */
1003
1004 /* $ Author_and_Institution */
1005
1006 /* N.J. Bachman (JPL) */
1007
1008 /* $ Version */
1009
1010 /* - Beta Version 1.0.0, 17-NOV-1995 (NJB) */
1011
1012 /* -& */
1013
1014 /* SPICELIB functions */
1015
1016
1017 /* Local parameters */
1018
1019
1020 /* Local variables */
1021
1022
1023 /* Standard SPICE error handling. */
1024
1025 if (return_()) {
1026 return 0;
1027 } else {
1028 chkin_("ZZEKBS02", (ftnlen)8);
1029 }
1030
1031 /* Before trying to actually write anything, do every error */
1032 /* check we can. */
1033
1034 /* Is this file handle valid--is the file open for paged write */
1035 /* access? Signal an error if not. */
1036
1037 zzekpgch_(handle, "WRITE", (ftnlen)5);
1038 if (failed_()) {
1039 chkout_("ZZEKBS02", (ftnlen)8);
1040 return 0;
1041 }
1042
1043 /* The metadata layout has the following form: */
1044
1045 /* +------------------------------------------+ */
1046 /* | | */
1047 /* | segment descriptor | */
1048 /* | | */
1049 /* +------------------------------------------+ */
1050 /* | column descriptor 1 | */
1051 /* +------------------------------------------+ */
1052 /* | column descriptor 2 | */
1053 /* +------------------------------------------+ */
1054 /* . */
1055 /* . */
1056 /* . */
1057 /* +------------------------------------------+ */
1058 /* | column descriptor m | */
1059 /* +------------------------------------------+ */
1060
1061 /* The column descriptors may span multiple pages, but they */
1062 /* always occupy contiguous DAS integer addresses. */
1063
1064 /* In addition, the metadata area includes a character page */
1065 /* that contains the segment's table name and the table's */
1066 /* column names. */
1067
1068 /* Calculate the number of contiguous integer pages we'll need. */
1069 /* This value is a function of the number of columns. */
1070
1071 metasz = *ncols * 11 + 24;
1072 nipage = (metasz + 255) / 256;
1073
1074 /* Allocate NIPAGE new integer pages. Insisting on new pages */
1075 /* enforces contiguity. Also allocate one character page, which */
1076 /* need not be new. */
1077
1078 zzekpgan_(handle, &c__3, &p1, &p1base);
1079 i__1 = nipage;
1080 for (i__ = 2; i__ <= i__1; ++i__) {
1081 zzekpgan_(handle, &c__3, &p, &base);
1082 }
1083
1084 /* Calculate the number of contiguous character pages we'll need. */
1085
1086 ncpage = ((*ncols << 5) + 1087) / 1024;
1087 zzekpgan_(handle, &c__1, &cp1, &cbase);
1088 i__1 = ncpage;
1089 for (i__ = 2; i__ <= i__1; ++i__) {
1090 zzekpgan_(handle, &c__1, &p, &base);
1091 }
1092
1093 /* On the third day of Christmas, we initialized three data page */
1094 /* trees: one for each data type. */
1095
1096 zzektrit_(handle, &cpt);
1097 zzektrit_(handle, &dpt);
1098 zzektrit_(handle, &ipt);
1099
1100 /* Prepare the contents of the first integer page: initialize */
1101 /* everything other than the column descriptors. */
1102
1103 /* The last data word in use for each data type is initialized */
1104 /* to indicate that no room is left in the current page. This */
1105 /* forces allocation of a new page when data must be added. The */
1106 /* `last word' counts of each type for both the data and modified */
1107 /* record trees are initialized in this fashion. */
1108
1109 cleari_(&c__256, ipage);
1110
1111 /* The value at index EKTIDX is the segment type. */
1112
1113 ipage[0] = 2;
1114 ipage[1] = eknseg_(handle) + 1;
1115 ipage[2] = p1base;
1116 ipage[3] = cbase;
1117 ipage[4] = *ncols;
1118 ipage[5] = 0;
1119 ipage[6] = 0;
1120 ipage[7] = cpt;
1121 ipage[8] = dpt;
1122 ipage[9] = ipt;
1123 ipage[10] = 1;
1124 ipage[11] = -1;
1125 ipage[12] = -1;
1126 ipage[13] = 0;
1127 ipage[14] = 0;
1128 ipage[15] = 0;
1129 ipage[16] = 0;
1130 ipage[17] = 0;
1131 ipage[18] = 1014;
1132 ipage[19] = 126;
1133 ipage[20] = 254;
1134 ipage[21] = cbase + 64;
1135
1136 /* Initialize the character metadata page: fill in the table name. */
1137 /* The table name gets converted to upper case and is left justified. */
1138
1139 s_copy(cpage, " ", (ftnlen)1024, (ftnlen)1);
1140 ljust_(tabnam, tmptnm, tabnam_len, (ftnlen)64);
1141 ucase_(tmptnm, tmptnm, (ftnlen)64, (ftnlen)64);
1142 s_copy(cpage, tmptnm, (ftnlen)64, (ftnlen)64);
1143
1144 /* Now for the column-specific tasks. We write out a descriptor for */
1145 /* each column. At the same time, we write out the column's name. */
1146
1147 ipagno = 1;
1148 cpagno = 1;
1149 p = p1;
1150 cp = cp1;
1151 i__1 = *ncols;
1152 for (i__ = 1; i__ <= i__1; ++i__) {
1153
1154 /* Insert the column's ordinal position in the segment into */
1155 /* the column's descriptor. */
1156
1157 cdscrs[i__ * 11 - 3] = i__;
1158
1159 /* Write the Ith column name into the character metdata page. (We */
1160 /* know the name is non-blank.) Blank-pad the name on the right, */
1161 /* up to a length of CNAMSZ characters, if necessary. Convert the */
1162 /* name to upper case as well. */
1163
1164 ucase_(cnames + (i__ - 1) * cnames_len, tmpcnm, cnames_len, (ftnlen)
1165 32);
1166 nambas = (i__ - 1 << 5) + 64 - (cpagno - 1 << 10);
1167 room = 1024 - nambas;
1168 if (32 <= room) {
1169 i__2 = nambas;
1170 s_copy(cpage + i__2, tmpcnm, nambas + 32 - i__2, (ftnlen)32);
1171
1172 /* Fill the column name's base address into the descriptor. */
1173
1174 cdscrs[i__ * 11 - 7] = cbase + (cpagno - 1 << 10) + nambas;
1175 } else {
1176
1177 /* Some or all of the column name will overflow onto the next */
1178 /* page. */
1179
1180 if (room > 0) {
1181 i__2 = nambas;
1182 s_copy(cpage + i__2, tmpcnm, nambas + room - i__2, room);
1183 cdscrs[i__ * 11 - 7] = cbase + (cpagno - 1 << 10) + nambas;
1184 } else {
1185 cdscrs[i__ * 11 - 7] = cbase + (cpagno << 10);
1186 }
1187
1188 /* Write out the page we just filled up. */
1189
1190 zzekpgwc_(handle, &cp, cpage, (ftnlen)1024);
1191
1192 /* The next character page will hold the overflow. The next */
1193 /* page is the successor of page CP, since we allocated */
1194 /* consecutive character pages. */
1195
1196 ++cp;
1197 ++cpagno;
1198 i__2 = room;
1199 s_copy(cpage, tmpcnm + i__2, (ftnlen)1024, 32 - i__2);
1200 }
1201
1202 /* Add the column descriptor to the metadata page, if the */
1203 /* descriptor will fit. We may need to allocate another page */
1204 /* to hold the descriptor. */
1205
1206 dscbas = (i__ - 1) * 11 + 24 - (ipagno - 1 << 8);
1207 room = 256 - dscbas;
1208 if (11 <= room) {
1209
1210 /* The whole descriptor fits in the current page. */
1211
1212 movei_(&cdscrs[i__ * 11 - 11], &c__11, &ipage[(i__2 = dscbas) <
1213 256 && 0 <= i__2 ? i__2 : s_rnge("ipage", i__2, "zzekbs0"
1214 "2_", (ftnlen)426)]);
1215 } else {
1216
1217 /* Some or all of the descriptor will overflow onto the next */
1218 /* page. */
1219
1220 if (room > 0) {
1221 movei_(&cdscrs[i__ * 11 - 11], &room, &ipage[(i__2 = dscbas) <
1222 256 && 0 <= i__2 ? i__2 : s_rnge("ipage", i__2,
1223 "zzekbs02_", (ftnlen)435)]);
1224 }
1225
1226 /* Write out the page we just filled up. */
1227
1228 zzekpgwi_(handle, &p, ipage);
1229
1230 /* The next integer page will hold the overflow. The next page */
1231 /* is the successor of page P, since we allocated consecutive */
1232 /* pages. */
1233
1234 ++p;
1235 ++ipagno;
1236 cleari_(&c__256, ipage);
1237 i__2 = 11 - room;
1238 movei_(&cdscrs[room + 1 + i__ * 11 - 12], &i__2, ipage);
1239 }
1240
1241 /* If we encountered a DAS error, leave now. */
1242
1243 if (failed_()) {
1244 chkout_("ZZEKBS02", (ftnlen)8);
1245 return 0;
1246 }
1247 }
1248
1249 /* Write out the last integer metadata page, and write out the */
1250 /* character metadata page. */
1251
1252 zzekpgwi_(handle, &p, ipage);
1253 zzekpgwc_(handle, &cp, cpage, (ftnlen)1024);
1254
1255 /* At this point, the segment's metadata is filled in. We must */
1256 /* update the file's segment list information to account for this */
1257 /* segment. All we need do is add a new entry to the file's */
1258 /* segment pointer tree. First, look up the tree. */
1259
1260 zzekpgbs_(&c__3, &c__1, &base);
1261 i__1 = base + 1;
1262 i__2 = base + 1;
1263 dasrdi_(handle, &i__1, &i__2, &sgtree);
1264
1265 /* Append the head node of this segment at the end of the segment */
1266 /* tree. The tree will point to the first integer metadata page of */
1267 /* the new segment. */
1268
1269 zzektrap_(handle, &sgtree, &p1, segno);
1270 chkout_("ZZEKBS02", (ftnlen)8);
1271 return 0;
1272 } /* zzekbs02_ */
1273
1274