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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
pub const BSIZE: i32 = 1024;
const IDWLEN: i32 = 8;
/// DAF, text to binary
///
/// Deprecated: This routine has been superseded by the SPICELIB
/// routine DAFTB. NAIF supports this routine only to provide backward
/// compatibility.
///
/// Reconstruct a binary DAF from a text file opened by
/// the calling program.
///
/// # Required Reading
///
/// * [DAF](crate::required_reading::daf)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// TEXT I Logical unit connected to text file.
/// BINARY I Name of a binary DAF to be created.
/// RESV I Number of records to reserve.
/// BSIZE P Buffer size.
/// ```
///
/// # Detailed Input
///
/// ```text
/// TEXT is a logical unit number, to which a text file has
/// been connected by the calling program, and into
/// which the contents of binary DAF have been
/// written. The file pointer should be placed just
/// before the file ID word.
///
/// BINARY is the name of a binary DAF to be created.
/// The binary DAF contains the same data as the
/// text file, but in a form more suitable for use
/// by application programs.
///
/// RESV is the number of records to be reserved in the
/// binary DAF.
/// ```
///
/// # Parameters
///
/// ```text
/// BSIZE is the size of the buffer used to read array elements
/// from the text file. No single group of elements should
/// contains more than BSIZE elements.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If for some reason the text file cannot be read,
/// the error SPICE(DAFREADFAIL) is signaled.
///
/// 2) If the architecture of the file is not DAF, as specified by
/// the ID word, the error SPICE(NOTADAFFILE) is signaled.
///
/// 3) If the text file does not contain matching internal file
/// names, the error SPICE(DAFNOIFNMATCH) is signaled.
///
/// 4) If the text file does not contain matching array names,
/// the error SPICE(DAFNONAMEMATCH) is signaled.
///
/// 5) If the buffer size is not sufficient, the error
/// SPICE(DAFOVERFLOW) is signaled.
/// ```
///
/// # Files
///
/// ```text
/// See arguments TEXT, BINARY.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine has been made obsolete by the new DAF text to binary
/// conversion routine DAFTB. This routine remains available for
/// reasons of backward compatibility. We strongly recommend that you
/// use the new conversion routines for any new software development.
/// Please see the header of the routine DAFTB for details.
///
/// This routine is necessary for converting older DAF text files into
/// their equivalent binary formats, as DAFTB uses a different text
/// file format that is incompatible with the text file format
/// expected by this routine.
///
/// Any binary DAF may be transferred between heterogeneous
/// Fortran environments by converting it to an equivalent file
/// containing only ASCII characters. Such a file can be transferred
/// almost universally, using any number of established protocols
/// (Kermit, FTP, and so on). Once transferred, the ASCII file can
/// be reconverted to a binary DAF, using the representations
/// native to the new host environment.
///
/// There are two pairs of routines that can be used to convert
/// DAFs between binary and ASCII. The first pair, DAFB2A
/// and DAFA2B, works with complete files. That is, DAFB2A creates
/// a complete ASCII file containing all of the information in
/// a particular binary DAF, and nothing else; this file can
/// be fed directly into DAFA2B to produce a complete binary DAF.
/// In each case, the names of the files are specified.
///
/// A related pair of routines, DAFB2T and DAFT2B, assume that
/// the ASCII data are to be stored in the midst of a text file.
/// This allows the calling program to surround the data with
/// standardized labels, to append several binary DAFs into a
/// single text file, and so on.
///
/// Note that you must select the number of records to be reserved
/// in the binary DAF. The contents of reserved records are ignored
/// by the normal transfer process.
/// ```
///
/// # Examples
///
/// ```text
/// DAFB2A and DAFA2B are typically used for simple transfers.
/// If A.DAF is a binary DAF in environment 1, it can be transferred
/// to environment 2 in three steps.
///
/// 1) Convert it to ASCII:
///
/// CALL DAFB2A ( 'A.DAF', 'A.ASCII' )
///
/// 2) Transfer the ASCII file, using FTP, Kermit, or some other
/// file transfer utility:
///
/// ftp> put a.ascii
///
/// 3) Convert it to binary on the new machine,
///
/// CALL DAFA2B ( 'A.ASCII', 'A.DAF', RESV )
///
/// Note that DAFB2A and DAFA2B work in any standard Fortran-77
/// environment.
///
/// If the file needs to contain other information---a standard
/// label, for instance---the first and third steps must be modified
/// to use DAFB2T and DAFT2B. The first step becomes
///
/// (Open a text file)
/// (Write the label)
/// CALL DAFB2T ( BINARY, UNIT )
/// (Close the text file)
///
/// The third step becomes
///
/// (Open the text file)
/// (Read the label)
/// CALL DAFT2B ( UNIT, BINARY, RESV )
/// (Close the text file)
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) DAFT2B cannot be executed while any other DAF is open
/// for writing.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// K.R. Gehringer (JPL)
/// J.E. McLean (JPL)
/// H.A. Neilan (JPL)
/// W.L. Taber (JPL)
/// I.M. Underwood (JPL)
/// E.D. Wright (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 3.1.0, 26-OCT-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard. Moved DAF
/// required reading from $Literature_References to
/// $Required_Reading section.
///
/// - SPICELIB Version 3.0.1, 26-JUL-2012 (EDW)
///
/// Edited $Abstract section to use "Deprecated" keyword
/// and state replacement routine.
///
/// Eliminated unneeded $Revisions section.
///
/// - SPICELIB Version 3.0.0, 04-OCT-1993 (KRG)
///
/// Removed the error SPICE(DAFNOIDWORD) as it was no longer
/// relevant.
///
/// Added the error SPICE(NOTADAFFILE) if this routine is called
/// with a file that does not contain an ID word identifying the
/// file as a DAF file.
///
/// There were no checks of the IOSTAT variable after attempting to
/// read from the text file, a single test of the IOSTAT variable
/// was made at the end of the routine. This was not adequate to
/// detect errors when writing to the text file. So after all of
/// these read statements, an IF ... END IF block was added to
/// signal an error if IOSTAT .NE. 0.
///
/// IF ( IOSTAT .NE. 0 ) THEN
///
/// CALL SETMSG ( 'The attempt to read from file ''#''' //
/// . ' failed. IOSTAT = #.' )
/// CALL ERRFNM ( '#', UNIT )
/// CALL SIGERR ( SPICE(DAFREADFAIL) )
/// CALL CHKOUT ( 'DAFT2B' )
/// RETURN
///
/// END IF
///
/// Removed the code from the end of the routine that purported to
/// check for read errors:
///
/// C
/// C If any read screws up, they should all screw up. Why
/// C make a billion separate checks?
/// C
/// IF ( IOSTAT .NE. 0 ) THEN
/// CALL SETMSG ( 'Value of IOSTAT was: #. ' )
/// CALL ERRINT ( '#', IOSTAT )
/// CALL SIGERR ( SPICE(DAFREADFAIL) )
/// END IF
///
/// The answer to the question is:
///
/// You have to do a billion separate checks because the IOSTAT
/// value is only valid for the most recently executed read.
///
/// Added a statement to the $Particulars section to the effect
/// that this routine has been made obsolete by the introduction of
/// the routine DAFTB, and that we strongly recommend the use of
/// the new routine. This routine must, however, be used when
/// converting older text files to binary, as the old and new
/// formats are not compatible.
///
/// Modified the $Abstract section to reflect the fact that this
/// routine is obsolete and maintained for purposes of backward
/// compatibility only.
///
/// - SPICELIB Version 2.0.2, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 2.0.1, 06-AUG-1990 (HAN)
///
/// Header documentation was corrected. This routine will
/// convert a file containing either ID word, 'NAIF/DAF' or
/// 'NAIF/NIP'. (Previous versions of SPICELIB software used
/// the ID word 'NAIF/NIP'.)
///
/// - SPICELIB Version 2.0.0, 02-AUG-1990 (JEM)
///
/// The previous version of this routine always failed and
/// signaled the error SPICE(DAFNOIDWORD) because of a faulty
/// logical expression in an error-checking IF statement.
/// The error SPICE(DAFNOIDWORD) should be signaled if the
/// next non-blank line in the text file does not begin with the
/// word 'NAIF/DAF' AND does not begin with the word 'NAIF/NIP'.
/// Previously the logic was incorrect causing the error to be
/// signaled every time no matter what the word was. The
/// correction consisted of replacing '.OR.' with '.AND.'
/// in the logical expression.
///
/// - SPICELIB Version 1.0.1, 22-MAR-1990 (HAN)
///
/// Literature references added to the header.
///
/// - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU)
/// ```
pub fn daft2b(ctx: &mut SpiceContext, text: i32, binary: &str, resv: i32) -> crate::Result<()> {
DAFT2B(text, binary.as_bytes(), resv, ctx.raw_context())?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure DAFT2B ( DAF, text to binary )
pub fn DAFT2B(TEXT: i32, BINARY: &[u8], RESV: i32, ctx: &mut Context) -> f2rust_std::Result<()> {
let mut NAME = ActualCharArray::new(1000, 1..=2);
let mut IDWORD = [b' '; IDWLEN as usize];
let mut IFNAME = ActualCharArray::new(60, 1..=2);
let mut TARCH = [b' '; IDWLEN as usize];
let mut TTYPE = [b' '; IDWLEN as usize];
let mut BUFFER = ActualArray::<f64>::new(1..=BSIZE);
let mut DC = StackArray::<f64, 125>::new(1..=125);
let mut SUM = StackArray::<f64, 125>::new(1..=125);
let mut CHUNK: i32 = 0;
let mut HANDLE: i32 = 0;
let mut IC = StackArray::<i32, 250>::new(1..=250);
let mut IOSTAT: i32 = 0;
let mut ISIZE: i32 = 0;
let mut LSIZE: i32 = 0;
let mut MORE: i32 = 0;
let mut ND: i32 = 0;
let mut NI: i32 = 0;
//
// SPICELIB functions
//
//
// Local Parameters
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(b"DAFT2B", ctx)?;
}
fstr::assign(&mut IDWORD, b" ");
fstr::assign(&mut TARCH, b" ");
fstr::assign(&mut TTYPE, b" ");
//
// We should be positioned and ready to read the file ID word from
// the text file, so let's try it.
//
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
reader.read_str(&mut IDWORD)?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
//
// Split the ID word into an architecture and type, and verify that
// the architecture is 'DAF'. If it is not, this is the wrong
// routine, and an error will be signaled.
//
IDW2AT(&IDWORD, &mut TARCH, &mut TTYPE, ctx)?;
if fstr::ne(&TARCH, b"DAF") {
SETMSG(b"File architecture is not \'DAF\' for file \'#\'", ctx);
ERRFNM(b"#", TEXT, ctx)?;
SIGERR(b"SPICE(NOTADAFFILE)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
ND = reader.read_i32()?;
NI = reader.read_i32()?;
reader.read_str(&mut IFNAME[1])?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
//
// Open the new binary file.
//
DAFOPN(BINARY, ND, NI, &IFNAME[1], RESV, &mut HANDLE, ctx)?;
if FAILED(ctx) {
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
//
// Each array is preceded by a '1', which indicates that more
// arrays are to come. The array itself begins with the name
// and the summary components, and ends with the name again.
// The contents are written in arbitrary chunks. The final
// chunk is followed by a '0', which indicates that no chunks
// remain. The names must match, or the array should not
// be terminated normally.
//
// If the chunks in the file are bigger than the local buffer
// size, we are in trouble.
//
LSIZE = ((ND + ((NI - 1) / 2)) + 1);
ISIZE = (LSIZE * 8);
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
MORE = reader.read_i32()?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
while (MORE > 0) {
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
reader.read_str(fstr::substr_mut(NAME.get_mut(1), 1..=ISIZE))?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
for I in intrinsics::range(1, ND, 1) {
DC[I] = reader.read_f64()?;
}
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
for I in intrinsics::range(1, (NI - 2), 1) {
IC[I] = reader.read_i32()?;
}
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
DAFPS(ND, NI, DC.as_slice(), IC.as_slice(), SUM.as_slice_mut());
DAFBNA(
HANDLE,
SUM.as_slice(),
fstr::substr(&NAME[1], 1..=ISIZE),
ctx,
)?;
if FAILED(ctx) {
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
CHUNK = reader.read_i32()?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
while (CHUNK > 0) {
if (CHUNK > BSIZE) {
DAFCLS(HANDLE, ctx)?;
SETMSG(b"Buffer size exceeded. Increase to #.", ctx);
ERRINT(b"#", CHUNK, ctx);
SIGERR(b"SPICE(DAFOVERFLOW)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
} else {
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
for I in intrinsics::range(1, CHUNK, 1) {
BUFFER[I] = reader.read_f64()?;
}
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
DAFADA(BUFFER.as_slice(), CHUNK, ctx)?;
if FAILED(ctx) {
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
CHUNK = reader.read_i32()?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
reader.read_str(fstr::substr_mut(NAME.get_mut(2), 1..=ISIZE))?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
if fstr::ne(
fstr::substr(NAME.get(1), 1..=ISIZE),
fstr::substr(NAME.get(2), 1..=ISIZE),
) {
DAFCLS(HANDLE, ctx)?;
SETMSG(b"Array name mismatch: # and #.", ctx);
ERRCH(b"#", fstr::substr(&NAME[1], 1..=ISIZE), ctx);
ERRCH(b"#", fstr::substr(&NAME[2], 1..=ISIZE), ctx);
SIGERR(b"SPICE(DAFNONAMEMATCH)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
} else {
DAFENA(ctx)?;
if FAILED(ctx) {
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
}
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
MORE = reader.read_i32()?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
}
//
// The final '0' indicates that no arrays remain. The first shall
// be last: the internal file name brings up the rear. If it doesn't
// match the one at the front, complain.
//
{
use f2rust_std::{
data::Val,
io::{self, Reader},
};
let mut reader = io::ListDirectedReader::new(ctx.io_unit(TEXT)?, None)?;
IOSTAT = io::capture_iostat(|| {
reader.start()?;
reader.read_str(&mut IFNAME[2])?;
reader.finish()?;
Ok(())
})?;
}
if (IOSTAT != 0) {
DAFCLS(HANDLE, ctx)?;
SETMSG(
b"The attempt to read from file \'#\' failed. IOSTAT = #.",
ctx,
);
ERRFNM(b"#", TEXT, ctx)?;
ERRINT(b"#", IOSTAT, ctx);
SIGERR(b"SPICE(DAFREADFAIL)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
if fstr::ne(IFNAME.get(1), IFNAME.get(2)) {
DAFCLS(HANDLE, ctx)?;
SETMSG(b"Internal file name mismatch: # and #", ctx);
ERRCH(b"#", &IFNAME[1], ctx);
ERRCH(b"#", &IFNAME[2], ctx);
SIGERR(b"SPICE(DAFNOIFNMATCH)", ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
return Ok(());
}
//
// Close the DAF file we just created.
//
DAFCLS(HANDLE, ctx)?;
CHKOUT(b"DAFT2B", ctx)?;
Ok(())
}