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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// DAS, read file record
///
/// Return the contents of the file record of a specified DAS
/// file.
///
/// # Required Reading
///
/// * [DAS](crate::required_reading::das)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// HANDLE I DAS file handle.
/// IDWORD O ID word.
/// IFNAME O DAS internal file name.
/// NRESVR O Number of reserved records in file.
/// NRESVC O Number of characters in use in reserved rec. area.
/// NCOMR O Number of comment records in file.
/// NCOMC O Number of characters in use in comment area.
/// ```
///
/// # Detailed Input
///
/// ```text
/// HANDLE is a file handle for a previously opened DAS file.
/// ```
///
/// # Detailed Output
///
/// ```text
/// IDWORD is the "ID word" contained in the first eight
/// characters of the file record.
///
/// IFNAME is the internal file name of the DAS file. The
/// maximum length of the internal file name is 60
/// characters.
///
/// NRESVR is the number of reserved records in the DAS file
/// specified by HANDLE.
///
/// NRESVC is the number of characters in use in the reserved
/// record area of the DAS file specified by HANDLE.
///
/// NCOMR is the number of comment records in the DAS file
/// specified by HANDLE.
///
/// NCOMC is the number of characters in use in the comment area
/// of the DAS file specified by HANDLE.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the file read attempted by this routine fails, an error is
/// signaled by a routine in the call tree of this routine.
///
/// 2) If the input file handle is invalid, an error is signaled by
/// a routine in the call tree of this routine.
///
/// 3) If a logical unit cannot be obtained for the file designated
/// by HANDLE, an error is signaled by a routine in the call tree
/// of this routine.
///
/// 4) If the file's binary format is unrecognized, an error is
/// signaled by a routine in the call tree of this routine.
///
/// 5) If the file designated by HANDLE has non-native binary format,
/// and if any numeric components of the file record cannot be
/// translated to native format, an error is signaled by a
/// routine in the call tree of this routine.
/// ```
///
/// # Files
///
/// ```text
/// See the description of HANDLE under $Detailed_Input.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine provides a convenient way of retrieving the
/// information contained in the file record of a DAS file.
/// ```
///
/// # Examples
///
/// ```text
/// The numerical results shown for this example may differ across
/// platforms. The results depend on the SPICE kernels used as
/// input, the compiler and supporting libraries, and the machine
/// specific arithmetic implementation.
///
/// 1) Obtain the internal file name, comment record count, and
/// comment character count of an existing DAS file.
///
/// Example code begins here.
///
///
/// PROGRAM DASRFR_EX1
/// IMPLICIT NONE
///
/// C
/// C Local constants
/// C
/// INTEGER IDWLEN
/// PARAMETER ( IDWLEN = 9 )
///
/// INTEGER IFNLEN
/// PARAMETER ( IFNLEN = 61 )
///
/// INTEGER FILSIZ
/// PARAMETER ( FILSIZ = 256 )
///
/// C
/// C Local variables
/// C
/// CHARACTER*(FILSIZ) FNAME
/// CHARACTER*(IDWLEN) IDWORD
/// CHARACTER*(IFNLEN) IFNAME
///
/// INTEGER HANDLE
/// INTEGER NCOMC
/// INTEGER NCOMR
/// INTEGER NRESVC
/// INTEGER NRESVR
///
/// C
/// C Obtain the file name.
/// C
/// CALL PROMPT ( 'Enter DAS file name > ', FNAME )
///
/// C
/// C Open the file for reading.
/// C
/// CALL DASOPR ( FNAME, HANDLE )
///
/// C
/// C Retrieve the internal file name and print it.
/// C
/// CALL DASRFR ( HANDLE, IDWORD, IFNAME, NRESVR,
/// . NRESVC, NCOMR, NCOMC )
///
/// WRITE(*,*) 'Internal file name is: ', IFNAME
/// WRITE(*,*) 'Number of comment records is: ', NCOMR
/// WRITE(*,*) 'Number of comment characters is: ', NCOMC
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, using the DSK file named phobos512.bds as input
/// DAS file, the output was:
///
///
/// Enter DAS file name > phobos512.bds
/// Internal file name is: phobos512.bds
/// Number of comment records is: 10
/// Number of comment characters is: 1390
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// K.R. Gehringer (JPL)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 3.1.0, 22-FEB-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Updated $Exceptions section to align it with changes
/// implemented in previous version.
///
/// Updated the header to comply with NAIF standard. Added
/// complete code example.
///
/// Updated entries in $Revisions section.
///
/// - SPICELIB Version 3.0.0, 05-FEB-2015 (NJB)
///
/// Updated to support integration with the handle
/// manager subsystem and to support reading of DAS
/// files having non-native binary formats.
///
/// - SPICELIB Version 2.1.0, 25-AUG-1995 (NJB)
///
/// Bug fix: local variables are now used in the direct
/// access of the file record. Previously, the routine read
/// directly into the CHARACTER*(*) arguments IDWORD and IFNAME.
///
/// - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG)
///
/// Removed references to specific DAS file open routines in the
/// $Detailed_Input section of the header. This was done in order
/// to minimize documentation changes if these open routines ever
/// change.
///
/// Removed the DASID parameter which had the value 'NAIF/DAS', as
/// it was not used and is also made obsolete by the change in the
/// format of the ID word being implemented.
///
/// Added a check of FAILED after the call to DASHLU which will
/// check out and return if DASHLU fails. This is so that when in
/// return mode of the error handling the READ following the call
/// to DASHLU will not be executed.
///
/// Reworded some of the descriptions contained in the
/// $Detailed_Output section of the header so that they were more
/// clear.
///
/// Changed the example so that it does not set a value for IFNAME
/// before calling DASRFR. This appears to have been a cut and
/// paste bug from DASWFR.
///
/// - SPICELIB Version 1.0.0, 15-JUL-1992 (NJB) (WLT)
/// ```
///
/// # Revisions
///
/// ```text
/// - SPICELIB Version 2.1.0, 25-AUG-1995 (NJB)
///
/// Bug fix: local variables are now used in the direct
/// access of the file record. Previously, the routine read
/// directly into the CHARACTER*(*) arguments IDWORD and IFNAME.
///
/// - SPICELIB Version 2.0.0, 27-OCT-1993 (KRG)
///
/// Removed the DASID parameter which had the value 'NAIF/DAS', as
/// it was not used and is also made obsolete by the change in the
/// format of the ID word being implemented.
///
/// Added a check of FAILED after the call to DASHLU which will
/// check out and return if DASHLU fails. This is so that when in
/// return mode of the error handling the READ following the call
/// to DASHLU will not be executed.
/// ```
pub fn dasrfr(
ctx: &mut SpiceContext,
handle: i32,
idword: &mut str,
ifname: &mut str,
nresvr: &mut i32,
nresvc: &mut i32,
ncomr: &mut i32,
ncomc: &mut i32,
) -> crate::Result<()> {
DASRFR(
handle,
fstr::StrBytes::new(idword).as_mut(),
fstr::StrBytes::new(ifname).as_mut(),
nresvr,
nresvc,
ncomr,
ncomc,
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure DASRFR ( DAS, read file record )
pub fn DASRFR(
HANDLE: i32,
IDWORD: &mut [u8],
IFNAME: &mut [u8],
NRESVR: &mut i32,
NRESVC: &mut i32,
NCOMR: &mut i32,
NCOMC: &mut i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
//
// SPICELIB functions
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"DASRFR", ctx)?;
ZZDASRFR(HANDLE, IDWORD, IFNAME, NRESVR, NRESVC, NCOMR, NCOMC, ctx)?;
if FAILED(ctx) {
CHKOUT(b"DASRFR", ctx)?;
return Ok(());
}
CHKOUT(b"DASRFR", ctx)?;
Ok(())
}