1 /* zzekad04.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_n2 = -2;
11 static integer c__3 = 3;
12 static logical c_false = FALSE_;
13 static integer c__0 = 0;
14
15 /* $Procedure ZZEKAD04 ( EK, add data to class 4 column ) */
zzekad04_(integer * handle,integer * segdsc,integer * coldsc,integer * recptr,integer * nvals,integer * ivals,logical * isnull)16 /* Subroutine */ int zzekad04_(integer *handle, integer *segdsc, integer *
17 coldsc, integer *recptr, integer *nvals, integer *ivals, logical *
18 isnull)
19 {
20 /* System generated locals */
21 integer i__1, i__2;
22
23 /* Local variables */
24 integer nrec;
25 extern integer zzekrp2n_(integer *, integer *, integer *);
26 integer room;
27 extern /* Subroutine */ int zzekpgbs_(integer *, integer *, integer *),
28 zzekglnk_(integer *, integer *, integer *, integer *), zzeksfwd_(
29 integer *, integer *, integer *, integer *), zzekslnk_(integer *,
30 integer *, integer *, integer *);
31 integer p, mbase, pbase;
32 extern /* Subroutine */ int chkin_(char *, ftnlen);
33 integer recno, ncols, lastw, start, p2;
34 extern /* Subroutine */ int dasudi_(integer *, integer *, integer *,
35 integer *);
36 integer remain, colidx, datptr, nlinks, nwrite, ptrloc;
37 logical fstpag;
38 extern /* Subroutine */ int setmsg_(char *, ftnlen), errint_(char *,
39 integer *, ftnlen), sigerr_(char *, ftnlen), chkout_(char *,
40 ftnlen), zzekaps_(integer *, integer *, integer *, logical *,
41 integer *, integer *);
42
43 /* $ Abstract */
44
45 /* Add a column entry to a specified record in a class 4 column. */
46 /* The entries of class 4 columns are arrays of integer values. */
47
48 /* $ Disclaimer */
49
50 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
51 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
52 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
53 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
54 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
55 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
56 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
57 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
58 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
59 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
60
61 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
62 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
63 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
64 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
65 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
66 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
67
68 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
69 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
70 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
71 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
72
73 /* $ Required_Reading */
74
75 /* EK */
76
77 /* $ Keywords */
78
79 /* EK */
80 /* PRIVATE */
81
82 /* $ Declarations */
83 /* $ Disclaimer */
84
85 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
86 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
87 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
88 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
89 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
90 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
91 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
92 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
93 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
94 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
95
96 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
97 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
98 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
99 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
100 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
101 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
102
103 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
104 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
105 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
106 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
107
108
109 /* Include Section: EK Boolean Enumerated Type */
110
111
112 /* ekbool.inc Version 1 21-DEC-1994 (NJB) */
113
114
115 /* Within the EK system, boolean values sometimes must be */
116 /* represented by integer or character codes. The codes and their */
117 /* meanings are listed below. */
118
119 /* Integer code indicating `true': */
120
121
122 /* Integer code indicating `false': */
123
124
125 /* Character code indicating `true': */
126
127
128 /* Character code indicating `false': */
129
130
131 /* End Include Section: EK Boolean Enumerated Type */
132
133 /* $ Disclaimer */
134
135 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
136 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
137 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
138 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
139 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
140 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
141 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
142 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
143 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
144 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
145
146 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
147 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
148 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
149 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
150 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
151 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
152
153 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
154 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
155 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
156 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
157
158
159 /* Include Section: EK Column Descriptor Parameters */
160
161 /* ekcoldsc.inc Version 6 23-AUG-1995 (NJB) */
162
163
164 /* Note: The column descriptor size parameter CDSCSZ is */
165 /* declared separately in the include section CDSIZE$INC.FOR. */
166
167 /* Offset of column descriptors, relative to start of segment */
168 /* integer address range. This number, when added to the last */
169 /* integer address preceding the segment, yields the DAS integer */
170 /* base address of the first column descriptor. Currently, this */
171 /* offset is exactly the size of a segment descriptor. The */
172 /* parameter SDSCSZ, which defines the size of a segment descriptor, */
173 /* is declared in the include file eksegdsc.inc. */
174
175
176 /* Size of column descriptor */
177
178
179 /* Indices of various pieces of column descriptors: */
180
181
182 /* CLSIDX is the index of the column's class code. (We use the */
183 /* word `class' to distinguish this item from the column's data */
184 /* type.) */
185
186
187 /* TYPIDX is the index of the column's data type code (CHR, INT, DP, */
188 /* or TIME). The type is actually implied by the class, but it */
189 /* will frequently be convenient to look up the type directly. */
190
191
192
193 /* LENIDX is the index of the column's string length value, if the */
194 /* column has character type. A value of IFALSE in this element of */
195 /* the descriptor indicates that the strings have variable length. */
196
197
198 /* SIZIDX is the index of the column's element size value. This */
199 /* descriptor element is meaningful for columns with fixed-size */
200 /* entries. For variable-sized columns, this value is IFALSE. */
201
202
203 /* NAMIDX is the index of the base address of the column's name. */
204
205
206 /* IXTIDX is the data type of the column's index. IXTIDX */
207 /* contains a type value only if the column is indexed. For columns */
208 /* that are not indexed, the location IXTIDX contains the boolean */
209 /* value IFALSE. */
210
211
212 /* IXPIDX is a pointer to the column's index. IXTPDX contains a */
213 /* meaningful value only if the column is indexed. The */
214 /* interpretation of the pointer depends on the data type of the */
215 /* index. */
216
217
218 /* NFLIDX is the index of a flag indicating whether nulls are */
219 /* permitted in the column. The value at location NFLIDX is */
220 /* ITRUE if nulls are permitted and IFALSE otherwise. */
221
222
223 /* ORDIDX is the index of the column's ordinal position in the */
224 /* list of columns belonging to the column's parent segment. */
225
226
227 /* METIDX is the index of the column's integer metadata pointer. */
228 /* This pointer is a DAS integer address. */
229
230
231 /* The last position in the column descriptor is reserved. No */
232 /* parameter is defined to point to this location. */
233
234
235 /* End Include Section: EK Column Descriptor Parameters */
236
237 /* $ Disclaimer */
238
239 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
240 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
241 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
242 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
243 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
244 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
245 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
246 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
247 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
248 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
249
250 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
251 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
252 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
253 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
254 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
255 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
256
257 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
258 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
259 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
260 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
261
262
263 /* Include Section: EK Data Page Parameters */
264
265 /* ekfilpar.inc Version 1 03-APR-1995 (NJB) */
266
267 /* These parameters apply to EK files using architecture 4. */
268 /* These files use a paged DAS file as their underlying file */
269 /* structure. */
270
271 /* In paged DAS EK files, data pages are structured: they contain */
272 /* metadata as well as data. The metadata is located in the last */
273 /* few addresses of each page, so as to interfere as little as */
274 /* possible with calculation of data addresses. */
275
276 /* Each data page belongs to exactly one segment. Some bookkeeping */
277 /* information, such as record pointers, is also stored in data */
278 /* pages. */
279
280 /* Each page contains a forward pointer that allows rapid lookup */
281 /* of data items that span multiple pages. Each page also keeps */
282 /* track of the current number of links from its parent segment */
283 /* to the page. Link counts enable pages to `know' when they */
284 /* are no longer in use by a segment; unused pages are deallocated */
285 /* and returned to the free list. */
286
287 /* The parameters in this include file depend on the parameters */
288 /* declared in the include file ekpage.inc. If those parameters */
289 /* change, this file must be updated. The specified parameter */
290 /* declarations we need from that file are: */
291
292 /* INTEGER PGSIZC */
293 /* PARAMETER ( PGSIZC = 1024 ) */
294
295 /* INTEGER PGSIZD */
296 /* PARAMETER ( PGSIZD = 128 ) */
297
298 /* INTEGER PGSIZI */
299 /* PARAMETER ( PGSIZI = 256 ) */
300
301
302
303 /* Character pages use an encoding mechanism to represent integer */
304 /* metadata. Each integer is encoded in five consecutive */
305 /* characters. */
306
307
308 /* Character data page parameters: */
309
310
311 /* Size of encoded integer: */
312
313
314 /* Usable page size: */
315
316
317 /* Location of character forward pointer: */
318
319
320 /* Location of character link count: */
321
322
323 /* Double precision data page parameters: */
324
325 /* Usable page size: */
326
327
328 /* Location of d.p. forward pointer: */
329
330
331 /* Location of d.p. link count: */
332
333
334 /* Integer data page parameters: */
335
336 /* Usable page size: */
337
338
339 /* Location of integer forward pointer: */
340
341
342 /* Location of integer link count: */
343
344
345 /* End Include Section: EK Data Page Parameters */
346
347 /* $ Disclaimer */
348
349 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
350 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
351 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
352 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
353 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
354 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
355 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
356 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
357 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
358 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
359
360 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
361 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
362 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
363 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
364 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
365 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
366
367 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
368 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
369 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
370 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
371
372
373 /* Include Section: EK Record Pointer Parameters */
374
375 /* ekrecptr.inc Version 2 18-JUL-1995 (NJB) */
376
377
378 /* This file declares parameters used in EK record pointers. */
379 /* Each segment references data in a given record via two levels */
380 /* of indirection: a record number points to a record pointer, */
381 /* which is a structured array of metadata and data pointers. */
382
383 /* Record pointers always occupy contiguous ranges of integer */
384 /* addresses. */
385
386 /* The parameter declarations in this file depend on the assumption */
387 /* that integer pages contain 256 DAS integer words and that the */
388 /* maximum number of columns in a segment is 100. Record pointers */
389 /* are stored in integer data pages, so they must fit within the */
390 /* usable data area afforded by these pages. The size of the usable */
391 /* data area is given by the parameter IPSIZE which is declared in */
392 /* ekdatpag.inc. The assumed value of IPSIZE is 254. */
393
394
395 /* The first element of each record pointer is a status indicator. */
396 /* The meanings of status indicators depend on whether the parent EK */
397 /* is shadowed or not. For shadowed EKs, allowed status values and */
398 /* their meanings are: */
399
400 /* OLD The record has not been modified since */
401 /* the EK containing the record was opened. */
402
403 /* UPDATE The record is an update of a previously existing */
404 /* record. The original record is now on the */
405 /* modified record list. */
406
407 /* NEW The record has been added since the EK containing the */
408 /* record was opened. The record is not an update */
409 /* of a previously existing record. */
410
411 /* DELOLD This status applies only to a backup record. */
412 /* DELOLD status indicates that the record corresponds */
413 /* to a deleted OLD record in the source segment. */
414
415 /* DELNEW This status applies only to a backup record. */
416 /* DELNEW status indicates that the record corresponds */
417 /* to a deleted NEW record in the source segment. */
418
419 /* DELUPD This status applies only to a backup record. */
420 /* DELUPD status indicates that the record corresponds */
421 /* to a deleted UPDATEd record in the source segment. */
422
423 /* In EKs that are not shadowed, all records have status OLD. */
424
425
426
427 /* The following parameters refer to indices within the record */
428 /* pointer structure: */
429
430 /* Index of status indicator: */
431
432
433 /* Each record pointer contains a pointer to its companion: for a */
434 /* record belonging to a shadowed EK, this is the backup counterpart, */
435 /* or if the parent EK is itself a backup EK, a pointer to the */
436 /* record's source record. The pointer is UNINIT (see below) if the */
437 /* record is unmodified. */
438
439 /* Record companion pointers contain record numbers, not record */
440 /* base addresses. */
441
442 /* Index of record's companion pointer: */
443
444
445 /* Each data item is referenced by an integer. The meaning of */
446 /* this integer depends on the representation of data in the */
447 /* column to which the data item belongs. Actual lookup of a */
448 /* data item must be done by subroutines appropriate to the class of */
449 /* the column to which the item belongs. Note that data items don't */
450 /* necessarily occupy contiguous ranges of DAS addresses. */
451
452 /* Base address of data pointers: */
453
454
455 /* Maximum record pointer size: */
456
457
458 /* Data pointers are given the value UNINIT to start with; this */
459 /* indicates that the data item is uninitialized. UNINIT is */
460 /* distinct from the value NULL. NOBACK indicates an uninitialized */
461 /* backup column entry. */
462
463
464 /* End Include Section: EK Record Pointer Parameters */
465
466 /* $ Disclaimer */
467
468 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
469 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
470 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
471 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
472 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
473 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
474 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
475 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
476 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
477 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
478
479 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
480 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
481 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
482 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
483 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
484 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
485
486 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
487 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
488 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
489 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
490
491
492 /* Include Section: EK Segment Descriptor Parameters */
493
494 /* eksegdsc.inc Version 8 06-NOV-1995 (NJB) */
495
496
497 /* All `base addresses' referred to below are the addresses */
498 /* *preceding* the item the base applies to. This convention */
499 /* enables simplied address calculations in many cases. */
500
501 /* Size of segment descriptor. Note: the include file ekcoldsc.inc */
502 /* must be updated if this parameter is changed. The parameter */
503 /* CDOFF in that file should be kept equal to SDSCSZ. */
504
505
506 /* Index of the segment type code: */
507
508
509 /* Index of the segment's number. This number is the segment's */
510 /* index in the list of segments contained in the EK to which */
511 /* the segment belongs. */
512
513
514 /* Index of the DAS integer base address of the segment's integer */
515 /* meta-data: */
516
517
518 /* Index of the DAS character base address of the table name: */
519
520
521 /* Index of the segment's column count: */
522
523
524 /* Index of the segment's record count: */
525
526
527 /* Index of the root page number of the record tree: */
528
529
530 /* Index of the root page number of the character data page tree: */
531
532
533 /* Index of the root page number of the double precision data page */
534 /* tree: */
535
536
537 /* Index of the root page number of the integer data page tree: */
538
539
540 /* Index of the `modified' flag: */
541
542
543 /* Index of the `initialized' flag: */
544
545
546 /* Index of the shadowing flag: */
547
548
549 /* Index of the companion file handle: */
550
551
552 /* Index of the companion segment number: */
553
554
555 /* The next three items are, respectively, the page numbers of the */
556 /* last character, d.p., and integer data pages allocated by the */
557 /* segment: */
558
559
560 /* The next three items are, respectively, the page-relative */
561 /* indices of the last DAS word in use in the segment's */
562 /* last character, d.p., and integer data pages: */
563
564
565 /* Index of the DAS character base address of the column name list: */
566
567
568 /* The last descriptor element is reserved for future use. No */
569 /* parameter is defined to point to this location. */
570
571
572 /* End Include Section: EK Segment Descriptor Parameters */
573
574 /* $ Disclaimer */
575
576 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
577 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
578 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
579 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
580 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
581 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
582 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
583 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
584 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
585 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
586
587 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
588 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
589 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
590 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
591 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
592 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
593
594 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
595 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
596 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
597 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
598
599
600 /* Include Section: EK Data Types */
601
602 /* ektype.inc Version 1 27-DEC-1994 (NJB) */
603
604
605 /* Within the EK system, data types of EK column contents are */
606 /* represented by integer codes. The codes and their meanings */
607 /* are listed below. */
608
609 /* Integer codes are also used within the DAS system to indicate */
610 /* data types; the EK system makes no assumptions about compatibility */
611 /* between the codes used here and those used in the DAS system. */
612
613
614 /* Character type: */
615
616
617 /* Double precision type: */
618
619
620 /* Integer type: */
621
622
623 /* `Time' type: */
624
625 /* Within the EK system, time values are represented as ephemeris */
626 /* seconds past J2000 (TDB), and double precision numbers are used */
627 /* to store these values. However, since time values require special */
628 /* treatment both on input and output, and since the `TIME' column */
629 /* has a special role in the EK specification and code, time values */
630 /* are identified as a type distinct from double precision numbers. */
631
632
633 /* End Include Section: EK Data Types */
634
635 /* $ Brief_I/O */
636
637 /* Variable I/O Description */
638 /* -------- --- -------------------------------------------------- */
639 /* HANDLE I File handle. */
640 /* SEGDSC I Segment descriptor. */
641 /* COLDSC I Column descriptor. */
642 /* RECPTR I Record pointer. */
643 /* NVALS I Number of values to add to column. */
644 /* IVALS I Integer values to add to column. */
645 /* ISNULL I Flag indicating whether column entry is null. */
646
647 /* $ Detailed_Input */
648
649 /* HANDLE is a file handle of an EK open for write access. */
650
651 /* SEGDSC is the descriptor of the segment in which */
652 /* the specified column entry is to be written. */
653
654 /* COLDSC is the descriptor of the column in which */
655 /* the specified column entry is to be written. */
656
657 /* RECPTR is a pointer to the record containing the column */
658 /* entry to be written. */
659
660 /* NVALS, */
661 /* IVALS are, respectively, the number of values to add to */
662 /* the specified column and the set of values */
663 /* themselves. The data values are written into the */
664 /* specified column and record. */
665
666 /* If the column has fixed-size entries, then NVALS */
667 /* must equal the entry size for the specified column. */
668
669 /* Only one value can be added to a virtual column. */
670
671
672 /* ISNULL is a logical flag indicating whether the entry is */
673 /* null. If ISNULL is .FALSE., the column entry */
674 /* defined by NVALS and IVALS is added to the */
675 /* specified kernel file. */
676
677 /* If ISNULL is .TRUE., NVALS and IVALS are ignored. */
678 /* The contents of the column entry are undefined. */
679 /* If the column has fixed-length, variable-size */
680 /* entries, the number of entries is considered to */
681 /* be 1. */
682
683 /* $ Detailed_Output */
684
685 /* None. See the $Particulars section for a description of the */
686 /* effect of this routine. */
687
688 /* $ Parameters */
689
690 /* None. */
691
692 /* $ Exceptions */
693
694 /* 1) If HANDLE is invalid, the error will be diagnosed by routines */
695 /* called by this routine. The file is not modified. */
696
697 /* 2) If the ordinal position of the column specified by COLDSC */
698 /* is out of range, the error SPICE(INVALIDINDEX) is signalled. */
699 /* The file is not modified. */
700
701 /* 3) If the input flag ISNULL is .TRUE. but the target column */
702 /* does not allow nulls, the error SPICE(BADATTRIBUTE) is */
703 /* signalled. The file is not modified. */
704
705 /* 4) If RECPTR is invalid, a DAS addressing error may occur. The */
706 /* error in *not* trapped in advance. This routine assumes that */
707 /* a valid value of RECPTR has been supplied by the caller. */
708
709 /* 3) If an I/O error occurs while reading or writing the indicated */
710 /* file, the error will be diagnosed by routines called by this */
711 /* routine. The file may be corrupted. */
712
713 /* $ Files */
714
715 /* See the EK Required Reading for a discussion of the EK file */
716 /* format. */
717
718 /* $ Particulars */
719
720 /* This routine operates by side effects: it sets the value of a */
721 /* column entry in an EK segment. If the column is indexed, the */
722 /* index is updated to reflect the presence of the new entry. This */
723 /* routine is intended to set values of uninitialized column entries */
724 /* only. To update existing entries, use the ZZEKUExx routines, or */
725 /* at the user level, the EKUCEx routines. */
726
727 /* This routine does not participate in shadowing functions. If the */
728 /* target EK is shadowed, the caller is responsible for performing */
729 /* necessary backup operations. If the target EK is not shadowed, */
730 /* the target record's status is not modified. */
731
732 /* The changes made by this routine to the target EK file become */
733 /* permanent when the file is closed. Failure to close the file */
734 /* properly will leave it in an indeterminate state. */
735
736 /* $ Examples */
737
738 /* See EKACEI. */
739
740 /* $ Restrictions */
741
742 /* 1) This routine cannot be used to update existing column entries. */
743
744 /* $ Literature_References */
745
746 /* None. */
747
748 /* $ Author_and_Institution */
749
750 /* N.J. Bachman (JPL) */
751
752 /* $ Version */
753
754 /* - Beta Version 1.0.0, 26-SEP-1995 (NJB) */
755
756 /* -& */
757
758 /* Non-SPICELIB functions */
759
760
761 /* Local variables */
762
763
764 /* Use discovery check-in. */
765
766 nrec = segdsc[5];
767 colidx = coldsc[8];
768
769 /* Make sure the column exists. */
770
771 ncols = segdsc[4];
772 if (colidx < 1 || colidx > ncols) {
773 chkin_("ZZEKAD04", (ftnlen)8);
774 setmsg_("Column index = #; valid range is 1:#.", (ftnlen)37);
775 errint_("#", &colidx, (ftnlen)1);
776 errint_("#", &nrec, (ftnlen)1);
777 sigerr_("SPICE(INVALIDINDEX)", (ftnlen)19);
778 chkout_("ZZEKAD04", (ftnlen)8);
779 return 0;
780 }
781
782 /* If the value is null, make sure that nulls are permitted */
783 /* in this column. */
784
785 if (*isnull && coldsc[7] != 1) {
786 recno = zzekrp2n_(handle, &segdsc[1], recptr);
787 chkin_("ZZEKAD04", (ftnlen)8);
788 setmsg_("Column having index # in segment # does not allow nulls, bu"
789 "t a null value was supplied for the element in record #.", (
790 ftnlen)115);
791 errint_("#", &colidx, (ftnlen)1);
792 errint_("#", &segdsc[1], (ftnlen)1);
793 errint_("#", &recno, (ftnlen)1);
794 sigerr_("SPICE(BADATTRIBUTE)", (ftnlen)19);
795 chkout_("ZZEKAD04", (ftnlen)8);
796 return 0;
797 }
798
799 /* Check NVALS. If the column has fixed-size entries, NVALS must */
800 /* match the declared entry size. In all cases, NVALS must be */
801 /* positive. */
802
803 if (*nvals < 1) {
804 chkin_("ZZEKAD04", (ftnlen)8);
805 setmsg_("COLIDX = #; segment = #; NVALS = #; NVALS must be positiv"
806 "e ", (ftnlen)61);
807 errint_("#", &colidx, (ftnlen)1);
808 errint_("#", &segdsc[1], (ftnlen)1);
809 errint_("#", nvals, (ftnlen)1);
810 sigerr_("SPICE(INVALIDCOUNT)", (ftnlen)19);
811 chkout_("ZZEKAD04", (ftnlen)8);
812 return 0;
813 }
814 if (coldsc[3] != -1) {
815 if (*nvals != coldsc[3]) {
816 chkin_("ZZEKAD04", (ftnlen)8);
817 setmsg_("COLIDX = #; segment = #; NVALS = #; declared entry siz"
818 "e = #. Sizes must match.", (ftnlen)80);
819 errint_("#", &colidx, (ftnlen)1);
820 errint_("#", &segdsc[1], (ftnlen)1);
821 errint_("#", nvals, (ftnlen)1);
822 errint_("#", &coldsc[3], (ftnlen)1);
823 sigerr_("SPICE(INVALIDCOUNT)", (ftnlen)19);
824 chkout_("ZZEKAD04", (ftnlen)8);
825 return 0;
826 }
827 }
828
829 /* Compute the data pointer location. */
830
831 ptrloc = *recptr + 2 + colidx;
832 if (*isnull) {
833
834 /* All we need do is set the data pointer. The segment's */
835 /* metadata are not affected. */
836
837 dasudi_(handle, &ptrloc, &ptrloc, &c_n2);
838 } else {
839 lastw = segdsc[20];
840 room = 254 - lastw;
841 remain = *nvals;
842 start = 1;
843 fstpag = TRUE_;
844 while(remain > 0) {
845
846 /* Decide where to write the data values. In order to write */
847 /* to the current page, we require enough room for the count */
848 /* and at least one column entry element. */
849
850 if (room >= 2) {
851
852 /* There's room in the current page. If this is the first */
853 /* page this entry is written on, set the data pointer */
854 /* and count. Write as much of the value as possible to */
855 /* the current page. */
856
857 p = segdsc[17];
858 zzekpgbs_(&c__3, &p, &pbase);
859 datptr = pbase + lastw + 1;
860 if (fstpag) {
861 dasudi_(handle, &ptrloc, &ptrloc, &datptr);
862 dasudi_(handle, &datptr, &datptr, nvals);
863 --room;
864 ++datptr;
865 }
866 nwrite = min(remain,room);
867 i__1 = datptr + nwrite - 1;
868 dasudi_(handle, &datptr, &i__1, &ivals[start - 1]);
869 remain -= nwrite;
870 room -= nwrite;
871 start += nwrite;
872
873 /* The page containing the data item gains a link. */
874
875 zzekglnk_(handle, &c__3, &p, &nlinks);
876 i__1 = nlinks + 1;
877 zzekslnk_(handle, &c__3, &p, &i__1);
878
879 /* The last integer word in use must be updated. Account */
880 /* for the count, if this is the first page on which the */
881 /* current entry is written. */
882
883 if (fstpag) {
884 segdsc[20] = lastw + 1 + nwrite;
885 fstpag = FALSE_;
886 } else {
887 segdsc[20] = lastw + nwrite;
888 }
889 } else {
890
891 /* Allocate a data page. If this is not the first data */
892 /* page written to, link the previous page to the current */
893 /* one. */
894
895 zzekaps_(handle, segdsc, &c__3, &c_false, &p2, &pbase);
896 if (! fstpag) {
897 zzeksfwd_(handle, &c__3, &p, &p2);
898 }
899
900 /* The last integer page and word in use must be updated. */
901
902 p = p2;
903 lastw = 0;
904 segdsc[17] = p;
905 segdsc[20] = lastw;
906 room = 254;
907
908 /* Make sure the link count is zeroed out. */
909
910 zzekslnk_(handle, &c__3, &p, &c__0);
911 }
912 }
913 }
914
915 /* Write out the updated segment descriptor. */
916
917 mbase = segdsc[2];
918 i__1 = mbase + 1;
919 i__2 = mbase + 24;
920 dasudi_(handle, &i__1, &i__2, segdsc);
921
922 /* Class 4 columns are not indexed, so we need not update any */
923 /* index to account for the new element. */
924
925 return 0;
926 } /* zzekad04_ */
927
928