home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / CKPM5X_S.ZIP / CKCPRO.C < prev    next >
C/C++ Source or Header  |  1990-03-03  |  27KB  |  745 lines

  1.  
  2. /* WARNING -- This C source program generated by Wart preprocessor. */
  3. /* Do not edit this file; edit the Wart-format source file instead, */
  4. /* and then run it through Wart to produce a new C source file.     */
  5.  
  6. /* Wart Version Info: */
  7. char *wartv = "Wart Version 1A(006) Jan 1989";
  8.  
  9. char *protv = "C-Kermit Protocol Module 5A(036), 27 Jan 90"; /* -*-C-*- */
  10.  
  11. /* C K C P R O  -- C-Kermit Protocol Module, in Wart preprocessor notation. */
  12. /*
  13.  Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),
  14.  Columbia University Center for Computing Activities.
  15.  First released January 1985.
  16.  Copyright (C) 1985, 1990, Trustees of Columbia University in the City of New 
  17.  York.  Permission is granted to any individual or institution to use, copy, or
  18.  redistribute this software so long as it is not sold for profit, provided this
  19.  copyright notice is retained. 
  20. */
  21. #include "ckcdeb.h"
  22. #include "ckcasc.h"
  23. #include "ckcker.h"
  24. /*
  25.  Note -- This file may also be preprocessed by the Unix Lex program, but 
  26.  you must indent the above #include statements before using Lex, and then
  27.  restore them to the left margin in the resulting C program before compilation.
  28.  Also, the invocation of the "wart()" function below must be replaced by an
  29.  invocation  of the "yylex()" function.  It might also be necessary to remove
  30.  comments in the %%...%% section.
  31. */
  32.  
  33. /* State definitions for Wart (or Lex) */
  34. #define ipkt 1
  35. #define rfile 2
  36. #define rattr 3
  37. #define rdata 4
  38. #define ssinit 5
  39. #define ssfile 6
  40. #define ssattr 7
  41. #define ssdata 8
  42. #define sseof 9
  43. #define sseot 10
  44. #define serve 11
  45. #define generic 12
  46. #define get 13
  47. #define rgen 14
  48.  
  49. /* External C-Kermit variable declarations */
  50.   extern char sstate, *versio, *srvtxt, *cmarg, *cmarg2, *rpar();
  51.   extern char *data, encbuf[], filnam[], srvcmd[], ttname[], *srvptr;
  52.   extern int timint, nfils, hcflg, xflg, speed, flow, mdmtyp, network;
  53.   extern int cxseen, czseen, server, local, displa, bctu, bctr, quiet;
  54.   extern int tsecs, parity, backgrd, nakstate, atcapu, wslotsn, winlo;
  55.   extern int wslots, success, cmdlvl, rprintf;
  56.   extern int putsrv(), puttrm(), putfil(), errpkt();
  57.   extern char *DIRCMD, *DELCMD, *TYPCMD, *SPACMD, *SPACM2, *WHOCMD;
  58.   extern char *rdatap;
  59.   extern struct zattr iattr;
  60.  
  61. /* Flags for the ENABLE and DISABLE commands */
  62. extern int en_cwd, en_del, en_dir, en_fin, 
  63.    en_get, en_hos, en_sen, en_spa, en_set, en_typ, en_who;
  64.  
  65. /* Local variables */
  66.   static char vstate = 0;          /* Saved State   */
  67.   static char vcmd = 0;            /* Saved Command */
  68.   int x;                /* General-purpose integer */
  69.   char *s;                /* General-purpose string pointer */
  70.  
  71. /* Macros - Note, BEGIN is predefined by Wart (and Lex) as "state = ", */
  72. /* BEGIN is NOT a GOTO! */
  73. #define TINIT  if (tinit() < 0) return(-9)
  74. #define SERVE  TINIT; nakstate = 1; BEGIN serve
  75. #define RESUME if (server) { SERVE; } else { sleep(2); return(0); }
  76. #define QUIT x=quiet; quiet=1; clsif(); clsof(1); tsecs=gtimer(); quiet=x; \
  77.  return(1)
  78.  
  79.  
  80. #define BEGIN state =
  81.  
  82. int state = 0;
  83.  
  84. wart()
  85. {
  86.     int c,actno;
  87.     extern CHAR tbl[];
  88.     while (1) {
  89.     c = input();
  90.     if ((actno = tbl[c + state*128]) != -1)
  91.         switch(actno) {
  92. case 1:
  93.     { TINIT;                /* Do Send command */
  94.     if (sinit()) BEGIN ssinit;
  95.        else RESUME; }
  96.     break;
  97. case 2:
  98.     { TINIT; nakstate = 1; BEGIN get; }
  99.     break;
  100. case 3:
  101.     { TINIT; vstate = get;  vcmd = 0;   sipkt('I'); BEGIN ipkt; }
  102.     break;
  103. case 4:
  104.     { TINIT; vstate = rgen; vcmd = 'C'; sipkt('I'); BEGIN ipkt; }
  105.     break;
  106. case 5:
  107.     { TINIT; vstate = rgen; vcmd = 'G'; sipkt('I'); BEGIN ipkt; }
  108.     break;
  109. case 6:
  110.     { sleep(1); SERVE; }
  111.     break;
  112. case 7:
  113.     { errpkt("User cancelled transaction"); /* "ABEND" -- Tell other side. */
  114.     success = 0;
  115.     return(0); }
  116.     break;
  117. case 8:
  118.     {            /* Receive Send-Init packet. */
  119.     nakstate = 1;            /* Can send NAKs from here. */
  120.     rinit(rdatap);            /* Set parameters */
  121.     bctu = bctr;            /* Switch to agreed-upon block check */
  122.     resetc();                /* Reset counters */
  123.     rtimer();                /* Reset timer */
  124.     BEGIN rfile;            /* Go into receive-file state */
  125. }
  126.     break;
  127. case 9:
  128.     {                /* Get ack for I-packet */
  129.     spar(rdatap);            /* Set parameters */
  130.     getsbuf(winlo = 0);            /* Set window-low back to zero */
  131.     if (vcmd) {                /* If sending a generic command */
  132.     scmd(vcmd,cmarg);        /* Do that */
  133.     vcmd = 0;            /* and then un-remember it. */
  134.     } else if (vstate == get) srinit();    /* If sending GET command, do that */
  135.     winlo = 0;                /* Again! */
  136.     nakstate = 1;            /* Can send NAKs from here. */
  137.     BEGIN vstate;            /* Switch to desired state */
  138. }
  139.     break;
  140. case 10:
  141.     {                /* Ignore Error reply to I packet */
  142.     if (vcmd) {                /* in case other Kermit doesn't */
  143.     scmd(vcmd,cmarg);        /* understand I-packets. */
  144.     vcmd = 0;            /* Otherwise act as above... */
  145.     }
  146.     if (vstate == get) srinit();
  147.     BEGIN vstate;
  148. }
  149.     break;
  150. case 11:
  151.     {        /* Resend of previous I-pkt ACK, same seq number! */
  152.     srinit();
  153. }
  154.     break;
  155. case 12:
  156.     {                /* Get I-packet */
  157.     spar(rdatap);            /* Set parameters from it */
  158.     ack1(rpar());            /* Respond with our own parameters */
  159.     pktinit();                /* Reinitialize packet numbers */
  160. }
  161.     break;
  162. case 13:
  163.     {                /* Get Receive-Init */
  164.     srvptr = srvcmd;            /* Point to server command buffer */
  165.     decode(rdatap,putsrv);        /* Decode the GET command into it */
  166.     cmarg = srvcmd;
  167.     nfils = -1;                /* Initialize number of files */
  168.     nakstate = 0;            /* Now I'm the sender! */
  169.     if (sinit())            /* Send Send-Init */
  170.       BEGIN ssinit;            /* If successful, switch state */
  171.     else { SERVE; }            /* Else back to server command wait */
  172. }
  173.     break;
  174. case 14:
  175.     {                /* Generic server command */
  176.     srvptr = srvcmd;            /* Point to command buffer */
  177.     decode(rdatap,putsrv);        /* Decode packet data into it */
  178.     putsrv('\0');            /* Insert a couple nulls */
  179.     putsrv('\0');            /* for termination */
  180.     sstate = srvcmd[0];            /* Set requested start state */
  181.     nakstate = 0;            /* Now I'm the sender. */
  182.     BEGIN generic;            /* Switch to generic command state */
  183. }
  184.     break;
  185. case 15:
  186.     {                /* Receive Host command */
  187.     srvptr = srvcmd;            /* Point to command buffer */
  188.     decode(rdatap,putsrv);        /* Decode command packet into it */
  189.     putsrv('\0');            /* Null-terminate */
  190.     nakstate = 0;            /* Now sending, not receiving */
  191.     if (syscmd(srvcmd,""))        /* Try to execute the command */
  192.       BEGIN ssinit;            /* If OK, send back its output */
  193.     else {                /* Otherwise */
  194.     errpkt("Can't do system command"); /* report error */
  195.     SERVE;                /* & go back to server command wait */
  196.     }
  197. }
  198.     break;
  199. case 16:
  200.     { success = 0; QUIT; }
  201.     break;
  202. case 17:
  203.     {                /* Any other command in this state */
  204.     errpkt("Unimplemented server function"); /* we don't know about */
  205.     SERVE;                /* back to server command wait */
  206. }
  207.     break;
  208. case 18:
  209.     {                /* Got REMOTE CWD command */
  210.     if (!en_hos) {
  211.     errpkt("REMOTE CD disabled");
  212.     SERVE;
  213.     } else {
  214.     if (!cwd(srvcmd+1)) errpkt("Can't change directory"); /* Try it */
  215.     SERVE;                /* Back to server command wait */
  216.     }
  217. }
  218.     break;
  219. case 19:
  220.     {                /* REMOTE DIRECTORY command */
  221.     if (!en_dir) {
  222.     errpkt("REMOTE DIRECTORY disabled");    
  223.     SERVE;
  224.     } else {
  225.     if (syscmd(DIRCMD,srvcmd+2))    /* If it can be done */
  226.       BEGIN ssinit;            /* send the results back */
  227.     else {                /* otherwise */
  228.         errpkt("Can't list directory"); /* report failure */
  229.         SERVE;            /* & return to server command wait */
  230.     }
  231.     }
  232. }
  233.     break;
  234. case 20:
  235.     {                /* REMOTE DELETE (Erase) command */
  236.     if (!en_del) {
  237.     errpkt("REMOTE DELETE disabled");    
  238.     SERVE;
  239.     } else {
  240.     if (syscmd(DELCMD,srvcmd+2))    /* Try to do it */
  241.       BEGIN ssinit;            /* If OK send results back */
  242.     else {                /* otherwise */
  243.         errpkt("Can't remove file"); /* report failure */
  244.         SERVE;            /* & return to server command wait */
  245.     }
  246.     }
  247. }
  248.     break;
  249. case 21:
  250.     {                /* FINISH */
  251.     if (!en_fin) {
  252.     errpkt("FINISH disabled");    
  253.     SERVE;
  254.     } else {
  255.     ack();                /* Acknowledge */
  256.     screen(SCR_TC,0,0l,"");        /* Display */
  257.     return(0);            /* Done */
  258.     }
  259. }
  260.     break;
  261. case 22:
  262.     {                /* BYE (LOGOUT) */
  263.     if (!en_fin) {
  264.     errpkt("BYE disabled");    
  265.     SERVE;
  266.     } else {
  267.     ack();                /* Acknowledge */
  268.     ttres();            /* Reset the terminal */
  269.     screen(SCR_TC,0,0l,"");        /* Display */
  270.     return(zkself());        /* Try to log self out */
  271.     }
  272. }
  273.     break;
  274. case 23:
  275.     {                /* REMOTE HELP */
  276.     if (sndhlp()) BEGIN ssinit;        /* Try to send it */
  277.     else {                /* If not ok, */
  278.     errpkt("Can't send help");    /* send error message instead */
  279.     SERVE;                /* and return to server command wait */
  280.     }
  281. }
  282.     break;
  283. case 24:
  284.     {                /* REMOTE SET */
  285.     if (!en_set) {
  286.     errpkt("REMOTE SET disabled");
  287.     SERVE;
  288.     } else {
  289.     if (remset(srvcmd+1))        /* Try to do what they ask */
  290.       ack();            /* If OK, then acknowledge */
  291.     else                /* Otherwise */
  292.       errpkt("Unknown REMOTE SET parameter"); /* give error message */
  293.     SERVE;                /* Return to server command wait */
  294.     }
  295. }
  296.     break;
  297. case 25:
  298.     {                /* REMOTE TYPE */
  299.     if (!en_typ) {
  300.     errpkt("REMOTE TYPE disabled");
  301.     SERVE;
  302.     } else {
  303.     if (syscmd(TYPCMD,srvcmd+2))    /* Try */
  304.       BEGIN ssinit;            /* OK */
  305.     else {                /* not OK */
  306.         errpkt("Can't type file");    /* give error message */
  307.         SERVE;            /* wait for next server command */
  308.     }
  309.     }
  310. }
  311.     break;
  312. case 26:
  313.     {                /* REMOTE SPACE */
  314.     if (!en_spa) {
  315.     errpkt("REMOTE SPACE disabled");
  316.     SERVE;
  317.     } else {
  318.     x = *(srvcmd+1);        /* Get area to check */
  319.     x = ((x == '\0') || (x == SP));
  320.     x = (x ? syscmd(SPACMD,"") : syscmd(SPACM2,srvcmd+2));
  321.     if (x)                /* If we got the info */
  322.       BEGIN ssinit;            /* send it */
  323.     else {                /* otherwise */
  324.         errpkt("Can't check space");    /* send error message */
  325.         SERVE;            /* and await next server command */
  326.     }
  327.     }
  328. }
  329.     break;
  330. case 27:
  331.     {                /* REMOTE WHO */
  332.     if (!en_who) {
  333.     errpkt("REMOTE WHO disabled");
  334.     SERVE;
  335.     } else {
  336.     if (syscmd(WHOCMD,srvcmd+2))    /* The now-familiar scenario... */
  337.       BEGIN ssinit;
  338.     else {
  339.         errpkt("Can't do who command");
  340.         SERVE;
  341.     }
  342.     }
  343. }
  344.     break;
  345. case 28:
  346.     { success = 0; QUIT; }
  347.     break;
  348. case 29:
  349.     {                /* Anything else in this state... */
  350.     errpkt("Unimplemented REMOTE command"); /* Complain */
  351.     SERVE;                /* and return to server command wait */
  352. }
  353.     break;
  354. case 30:
  355.     {                /* Short-Form reply */
  356.     decode(rdatap,puttrm);        /* in ACK Data field */
  357.     RESUME;
  358. }
  359.     break;
  360. case 31:
  361.     {                /* File header */
  362.     xflg = 0;                /* Not screen data */
  363.     rcvfil(filnam);            /* Figure out local filename */
  364.     encstr(filnam);            /* Encode it */
  365.     ack1(encbuf);            /* Send it back in ACK */
  366.     initattr(&iattr);            /* Clear file attribute structure */
  367.     window(wslotsn);            /* allocate negotiated window slots */
  368.     BEGIN rattr;            /* Now expect Attribute packets */
  369. }
  370.     break;
  371. case 32:
  372.     {                /* X-packet instead of file header */
  373.     xflg = 1;                /* Screen data */
  374.     ack();                /* Acknowledge the X-packet */
  375.     initattr(&iattr);            /* Initialize attribute structure */
  376.     window(wslotsn);            /* allocate negotiated window slots */
  377.     BEGIN rattr;            /* Expect Attribute packets */
  378. }
  379.     break;
  380. case 33:
  381.     {                /* Attribute packet */
  382.     if (gattr(rdatap,&iattr) == 0)    /* Read into attribute structure */
  383.       ack();                /* If OK, acknowledge */
  384.     else
  385.       ack1(iattr.reply.val);        /* refuse to accept the file */
  386. }
  387.     break;
  388. case 34:
  389.     {                /* First data packet */
  390.     if (xflg)                /* If screen data */
  391.       x = opent(&iattr);        /* "open" the screen */
  392.     else                /* otherwise */
  393.       x = opena(filnam,&iattr);        /* open the file, with attributes */
  394.     if (x) {                /* If file was opened ok */
  395.     if (decode(rdatap,putfil) < 0) { /* decode first data packet */
  396.         errpkt("Error writing data");
  397.         RESUME;
  398.     }
  399.     ack();                /* acknowledge it */
  400.     BEGIN rdata;            /* and switch to receive-data state */
  401.     } else {                /* otherwise */
  402.     errpkt("Can't open file");    /* send error message */
  403.     RESUME;                /* and quit. */
  404.     }
  405. }
  406.     break;
  407. case 35:
  408.     {                /* EOT, no more files */
  409.     ack();                /* Acknowledge */
  410.     tsecs = gtimer();            /* Get timing for statistics */
  411.     reot();                /* Do EOT things */
  412.     RESUME;                /* and quit */
  413. }
  414.     break;
  415. case 36:
  416.     {                /* Data packet */
  417.     if (cxseen)                /* If file interrupt */
  418.       ack1("X");            /* put "X" in ACK */
  419.     else if (czseen)            /* If file-group interrupt */
  420.       ack1("Z");            /* put "Z" in ACK */
  421.     else if (decode(rdatap,putfil) < 0) { /* Normal case, */
  422.     errpkt("Error writing data");    /*   decode data to file */
  423.     RESUME;                /* Send ACK if data written */
  424.     } else ack();            /* to file OK. */
  425. }
  426.     break;
  427. case 37:
  428.     {            /* End Of File (EOF) Packet */
  429. /*  wslots = 1;                /* Window size back to 1 */
  430.     if (reof(filnam, &iattr) < 0) {    /* Close & dispose of the file */
  431.     errpkt("Can't close file");    /* If problem, send error message */
  432.     RESUME;                /* and quit */
  433.     } else {                /* otherwise */
  434.     ack();                /* acknowledge the EOF packet */
  435.     success = 1;
  436.     BEGIN rfile;            /* and await another file */
  437.     }
  438. }
  439.     break;
  440. case 38:
  441.     {                /* ACK for Send-Init */
  442.     spar(rdatap);            /* set parameters from it */
  443.     bctu = bctr;            /* switch to agreed-upon block check */
  444.     x = sfile(xflg);            /* Send X or F header packet */
  445.     if (x) {                /* If the packet was sent OK */
  446.     resetc();            /* reset per-transaction counters */
  447.     rtimer();            /* reset timers */
  448.     BEGIN ssfile;            /* and switch to receive-file state */
  449.     } else {                /* otherwise send error msg & quit */
  450.     s = xflg ? "Can't execute command" : "Can't open file";
  451.     errpkt(s);
  452.     RESUME;
  453.     }
  454. }
  455.     break;
  456. case 39:
  457.     {                /* ACK for F packet */
  458.     srvptr = srvcmd;            /* Point to string buffer */
  459.     decode(rdatap,putsrv);        /* Decode data field, if any */
  460.     putsrv('\0');            /* Terminate with null */
  461.     if (*srvcmd)            /* If remote name was recorded */
  462.       tlog(F110," stored as",srvcmd,0); /* Record it in transaction log. */
  463.     if (atcapu) {            /* If attributes are to be used */
  464.     if (sattr(xflg) < 0) {        /* set and send them */
  465.         errpkt("Can't send attributes"); /* if problem, say so */
  466.         RESUME;                 /* and quit */
  467.     } else BEGIN ssattr;        /* if ok, switch to attribute state */
  468.     } else {
  469.     window(wslotsn);
  470.     if (sdata() < 0) {        /* No attributes, send data */
  471.         clsif();            /* If not ok, close input file, */
  472.         seof("");            /* send EOF packet */
  473.         BEGIN sseof;        /* and switch to EOF state. */
  474.     } else BEGIN ssdata;        /* All ok, switch to send-data state */
  475.     }
  476. }
  477.     break;
  478. case 40:
  479.     {                /* Got ACK to A packet */
  480.     if (rsattr(rdatap) < 0) {        /* Was the file refused? */
  481.     clsif();            /* yes, close it */
  482.     sxeof("D");            /* send EOF with "discard" code */
  483.     BEGIN sseof;            /* switch to send-EOF state */
  484.     } else {
  485.     window(wslotsn);        /* Allocate negotiated window. */
  486.     if (sdata() < 0) {        /* File accepted, send data */
  487.         clsif();            /* If problem, close input file */
  488. /***        wslots = 1;            /* Window size back to 1... */
  489.         seof("");            /* send EOF packet */
  490.         BEGIN sseof;        /* and switch to send-EOF state. */
  491.     } else {            /* All ok, enter send-data state. */
  492.         BEGIN ssdata;
  493.     }
  494.     }
  495. }
  496.     break;
  497. case 41:
  498.     {                /* Got ACK to Data packet */
  499.     canned(rdatap);            /* Check if file transfer cancelled */
  500.     if ((sdata() < 0) || cxseen || czseen) { /* Try to send next data */
  501.     clsif();            /* If no more data, close file */
  502. /****    wslots = 1;  ***/        /* Window size back to 1... */
  503.     if (cxseen || czseen)        /* If interrupted */
  504.       seof("D");            /* send special EOF packet */
  505.     else seof("");            /* Otherwise regular EOF packet */
  506.     BEGIN sseof;            /* And enter send-eof state */
  507.     }
  508. }
  509.     break;
  510. case 42:
  511.     {                /* Got ACK to EOF */
  512.     success = (cxseen == 0 && czseen == 0); /* Set this for IF command */
  513.     cxseen = 0;                /* This goes back to zero. */
  514.     if (gnfile() > 0) {            /* Any more files to send? */
  515.     if (sfile(xflg))        /* Yes, try to send next file header */
  516.       BEGIN ssfile;            /* if ok, enter send-file state */
  517.     else {                /* otherwise */
  518.         errpkt("Can't open file");    /* send error message */
  519.         RESUME;            /* and quit */
  520.     }
  521.     } else {                /* No next file */
  522.     tsecs = gtimer();        /* get statistics timers */
  523.     seot();                /* send EOT packet */
  524.     BEGIN sseot;            /* enter send-eot state */
  525.     }
  526. }
  527.     break;
  528. case 43:
  529.     {                /* Got ACK to EOT */
  530.     RESUME;                /* All done, just quit */
  531. }
  532.     break;
  533. case 44:
  534.     {                    /* Got Error packet, in any state */
  535.     ermsg(rdatap);            /* Issue message. */
  536.     success = 0;            /* For IF SUCCESS/FAIL. */
  537.     x = quiet; quiet = 1;        /* Close files silently, */
  538.     clsif(); clsof(1);            /* discarding any output file. */
  539.     tsecs = gtimer();            /* Get timers */
  540.     quiet = x;                /* restore quiet state */
  541.     if (backgrd && !server) fatal("Protocol error");
  542.     RESUME;
  543. }
  544.     break;
  545. case 45:
  546.     { QUIT; }
  547.     break;
  548. case 46:
  549.     {                    /* Anything not accounted for above */
  550.     errpkt("Unexpected packet type");    /* Give error message */
  551.     RESUME;                /* and quit */
  552. }
  553.     break;
  554.  
  555.         }
  556.     }
  557. }
  558.  
  559. CHAR tbl[] = {
  560. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  561. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  562. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  563. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  564. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  565. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  566. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  567. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  568. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  569. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  570. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  571. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  572. 46, 46, 46, 46, 46, 10, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  573. 46, 46, 46, 46, 46, 46, 46, 46, 46,  9, 46, 46, 46, 46, 46, 46, 
  574. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  575. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  576. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  577. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  578. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  579. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  580. 46, 46, 35, 46, 46, 44, 31, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  581. 46, 46, 46, 46, 46, 46, 46, 46, 32, 46, 46, 46, 46, 46, 46, 46, 
  582. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  583. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  584. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  585. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  586. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  587. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  588. 46, 33, 46, 46, 34, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  589. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 37, 46, 46, 46, 46, 46, 
  590. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  591. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  592. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  593. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  594. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  595. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  596. 46, 46, 46, 46, 36, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  597. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 37, 46, 46, 46, 46, 46, 
  598. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  599. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  600. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  601. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  602. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  603. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  604. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  605. 46, 46, 46, 46, 46, 46, 46, 46, 46, 38, 46, 46, 46, 46, 46, 46, 
  606. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  607. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  608. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  609. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  610. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  611. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  612. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  613. 46, 46, 46, 46, 46, 46, 46, 46, 46, 39, 46, 46, 46, 46, 46, 46, 
  614. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  615. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  616. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  617. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  618. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  619. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  620. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  621. 46, 46, 46, 46, 46, 46, 46, 46, 46, 40, 46, 46, 46, 46, 46, 46, 
  622. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  623. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  624. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  625. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  626. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  627. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  628. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  629. 46, 46, 46, 46, 46, 46, 46, 46, 46, 41, 46, 46, 46, 46, 46, 46, 
  630. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  631. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  632. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  633. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  634. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  635. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  636. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  637. 46, 46, 46, 46, 46, 46, 46, 46, 46, 42, 46, 46, 46, 46, 46, 46, 
  638. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  639. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  640. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  641. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  642. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  643. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  644. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  645. 46, 46, 46, 46, 46, 46, 46, 46, 46, 43, 46, 46, 46, 46, 46, 46, 
  646. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  647. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  648. -1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 
  649. 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 
  650. 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 
  651. 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 
  652. 17, 17, 17, 15, 17, 17, 17, 14, 17, 12, 17, 17, 17, 17, 17, 17, 
  653. 17, 17, 13,  8, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 
  654. 17,  7, 17,  4, 17, 17, 17,  5, 17, 17, 17, 17, 17, 17, 17, 17, 
  655. 17, 16,  3,  1, 17, 17,  2, 17,  6, 17, 17, 17, 17, 17, 17, 17, 
  656. -1, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
  657. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
  658. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
  659. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
  660. 29, 29, 29, 18, 19, 20, 21, 29, 23, 29, 29, 29, 22, 29, 29, 29, 
  661. 29, 29, 29, 24, 25, 26, 29, 27, 29, 29, 29, 29, 29, 29, 29, 29, 
  662. 29,  7, 29,  4, 29, 29, 29,  5, 29, 29, 29, 29, 29, 29, 29, 29, 
  663. 29, 28,  3,  1, 29, 29,  2, 29,  6, 29, 29, 29, 29, 29, 29, 29, 
  664. -1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  665. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  666. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  667. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  668. 46, 46, 46, 46, 46, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  669. 46, 46, 46,  8, 46, 46, 46, 46, 46, 11, 46, 46, 46, 46, 46, 46, 
  670. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  671. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  672.  0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  673. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  674. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  675. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  676. 46, 46, 46, 46, 46, 44, 31, 46, 46, 46, 46, 46, 46, 46, 46, 46, 
  677. 46, 46, 46,  8, 46, 46, 46, 46, 32, 30, 46, 46, 46, 46, 46, 46, 
  678. 46,  7, 46,  4, 46, 46, 46,  5, 46, 46, 46, 46, 46, 46, 46, 46, 
  679. 46, 45,  3,  1, 46, 46,  2, 46,  6, 46, 46, 46, 46, 46, 46, 46, 
  680. };
  681.  
  682.  
  683. /*  P R O T O  --  Protocol entry function  */
  684.  
  685. proto() {
  686.  
  687.     extern int sigint();
  688.     int x;
  689.  
  690.     conint(sigint);            /* Enable console interrupts */
  691.  
  692. /* Set up the communication line for file transfer. */
  693.  
  694.     if (local && (speed < 0) && (network == 0)) {
  695.     screen(SCR_EM,0,0l,"Sorry, you must 'set speed' first");
  696.     return;
  697.     }
  698.     x = -1;
  699.     if (ttopen(ttname,&x,mdmtyp) < 0) {
  700.     debug(F111,"failed: proto ttopen local",ttname,local);
  701.     screen(SCR_EM,0,0l,"Can't open line");
  702.     return;
  703.     }
  704.     if (x > -1) local = x;
  705.     debug(F111,"proto ttopen local",ttname,local);
  706.  
  707.     x = (local && !network) ? speed : -1;
  708.     if (ttpkt(x,flow,parity) < 0) {    /* Put line in packet mode, */
  709.     screen(SCR_EM,0,0l,"Can't condition line");
  710.     return;
  711.     }
  712.     if (sstate == 'x') {        /* If entering server mode, */
  713.     server = 1;            /* set flag, */
  714.     if (!quiet) {
  715.         if (!local)            /* and issue appropriate message. */
  716.             conol(srvtxt);
  717.         else {
  718.             conol("Entering server mode on ");
  719.         conoll(ttname);
  720.         }
  721.     }
  722.     } else server = 0;
  723.     if (sstate == 'v' && !local && !quiet && cmdlvl == 0)
  724.       conoll("Escape back to your local Kermit and give a SEND command...");
  725.     if (sstate == 's' && !local && !quiet && cmdlvl == 0)
  726.       conoll("Escape back to your local Kermit and give a RECEIVE command...");
  727.     sleep(1);
  728. /*
  729.  The 'wart()' function is generated by the wart program.  It gets a
  730.  character from the input() routine and then based on that character and
  731.  the current state, selects the appropriate action, according to the state
  732.  table above, which is transformed by the wart program into a big case
  733.  statement.  The function is active for one transaction.
  734. */
  735.     wart();                /* Enter the state table switcher. */
  736.     
  737.     if (server) {            /* Back from packet protocol. */
  738.     server = 0;
  739.         if (!quiet)              /* Give appropriate message */
  740.         conoll("C-Kermit server done");
  741.     }
  742.     ttres();                /* Reset the terminal */
  743.     screen(SCR_TC,0,0l,"");        /* Transaction complete */
  744. }
  745.