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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const FTSIZE: i32 = 5000;
const RSVUNT: i32 = 2;
const SCRUNT: i32 = 1;
const UTSIZE: i32 = ((20 + SCRUNT) + RSVUNT);
const READ: i32 = 1;
const WRITE: i32 = 2;
const SCRTCH: i32 = 3;
const NEW: i32 = 4;
const NUMAMH: i32 = 4;
const BIGI3E: i32 = 1;
const LTLI3E: i32 = 2;
const VAXGFL: i32 = 3;
const VAXDFL: i32 = 4;
const NUMBFF: i32 = 4;
const STRSIZ: i32 = 8;
const STRLEN: i32 = ((STRSIZ + 1) * NUMBFF);
const DAF: i32 = 1;
const DAS: i32 = 2;
const NUMARC: i32 = 2;
const RECL: i32 = 1024;
const FILEN: i32 = 255;
const CBFSIZ: i32 = 1024;
const MAXNUM: i32 = 32;
/// Insert DAF/DAS file name into long error message
///
/// Substitute the first occurrence of a marker in the current long
/// error message with the file name associated with a given
/// DAF/DAS handle.
///
/// # Required Reading
///
/// * [ERROR](crate::required_reading::error)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// MARKER I A substring in the long error message to be
/// replaced.
/// HANDLE I DAF/DAS handle associated with a file.
/// FILEN P Maximum length of filename.
/// ```
///
/// # Detailed Input
///
/// ```text
/// MARKER is a character string that marks a position in
/// the long error message where a file name is to be
/// substituted. Leading and trailing blanks in MARKER
/// are not significant.
///
/// Case IS significant; 'XX' is considered to be
/// a different marker from 'xx'.
///
/// HANDLE is the DAF/DAS handle associated with the file of
/// interest. HANDLE must be associated with a currently
/// loaded DAF or DAS file.
/// ```
///
/// # Parameters
///
/// ```text
/// FILEN is the maximum file name length that can be
/// accommodated by this routine. Currently this
/// parameter is defined in the include file
/// zzddhman.inc.
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
///
/// 1) If HANDLE refers to a scratch DAS file, the string inserted
/// into the long error message is
///
/// 'DAS SCRATCH FILE'
///
/// 2) If HANDLE is not associated with a loaded DAF or DAS file,
/// the string inserted into the long error message is:
///
/// '<No name found for handle #>'
///
/// where the handle number is substituted for the marker '#'.
/// ```
///
/// # Files
///
/// ```text
/// See "Detailed_Input" description of the variable HANDLE.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine provides a convenient and error-free mechanism
/// for inserting a DAF or DAS file name into an error message,
/// given the file handle associated with the file of interest.
/// ```
///
/// # Examples
///
/// ```text
/// 1) Create an error message pertaining to an SPK file
/// designated by HANDLE, then signal an error.
///
/// CALL SETMSG ( 'SPK file # contains a type 3 segment ' //
/// . 'with invalid polynomial degree #. ' //
/// . 'Segment index in file is #.' )
/// CALL ERRHAN ( '#', HANDLE )
/// CALL ERRINT ( '#', DEGREE )
/// CALL ERRINT ( '#', I )
/// CALL SIGERR ( 'SPICE(INVALIDDEGREE)' )
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) The supported filename length is limited by the parameter
/// FILEN.
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.0.2, 02-JUN-2021 (JDR)
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.1, 05-FEB-2015 (NJB)
///
/// Removed header comments about restrictions
/// on using this routine for DAS files.
///
/// - SPICELIB Version 1.0.0, 04-JAN-2002 (NJB)
/// ```
pub fn errhan(ctx: &mut SpiceContext, marker: &str, handle: i32) -> crate::Result<()> {
ERRHAN(marker.as_bytes(), handle, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure ERRHAN ( Insert DAF/DAS file name into long error message )
pub fn ERRHAN(MARKER: &[u8], HANDLE: i32, ctx: &mut Context) -> f2rust_std::Result<()> {
let mut FNAME = [b' '; FILEN as usize];
let mut NUMSTR = [b' '; MAXNUM as usize];
let mut INTARC: i32 = 0;
let mut INTBFF: i32 = 0;
let mut INTAMH: i32 = 0;
let mut FOUND: bool = false;
//
// Local parameters
//
//
// Local variables
//
//
// Get the name of the file designated by the input handle.
//
ZZDDHNFO(
HANDLE,
&mut FNAME,
&mut INTARC,
&mut INTBFF,
&mut INTAMH,
&mut FOUND,
ctx,
)?;
if !FOUND {
INTSTR(HANDLE, &mut NUMSTR, ctx);
fstr::assign(&mut FNAME, b"<No name found for handle ");
SUFFIX(&NUMSTR, 1, &mut FNAME);
SUFFIX(b">", 0, &mut FNAME);
}
//
// Insert the file name string into the long error message.
//
ERRCH(MARKER, &FNAME, ctx);
Ok(())
}