2 /* WARNING -- This C source program generated by gwart preprocessor. */
3 /* Do not edit this file; edit the gwart-format source file instead, */
4 /* and then run it through gwart to produce a new C source file. */
6 /* G P R O T O -- Protocol module for gkermit */ /* -*-C-*- */
14 New York NY 10025-7799 USA
15 http://www.columbia.edu/kermit/
19 The Trustees of Columbia University in the City of New York.
21 This program is free software; you can redistribute it and/or modify
22 it under the terms of the GNU General Public License as published by
23 the Free Software Foundation; either version 2 of the License, or
24 (at your option) any later version.
26 This program is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 GNU General Public License for more details.
31 You should have received a copy of the GNU General Public License
32 along with this program; if not, write to the Free Software
33 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 _MYPROTOTYPE( int closof
, (void) ); /* Close output file */
39 _MYPROTOTYPE( VOID errpkt
, (char *) ); /* Send Error packet */
41 extern char * xdata
, *rdatap
, **cmlist
, *cmarg
, *rpar(), strbuf
[], filnam
[];
42 extern int start
, bctu
, bctr
, delay
, cx
, cz
, failure
, attributes
, datalen
;
43 extern int streamok
, streaming
, timint
;
49 streamon() { /* Start streaming if negotiated */
57 /* Declare gwart states (like lex) */
71 /* Packets are read by the input() function, which returns the packet type */
72 /* that serves as the input to the state machine, which follows... */
86 if (c
< 0 || c
> 95) c
= 0;
87 if ((actno
= tbl
[c
+ state
*96]) != -1)
90 { /* Start state for Send. */
91 tinit(); /* Initialize transaction. */
92 if (sinit('S') < 0) { errpkt("sinit"); } /* Build and send the S packet. */
97 { /* Receive ACK to I packet */
98 spar(rdatap
); /* Set parameters from it */
99 bctu
= bctr
; /* Switch to negotiated block check */
100 if (gnfile() > 0) { /* Is there a file to send? */
101 if (sfile() < 0) { /* Yes, open it, send F packet, */
103 } else { /* No error */
107 } else { /* No files to send, */
108 if (seot() < 0) { errpkt("seot"); } /* so send EOT packet. */
114 { /* Receive ACK to File header packet */
115 if (attributes
) { /* If attributes negotiated */
116 if (sattr() < 0) { /* Send file attributes */
120 } else if ((x
= sdata()) == 0) { /* Otherwise send first Data packet */
121 if (seof("") < 0) { /* Empty file - send EOF */
126 } else if (x
< 0) { /* Error */
128 } else { /* OK - switch to Data state */
134 { /* Receive ACK to Attribute packet */
135 if (*rdatap
== 'N') { /* Check for refusal */
138 } else if ((x
= sdata()) == 0) { /* Otherwise send first Data packet */
139 if (seof("") < 0) { /* Empty file - send EOF */
144 } else if (x
< 0) { /* Error */
146 } else { /* OK - switch to Data state */
152 { /* Receive ACK to Data packet */
153 if (*rdatap
== 'X') /* Check for file cancellation */
155 else if (*rdatap
== 'Z') /* Check for batch cancellation */
157 if ((x
= sdata()) == 0) { /* Send data packet if data left. */
158 if (seof((cx
| cz
) ? "D" : "") < 0) { /* If not, send Z packet */
163 } else if (x
< 0) /* Fatal error sending data */
168 { /* Receive ACK to EOF */
169 if (gnfile() > 0) { /* Get next file from list */
172 else { errpkt("sfile"); }
173 } else { /* No more files */
174 seot(); /* Send EOT */
183 { tinit(); rinit(); BEGIN srini
; }
186 { /* Receive S packet */
187 spar(rdatap
); /* Set parameters from it */
188 ack1(rpar()); /* ACK with our parameters */
189 bctu
= bctr
; /* Switch to negotiated block check */
191 BEGIN srfil
; /* Wait for file or EOT */
195 { ack(); return(failure
); }
198 { /* Receive File header packet */
210 { /* Receive Attribute packet */
211 if (gattr(rdatap
) == 0) {
219 { /* Receive first Data packet */
220 if (decode(datalen
) < 0) {
221 errpkt("Packet decoding error");
230 if (*rdatap
== 'D') /* Check for Discard directive */
232 if (closof() < 0) { /* Close the output file */
235 ack(); /* Send ACK */
236 BEGIN srfil
; /* Wait for another file or EOT */
241 { /* Receive Data packet */
242 if (decode(datalen
) < 0)
243 errpkt("Packet decoding error");
249 { /* Receive EOF packet */
250 if (*rdatap
== 'D') /* Check for Discard directive */
252 if (closof() < 0) { /* Close the output file */
255 ack(); /* Send ACK */
256 BEGIN srfil
; /* Wait for another file or EOT */
261 { /* Start state for Get */
262 tinit(); /* Initialize transaction */
263 ginit(); /* Initialize Get */
264 sinit('I'); /* Send I packet */
269 { /* Receive ACK for I packet */
270 spar(rdatap
); /* Set parameters from it */
271 if (scmd('R',cmarg
) < 0) /* Send GET packet file filespec */
274 BEGIN srini
; /* Wait for S packet */
278 { return(failure
= 1); }
281 { errpkt("Unknown packet type"); }
289 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
290 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
291 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
292 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
293 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
294 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
295 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
296 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
297 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
298 20, 20, 20, 20, 20, 20, 20, 20, 20, 2, 20, 20, 20, 20, 20, 20,
299 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
300 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
301 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
302 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
303 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
304 20, 20, 20, 20, 20, 20, 20, 20, 20, 3, 20, 20, 20, 20, 20, 20,
305 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
306 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
307 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
308 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
309 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
310 20, 20, 20, 20, 20, 20, 20, 20, 20, 5, 20, 20, 20, 20, 20, 20,
311 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
312 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
313 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
314 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
315 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
316 20, 20, 20, 20, 20, 20, 20, 20, 20, 4, 20, 20, 20, 20, 20, 20,
317 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
318 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
319 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
320 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
321 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
322 20, 20, 20, 20, 20, 20, 20, 20, 20, 7, 20, 20, 20, 20, 20, 20,
323 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
324 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
325 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
326 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
327 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
328 20, 20, 20, 20, 20, 20, 20, 20, 20, 6, 20, 20, 20, 20, 20, 20,
329 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
330 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
331 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
332 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
333 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
334 20, 20, 20, 20, 20, 20, 20, 20, 20, 18, 20, 20, 20, 20, 20, 20,
335 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
336 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
337 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
338 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
339 20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
340 20, 20, 20, 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
341 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
342 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
343 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
344 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
345 20, 20, 10, 20, 20, 19, 11, 20, 20, 20, 20, 20, 20, 20, 20, 20,
346 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
347 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
348 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
349 -1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
350 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
351 20, 20, 20, 20, 15, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
352 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 20, 20, 20, 20, 20,
353 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
354 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
355 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
356 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
357 20, 12, 20, 20, 13, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
358 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 14, 20, 20, 20, 20, 20,
359 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
360 20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20,20