1 /* zzekreqi.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__15 = 15;
11
12 /* $Procedure ZZEKREQI ( Private: EK, read from encoded query, integer ) */
zzekreqi_(integer * eqryi,char * name__,integer * value,ftnlen name_len)13 /* Subroutine */ int zzekreqi_(integer *eqryi, char *name__, integer *value,
14 ftnlen name_len)
15 {
16 /* Initialized data */
17
18 static char namlst[32*15] = "ARCHITECTURE " "INITIALI"
19 "ZED " "PARSED "
20 "NAMES_RESOLVED " "TIMES_RESOLVED "
21 " " "SEM_CHECKED " "NUM_TABLES "
22 " " "NUM_CONJUNCTIONS " "NUM_CONSTRAINTS "
23 " " "NUM_SELECT_COLS " "NUM_ORDERB"
24 "Y_COLS " "NUM_BUF_SIZE " "FREE"
25 "_NUM " "CHR_BUF_SIZE "
26 "FREE_CHR ";
27 static integer namidx[15] = { 2,3,4,5,6,7,8,10,9,12,11,13,14,15,16 };
28
29 /* System generated locals */
30 integer i__1;
31
32 /* Builtin functions */
33 integer s_rnge(char *, integer, char *, integer);
34
35 /* Local variables */
36 static integer i__;
37 extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
38 ftnlen, ftnlen), errch_(char *, char *, ftnlen, ftnlen), ljust_(
39 char *, char *, ftnlen, ftnlen);
40 extern integer isrchc_(char *, integer *, char *, ftnlen, ftnlen);
41 static char tmpnam[32];
42 extern /* Subroutine */ int setmsg_(char *, ftnlen), sigerr_(char *,
43 ftnlen), chkout_(char *, ftnlen);
44
45 /* $ Abstract */
46
47 /* SPICE Private routine intended solely for the support of SPICE */
48 /* routines. Users should not call this routine directly due */
49 /* to the volatile nature of this routine. */
50
51 /* Read scalar integer value from encoded EK query. */
52
53 /* $ Disclaimer */
54
55 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
56 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
57 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
58 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
59 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
60 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
61 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
62 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
63 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
64 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
65
66 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
67 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
68 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
69 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
70 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
71 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
72
73 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
74 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
75 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
76 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
77
78 /* $ Required_Reading */
79
80 /* EK */
81
82 /* $ Keywords */
83
84 /* EK */
85 /* PRIVATE */
86
87 /* $ Declarations */
88 /* $ Disclaimer */
89
90 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
91 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
92 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
93 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
94 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
95 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
96 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
97 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
98 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
99 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
100
101 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
102 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
103 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
104 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
105 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
106 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
107
108 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
109 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
110 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
111 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
112
113
114 /* Include Section: EK Encoded Query Internal Parameters */
115
116 /* ekquery.inc Version 3 16-NOV-1995 (NJB) */
117
118 /* Updated to reflect increased value of MAXCON in */
119 /* ekqlimit.inc. */
120
121 /* ekquery.inc Version 2 03-AUG-1995 (NJB) */
122
123 /* Updated to support representation of the SELECT clause. */
124
125
126 /* ekquery.inc Version 1 12-JAN-1995 (NJB) */
127
128
129 /* An encoded EK query is an abstract data type implemented */
130 /* as an integer cell, along with a double precision cell and */
131 /* a character string. The d.p. cell and string contain numeric */
132 /* and string values from the query string represented by the */
133 /* encoded query. */
134
135 /* The parameters in this file are intended for use only by the */
136 /* EK encoded query access routines. Callers of EK routines should */
137 /* not use these parameters. */
138
139 /* The following parameters are indices of specified elements */
140 /* in the integer portion of the encoded query. */
141
142 /* Encoded query architecture type: */
143
144
145 /* `Name resolution' consists of: */
146
147 /* - Verifying existence of tables: any table names listed */
148 /* in the FROM clause of a query must be loaded. */
149
150 /* - Validating table aliases used to qualify column names. */
151
152 /* - Verifying existence of columns and obtaining data types */
153 /* for columns. */
154
155 /* - Setting data type codes for literal values in the encoded */
156 /* query. */
157
158 /* - Checking consistency of operators and operand data types. */
159
160 /* - Making sure unqualified column names are unambiguous. */
161
162 /* - For constraints, mapping the table names used to qualify */
163 /* column names to the ordinal position in the FROM clause */
164 /* of the corresponding table. */
165
166
167 /* Initialization status---this flag indicates whether the encoded */
168 /* query has been initialized. Values are ITRUE or IFALSE. See the */
169 /* include file ekbool.inc for parameter values. */
170
171
172 /* Parse status---this flag indicates whether the parsing operation */
173 /* that produced an encoded query has been completed. Values are */
174 /* ITRUE or IFALSE. */
175
176
177 /* Name resolution status---this flag indicates whether names */
178 /* have been resolved in an encoded query. Values are ITRUE or */
179 /* IFALSE. */
180
181
182 /* Time resolution status---this flag indicates whether time values */
183 /* have been resolved in an encoded query. Time resolution */
184 /* consists of converting strings representing time values to ET. */
185 /* Values of the status are ITRUE or IFALSE. */
186
187
188 /* Semantic check status---this flag indicates whether semantic */
189 /* checking of constraints has been performed. */
190
191
192 /* Number of tables specified in FROM clause: */
193
194
195 /* Number of constraints in query: */
196
197
198 /* A special value is used to indicate the `maximal' constraint--- */
199 /* one that logically cannot be satisfied. If the constraints */
200 /* are equivalent to the maximal constraint, the location EQNCNS */
201 /* is assigned the value EQMXML */
202
203
204 /* Number of constraint conjunctions: */
205
206
207 /* Number of order-by columns: */
208
209
210 /* Number of SELECT columns: */
211
212
213 /* Size of double precision buffer: */
214
215
216 /* `Free' pointer into double precision buffer: */
217
218
219 /* Size of character string buffer: */
220
221
222 /* `Free' pointer into character string buffer: */
223
224
225 /* The following four base pointers will be valid after a query */
226 /* has been parsed: */
227
228 /* Base pointer for SELECT column descriptors: */
229
230
231 /* Base pointer for constraint descriptors: */
232
233
234 /* Base pointer for conjunction sizes: */
235
236
237 /* Base pointer for order-by column descriptors: */
238
239
240 /* After the quantities named above, the integer array contains */
241 /* series of descriptors for tables, constraints, and order-by */
242 /* columns, as well as a list of `conjunction sizes'---that is, */
243 /* the sizes of the groups of constraints that form conjunctions, */
244 /* after the input query has been re-arranged as a disjunction of */
245 /* conjunctions of constraints. */
246
247
248 /* The offsets of specific elements within descriptors are */
249 /* parameterized. The base addresses of the descriptors themselves */
250 /* must be calculated using the counts and sizes of the items */
251 /* preceding them. */
252
253 /* A diagram of the structure of the variable-size portion of the */
254 /* integer array is shown below: */
255
256
257 /* +-------------------------------------+ */
258 /* | Fixed-size portion of encoded query | */
259 /* +-------------------------------------+ */
260 /* | Encoded FROM clause | */
261 /* +-------------------------------------+ */
262 /* | Encoded constraint clause | */
263 /* +-------------------------------------+ */
264 /* | Conjunction sizes | */
265 /* +-------------------------------------+ */
266 /* | Encoded ORDER BY clause | */
267 /* +-------------------------------------+ */
268 /* | Encoded SELECT clause | */
269 /* +-------------------------------------+ */
270
271
272 /* Value Descriptors */
273 /* ---------------- */
274
275 /* In order to discuss the various descriptors below, we'll make use */
276 /* of sub-structures called `value descriptors'. These descriptors */
277 /* come in two flavors: character and double precision. For */
278 /* strings, a descriptor is a set of begin and end pointers that */
279 /* indicate the location of the string in the character portion of an */
280 /* encoded query, along with the begin and end pointers for the */
281 /* corresponding lexeme in the original query. The pointers are set */
282 /* to zero when they are not in use, for example if they refer to an */
283 /* optional lexeme that did not appear in the input query. */
284
285 /* All value descriptors start with a data type indicator; values */
286 /* are from ektype.inc. Integer and time values are referred to */
287 /* by double precision descriptors. */
288
289 /* Parameters for string value descriptor elements: */
290
291
292 /* Numeric value descriptors are similar to those for string values, */
293 /* the difference being that they have only one pointer to the value */
294 /* they represent. This pointer is the index of the value in the */
295 /* encoded query's numeric buffer. */
296
297
298 /* All value descriptors have the same size. In order to allow */
299 /* table descriptors to have the same size as value descriptors, */
300 /* we include an extra element in the descriptor. */
301
302
303 /* Column Descriptors */
304 /* ----------------- */
305
306 /* Each column descriptor consists of a character descriptor for the */
307 /* name of the column, followed by an index, which gives the ordinal */
308 /* position of the column in the logical table to which the column */
309 /* belongs. The index element is filled in during name resolution. */
310
311
312 /* Table Descriptors */
313 /* ----------------- */
314
315 /* Each table descriptor consists of a character descriptor for the */
316 /* name of the table, followed by an index, which gives the ordinal */
317 /* position of the table in the FROM clause in the original query. */
318 /* The index element is filled in during name resolution. Aliases */
319 /* and table names have identical descriptor structures. */
320
321
322 /* Constraint descriptors */
323 /* ------------------ */
324
325 /* Each constraint is characterized by: */
326
327 /* - A code indicating whether the constraint compares values */
328 /* in two columns or the value in a column and a literal */
329 /* value. The values of this element are EQCOL and EQVAL. */
330
331
332
333 /* - A descriptor for the table used to qualify the */
334 /* column name on the left side of the constraint. */
335
336
337 /* - A character value descriptor for the column name on the left */
338 /* side of the query. */
339
340
341 /* - An operator code indicating the relational operator used */
342 /* in the constraint. */
343
344
345 /* If the constraint compares values from two columns, the */
346 /* next items are table and column name descriptors that apply to */
347 /* the column named on the right side of the relational operator. */
348
349
350 /* If the constraint has a literal value on the right side, the */
351 /* operator code is followed by... */
352
353 /* - a value descriptor. */
354
355
356 /* - Size of a constraint descriptor: */
357
358
359 /* Conjunction sizes */
360 /* ----------------- */
361
362 /* The size of each conjunction of constraints occupies a single */
363 /* integer. */
364
365
366
367
368 /* Order-by Column Descriptors */
369 /* --------------------------- */
370
371 /* Each order-by column descriptor contains descriptors for */
372 /* the table containing the column and for the name of the column */
373 /* itself; one additional element is used to indicate the direction */
374 /* of the ordering (ascending vs descending). */
375
376
377 /* - The last integer in the descriptor indicates whether the */
378 /* order direction is ascending or descending. */
379
380
381 /* - Size of an order-by column descriptor: */
382
383
384 /* Codes indicating sense of ordering (ascending vs descending): */
385
386
387 /* SELECT Column Descriptors */
388 /* --------------------------- */
389
390 /* Each SELECT column descriptor contains descriptors for */
391 /* the table containing the column and for the name of the column */
392 /* itself. */
393
394
395 /* - Size of a SELECT column descriptor: */
396
397
398 /* Miscellaneous parameters: */
399
400
401 /* EQIMIN is the minimum size of the integer portion of */
402 /* an encoded query. EQIMIN depends on the parameters */
403
404 /* MAXTAB */
405 /* MAXCON */
406 /* MAXORD */
407 /* MAXSEL */
408
409 /* all of which are declared in the include file ekqlimit.inc. */
410 /* The functional definition of EQIMIN is: */
411
412 /* INTEGER EQIMIN */
413 /* PARAMETER ( EQIMIN = EQVBAS */
414 /* . + MAXTAB * EQVDSZ * 2 */
415 /* . + MAXCON * EQCDSZ */
416 /* . + MAXCON */
417 /* . + MAXORD * EQODSZ */
418 /* . + MAXSEL * EQSDSZ ) */
419
420
421 /* End Include Section: EK Encoded Query Internal Parameters */
422
423 /* $ Brief_I/O */
424
425 /* Variable I/O Description */
426 /* -------- --- -------------------------------------------------- */
427 /* EQRYI I Integer component of query. */
428 /* NAME I Name of scalar item to read. */
429 /* VALUE O Value of item. */
430
431 /* $ Detailed_Input */
432
433 /* EQRYI is the integer portion of an encoded EK query. */
434
435 /* NAME is the name of the item whose value is to be read. */
436 /* This item is some element of the integer portion */
437 /* of an encoded query. */
438
439 /* $ Detailed_Output */
440
441 /* VALUE is the integer value designated by NAME. */
442
443 /* $ Parameters */
444
445 /* None. */
446
447 /* $ Exceptions */
448
449 /* 1) If the input name is not recognized, the error */
450 /* SPICE(INVALIDNAME) is signalled. The encoded query is not */
451 /* modified. */
452
453 /* $ Files */
454
455 /* None. */
456
457 /* $ Particulars */
458
459 /* This routine is the inverse of ZZEKWEQI. */
460
461 /* $ Examples */
462
463 /* See EKSRCH. */
464
465 /* $ Restrictions */
466
467 /* None. */
468
469 /* $ Literature_References */
470
471 /* None. */
472
473 /* $ Author_and_Institution */
474
475 /* N.J. Bachman (JPL) */
476
477 /* $ Version */
478
479 /* - Beta Version 1.0.0, 17-OCT-1995 (NJB) */
480
481 /* -& */
482
483 /* SPICELIB functions */
484
485
486 /* Local parameters */
487
488
489 /* Local variables */
490
491
492 /* Saved variables */
493
494
495 /* Initial values */
496
497
498 /* Use discovery check-in. */
499
500
501 /* Find the location of the named item. */
502
503 ljust_(name__, tmpnam, name_len, (ftnlen)32);
504 ucase_(tmpnam, tmpnam, (ftnlen)32, (ftnlen)32);
505 i__ = isrchc_(tmpnam, &c__15, namlst, (ftnlen)32, (ftnlen)32);
506 if (i__ == 0) {
507 chkin_("ZZEKREQI", (ftnlen)8);
508 setmsg_("Item # not found.", (ftnlen)17);
509 errch_("#", name__, (ftnlen)1, name_len);
510 sigerr_("SPICE(INVALIDNAME)", (ftnlen)18);
511 chkout_("ZZEKREQI", (ftnlen)8);
512 return 0;
513 }
514
515 /* Do the deed. */
516
517 *value = eqryi[namidx[(i__1 = i__ - 1) < 15 && 0 <= i__1 ? i__1 : s_rnge(
518 "namidx", i__1, "zzekreqi_", (ftnlen)191)] + 5];
519 return 0;
520 } /* zzekreqi_ */
521
522