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
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const SIZSTR: i32 = 16;
const SIZEXP: i32 = (3 * SIZSTR);
const SIZEND: i32 = 6;
const SIZFTP: i32 = (SIZSTR + (2 * SIZEND));
const SIZDLM: i32 = 1;
const NUMTST: i32 = 6;
const SIZTSQ: i32 = 5;
const INT000: i32 = 0;
const INT010: i32 = 10;
const INT013: i32 = 13;
const INT016: i32 = 16;
const INT129: i32 = 129;
const INT206: i32 = 206;
struct SaveVars {
LOCDLM: Vec<u8>,
LOCLND: Vec<u8>,
LOCRND: Vec<u8>,
LOCSTR: Vec<u8>,
FIRST: bool,
}
impl SaveInit for SaveVars {
fn new() -> Self {
let mut LOCDLM = vec![b' '; SIZDLM as usize];
let mut LOCLND = vec![b' '; SIZEND as usize];
let mut LOCRND = vec![b' '; SIZEND as usize];
let mut LOCSTR = vec![b' '; SIZSTR as usize];
let mut FIRST: bool = false;
FIRST = true;
fstr::assign(&mut LOCDLM, b":");
fstr::assign(&mut LOCLND, b"FTPSTR");
fstr::assign(&mut LOCRND, b"ENDFTP");
Self {
LOCDLM,
LOCLND,
LOCRND,
LOCSTR,
FIRST,
}
}
}
//$Procedure ZZFTPSTR ( Private --- Fetch FTP Validation String )
pub fn ZZFTPSTR(
TSTCOM: &mut [u8],
LEND: &mut [u8],
REND: &mut [u8],
DELIM: &mut [u8],
ctx: &mut Context,
) {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
let mut TESTSQ = ActualCharArray::new(SIZTSQ, 1..=NUMTST);
let mut ASC000 = [b' '; 1 as usize];
let mut ASC010 = [b' '; 1 as usize];
let mut ASC013 = [b' '; 1 as usize];
let mut ASC016 = [b' '; 1 as usize];
let mut ASC129 = [b' '; 1 as usize];
let mut ASC206 = [b' '; 1 as usize];
//
// Local Parameters
//
// Maximum size of an individual test cluster component
// including the ':'.
//
//
// Integer codes of characters appearing in test clusters.
//
//
//
// Local Variables
//
//
// Non-printing character values.
//
//
// Saved Variables
//
//
// Data Statements
//
//
// Set up the components of the FTP validation string that
// are not supposed to change for forward and backward
// compatibility.
//
//
// On the first invocation initialize the string values.
//
if save.FIRST {
//
// Convert the integer parameters to their non-printing ASCII
// equivalents.
//
fstr::assign(&mut ASC000, &intrinsics::CHAR(INT000));
fstr::assign(&mut ASC010, &intrinsics::CHAR(INT010));
fstr::assign(&mut ASC013, &intrinsics::CHAR(INT013));
fstr::assign(&mut ASC016, &intrinsics::CHAR(INT016));
fstr::assign(&mut ASC129, &intrinsics::CHAR(INT129));
fstr::assign(&mut ASC206, &intrinsics::CHAR(INT206));
//
// Now build the individual components of the test clusters.
// Make certain the first component begins and ends with a ':',
// and that the remaining pieces end in ':'. If you intend to
// add some clusters, then append them to the end of the
// sequence so as not to break the existing detection code.
//
//
// Cluster #1 : <CR> - <13> - Macintosh Line Terminator
//
fstr::assign(
TESTSQ.get_mut(1),
&fstr::concat(&fstr::concat(&save.LOCDLM, &ASC013), &save.LOCDLM),
);
//
// Cluster #2 : <LF> - <10> - Unix Line Terminator
//
fstr::assign(TESTSQ.get_mut(2), &fstr::concat(&ASC010, &save.LOCDLM));
//
// Cluster #3 : <CR><LF> - <10><13> - Microsoft Line Terminator
//
fstr::assign(
TESTSQ.get_mut(3),
&fstr::concat(&fstr::concat(&ASC013, &ASC010), &save.LOCDLM),
);
//
// Cluster #4 : <13><0>
//
fstr::assign(
TESTSQ.get_mut(4),
&fstr::concat(&fstr::concat(&ASC013, &ASC000), &save.LOCDLM),
);
//
// Cluster #5 : <129> - Macintosh Permutation of Parity Codes
//
fstr::assign(TESTSQ.get_mut(5), &fstr::concat(&ASC129, &save.LOCDLM));
//
// Cluster #6 : <16><206>
//
fstr::assign(
TESTSQ.get_mut(6),
&fstr::concat(&fstr::concat(&ASC016, &ASC206), &save.LOCDLM),
);
//
// Sample cluster addition code follows
//
// Cluster #7 : <xxx> - Description
//
// TESTSQ(7) = ASCxxx // ... // LOCDLM
//
//
// Now build the local copy of TSTCOM, LOCSTR. First clear the
// uninitialized contents.
//
fstr::assign(&mut save.LOCSTR, b" ");
for I in 1..=NUMTST {
//
// Append TESTSQ(I) to LOCSTR to properly construct the
// test component of the FTP validation string.
//
SUFFIX(&TESTSQ[I], 0, &mut save.LOCSTR);
}
//
// Prevent execution of this initialization code after first pass.
//
save.FIRST = false;
}
//
// Copy the local copies of the FTP string components to the
// arguments passed in from the caller.
//
fstr::assign(TSTCOM, &save.LOCSTR);
fstr::assign(LEND, &save.LOCLND);
fstr::assign(REND, &save.LOCRND);
fstr::assign(DELIM, &save.LOCDLM);
}