home *** CD-ROM | disk | FTP | other *** search
-
- /* WARNING -- This C source program generated by Wart preprocessor. */
- /* Do not edit this file; edit the Wart-format source file instead, */
- /* and then run it through Wart to produce a new C source file. */
-
-
- #include "lckdeb.h"
- #include "lckerm.h"
-
- /* Wart Version Info: */
- CHAR *wartv = (CHAR *)"Wart Version 1A(003) 27 May 85";
-
- CHAR *protv = (CHAR *)"C-Kermit Protocol Module 4C(026), 12 Jun 85"; /* -*-C-*- */
-
- /* C K C P R O -- C-Kermit Protocol Module, in Wart preprocessor notation. */
- /*
- Author: Frank da Cruz (SY.FDC@CU20B),
- Columbia University Center for Computing Activities, January 1985.
- Copyright (C) 1985, Trustees of Columbia University in the City of New York.
- Permission is granted to any individual or institution to use, copy, or
- redistribute this software so long as it is not sold for profit, provided this
- copyright notice is retained.
- */
- /* Modified for sliding windows impl. by: Jan A. van der Eijk */
-
- /*
- Note -- This file may also be preprocessed by the Unix Lex program, but
- you must indent the above #include statement before using Lex, and then
- restore it to the left margin in the resulting C program before compilation.
- Also, the invocation of the "wart()" function below must be replaced by an
- invocation of the "yylex()" function. It might also be necessary to remove
- comments in the %%...%% section.
- */
-
- /* State definitions for Wart (or Lex) */
- #define RFILE 1
- #define RDATA 2
- #define SSINIT 3
- #define SSDATA 4
- #define SSEOF 5
- #define SSEOT 6
- #define GET 7
- #define RATTR 8
- #define SSATTR 9
- #define SWDATA 10
- #define RWDATA 11
- #define SWEOF 12
-
- /* External C-Kermit variable declarations */
- extern CHAR sstate, *versio, *cmarg, *cmarg2;
- extern CHAR data[], filnam[], ttname[];
- extern int pktnum, timint, nfils, image, hcflg, xflg, speed, flow, mdmtyp;
- extern int prvpkt, cxseen, czseen, local, displa, bctu, bctr, quiet;
- extern int putfil(), errpkt();
- extern int filatr,nxtcas, rpktno, window;
-
- /* Local variables */
- static CHAR vstate = 0; /* Saved State */
- static CHAR vcmd = 0; /* Saved Command */
- static int x; /* General-purpose integer */
-
- /* Macros - Note, BEGIN is predefined by Wart (and Lex) */
- #define RESUME return
-
-
- #define BEGIN state =
-
- int state = 0;
-
- wart()
- {
- int c,actno;
- extern int tbl[];
-
- state = 0;
- while (1) {
- c = input();
- actno = tbl[c + state*128];
- if (actno != -1)
- switch(actno) {
- case 1: /*s*/
- { tinit(); /* Do Send command */
- if (sinit()) BEGIN SSINIT;
- else RESUME; }
- break;
- case 2: /*v*/
- { tinit(); sleep(1); nack(); BEGIN GET; }
- break;
- case 3: /*a*/
- { errpkt("User cancelled transaction"); /* Tell other side what's going on */
- clsif(); clsof();
- return(0); }
- break;
- case 4: /*S*/
- { rinit(data); bctu = bctr; BEGIN RFILE; }
- break;
- case 5: /*F*/
- { if (rcvfil()) { /* A file is coming */
- ack();
- if (filatr) BEGIN RATTR; /* Both want attributes */
- else if ( wdinit() ) BEGIN RWDATA; /* Both want windows */
- else BEGIN RDATA; }
- else { errpkt("Can't open file"); RESUME; } }
- break;
- case 6: /*B*/
- { ack(); reot(); sleep(2); RESUME; }
- break;
- case 7: /*A*/
- { if ( rdattr(data)) ack(); /* Got file Attributes */
- else { errpkt("Not enough disk space"); clsof(); RESUME; } }
- break;
- case 8: /*D*/
- { ack(); decode(data,putfil); /* First data packet */
- if ( wdinit() ) BEGIN RWDATA;
- else BEGIN RDATA; }
- break;
- case 9: /*Z*/
- { ack(); reof(); BEGIN RFILE; }
- break;
- case 10: /*Z*/
- { if ( !(cxseen || czseen) ) { /* Not aborted by me */
- rweof(); } /* write data to disk */
- pktnum = rpktno; /* make sure we have the right packet number */
- ack(); reof();
- BEGIN RFILE; }
- break;
- case 11: /*D*/
- { if (cxseen) ack1("X"); /* Got data. */
- else if (czseen) ack1("Z");
- else ack();
- decode(data,putfil); }
- break;
- case 12: /*D*/
- { if (cxseen || czseen) { /* Got data, in window */
- pktnum = rpktno; /* Resynch. packet numbers */
- if (czseen) ack1("Z");
- else ack1("X");
- ttflui(); sleep(3);
- ttflui(); } /* Flush input buffer */
- else if ( !gwdata()) {
- wnderr("Protocol Error");
- RESUME; } }
- break;
- case 13: /*N*/
- { if ( ! nackdp() ) { /* Got bad data, NACK it */
- wnderr("Timed out."); /* Timed out, issue message and */
- RESUME; } }
- break;
- case 14: /*N*/
- { resend(); }
- break;
- case 15: /*Y*/
- { spar(data); /* Got ACK to Send-Init */
-
- bctu = bctr;
- if (sfile()) {
- if (filatr) { BEGIN SSATTR; nxtcas = 1;}
- else BEGIN SSDATA;
- } else { errpkt("Can't open file"); RESUME; } }
- break;
- case 16: /*Y*/
- { if (canned(data)) { seof(); clsif(); BEGIN SSEOF; }
- else if (!sattr()) { /* Send Attr packet(s) */
- BEGIN SSDATA; } }
- break;
- case 17: /*Y*/
- { if (canned(data) || !sdata()) { /* Got ACK to data */
- seof(); clsif();
- BEGIN SSEOF; }
- else if (wdinit()) BEGIN SWDATA; }
- break;
- case 18: /*Y*/
- { if (canned(data) || !sdataw() ) { /* Got ACK, with Abort data */
- if (!cxseen && !czseen && window ) { /* or abort by me or EOF */
- BEGIN SWEOF; /* EOF but window not empty */
- } else {
- pktnum = rpktno; /* Get the right number */
- ttfluo(); sleep(2);
- ttflui(); /* Wait and flush buffer */
- seof();clsif(); /* Send the Z packet */
- BEGIN SSEOF; } } }
- break;
- case 19: /*N*/
- { if ( !wresnd() ) { /* Not an ACK, try resend */
- wnderr("Timed out."); /* Timed out, issue message */
- RESUME; } }
- break;
- case 20: /*Y*/
- { if ( weof() ) { /* If all the packets are ACKEd */
- seof(); clsif(); /* End Of File state */
- BEGIN SSEOF; } }
- break;
- case 21: /*Y*/
- { if (gnfile() > 0) { /* Got ACK to EOF, get next file */
- if (sfile()) {
- if (filatr) { BEGIN SSATTR; nxtcas = 1;}
- else BEGIN SSDATA;
- } else { errpkt("Can't open file") ; RESUME; }
- } else { /* If no next file, EOT */
- seot();
- BEGIN SSEOT; } }
- break;
- case 22: /*Y*/
- { RESUME; }
- break;
- case 23: /*E*/
- { ermsg(data); /* Error packet, issue message */
- x = quiet, quiet = 1; /* close files silently */
- clsif(); clsof();
- quiet = x;
- RESUME; }
- break;
- case 24: /*.*/
- { nack(); }
- break;
-
- }
- }
- }
-
- int tbl[] = {
- -1,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 6, 24, 24, 23, 5, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 11, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 9, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24,
- 24, 14, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 15, 24, 24, 24, 24, 24, 24, 24,
- 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24,
- 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 23, 24, 24, 24, 24, 24, 24, 24, 24, 14, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 17, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24, 24, 14, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 21, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 24, 24, 24,
- 24, 24, 24, 24, 24, 14, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 22, 24, 24, 24,
- 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 7, 24, 24, 8, 23, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 9, 24, 24, 24, 24, 24, 24,
- 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24,
- 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 16, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24, 24, 19, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 18, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, -1, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 12, 23, 24, 24, 24,
- 24, 24, 24, 24, 24, 13, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 10, 24, 24,
- 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24, 24, 19, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 20, 24, 24, 24, 24, 24, 24, 24, 3, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 1, 24, 24, 2, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, };
-