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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const LINLEN: i32 = 255;
const BUFSIZ: i32 = 22;
/// DAS extract comments to a logical unit
///
/// Extract comments from a previously opened binary DAS file to a
/// previously opened text file attached to a Fortran logical unit.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// HANDLE I Handle of a DAS file opened with read access.
/// COMLUN I Logical unit of an opened text file.
/// COMNTS O Logical flag, indicating comments were found.
/// ```
///
/// # Detailed Input
///
/// ```text
/// HANDLE is the file handle for a binary DAS file that has been
/// opened with read access.
///
/// COMLUN is the Fortran logical unit of a previously opened text
/// file to which the comments from a binary DAS file are
/// to be written.
///
/// The comments will be placed into the text file beginning
/// at the current location in the file, and continuing
/// until all of the comments have been written.
/// ```
///
/// # Detailed Output
///
/// ```text
/// COMNTS is a logical flag indicating whether or not any comments
/// were found in the comment area of a DAS file. COMNTS will
/// have the value .TRUE. if there were some comments, and
/// the value .FALSE. otherwise.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If an error occurs while reading from the binary DAS file
/// attached to HANDLE, the error is signaled by a routine in the
/// call tree of this routine.
///
/// 2) If an error occurs while writing to the text file attached to
/// COMLUN, the error is signaled by a routine in the call tree of
/// this routine.
/// ```
///
/// # Files
///
/// ```text
/// See parameters COMLUN and HANDLE in the $Detailed_Inputs section.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine will extract all of the comments from the comment
/// area of a binary DAS file, placing them into a text file
/// attached to COMLUN, beginning at the current position in the
/// text file. If there are no comments in the DAS file, nothing is
/// written to the text file attached to COMLUN.
/// ```
///
/// # Examples
///
/// ```text
/// Let
///
/// HANDLE be the DAS file handle of a previously opened binary
/// DAS file.
///
/// COMLUN be the Fortran logical unit of a previously opened
/// text file that is to accept the comments from the
/// DAS comment area.
///
/// The subroutine call
///
/// CALL DASECU ( HANDLE, COMLUN, COMNTS )
///
/// will extract the comments from the comment area of the binary
/// DAS file attached to HANDLE, if there are any, and write them
/// to the logical unit COMLUN. Upon successful completion, the
/// value of COMNTS will be .TRUE. if there were some comments
/// in the comment area and .FALSE. otherwise.
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) The maximum length of a single line comment in the comment
/// area is specified by the parameter LINLEN defined below.
/// Currently this value is 255 characters.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// K.R. Gehringer (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 20-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.0, 05-JAN-1993 (KRG)
/// ```
pub fn dasecu(
ctx: &mut SpiceContext,
handle: i32,
comlun: i32,
comnts: &mut bool,
) -> crate::Result<()> {
DASECU(handle, comlun, comnts, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure DASECU ( DAS extract comments to a logical unit )
pub fn DASECU(
HANDLE: i32,
COMLUN: i32,
COMNTS: &mut bool,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut COMBUF = ActualCharArray::new(LINLEN, 1..=BUFSIZ);
let mut NUMCOM: i32 = 0;
let mut EOC: bool = false;
let mut GOTSOM: bool = false;
//
// SPICELIB functions
//
//
// Local parameters
//
// Set the value for the maximum length of a text line.
//
//
// Set the size of the comment buffer.
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(b"DASECU", ctx)?;
}
//
// Verify that the DAS file attached to HANDLE is opened for reading.
//
DASSIH(HANDLE, b"READ", ctx)?;
if FAILED(ctx) {
CHKOUT(b"DASECU", ctx)?;
return Ok(());
}
//
// Initialize some things before the loop.
//
NUMCOM = 0;
EOC = false;
GOTSOM = false;
while !EOC {
//
// While we have not reached the end of the comments, get some
// more.
//
DASEC(
HANDLE,
BUFSIZ,
&mut NUMCOM,
COMBUF.as_arg_mut(),
&mut EOC,
ctx,
)?;
if FAILED(ctx) {
CHKOUT(b"DASECU", ctx)?;
return Ok(());
}
if (NUMCOM > 0) {
//
// If NUMCOM .GT. 0 then we did get some comments, and we need
// to write them out, but first, set the flag indicating that
// we got some comments.
//
if !GOTSOM {
GOTSOM = true;
}
WRITLA(NUMCOM, COMBUF.as_arg(), COMLUN, ctx)?;
if FAILED(ctx) {
CHKOUT(b"DASECU", ctx)?;
return Ok(());
}
}
}
//
// Set the output flag indicating whether or not we got any comments.
//
*COMNTS = GOTSOM;
CHKOUT(b"DASECU", ctx)?;
Ok(())
}