1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const SHRTLN: i32 = 25;
const OPTLEN: i32 = 10;
/// Get Error Message
///
/// Retrieve the current short error message, the explanation of the
/// short error message, or the long error message.
///
/// # Required Reading
///
/// * [ERROR](crate::required_reading::error)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// OPTION I Indicates type of error message.
/// MSG O The error message to be retrieved.
/// ```
///
/// # Detailed Input
///
/// ```text
/// OPTION is a string that indicates the type of error message to
/// be retrieved.
///
/// Possible values of OPTION are:
///
/// 'SHORT' indicates that the short message is to be
/// retrieved.
///
/// 'EXPLAIN' indicates that the explanation of the
/// short message is to be retrieved.
///
/// 'LONG' indicates that the long message is to be
/// retrieved.
///
/// The input strings indicating the choice of option may be
/// in mixed case. Leading and trailing blanks in OPTION are
/// not significant.
/// ```
///
/// # Detailed Output
///
/// ```text
/// MSG is the error message to be retrieved. Its value depends
/// on OPTION, and on whether an error condition exists.
///
/// When there is no error condition, MSG is blank.
///
/// If an error condition does exist, and OPTION is
///
/// 'SHORT' MSG is the current short error message.
/// This is a very condensed, 25-character
/// description of the error.
///
/// 'EXPLAIN' MSG is the explanation of the current
/// short error message. This is a one-line
/// expansion of the text of the short
/// message.
///
/// All SPICELIB short error messages
/// do have corresponding explanation text.
/// For other short error messages, if
/// there is no explanation text, MSG
/// will be blank.
///
/// 'LONG' MSG is the current long error message.
/// The long error message is a detailed
/// explanation of the error, possibly
/// containing data specific to the
/// particular occurrence of the error.
/// Not all errors have long error messages.
/// If there is none, MSG will be blank.
/// Long error messages are no longer than
/// 320 characters.
///
/// If OPTION is invalid, MSG will remain unchanged from its
/// value on input.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the input OPTION is invalid, the error
/// SPICE(INVALIDMSGTYPE) is signaled. In that case no messages
/// are returned; MSG retains the value it had on input.
/// ```
///
/// # Particulars
///
/// ```text
/// Please read the "required reading" first!
///
/// A good time to call this routine would be when an error
/// condition exists, as indicated by the SPICELIB function,
/// FAILED.
///
/// See the example below for a serving suggestion.
///
/// GETMSG isn't too useful if an error condition doesn't
/// exist, since it will return a blank string in that case.
/// ```
///
/// # Examples
///
/// ```text
/// Here's an example of a real-life call to GETMSG to get the
/// explanation of the current short error message.
///
/// In this example, a SPICELIB routine, RDTEXT, is called.
/// Following the return from RDTEXT, the logical function,
/// FAILED, is tested to see whether an error occurred.
/// If it did, the message is retrieved and output via
/// a user-defined output routine:
///
///
/// C
/// C We call RDTEXT; then test for errors...
/// C
/// CALL RDTEXT ( FILE, LINE, EOF )
///
/// IF ( FAILED ) THEN
///
/// C
/// C Get explanation text for the current short message
/// C and print it:
/// C
///
/// CALL GETMSG ( 'EXPLAIN', TEXT )
///
/// CALL USER_DEFINED_OUTPUT ( TEXT )
///
/// .
/// . [Do more stuff here]
/// .
///
/// END IF
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) This routine is part of the interface to the SPICELIB error
/// handling mechanism. For this reason, this routine does not
/// participate in the trace scheme, even though it has external
/// references.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 20-APR-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard. Moved
/// disclaimer on participation of this routine in the SPICELIB
/// trace scheme from $Exceptions to $Restrictions section.
///
/// - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 31-JAN-1990 (NJB)
/// ```
pub fn getmsg(ctx: &mut SpiceContext, option: &str, msg: &mut str) -> crate::Result<()> {
GETMSG(
option.as_bytes(),
fstr::StrBytes::new(msg).as_mut(),
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure GETMSG ( Get Error Message )
pub fn GETMSG(OPTION: &[u8], MSG: &mut [u8], ctx: &mut Context) -> f2rust_std::Result<()> {
let mut SHRTMS = [b' '; SHRTLN as usize];
let mut UPOPT = [b' '; OPTLEN as usize];
let mut LOCOPT = [b' '; OPTLEN as usize];
//
// Local Variables:
//
//
// Length of short error message:
//
//
// Upper case version of the option:
//
//
// Heeeeeeeeeeeeeeeeeeeeer's the code!
//
//
// We only speak upper case in this routine,
// so convert any lower case letters in OPTION
// to upper case. We save the original OPTION
// string just in case we need to echo it in
// an error message.
//
LJUST(OPTION, &mut UPOPT);
UCASE(&UPOPT.clone(), &mut UPOPT, ctx);
if fstr::eq(&UPOPT, b"SHORT") {
//
// Retrieve short message:
//
GETSMS(MSG, ctx);
} else if fstr::eq(&UPOPT, b"EXPLAIN") {
//
// Get current short message; then get explanation
// corresponding to current short error message:
//
GETSMS(&mut SHRTMS, ctx);
EXPLN(&SHRTMS, MSG);
} else if fstr::eq(&UPOPT, b"LONG") {
//
// Grab long error message:
//
GETLMS(MSG, ctx);
} else {
//
// Invalid value of OPTION!! Signal error, and set long
// error message as well:
//
fstr::assign(&mut LOCOPT, OPTION);
SETMSG(&fstr::concat(b"GETMSG: An invalid value of OPTION was input. Valid choices are \'SHORT\', \'EXPLAIN\', or \'LONG\'. The value that was input was: ", &LOCOPT), ctx);
SIGERR(b"SPICE(INVALIDMSGTYPE)", ctx)?;
}
Ok(())
}