1 /* erract.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__5 = 5;
11 static integer c__2 = 2;
12
13 /* $Procedure ERRACT ( Get/Set Default Error Action ) */
erract_(char * op,char * action,ftnlen op_len,ftnlen action_len)14 /* Subroutine */ int erract_(char *op, char *action, ftnlen op_len, ftnlen
15 action_len)
16 {
17 /* Initialized data */
18
19 static char actns[7*5] = "ABORT " "REPORT " "RETURN " "IGNORE " "DEFAULT"
20 ;
21
22 /* System generated locals */
23 address a__1[2];
24 integer i__1, i__2[2];
25 char ch__1[73], ch__2[65];
26
27 /* Builtin functions */
28 integer s_cmp(char *, char *, ftnlen, ftnlen), s_rnge(char *, integer,
29 char *, integer);
30 /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
31 char **, integer *, integer *, ftnlen);
32
33 /* Local variables */
34 integer iact;
35 extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
36 ftnlen, ftnlen);
37 char locop[3];
38 extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
39 char locact[7];
40 extern /* Subroutine */ int getact_(integer *);
41 extern integer isrchc_(char *, integer *, char *, ftnlen, ftnlen);
42 extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *,
43 ftnlen), putact_(integer *), setmsg_(char *, ftnlen);
44
45 /* $ Abstract */
46
47 /* Retrieve or set the default error action. */
48
49 /* $ Disclaimer */
50
51 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
52 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
53 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
54 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
55 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
56 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
57 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
58 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
59 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
60 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
61
62 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
63 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
64 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
65 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
66 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
67 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
68
69 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
70 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
71 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
72 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
73
74 /* $ Required_Reading */
75
76 /* ERROR */
77
78 /* $ Keywords */
79
80 /* ERROR */
81
82 /* $ Declarations */
83 /* $ Brief_I/O */
84
85 /* VARIABLE I/O DESCRIPTION */
86 /* -------- --- -------------------------------------------------- */
87 /* OP I Operation -- 'GET' or 'SET' */
88 /* ACTION I/O Error response action */
89
90 /* $ Detailed_Input */
91
92 /* OP Indicates the operation -- 'GET' or 'SET'. 'GET' means, */
93 /* "Set ACTION to the current value of the error response */
94 /* action." */
95 /* 'SET' means, "update the error response action to the */
96 /* value indicated by ACTION." */
97
98 /* OP may be in mixed case; for example, */
99
100 /* CALL ERRACT ( 'gEt', ACTION ) */
101
102 /* will work. */
103
104
105 /* ACTION When OP is 'SET', ACTION is an input argument. It */
106 /* takes the values, 'ABORT', 'IGNORE', */
107 /* 'REPORT', 'RETURN', and 'DEFAULT'. */
108
109 /* Please read the "required reading" file if you */
110 /* haven't already done so! */
111
112 /* Briefly, the meanings of the error response */
113 /* choices are as follows: */
114
115 /* 1. 'ABORT' -- When an error is detected by a */
116 /* SPICELIB routine, or when */
117 /* ANY routine signals detection */
118 /* of an error via a call to SIGERR, the */
119 /* toolkit will output any error messages that */
120 /* it has been enabled to output (see ERRPRT */
121 /* and ERRDEV also ), and then execute a */
122 /* FORTRAN STOP statement. */
123
124 /* 2. 'REPORT' -- In this mode, the toolkit does */
125 /* NOT abort when errors are detected. */
126 /* When SIGERR is called to report */
127 /* an error, all error messages that the toolkit */
128 /* is enabled to output will be sent to the */
129 /* designated error output device. Similarly, */
130 /* a call to SETMSG will result in the long */
131 /* error message being output, if the toolkit */
132 /* is enabled to output it. */
133
134
135 /* 3. 'RETURN' -- In this mode, the toolkit also */
136 /* does NOT abort when errors are */
137 /* detected. Instead, error messages */
138 /* are output if the toolkit is enabled to do */
139 /* so, and subsequently, ALL TOOLKIT ROUTINES */
140 /* RETURN IMMEDIATELY UPON ENTRY until the */
141 /* error status is reset via a call to RESET. */
142 /* (No, RESET itself doesn't return on entry). */
143 /* Resetting the error status will cause the */
144 /* toolkit routines to resume their normal */
145 /* execution threads. */
146
147
148
149 /* 4. 'IGNORE' -- The toolkit will not take any */
150 /* action in response to errors; */
151 /* calls to SIGERR will have no */
152 /* effect. */
153
154
155 /* 5. 'DEFAULT' -- This mode is the same as 'ABORT', */
156 /* except that an additional error */
157 /* message is output. The additional */
158 /* message informs the user that the */
159 /* error response action can be */
160 /* modified, and refers to documentation */
161 /* of the error handling feature. */
162
163
164
165 /* ACTION may be in mixed case; for example, */
166
167 /* CALL ERRACT ( 'SET', 'igNORe' ) */
168
169 /* will work. */
170
171 /* $ Detailed_Output */
172
173 /* ACTION When OP is 'GET', ACTION is the current error response */
174 /* action. Possible values are: 'ABORT', 'REPORT', */
175 /* 'RETURN', and 'IGNORE'. See "Detailed Input" */
176 /* for descriptions of the meanings of these values. */
177
178 /* ACTION is not an output unless OP is 'GET'. */
179
180 /* $ Parameters */
181
182 /* None. */
183
184 /* $ Exceptions */
185
186 /* This routine detects invalid values of OP and ACTION. */
187
188 /* The short error messages set by this routine are: */
189
190 /* 1. 'SPICE(INVALIDOPERATION)' -- bad OP value */
191 /* 2. 'SPICE(INVALIDACTION)' -- bad ACTION value. */
192
193
194 /* Also, this routine is part of the SPICELIB error */
195 /* handling mechanism. */
196
197 /* $ Files */
198
199 /* None. */
200
201 /* $ Particulars */
202
203 /* First of all, please read the ``required reading'' file. */
204 /* The information below will make a lot more sense if you do. */
205
206 /* Here is a brief discussion of how to use this routine. */
207
208 /* If you are a user, you will probably be interested */
209 /* in only the 'SET' operation (as far as this routine is */
210 /* concerned, ok?). As indicated in the "detailed */
211 /* input" section above, the choices for ACTION are */
212 /* 'ABORT', 'REPORT', 'RETURN', 'IGNORE', and 'DEFAULT'. These */
213 /* choices control the way the toolkit behaves when an */
214 /* error is detected. The toolkit thinks an error has */
215 /* been detected when SIGERR is called. */
216
217 /* 1. 'ABORT' In this mode, the toolkit sends error messages */
218 /* to the error output device and then stops. */
219 /* This is the default mode. It is probably */
220 /* the one to choose for running non-interactive programs. */
221 /* You may also wish to use this for programs which */
222 /* have many bugs, or in other cases where continued */
223 /* operation following detection of an error isn't useful. */
224
225 /* 2. 'REPORT' In this mode, the toolkit sends error messages */
226 /* to the error output device and keeps going. This mode */
227 /* may be useful if you are debugging a large program, */
228 /* since you can get more information from a single test run. */
229 /* You will probably want to use ERRDEV to indicate a file */
230 /* where your error messages should be sent. */
231
232 /* 3. 'RETURN' In this mode, the toolkit also sends error messages */
233 /* to the error output device and "keeps going". But */
234 /* instead of following their normal execution threads, */
235 /* the toolkit routines will simply return immediately upon */
236 /* entry, once an error has been detected. */
237 /* The availability of this feature makes it safe to call */
238 /* multiple toolkit routines without checking the error */
239 /* status after each one returns; if one routine detects */
240 /* an error, subsequent calls to toolkit routines will have */
241 /* no effect; therefore, no crash will occur. The error */
242 /* messages set by the routine which detected the error */
243 /* will remain available for retrieval by GETMSG. */
244
245 /* 4. 'IGNORE' This mode can be dangerous! It is best */
246 /* used when running a program whose behavior you */
247 /* understand well, in cases where you wish to suppress */
248 /* annoying messages. BUT, if an unexpected error */
249 /* occurs, you won't hear about it from anyone, except */
250 /* possibly your run-time system. */
251
252 /* 5. 'DEFAULT' As the name suggests, this is the default */
253 /* error handling mode. The error handling mechanism */
254 /* starts out in this mode when a program using the */
255 /* toolkit is run, and the mode remains 'DEFAULT' until */
256 /* it is changed via a call to this routine. */
257 /* This mode is the same as 'ABORT', */
258 /* except that an additional error message is output. */
259 /* The additional message informs the user that the */
260 /* error response action can be modified, and refers */
261 /* to documentation of the error handling feature. */
262
263
264 /* NOTE: */
265
266 /* By default, error messages are printed to the screen */
267 /* when errors are detected. You may want to send them */
268 /* to a different output device, or choose a subset to */
269 /* output. Use the routines ERRDEV and ERRPRT to choose */
270 /* the output device and select the messages to output, */
271 /* respectively. */
272
273 /* You can also suppress the automatic output of messages */
274 /* and retrieve them directly in your own program. GETMSG */
275 /* can be used for this. To make sure that the messages */
276 /* retrieved correspond to the FIRST error that occurred, */
277 /* use 'RETURN' mode. In 'REPORT' mode, new messages */
278 /* overwrite old ones in the SPICELIB message storage */
279 /* area, so GETMSG will get the messages from the LATEST */
280 /* error that occurred. */
281
282
283 /* $ Examples */
284
285
286 /* 1. Setting up 'ABORT' mode: */
287
288
289 /* C */
290 /* C We wish to have our program abort if an error */
291 /* C is detected. But instead of having the error */
292 /* C messages printed on the screen, we want them */
293 /* C to be written to the file, ERROR_LOG.DAT */
294 /* C (This is valid VAX/VMS file name; syntax */
295 /* C on your system may be different ). */
296 /* C */
297 /* C We want to see all of the messages, so we */
298 /* C call ERRPRT, using the 'ALL' option. */
299 /* C */
300 /* C Finally, we call ERRACT to set the action to 'ABORT': */
301 /* C */
302
303 /* CALL ERRDEV ( 'SET', 'ERROR_LOG.DAT' ) */
304
305 /* CALL ERRPRT ( 'SET', 'ALL' ) */
306
307 /* CALL ERRACT ( 'SET', 'ABORT' ) */
308
309
310
311 /* 2. Setting up 'REPORT' mode: */
312
313 /* C */
314 /* C This is the same thing as before, except */
315 /* C that the argument supplied to ERRACT */
316 /* C is different. */
317 /* C */
318
319 /* CALL ERRDEV ( 'SET', 'ERROR_LOG.DAT' ) */
320
321 /* CALL ERRPRT ( 'SET', 'ALL' ) */
322
323 /* CALL ERRACT ( 'SET', 'REPORT' ) */
324
325
326 /* 3. Setting up 'RETURN' mode: This is the same */
327 /* as example #2, except that the ERRACT call becomes: */
328
329 /* CALL ERRACT ( 'SET', 'RETURN' ) */
330
331
332
333 /* 4. Setting up 'IGNORE' mode: */
334
335 /* C In this case, we aren't going to have */
336 /* C ANY error messages (unless the call */
337 /* C to ERRACT itself fails), so we don't */
338 /* C really need to call ERRPRT and ERRDEV. */
339 /* C (If the call to ERRACT DOES fail, which */
340 /* C it can do only if we misspell "IGNORE," */
341 /* C the resulting error messages will go to */
342 /* C the screen). */
343
344
345 /* CALL ERRACT ( 'SET', 'IGNORE' ) */
346
347 /* $ Restrictions */
348
349 /* None. */
350
351 /* $ Literature_References */
352
353 /* None. */
354
355 /* $ Author_and_Institution */
356
357 /* N.J. Bachman (JPL) */
358 /* K.R. Gehringer (JPL) */
359
360 /* $ Version */
361
362 /* - SPICELIB Version 2.0.0, 22-APR-1996 (KRG) */
363
364 /* This subroutine has been modified in an attempt to improve */
365 /* the general performance of the SPICELIB error handling */
366 /* mechanism. The specific modification has been to change the */
367 /* type of the error action passed to PUTACT from a short */
368 /* character string to an integer. This change is backwardly */
369 /* incompatible because the type of the input argument has */
370 /* changed. This should pose no difficulties because PUTACT is a */
371 /* private subroutine used by the error handling system, and */
372 /* hence isolated from direct use. */
373
374 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
375
376 /* Comment section for permuted index source lines was added */
377 /* following the header. */
378
379 /* - SPICELIB Version 1.0.0, 31-JAN-1990 (NJB) */
380
381 /* -& */
382 /* $ Index_Entries */
383
384 /* get/set default error action */
385
386 /* -& */
387 /* $ Revisions */
388
389 /* - SPICELIB Version 2.0.0, 22-APR-1996 (KRG) */
390
391 /* This subroutine has been modified in an attempt to improve */
392 /* the general performance of the SPICELIB error handling */
393 /* mechanism. The specific modification has been to change the */
394 /* type of the error action passed to PUTACT from a short */
395 /* character string to an integer. This change is backwardly */
396 /* incompatible because the type of the input argument has */
397 /* changed. This should pose no difficulties because PUTACT is a */
398 /* private subroutine used by the error handling system, and */
399 /* hence isolated from direct use. */
400
401 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
402
403 /* Comment section for permuted index source lines was added */
404 /* following the header. */
405
406 /* - Beta Version 1.1.0, 28-FEB-1989 (NJB) */
407
408 /* Trace participation added. This routine now checks in */
409 /* and checks out. However, it does not test RETURN, */
410 /* because it should be able to execute in RETURN mode when */
411 /* an error condition exists. */
412
413 /* -& */
414
415 /* SPICELIB Functions */
416
417
418 /* Local Parameters */
419
420 /* Define the length of an option. */
421
422
423 /* Define the maximum length of an action. */
424
425
426 /* Define the number of actions */
427
428
429 /* Local Variables */
430
431
432 /* Saved Variables */
433
434
435 /* Initial Values: */
436
437
438 /* Executable Code: */
439
440 chkin_("ERRACT", (ftnlen)6);
441
442 /* We convert the input values to upper case, as needed. Note: we */
443 /* only check the first character of the input variable OP, as that */
444 /* is sufficient to distinguish 'GET' from 'SET' */
445
446 ljust_(op, locop, op_len, (ftnlen)3);
447 ucase_(locop, locop, (ftnlen)3, (ftnlen)3);
448 if (s_cmp(locop, "GET", (ftnlen)3, (ftnlen)3) == 0) {
449 getact_(&iact);
450 s_copy(action, actns + ((i__1 = iact - 1) < 5 && 0 <= i__1 ? i__1 :
451 s_rnge("actns", i__1, "erract_", (ftnlen)442)) * 7,
452 action_len, (ftnlen)7);
453 } else if (s_cmp(locop, "SET", (ftnlen)3, (ftnlen)3) == 0) {
454 ljust_(action, locact, action_len, (ftnlen)7);
455 ucase_(locact, locact, (ftnlen)7, (ftnlen)7);
456 iact = isrchc_(locact, &c__5, actns, (ftnlen)7, (ftnlen)7);
457 if (iact > 0) {
458 putact_(&iact);
459 } else {
460
461 /* We have an invalid value of ACTION */
462
463 s_copy(locact, action, (ftnlen)7, action_len);
464 /* Writing concatenation */
465 i__2[0] = 66, a__1[0] = "ERRACT: An invalid value of ACTION was "
466 "supplied. The value was: ";
467 i__2[1] = 7, a__1[1] = locact;
468 s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)73);
469 setmsg_(ch__1, (ftnlen)73);
470 sigerr_("SPICE(INVALIDACTION)", (ftnlen)20);
471 }
472
473 /* We've set the error action, or signalled an error. */
474
475 } else {
476
477 /* We have an invalid value of OP */
478
479 s_copy(locop, op, (ftnlen)3, op_len);
480 /* Writing concatenation */
481 i__2[0] = 62, a__1[0] = "ERRACT: An invalid value of OP was supplied"
482 ". The value was: ";
483 i__2[1] = 3, a__1[1] = locop;
484 s_cat(ch__2, a__1, i__2, &c__2, (ftnlen)65);
485 setmsg_(ch__2, (ftnlen)65);
486 sigerr_("SPICE(INVALIDOPERATION)", (ftnlen)23);
487 }
488
489 /* We've performed the requested operation, or signalled an */
490 /* error. */
491
492 chkout_("ERRACT", (ftnlen)6);
493 return 0;
494 } /* erract_ */
495
496