1 /* zzekweqi.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   ZZEKWEQI ( Private: EK, write to encoded query, integer ) */
zzekweqi_(char * name__,integer * value,integer * eqryi,ftnlen name_len)13 /* Subroutine */ int zzekweqi_(char *name__, integer *value, integer *eqryi,
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 /*     Write scalar integer value to 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 /*     NAME       I   Name of scalar item to write. */
428 /*     VALUE      I   Value to write. */
429 /*     EQRYI     I-O  Integer component of query. */
430 
431 /* $ Detailed_Input */
432 
433 /*     NAME           is the name of the item whose value is to be set. */
434 /*                    This item is some element of the integer portion */
435 /*                    of an encoded query.  The currently supported set */
436 /*                    of names is: */
437 
438 /*                       ARCHITECTURE */
439 /*                       INITIALIZED */
440 /*                       PARSED */
441 /*                       NAMES_RESOLVED */
442 /*                       TIMES_RESOLVED */
443 /*                       SEM_CHECKED */
444 /*                       NUM_TABLES */
445 /*                       NUM_CONJUNCTIONS */
446 /*                       NUM_CONSTRAINTS */
447 /*                       NUM_SELECT_COLS */
448 /*                       NUM_ORDERBY_COLS */
449 /*                       NUM_BUF_SIZE */
450 /*                       FREE_NUM */
451 /*                       CHR_BUF_SIZE */
452 /*                       FREE_CHR */
453 
454 /*     VALUE          is an integer value to assign to the quantity */
455 /*                    designated by NAME. */
456 
457 /*     EQRYI          is the integer portion of an encoded EK query. */
458 
459 /* $ Detailed_Output */
460 
461 /*     EQRYI          is the integer portion of an encoded EK query, */
462 /*                    updated to reflect the requested assignment. */
463 
464 /* $ Parameters */
465 
466 /*     None. */
467 
468 /* $ Exceptions */
469 
470 /*     1)  If the input name is not recognized, the error */
471 /*         SPICE(INVALIDNAME) is signalled.  The encoded query is not */
472 /*         modified. */
473 
474 /* $ Files */
475 
476 /*     None. */
477 
478 /* $ Particulars */
479 
480 /*     This routine is intended to hide from calling routines the */
481 /*     specifics of the EK encoded query structure.  See the include */
482 /*     file ekquery.inc if details of this structure are desired. */
483 
484 /* $ Examples */
485 
486 /*     See ZZEKNRES. */
487 
488 /* $ Restrictions */
489 
490 /*     1) Uses EK encoded query architecture version 2. */
491 
492 /* $ Literature_References */
493 
494 /*     None. */
495 
496 /* $ Author_and_Institution */
497 
498 /*     N.J. Bachman       (JPL) */
499 
500 /* $ Version */
501 
502 /* -    Beta Version 1.0.0, 01-AUG-1995 (NJB) */
503 
504 /* -& */
505 
506 /*     SPICELIB functions */
507 
508 
509 /*     Local parameters */
510 
511 
512 /*     Local variables */
513 
514 
515 /*     Saved variables */
516 
517 
518 /*     Initial values */
519 
520 
521 /*     Use discovery check-in. */
522 
523 
524 /*     Find the location of the named item. */
525 
526     ljust_(name__, tmpnam, name_len, (ftnlen)32);
527     ucase_(tmpnam, tmpnam, (ftnlen)32, (ftnlen)32);
528     i__ = isrchc_(tmpnam, &c__15, namlst, (ftnlen)32, (ftnlen)32);
529     if (i__ == 0) {
530 	chkin_("ZZEKWEQI", (ftnlen)8);
531 	setmsg_("Item # not found.", (ftnlen)17);
532 	errch_("#", name__, (ftnlen)1, name_len);
533 	sigerr_("SPICE(INVALIDNAME)", (ftnlen)18);
534 	chkout_("ZZEKWEQI", (ftnlen)8);
535 	return 0;
536     }
537 
538 /*     Do the deed. */
539 
540     eqryi[namidx[(i__1 = i__ - 1) < 15 && 0 <= i__1 ? i__1 : s_rnge("namidx",
541 	    i__1, "zzekweqi_", (ftnlen)214)] + 5] = *value;
542     return 0;
543 } /* zzekweqi_ */
544 
545