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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
pub const FILEN: i32 = 255;
const OPLEN: i32 = 3;
/// Get/Set Error Output Device Name
///
/// Retrieve or set the name of the current output
/// device for error messages.
///
/// # Required Reading
///
/// * [ERROR](crate::required_reading::error)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// OP I The operation: 'GET' or 'SET'.
/// DEVICE I-O The device name.
/// FILEN P Maximum length of file name.
/// ```
///
/// # Detailed Input
///
/// ```text
/// OP indicates the operation to be performed. Possible
/// values are 'GET' and 'SET'. 'GET' means, "set
/// DEVICE equal to the name of the current error
/// output device" 'SET' means, "set the name of the
/// current error output device equal to the value of
/// DEVICE."
///
/// DEVICE is an input when OP has the value, 'SET'. It
/// indicates an output device to which error messages
/// are to be sent. Possible values for DEVICE are:
///
/// A file name Note that the name must not
/// be any of the reserved strings below.
///
/// 'SCREEN' The output will go to the
/// screen. This is the default device.
///
/// 'NULL' The data will not be output.
///
/// 'SCREEN' and 'NULL' can be written in mixed
/// case. For example, the following call will work:
///
/// CALL ERRDEV ( 'SET' , 'screEn' )
/// ```
///
/// # Detailed Output
///
/// ```text
/// DEVICE is an output when OP is 'GET'. It is the
/// current error output device. See "Detailed
/// Input" for possible values and meanings.
/// ```
///
/// # Parameters
///
/// ```text
/// FILEN is the maximum length of a file name that can be
/// processed by this routine. FILEN is currently set to 255
/// characters.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If an invalid value of the argument OP is supplied, the error
/// SPICE(INVALIDOPERATION) is signaled.
///
/// 2) If OP is 'SET' and the device name DEVICE exceeds the maximum
/// length FILEN, the error SPICE(DEVICENAMETOOLONG) is signaled.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine is part of the SPICELIB error handling mechanism.
///
/// Please read the "required reading"!
///
/// This routine can't tell whether the name supplied
/// to indicate the output device is valid. Be careful!
/// ```
///
/// # Examples
///
/// ```text
/// 1. In this example, we select as the output device
/// the file, SPUD.DAT.
///
/// C
/// C Set the error output device to SPUD.DAT:
/// C
///
/// CALL ERRDEV ( 'SET', 'SPUD.DAT' )
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) This routine has no capability of determining the validity of
/// the name of an output device. Care must be taken to ensure
/// that the file named is the correct one.
///
/// The device name is assumed to be no longer than FILEN
/// characters.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// H.A. Neilan (JPL)
/// B.V. Semenov (JPL)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 2.27.0, 28-NOV-2021 (BVS)
///
/// Updated for MAC-OSX-M1-64BIT-CLANG_C.
///
/// - SPICELIB Version 2.26.0, 07-JUN-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard. $Exceptions
/// section has been completely updated to provide only the list
/// of exceptions. Additional information provided there has been
/// moved to $Particulars.
///
/// - SPICELIB Version 2.25.0, 10-MAR-2014 (BVS)
///
/// Updated for SUN-SOLARIS-64BIT-INTEL.
///
/// - SPICELIB Version 2.24.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-LINUX-64BIT-IFORT.
///
/// - SPICELIB Version 2.23.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-CYGWIN-GFORTRAN.
///
/// - SPICELIB Version 2.22.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-CYGWIN-64BIT-GFORTRAN.
///
/// - SPICELIB Version 2.21.0, 10-MAR-2014 (BVS)
///
/// Updated for PC-CYGWIN-64BIT-GCC_C.
///
/// - SPICELIB Version 2.20.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-INTEL.
///
/// - SPICELIB Version 2.19.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-INTEL-CC_C.
///
/// - SPICELIB Version 2.18.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-INTEL-64BIT-CC_C.
///
/// - SPICELIB Version 2.17.0, 13-MAY-2010 (BVS)
///
/// Updated for SUN-SOLARIS-64BIT-NATIVE_C.
///
/// - SPICELIB Version 2.16.0, 13-MAY-2010 (BVS)
///
/// Updated for PC-WINDOWS-64BIT-IFORT.
///
/// - SPICELIB Version 2.15.0, 13-MAY-2010 (BVS)
///
/// Updated for PC-LINUX-64BIT-GFORTRAN.
///
/// - SPICELIB Version 2.14.0, 13-MAY-2010 (BVS)
///
/// Updated for PC-64BIT-MS_C.
///
/// - SPICELIB Version 2.13.0, 13-MAY-2010 (BVS)
///
/// Updated for MAC-OSX-64BIT-INTEL_C.
///
/// - SPICELIB Version 2.12.0, 13-MAY-2010 (BVS)
///
/// Updated for MAC-OSX-64BIT-IFORT.
///
/// - SPICELIB Version 2.11.0, 13-MAY-2010 (BVS)
///
/// Updated for MAC-OSX-64BIT-GFORTRAN.
///
/// - SPICELIB Version 2.10.0, 18-MAR-2009 (BVS)
///
/// Updated for PC-LINUX-GFORTRAN.
///
/// - SPICELIB Version 2.9.0, 18-MAR-2009 (BVS)
///
/// Updated for MAC-OSX-GFORTRAN.
///
/// - SPICELIB Version 2.8.0, 19-FEB-2008 (BVS)
///
/// Updated for PC-LINUX-IFORT.
///
/// - SPICELIB Version 2.7.0, 14-NOV-2006 (BVS)
///
/// Updated for PC-LINUX-64BIT-GCC_C.
///
/// - SPICELIB Version 2.6.0, 14-NOV-2006 (BVS)
///
/// Updated for MAC-OSX-INTEL_C.
///
/// - SPICELIB Version 2.5.0, 14-NOV-2006 (BVS)
///
/// Updated for MAC-OSX-IFORT.
///
/// - SPICELIB Version 2.4.0, 14-NOV-2006 (BVS)
///
/// Updated for PC-WINDOWS-IFORT.
///
/// - SPICELIB Version 2.3.0, 26-OCT-2005 (BVS)
///
/// Updated for SUN-SOLARIS-64BIT-GCC_C.
///
/// - SPICELIB Version 2.2.0, 03-JAN-2005 (BVS)
///
/// Updated for PC-CYGWIN_C.
///
/// - SPICELIB Version 2.1.0, 03-JAN-2005 (BVS)
///
/// Updated for PC-CYGWIN.
///
/// - SPICELIB Version 2.0.5, 17-JUL-2002 (BVS)
///
/// Added MAC-OSX environments.
///
/// - SPICELIB Version 2.0.4, 08-OCT-1999 (WLT)
///
/// The environment lines were expanded so that the supported
/// environments are now explicitly given. New
/// environments are WIN-NT
///
/// - SPICELIB Version 2.0.3, 24-SEP-1999 (NJB)
///
/// CSPICE environments were added. Some typos were corrected.
///
/// - SPICELIB Version 2.0.2, 28-JUL-1999 (WLT)
///
/// The environment lines were expanded so that the supported
/// environments are now explicitly given. New
/// environments are PC-DIGITAL, SGI-O32 and SGI-N32.
///
/// - SPICELIB Version 2.0.1, 18-MAR-1999 (WLT)
///
/// The environment lines were expanded so that the supported
/// environments are now explicitly given. Previously,
/// environments such as SUN-SUNOS and SUN-SOLARIS were implied
/// by the environment label SUN.
///
/// - SPICELIB Version 2.0.0, 05-APR-1998 (NJB)
///
/// References to the PC-LINUX environment were added.
///
/// - SPICELIB Version 1.2.0, 03-NOV-1993 (HAN)
///
/// Module was updated to include the value for FILEN
/// for the Silicon Graphics, DEC Alpha-OSF/1, and
/// NeXT platforms. Also, the previous value of 256 for
/// Unix platforms was changed to 255.
///
/// - SPICELIB Version 1.1.0, 09-OCT-1992 (HAN)
///
/// Updated module for multiple environments.
///
/// The code was also reformatted so that a utility program can
/// create the source file for a specific environment given a
/// master source file.
///
/// - 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)
/// ```
///
/// # Revisions
///
/// ```text
/// - SPICELIB Version 2.0.0, 05-APR-1998 (NJB)
///
/// References to the PC-LINUX environment were added.
///
/// - SPICELIB Version 1.2.0, 03-NOV-1993 (HAN)
///
/// Module was updated to include the value for FILEN
/// for the Silicon Graphics, DEC Alpha-OSF/1, and
/// NeXT platforms. Also, the previous value of 256 for
/// Unix platforms was changed to 255.
///
/// - SPICELIB Version 1.1.0, 09-OCT-1992 (HAN)
///
/// Updated module for multiple environments.
///
/// The code was also reformatted so that a utility program can
/// create the source file for a specific environment given a
/// master source file.
///
/// - Beta Version 1.1.0, 16-FEB-1989 (NJB)
///
/// File name length parameter added to $Parameters section.
/// Declaration of the unused function FRSTNB removed.
/// Trace participation added. This routine now checks in
/// and checks out. However, it does not test RETURN,
/// because it should be able to execute in RETURN mode when
/// an error condition exists.
/// ```
pub fn errdev(ctx: &mut SpiceContext, op: &str, device: &mut str) -> crate::Result<()> {
ERRDEV(
op.as_bytes(),
fstr::StrBytes::new(device).as_mut(),
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure ERRDEV ( Get/Set Error Output Device Name )
pub fn ERRDEV(OP: &[u8], DEVICE: &mut [u8], ctx: &mut Context) -> f2rust_std::Result<()> {
let mut UPNAM = [b' '; FILEN as usize];
let mut LOCNAM = [b' '; FILEN as usize];
let mut UPOP = [b' '; OPLEN as usize];
let mut LOCOP = [b' '; OPLEN as usize];
//
// SPICELIB functions
//
//
// Local Variables:
//
//
// Initial Values:
//
//
// Executable Code:
//
CHKIN(b"ERRDEV", ctx)?;
//
// We save the operation string as input, and get
// an upper case version for our own use:
//
LJUST(OP, &mut UPOP);
UCASE(&UPOP.clone(), &mut UPOP, ctx);
if fstr::eq(&UPOP, b"GET") {
GETDEV(DEVICE, ctx);
} else if fstr::eq(&UPOP, b"SET") {
//
// We want the reserved words to be in upper
// case for our own use. So, save the input value
// and get an upper case version:
//
LJUST(DEVICE, &mut UPNAM);
UCASE(&UPNAM.clone(), &mut UPNAM, ctx);
if (LASTNB(&UPNAM) > FILEN) {
fstr::assign(&mut LOCNAM, DEVICE);
SETMSG(&fstr::concat(b"ERRDEV: Device name exceeds FILEN characters; device selection not updated. The first FILEN characters of the name were: ", &LOCNAM), ctx);
SIGERR(b"SPICE(DEVICENAMETOOLONG)", ctx)?;
CHKOUT(b"ERRDEV", ctx)?;
return Ok(());
}
if (fstr::eq(&UPNAM, b"SCREEN") || fstr::eq(&UPNAM, b"NULL")) {
//
// Store upper case version of DEVICE:
//
PUTDEV(&UPNAM, ctx);
} else {
//
// We assume we've got a file name...
// Store it as it was input.
//
PUTDEV(DEVICE, ctx);
}
} else {
//
// An invalid value of OP was supplied.
//
fstr::assign(&mut LOCOP, OP);
SETMSG(
&fstr::concat(
b"ERRDEV: An invalid value of OP was supplied. The value was: ",
&LOCOP,
),
ctx,
);
SIGERR(b"SPICE(INVALIDOPERATION)", ctx)?;
}
CHKOUT(b"ERRDEV", ctx)?;
Ok(())
}