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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const VERIDX: i32 = 1;
const LLBIDX: i32 = (VERIDX + 1);
const LLEIDX: i32 = (LLBIDX + 1);
const NULPTR: i32 = -1;
const BWDIDX: i32 = 1;
const FWDIDX: i32 = (BWDIDX + 1);
const IBSIDX: i32 = (FWDIDX + 1);
const ISZIDX: i32 = (IBSIDX + 1);
const DBSIDX: i32 = (ISZIDX + 1);
const DSZIDX: i32 = (DBSIDX + 1);
const CBSIDX: i32 = (DSZIDX + 1);
const CSZIDX: i32 = (CBSIDX + 1);
const DLADSZ: i32 = CSZIDX;
const FMTVER: i32 = 1000000;
const NCHREC: i32 = 1024;
/// DSK, open new file
///
/// Open a new DSK file for subsequent write operations.
///
/// # Required Reading
///
/// * [DAS](crate::required_reading::das)
/// * [DSK](crate::required_reading::dsk)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// FNAME I Name of a DSK file to be opened.
/// IFNAME I Internal file name.
/// NCOMCH I Number of comment characters to allocate.
/// HANDLE O Handle assigned to the opened DSK file.
/// ```
///
/// # Detailed Input
///
/// ```text
/// FNAME is the name of a new DSK file to be created. The
/// file will be left opened for write access.
///
/// IFNAME is the internal file name for the new file. The name
/// may contain as many as 60 characters. All characters
/// of IFNAME should be printing characters (ASCII codes
/// 32-126 decimal). This name should uniquely identify
/// the file.
///
/// NCOMCH is the number of comment characters to allocate.
/// Allocating comment characters at file creation time
/// may reduce the likelihood of having to expand the
/// comment area later.
/// ```
///
/// # Detailed Output
///
/// ```text
/// HANDLE is the file handle associated with the file. This
/// handle is used to identify the file in subsequent
/// calls to other DSK routines.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the input filename is blank, an error is signaled by a
/// routine in the call tree of this routine. No file will be
/// created.
///
/// 2) If the specified file cannot be opened without exceeding the
/// maximum allowed number of open DAS files, an error is signaled
/// by a routine in the call tree of this routine. No file will be
/// created.
///
/// 3) If the file cannot be opened properly, an error is signaled by
/// a routine in the call tree of this routine. No file will be
/// created.
///
/// 4) If the initial records in the file cannot be written, an error
/// is signaled by a routine in the call tree of this routine. No
/// file will be created.
///
/// 5) If no logical units are available, an error is signaled by a
/// routine in the call tree of this routine. No file will be
/// created.
///
/// 6) If the internal file name contains nonprinting characters
/// (ASCII codes decimal 0-31 and 127-255), an error is signaled
/// by a routine in the call tree of this routine. No file will be
/// created.
///
/// 7) If the number of comment characters allocated NCOMCH is
/// negative, an error is signaled by a routine in the call
/// tree of this routine. No file will be created.
/// ```
///
/// # Files
///
/// ```text
/// See argument FNAME.
/// ```
///
/// # Particulars
///
/// ```text
/// DSK files are built using the DLA low-level format and
/// the DAS architecture; DLA files are a specialized type of DAS
/// file in which data are organized as a doubly linked list of
/// segments. Each segment's data belong to contiguous components of
/// character, double precision, and integer type.
///
/// This routine creates a new DSK file and sets the type of the
/// file to the mnemonic code passed to it.
///
/// DSK files created by this routine have initialized file records.
/// The ID word in a DSK file record has the form
///
/// DAS/DSK
///
/// where the characters following the slash are supplied by the
/// caller of this routine.
/// ```
///
/// # Examples
///
/// ```text
/// 1) Create a new DSK file, using an internal file name that
/// attempts to serve as an unique identifier. No room for
/// comments will be reserved.
///
/// FNAME = 'TEST.DSK'
/// IFNAME = 'TEST.DSK/NAIF/NJB/20-OCT-2006/14:37:00'
/// NCOMCH = 0
///
/// CALL DSKOPN ( FNAME, IFNAME, NCOMCH, HANDLE )
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.0.1, 02-JUL-2021 (JDR)
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.0, 08-FEB-2017 (NJB)
///
/// Corrected a few header typos.
///
/// 29-APR-2010 (NJB)
///
/// Now passes NCOMCH to DLAOPN.
///
/// 08-OCT-2009 (NJB)
///
/// Updated header.
///
/// 20-OCT-2006 (NJB)
/// ```
pub fn dskopn(
ctx: &mut SpiceContext,
fname: &str,
ifname: &str,
ncomch: i32,
handle: &mut i32,
) -> crate::Result<()> {
DSKOPN(
fname.as_bytes(),
ifname.as_bytes(),
ncomch,
handle,
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure DSKOPN ( DSK, open new file )
pub fn DSKOPN(
FNAME: &[u8],
IFNAME: &[u8],
NCOMCH: i32,
HANDLE: &mut i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
//
// SPICELIB functions
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"DSKOPN", ctx)?;
DLAOPN(FNAME, b"DSK", IFNAME, NCOMCH, HANDLE, ctx)?;
CHKOUT(b"DSKOPN", ctx)?;
Ok(())
}