/* 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. */ /* Wart Version Info: */ char *wartv = "Wart Version 1A(006) May 1990"; #ifndef MCS_FLAG char *protv = "IVS-Kermit Protocol Module 4E(032), 31 May 90"; #else char *protv = "MCS-Kermit Protocol Module 4E(032), 31 May 90"; #endif /* -*-C-*- */ /* C K V P R O -- C-Kermit Protocol Module, in Wart preprocessor notation. */ /********************************************************************** * * * IVS / MCS-Kermit REL 2 * * source code * * * * Change History: * * * * 1. Modify C-Kermit(4E) source code to * * produce new module for MCS/IVS-Kermit * * ORIGINAL RELEASE * * June 22, 1990 * * * * * ***********************************************************************/ /* Authors: Frank da Cruz (SY.FDC@CU20B), Bill Catchings, Jeff Damens; 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. */ #include "ckcdeb.h" #include "ckcker.h" /* Note -- This file may also be preprocessed by the NCR-VRX Lex program, but you must indent the above #include statements before using Lex, and then restore them 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 ipkt 1 #define rfile 2 #define rdata 3 #define ssinit 4 #define ssfile 5 #define ssdata 6 #define sseof 7 #define sseot 8 #define serve 9 #define generic 10 #define get 11 #define rgen 12 /* External C-Kermit variable declarations */ extern char sstate, deblog, *versio, *srvtxt, *cmarg, *cmarg2, *rpar(); extern char data[], filnam[], srvcmd[], ttname[], *srvptr; extern int pktnum, timint, nfils, hcflg, xflg, speed, flow, mdmtyp; extern int prvpkt, cxseen, czseen, server, local, displa, bctu, bctr, quiet; extern int tsecs, parity, backgrd; extern int putsrv(), puttrm(), putfil(), errpkt(); extern char *rdatap; /* Local variables */ static char vstate = 0; /* Saved State */ static char vcmd = 0; /* Saved Command */ int x; /* General-purpose integer */ char *s; /* General-purpose string pointer */ /* Macros - Note, BEGIN is predefined by Wart (and Lex) */ #define SERVE tinit(); BEGIN serve #define RESUME if (server) { SERVE; } else { sleep(2); return; } #define BEGIN state = int state = 0; wart() { int c, actno; extern short tbl[]; while (1) { c = input(); if ((actno = tbl[c + state*128]) != -1) switch (actno) { case 1: { tinit(); /* Do Send command */ if (sinit()) BEGIN ssinit; else RESUME; } break; case 2: { tinit(); BEGIN get; } break; case 3: { tinit(); vstate = get; vcmd = 0; sipkt('I'); BEGIN ipkt; } break; case 4: { tinit(); vstate = rgen; vcmd = 'C'; sipkt('I'); BEGIN ipkt; } break; case 5: { tinit(); vstate = rgen; vcmd = 'G'; sipkt('I'); BEGIN ipkt; } break; case 6: { sleep(1); SERVE; } break; case 7: { /* "Abort" -- Tell other side. */ errpkt("User cancelled transaction"); x = quiet; quiet = 1; /* Close files silently. */ clsif(); clsof(1); quiet = x; return(0); } break; case 8: { rinit(rdatap); bctu = bctr; /* Get Send-Init */ resetc(); /* Reset counters */ rtimer(); /* Reset timer */ BEGIN rfile; } break; case 9: { spar(rdatap); /* Get ack for I-packet */ if (vcmd) { scmd(vcmd, cmarg); vcmd = 0; } if (vstate == get) srinit(); BEGIN vstate; } break; case 10: { if (vcmd) /* Get E for I-packet (ignore) */ scmd(vcmd, cmarg); vcmd = 0; if (vstate == get) srinit(); BEGIN vstate; } break; case 11: { srinit(); } break; case 12: { srvptr = srvcmd; decode(rdatap, putsrv); /* Get Receive-Init */ cmarg = srvcmd; nfils = -1; if (sinit()) BEGIN ssinit; else { SERVE; } } break; case 13: { spar(rdatap); ack1(rpar()); /* Get Init Parameters */ pktnum = 0; prvpkt = -1; } break; case 14: { srvptr = srvcmd; decode(rdatap, putsrv); /* Get & decode command. */ putsrv('\0'); putsrv('\0'); sstate = srvcmd[0]; BEGIN generic; } break; case 15: { srvptr = srvcmd; /* Get command for shell */ decode(rdatap, putsrv); putsrv('\0'); if (syscmd(srvcmd, "")) BEGIN ssinit; else { errpkt("Can't do system command"); SERVE; } } break; case 16: { errpkt("Unimplemented server function"); SERVE; } break; case 17: { if (!cwd(srvcmd + 1)) errpkt("Can't change directory"); /* CWD */ SERVE; } break; case 18: { errpkt("Can't list directory"); SERVE; } break; case 19: { errpkt("Can't remove file"); SERVE; } break; case 20: { ack(); screen(SCR_TC, 0, 0l, ""); return(0); } break; case 21: { ack(); ttres(); screen(SCR_TC, 0, 0l, ""); return(zkself()); } break; case 22: { if (sndhlp()) BEGIN ssinit; else { errpkt("Can't send help"); SERVE; } } break; case 23: { errpkt("Can't type file"); SERVE; } break; case 24: { errpkt("Can't check space"); SERVE; } break; case 25: { errpkt("Can't do who command"); SERVE; } break; case 26: { errpkt("Unimplemented generic server function"); SERVE; } break; case 27: { decode(rdatap, puttrm); RESUME; } break; case 28: { if (rcvfil()) /* File header */ { encstr(filnam); ack1(data); BEGIN rdata; } else { errpkt("Can't open file"); RESUME; } } break; case 29: { opent(); ack(); BEGIN rdata; } break; case 30: { ack(); tsecs = gtimer(); reot(); RESUME; } break; case 31: { if (cxseen) ack1("X"); /* Got data. */ else if (czseen) ack1("Z"); else ack(); decode(rdatap, putfil); } break; case 32: { if (reof() < 0) { /* Got End Of File */ errpkt("Can't close file"); RESUME; } else { ack(); BEGIN rfile; } } break; case 33: { spar(rdatap); bctu = bctr; /* Got ACK to Send-Init */ x = sfile(xflg); /* Send X or F header packet */ if (x) { resetc(); rtimer(); BEGIN ssfile; } else { s = xflg ? "Can't execute command" : "Can't open file"; errpkt(s); RESUME; } } break; case 34: { srvptr = srvcmd; /* Got ACK to F */ decode(rdatap, putsrv); putsrv('\0'); if (*srvcmd) tlog(F110, " stored as", srvcmd, 0); if (sdata() < 0) { clsif(); seof(""); BEGIN sseof; } else BEGIN ssdata; } break; case 35: { if (canned(rdatap)) { clsif(); seof("D"); BEGIN sseof; } else if (sdata() < 0) { clsif(); seof(""); BEGIN sseof; } } break; case 36: { if (gnfile() > 0) { /* Got ACK to EOF, get next file */ if (sfile(xflg)) BEGIN ssdata; else { errpkt("Can't open file") ; RESUME; } } else { /* If no next file, EOT */ tsecs = gtimer(); seot(); BEGIN sseot; } } break; case 37: { RESUME; } break; case 38: { /* Error packet, issue message. * ermsg(rdatap); / x = quiet; quiet = 1; /* Close files silently, */ clsif(); clsof(1); /* discarding any output file. */ tsecs = gtimer(); quiet = x; if (backgrd && !server) fatal("Protocol error"); RESUME; } break; case 39: { errpkt("Unknown packet type-> Please retry"); RESUME; } break; } } } short tbl[] = { -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 10, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 9, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 30, 39, 39, 38, 28, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 29, 39, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 31, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 32, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 33, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 34, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 35, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 36, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 37, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, -1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 12, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 7, 16, 4, 16, 16, 16, 5, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 1, 16, 16, 2, 16, 6, 16, 16, 16, 16, 16, 16, 16, -1, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 17, 18, 19, 20, 26, 22, 26, 26, 26, 21, 26, 26, 26, 26, 26, 26, 26, 23, 24, 26, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 7, 26, 4, 26, 26, 26, 5, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 3, 1, 26, 26, 2, 26, 6, 26, 26, 26, 26, 26, 26, 26, -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 8, 39, 39, 39, 39, 39, 11, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, 0, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 28, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 8, 39, 39, 39, 39, 29, 27, 39, 39, 39, 39, 39, 39, 39, 7, 39, 4, 39, 39, 39, 5, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 1, 39, 39, 2, 39, 6, 39, 39, 39, 39, 39, 39, 39, }; /* P R O T O -- Protocol entry function */ proto() { extern int sigint(); int x; conint(sigint); /* Enable console interrupts */ /* Set up the communication line for file transfer. */ if (local && (speed < 0)) { screen(SCR_EM, 0, 0l, "Sorry, you must 'set speed' first"); return; } x = -1; if (ttopen(ttname, &x, mdmtyp) < 0) { if (deblog) debug(F111, "failed: proto ttopen local", ttname, local); screen(SCR_EM, 0, 0l, "Can't open line"); return; } if (x > -1) local = x; if (deblog) debug(F111, "proto ttopen local", ttname, local); x = (local) ? speed : -1; if (ttpkt(x, flow, parity) < 0) { /* Put line in packet mode, */ screen(SCR_EM, 0, 0l, "Can't condition line"); return; } if (sstate == 'x') { /* If entering server mode, */ server = 1; /* set flag, */ if (!quiet) { if (!local) /* and issue appropriate message. */ conol(srvtxt); else { conol("Entering server mode on "); conoll(ttname); } } } else server = 0; if (sstate == 'v' && !local && !quiet) conoll("ESC back to local system and give a SEND command..."); if (sstate == 's' && !local && !quiet) conoll("ESC back to local system and give a RECEIVE command..."); sleep(1); /* The 'wart()' function is generated by the wart program. It gets a character from the input() routine and then based on that character and the current state, selects the appropriate action, according to the state table above, which is transformed by the wart program into a big case statement. The function is active for one transaction. */ wart(); /* Enter the state table switcher. */ if (server) { /* Back from packet protocol. */ server = 0; if (!quiet) /* Give appropriate message */ #ifndef MCS_FLAG conoll("IVS-Kermit server done"); #else conoll("MCS-Kermit server done"); #endif } ttres(); screen(SCR_TC, 0, 0l, ""); /* Transaction complete */ }