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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const CDOFF: i32 = 24;
const CDSCSZ: i32 = 11;
const CLSIDX: i32 = 1;
const TYPIDX: i32 = (CLSIDX + 1);
const LENIDX: i32 = (TYPIDX + 1);
const SIZIDX: i32 = (LENIDX + 1);
const NAMIDX: i32 = (SIZIDX + 1);
const IXTIDX: i32 = (NAMIDX + 1);
const IXPIDX: i32 = (IXTIDX + 1);
const NFLIDX: i32 = (IXPIDX + 1);
const ORDIDX: i32 = (NFLIDX + 1);
const METIDX: i32 = (ORDIDX + 1);
const ENCSIZ: i32 = 5;
const CPSIZE: i32 = 1014;
const CFPIDX: i32 = (CPSIZE + 1);
const CLCIDX: i32 = (CFPIDX + ENCSIZ);
const DPSIZE: i32 = 126;
const DFPIDX: i32 = (DPSIZE + 1);
const DLCIDX: i32 = (DFPIDX + 1);
const IPSIZE: i32 = 254;
const IFPIDX: i32 = (IPSIZE + 1);
const ILCIDX: i32 = (IFPIDX + 1);
const OLD: i32 = 1;
const UPDATE: i32 = (OLD + 1);
const NEW: i32 = (UPDATE + 1);
const DELOLD: i32 = (NEW + 1);
const DELNEW: i32 = (DELOLD + 1);
const DELUPD: i32 = (DELNEW + 1);
const STAIDX: i32 = 1;
const RCPIDX: i32 = (STAIDX + 1);
const DPTBAS: i32 = 2;
const MXRPSZ: i32 = 254;
const UNINIT: i32 = -1;
const NULL: i32 = (UNINIT - 1);
const NOBACK: i32 = (NULL - 1);
const SDSCSZ: i32 = 24;
const EKTIDX: i32 = 1;
const SNOIDX: i32 = (EKTIDX + 1);
const IMDIDX: i32 = (SNOIDX + 1);
const TNMIDX: i32 = (IMDIDX + 1);
const NCIDX: i32 = (TNMIDX + 1);
const NRIDX: i32 = (NCIDX + 1);
const RTIDX: i32 = (NRIDX + 1);
const CPTIDX: i32 = (RTIDX + 1);
const DPTIDX: i32 = (CPTIDX + 1);
const IPTIDX: i32 = (DPTIDX + 1);
const MFLIDX: i32 = (IPTIDX + 1);
const IFLIDX: i32 = (MFLIDX + 1);
const SHDIDX: i32 = (IFLIDX + 1);
const CFHIDX: i32 = (SHDIDX + 1);
const CSNIDX: i32 = (CFHIDX + 1);
const LCPIDX: i32 = (CSNIDX + 1);
const LDPIDX: i32 = (LCPIDX + 1);
const LIPIDX: i32 = (LDPIDX + 1);
const LCWIDX: i32 = (LIPIDX + 1);
const LDWIDX: i32 = (LCWIDX + 1);
const LIWIDX: i32 = (LDWIDX + 1);
const NMLIDX: i32 = (LIWIDX + 1);
const CHR: i32 = 1;
const DP: i32 = 2;
const INT: i32 = 3;
const TIME: i32 = 4;
//$Procedure ZZEKDE04 ( EK, delete column entry, class 4 )
pub fn ZZEKDE04(
HANDLE: i32,
SEGDSC: &mut [i32],
COLDSC: &[i32],
RECPTR: i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut SEGDSC = DummyArrayMut::new(SEGDSC, 1..=SDSCSZ);
let COLDSC = DummyArray::new(COLDSC, 1..=CDSCSZ);
let mut BASE: i32 = 0;
let mut DATPTR: i32 = 0;
let mut NELTS: i32 = 0;
let mut NEXT: i32 = 0;
let mut NLINKS: i32 = 0;
let mut NSEEN: i32 = 0;
let mut P: i32 = 0;
let mut PTRLOC: i32 = 0;
let RECNO: i32 = 0;
//
// SPICELIB functions
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"ZZEKDE04", ctx)?;
//
// Before trying to actually modify the file, do every error
// check we can.
//
// Is this file handle valid--is the file open for paged write
// access? Signal an error if not.
//
ZZEKPGCH(HANDLE, b"WRITE", ctx)?;
if FAILED(ctx) {
CHKOUT(b"ZZEKDE04", ctx)?;
return Ok(());
}
//
// Compute the data pointer location. If the data pointer is
// already set to `uninitialized', there's nothing to do. If
// the element is null, just set it to `uninitialized'. The
// presence of actual data obligates us to clean up, however.
//
PTRLOC = ((RECPTR + DPTBAS) + COLDSC[ORDIDX]);
DASRDI(
HANDLE,
PTRLOC,
PTRLOC,
std::slice::from_mut(&mut DATPTR),
ctx,
)?;
if (DATPTR > 0) {
//
// Get the element count for the entry.
//
DASRDI(
HANDLE,
DATPTR,
DATPTR,
std::slice::from_mut(&mut NELTS),
ctx,
)?;
//
// Set the data pointer to indicate the item is uninitialized.
//
DASUDI(HANDLE, PTRLOC, PTRLOC, &[UNINIT], ctx)?;
//
// Find the number of the page containing the column entry.
//
ZZEKPGPG(INT, DATPTR, &mut P, &mut BASE, ctx)?;
//
// Look up the forward pointer. This pointer will be valid
// if the column entry is continued on another page.
//
ZZEKGFWD(HANDLE, INT, P, &mut NEXT, ctx)?;
//
// Get the link count for the current page. If we have more
// than one link to the page, decrement the link count. If
// we're down to one link, this deletion will finish off the
// page: we'll deallocate it.
//
ZZEKGLNK(HANDLE, INT, P, &mut NLINKS, ctx)?;
if (NLINKS > 1) {
ZZEKSLNK(HANDLE, INT, P, (NLINKS - 1), ctx)?;
} else {
//
// If we removed the last item from the page, we can delete
// the page. ZZEKDPS adjusts the segment's metadata
// to reflect the deallocation.
//
ZZEKDPS(HANDLE, SEGDSC.as_slice_mut(), INT, P, ctx)?;
}
NSEEN = intrinsics::MIN0(&[NELTS, ((BASE + IPSIZE) - DATPTR)]);
while ((NSEEN < NELTS) && !FAILED(ctx)) {
//
// The column entry is continued on the page indicated by
// NEXT.
//
// Get the link count for the current page. If we have more
// than one link to the page, decrement the link count. If
// we're down to one link, this deletion will finish off the
// page: we'll deallocate it.
//
P = NEXT;
ZZEKGFWD(HANDLE, INT, P, &mut NEXT, ctx)?;
ZZEKGLNK(HANDLE, INT, P, &mut NLINKS, ctx)?;
if (NLINKS > 1) {
ZZEKSLNK(HANDLE, INT, P, (NLINKS - 1), ctx)?;
} else {
//
// If we removed the last item from the page, we can delete
// the page. ZZEKDPS adjusts the segment's metadata
// to reflect the deallocation.
//
ZZEKDPS(HANDLE, SEGDSC.as_slice_mut(), INT, P, ctx)?;
}
NSEEN = intrinsics::MIN0(&[NELTS, (IPSIZE + NSEEN)]);
}
} else if (DATPTR == NULL) {
//
// Mark the entry as `uninitialized'.
//
DASUDI(HANDLE, PTRLOC, PTRLOC, &[UNINIT], ctx)?;
} else if (DATPTR != UNINIT) {
//
// UNINIT was the last valid possibility. The data pointer is
// corrupted.
//
SETMSG(
b"Data pointer is corrupted. SEGNO = #; COLIDX = #; RECNO = #; EK = #",
ctx,
);
ERRINT(b"#", SEGDSC[SNOIDX], ctx);
ERRINT(b"#", COLDSC[ORDIDX], ctx);
ERRINT(b"#", RECNO, ctx);
ERRHAN(b"#", HANDLE, ctx)?;
SIGERR(b"SPICE(BUG)", ctx)?;
CHKOUT(b"ZZEKDE04", ctx)?;
return Ok(());
}
//
// Set the record's status to indicate that this record is updated.
//
DASUDI(HANDLE, (RECPTR + STAIDX), (RECPTR + STAIDX), &[UPDATE], ctx)?;
CHKOUT(b"ZZEKDE04", ctx)?;
Ok(())
}