home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ncr9800 / ckvpro.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  27KB  |  745 lines

  1. /* WARNING -- This C source program generated by Wart preprocessor. */
  2. /* Do not edit this file; edit the Wart-format source file instead, */
  3. /* and then run it through Wart to produce a new C source file.     */
  4.  
  5. /* Wart Version Info: */
  6. char     *wartv = "Wart Version 1A(006) May 1990";
  7.  
  8. #ifndef MCS_FLAG
  9. char     *protv = "IVS-Kermit Protocol Module 4E(032), 31 May 90";
  10. #else
  11. char     *protv = "MCS-Kermit Protocol Module 4E(032), 31 May 90";
  12. #endif
  13.                           /* -*-C-*- */
  14.  
  15. /* C K V P R O  -- C-Kermit Protocol Module, in Wart preprocessor notation. */
  16.  
  17. /**********************************************************************
  18. *                                                                     *
  19. * IVS / MCS-Kermit REL 2                                              *
  20. * source code                                                         *
  21. *                                                                     *
  22. * Change History:                                                     *
  23. *                                                                     *
  24. *                1. Modify C-Kermit(4E) source code to                *
  25. *                   produce new module for MCS/IVS-Kermit             *
  26. *                   ORIGINAL RELEASE                                  *
  27. *                   June 22, 1990                                     *
  28. *                                                                     *
  29. *                                                                     *
  30. ***********************************************************************/
  31.  
  32.  
  33. /*
  34.  Authors: Frank da Cruz (SY.FDC@CU20B), Bill Catchings, Jeff Damens;
  35.  Columbia University Center for Computing Activities, January 1985.
  36.  Copyright (C) 1985, Trustees of Columbia University in the City of New York.
  37.  Permission is granted to any individual or institution to use, copy, or
  38.  redistribute this software so long as it is not sold for profit, provided this
  39.  copyright notice is retained.
  40. */
  41. #include "ckcdeb.h"
  42. #include "ckcker.h"
  43. /*
  44.  Note -- This file may also be preprocessed by the NCR-VRX Lex program, but
  45.  you must indent the above #include statements before using Lex, and then
  46.  restore them to the left margin in the resulting C program before compilation.
  47.  Also, the invocation of the "wart()" function below must be replaced by an
  48.  invocation  of the "yylex()" function.  It might also be necessary to remove
  49.  comments in the %%...%% section.
  50. */
  51.  
  52. /* State definitions for Wart (or Lex) */
  53. #define ipkt 1
  54. #define rfile 2
  55. #define rdata 3
  56. #define ssinit 4
  57. #define ssfile 5
  58. #define ssdata 6
  59. #define sseof 7
  60. #define sseot 8
  61. #define serve 9
  62. #define generic 10
  63. #define get 11
  64. #define rgen 12
  65.  
  66. /* External C-Kermit variable declarations */
  67. extern char     sstate, deblog, *versio, *srvtxt, *cmarg, *cmarg2, *rpar();
  68. extern char     data[], filnam[], srvcmd[], ttname[], *srvptr;
  69. extern int     pktnum, timint, nfils, hcflg, xflg, speed, flow, mdmtyp;
  70. extern int     prvpkt, cxseen, czseen, server, local, displa, bctu, bctr,
  71.                quiet;
  72. extern int     tsecs, parity, backgrd;
  73. extern int     putsrv(), puttrm(), putfil(), errpkt();
  74. extern char     *rdatap;
  75.  
  76. /* Local variables */
  77. static char     vstate = 0;               /* Saved State   */
  78. static char     vcmd = 0;                 /* Saved Command */
  79. int     x;                                /* General-purpose integer */
  80. char     *s;                              /* General-purpose string pointer */
  81.  
  82. /* Macros - Note, BEGIN is predefined by Wart (and Lex) */
  83. #define SERVE  tinit(); BEGIN serve
  84. #define RESUME if (server) { SERVE; } else { sleep(2); return; }
  85.  
  86.  
  87. #define BEGIN state =
  88.  
  89. int     state = 0;
  90.  
  91. wart()
  92. {
  93.      int     c, actno;
  94.      extern short     tbl[];
  95.      while (1) {
  96.           c = input();
  97.           if ((actno = tbl[c + state*128]) != -1)
  98.                switch (actno) {
  99.                case 1:
  100.                      {
  101.                          tinit();                /* Do Send command */
  102.                          if (sinit())
  103.                               BEGIN ssinit;
  104.                          else
  105.                               RESUME;
  106.                     }
  107.                     break;
  108.                case 2:
  109.                      {
  110.                          tinit();
  111.                          BEGIN get;
  112.                     }
  113.                     break;
  114.                case 3:
  115.                      {
  116.                          tinit();
  117.                          vstate = get;
  118.                          vcmd = 0;
  119.                          sipkt('I');
  120.                          BEGIN ipkt;
  121.                     }
  122.                     break;
  123.                case 4:
  124.                      {
  125.                          tinit();
  126.                          vstate = rgen;
  127.                          vcmd = 'C';
  128.                          sipkt('I');
  129.                          BEGIN ipkt;
  130.                     }
  131.                     break;
  132.                case 5:
  133.                      {
  134.                          tinit();
  135.                          vstate = rgen;
  136.                          vcmd = 'G';
  137.                          sipkt('I');
  138.                          BEGIN ipkt;
  139.                     }
  140.                     break;
  141.                case 6:
  142.                      {
  143.                          sleep(1);
  144.                          SERVE;
  145.                     }
  146.                     break;
  147.                case 7:
  148.                      {   /* "Abort" -- Tell other side. */
  149.                          errpkt("User cancelled transaction");
  150.                          x = quiet;
  151.                          quiet = 1;               /* Close files silently. */
  152.                          clsif();
  153.                          clsof(1);
  154.                          quiet = x;
  155.                          return(0);
  156.                     }
  157.                     break;
  158.                case 8:
  159.                      {
  160.                          rinit(rdatap);
  161.                          bctu = bctr; /* Get Send-Init */
  162.                          resetc();                    /* Reset counters */
  163.                          rtimer();                    /* Reset timer */
  164.                          BEGIN rfile;
  165.                     }
  166.                     break;
  167.                case 9:
  168.                      {
  169.                          spar(rdatap);             /* Get ack for I-packet */
  170.                          if (vcmd) {
  171.                               scmd(vcmd, cmarg);
  172.                               vcmd = 0;
  173.                          }
  174.                          if (vstate == get)
  175.                               srinit();
  176.                          BEGIN vstate;
  177.                     }
  178.                     break;
  179.                case 10:
  180.                      {
  181.                          if (vcmd)   /* Get E for I-packet (ignore) */
  182.                               scmd(vcmd, cmarg);
  183.                          vcmd = 0;
  184.                          if (vstate == get)
  185.                               srinit();
  186.                          BEGIN vstate;
  187.                     }
  188.                     break;
  189.                case 11:
  190.                      {
  191.                          srinit();
  192.                     }
  193.                     break;
  194.                case 12:
  195.                      {
  196.                          srvptr = srvcmd;
  197.                          decode(rdatap, putsrv); /* Get Receive-Init */
  198.                          cmarg = srvcmd;
  199.                          nfils = -1;
  200.                          if (sinit())
  201.                               BEGIN ssinit;
  202.                          else {
  203.                               SERVE;
  204.                          }
  205.                     }
  206.                     break;
  207.                case 13:
  208.                      {
  209.                          spar(rdatap);
  210.                          ack1(rpar());     /* Get Init Parameters */
  211.                          pktnum = 0;
  212.                          prvpkt = -1;
  213.                     }
  214.                     break;
  215.                case 14:
  216.                      {
  217.                          srvptr = srvcmd;
  218.                          decode(rdatap, putsrv); /* Get & decode command. */
  219.                          putsrv('\0');
  220.                          putsrv('\0');
  221.                          sstate = srvcmd[0];
  222.                          BEGIN generic;
  223.                     }
  224.                     break;
  225.                case 15:
  226.                      {
  227.                          srvptr = srvcmd;          /* Get command for shell */
  228.                          decode(rdatap, putsrv);
  229.                          putsrv('\0');
  230.                          if (syscmd(srvcmd, ""))
  231.                               BEGIN ssinit;
  232.                          else {
  233.                               errpkt("Can't do system command");
  234.                               SERVE;
  235.                          }
  236.                     }
  237.                     break;
  238.                case 16:
  239.                      {
  240.                          errpkt("Unimplemented server function");
  241.                          SERVE;
  242.                     }
  243.                     break;
  244.                case 17:
  245.                      {
  246.                          if (!cwd(srvcmd + 1))
  247.                               errpkt("Can't change directory"); /* CWD */
  248.                          SERVE;
  249.                     }
  250.                     break;
  251.                case 18:
  252.                      {
  253.                          errpkt("Can't list directory");
  254.                          SERVE;
  255.                     }
  256.                     break;
  257.                case 19:
  258.                      {
  259.                          errpkt("Can't remove file");
  260.                          SERVE;
  261.                     }
  262.                     break;
  263.                case 20:
  264.                      {
  265.                          ack();
  266.                          screen(SCR_TC, 0, 0l, "");
  267.                          return(0);
  268.                     }
  269.                     break;
  270.                case 21:
  271.                      {
  272.                          ack();
  273.                          ttres();
  274.                          screen(SCR_TC, 0, 0l, "");
  275.                          return(zkself());
  276.                     }
  277.                     break;
  278.                case 22:
  279.                      {
  280.                          if (sndhlp())
  281.                               BEGIN ssinit;
  282.                          else {
  283.                               errpkt("Can't send help");
  284.                               SERVE;
  285.                          }
  286.                     }
  287.                     break;
  288.                case 23:
  289.                      {
  290.                          errpkt("Can't type file");
  291.                          SERVE;
  292.                     }
  293.                     break;
  294.                case 24:
  295.                      {
  296.                          errpkt("Can't check space");
  297.                          SERVE;
  298.                     }
  299.                     break;
  300.                case 25:
  301.                      {
  302.                          errpkt("Can't do who command");
  303.                          SERVE;
  304.                     }
  305.                     break;
  306.                case 26:
  307.                      {
  308.                          errpkt("Unimplemented generic server function");
  309.                          SERVE;
  310.                     }
  311.                     break;
  312.                case 27:
  313.                      {
  314.                          decode(rdatap, puttrm);
  315.                          RESUME;
  316.                     }
  317.                     break;
  318.                case 28:
  319.                      {
  320.                          if (rcvfil())                   /* File header */ {
  321.                               encstr(filnam);
  322.                               ack1(data);
  323.                               BEGIN rdata;
  324.                          } else {
  325.                               errpkt("Can't open file");
  326.                               RESUME;
  327.                          }
  328.                     }
  329.                     break;
  330.                case 29:
  331.                      {
  332.                          opent();
  333.                          ack();
  334.                          BEGIN rdata;
  335.                     }
  336.                     break;
  337.                case 30:
  338.                      {
  339.                          ack();
  340.                          tsecs = gtimer();
  341.                          reot();
  342.                          RESUME;
  343.                     }
  344.                     break;
  345.                case 31:
  346.                      {
  347.                          if (cxseen)
  348.                               ack1("X");    /* Got data. */
  349.                          else if (czseen)
  350.                               ack1("Z");
  351.                          else
  352.                               ack();
  353.                          decode(rdatap, putfil);
  354.                     }
  355.                     break;
  356.                case 32:
  357.                      {
  358.                          if (reof() < 0) {         /* Got End Of File */
  359.                               errpkt("Can't close file");
  360.                               RESUME;
  361.                          } else {
  362.                               ack();
  363.                               BEGIN rfile;
  364.                          }
  365.                     }
  366.                     break;
  367.                case 33:
  368.                      {
  369.                          spar(rdatap);
  370.                          bctu = bctr;        /* Got ACK to Send-Init */
  371.                          x = sfile(xflg);    /* Send X or F header packet */
  372.                          if (x) {
  373.                               resetc();
  374.                               rtimer();
  375.                               BEGIN ssfile;
  376.                          } else {
  377.                               s = xflg ? "Can't execute command" :
  378.                                   "Can't open file";
  379.                               errpkt(s);
  380.                               RESUME;
  381.                          }
  382.                     }
  383.                     break;
  384.                case 34:
  385.                      {
  386.                          srvptr = srvcmd;                   /* Got ACK to F */
  387.                          decode(rdatap, putsrv);
  388.                          putsrv('\0');
  389.                          if (*srvcmd)
  390.                               tlog(F110, " stored as",
  391.                                    srvcmd, 0);
  392.                          if (sdata() < 0) {
  393.                               clsif();
  394.                               seof("");
  395.                               BEGIN sseof;
  396.                          } else
  397.                               BEGIN ssdata;
  398.                     }
  399.                     break;
  400.                case 35:
  401.                      {
  402.                          if (canned(rdatap)) {
  403.                               clsif();
  404.                               seof("D");
  405.                               BEGIN sseof;
  406.                          } else if (sdata() < 0) {
  407.                               clsif();
  408.                               seof("");
  409.                               BEGIN sseof;
  410.                          }
  411.                     }
  412.                     break;
  413.                case 36:
  414.                      {
  415.                          if (gnfile() > 0) {
  416.                               /* Got ACK to EOF, get next file */
  417.                               if (sfile(xflg))
  418.                                    BEGIN ssdata;
  419.                               else {
  420.                                    errpkt("Can't open file") ;
  421.                                    RESUME;
  422.                               }
  423.                          } else {                    /* If no next file, EOT */
  424.                               tsecs = gtimer();
  425.                               seot();
  426.                               BEGIN sseot;
  427.                          }
  428.                     }
  429.                     break;
  430.                case 37:
  431.                      {
  432.                          RESUME;
  433.                     }
  434.                     break;
  435.                case 38:
  436.                      {   /* Error packet, issue message. *
  437.                          ermsg(rdatap);         /
  438.                          x = quiet;
  439.                          quiet = 1;           /* Close files silently, */
  440.                          clsif();
  441.                          clsof(1);            /* discarding any output file. */
  442.                          tsecs = gtimer();
  443.                          quiet = x;
  444.                          if (backgrd && !server)
  445.                               fatal("Protocol error");
  446.                          RESUME;
  447.                     }
  448.                     break;
  449.                case 39:
  450.                      {
  451.                          errpkt("Unknown packet type-> Please retry");
  452.                          RESUME;
  453.                     }
  454.                     break;
  455.  
  456.                }
  457.      }
  458. }
  459.  
  460.  
  461. short     tbl[] = {
  462.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  463.          39,
  464.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  465.          39,
  466.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  467.          39,
  468.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  469.          39,
  470.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  471.          39,
  472.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  473.          39,
  474.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  475.          39,
  476.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  477.          39,
  478.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  479.          39,
  480.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  481.          39,
  482.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  483.          39,
  484.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  485.          39,
  486.      39, 39, 39, 39, 39, 10, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  487.          39,
  488.      39, 39, 39, 39, 39, 39, 39, 39, 39,  9, 39, 39, 39, 39, 39,
  489.          39,
  490.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  491.          39,
  492.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  493.          39,
  494.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  495.          39,
  496.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  497.          39,
  498.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  499.          39,
  500.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  501.          39,
  502.      39, 39, 30, 39, 39, 38, 28, 39, 39, 39, 39, 39, 39, 39, 39,
  503.          39,
  504.      39, 39, 39, 39, 39, 39, 39, 39, 29, 39, 39, 39, 39, 39, 39,
  505.          39,
  506.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  507.          39,
  508.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  509.          39,
  510.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  511.          39,
  512.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  513.          39,
  514.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  515.          39,
  516.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  517.          39,
  518.      39, 39, 39, 39, 31, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  519.          39,
  520.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 32, 39, 39, 39, 39,
  521.          39,
  522.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  523.          39,
  524.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  525.          39,
  526.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  527.          39,
  528.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  529.          39,
  530.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  531.          39,
  532.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  533.          39,
  534.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  535.          39,
  536.      39, 39, 39, 39, 39, 39, 39, 39, 39, 33, 39, 39, 39, 39, 39,
  537.          39,
  538.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  539.          39,
  540.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  541.          39,
  542.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  543.          39,
  544.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  545.          39,
  546.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  547.          39,
  548.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  549.          39,
  550.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  551.          39,
  552.      39, 39, 39, 39, 39, 39, 39, 39, 39, 34, 39, 39, 39, 39, 39,
  553.          39,
  554.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  555.          39,
  556.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  557.          39,
  558.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  559.          39,
  560.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  561.          39,
  562.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  563.          39,
  564.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  565.          39,
  566.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  567.          39,
  568.      39, 39, 39, 39, 39, 39, 39, 39, 39, 35, 39, 39, 39, 39, 39,
  569.          39,
  570.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  571.          39,
  572.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  573.          39,
  574.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  575.          39,
  576.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  577.          39,
  578.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  579.          39,
  580.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  581.          39,
  582.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  583.          39,
  584.      39, 39, 39, 39, 39, 39, 39, 39, 39, 36, 39, 39, 39, 39, 39,
  585.          39,
  586.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  587.          39,
  588.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  589.          39,
  590.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  591.          39,
  592.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  593.          39,
  594.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  595.          39,
  596.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  597.          39,
  598.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  599.          39,
  600.      39, 39, 39, 39, 39, 39, 39, 39, 39, 37, 39, 39, 39, 39, 39,
  601.          39,
  602.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  603.          39,
  604.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  605.          39,
  606.      -1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  607.          16,
  608.      16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  609.          16,
  610.      16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  611.          16,
  612.      16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  613.          16,
  614.      16, 16, 16, 15, 16, 16, 16, 14, 16, 13, 16, 16, 16, 16, 16,
  615.          16,
  616.      16, 16, 12,  8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  617.          16,
  618.      16,  7, 16,  4, 16, 16, 16,  5, 16, 16, 16, 16, 16, 16, 16,
  619.          16,
  620.      16, 16,  3,  1, 16, 16,  2, 16,  6, 16, 16, 16, 16, 16, 16,
  621.          16,
  622.      -1, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
  623.          26,
  624.      26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
  625.          26,
  626.      26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
  627.          26,
  628.      26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
  629.          26,
  630.      26, 26, 26, 17, 18, 19, 20, 26, 22, 26, 26, 26, 21, 26, 26,
  631.          26,
  632.      26, 26, 26, 26, 23, 24, 26, 25, 26, 26, 26, 26, 26, 26, 26,
  633.          26,
  634.      26,  7, 26,  4, 26, 26, 26,  5, 26, 26, 26, 26, 26, 26, 26,
  635.          26,
  636.      26, 26,  3,  1, 26, 26,  2, 26,  6, 26, 26, 26, 26, 26, 26,
  637.          26,
  638.      -1, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  639.          39,
  640.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  641.          39,
  642.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  643.          39,
  644.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  645.          39,
  646.      39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  647.          39,
  648.      39, 39, 39,  8, 39, 39, 39, 39, 39, 11, 39, 39, 39, 39, 39,
  649.          39,
  650.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  651.          39,
  652.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  653.          39,
  654.      0, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  655.           39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  656.           39,
  657.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  658.          39,
  659.      39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
  660.          39,
  661.      39, 39, 39, 39, 39, 38, 28, 39, 39, 39, 39, 39, 39, 39, 39,
  662.          39,
  663.      39, 39, 39,  8, 39, 39, 39, 39, 29, 27, 39, 39, 39, 39, 39,
  664.          39,
  665.      39,  7, 39,  4, 39, 39, 39,  5, 39, 39, 39, 39, 39, 39, 39,
  666.          39,
  667.      39, 39,  3,  1, 39, 39,  2, 39,  6, 39, 39, 39, 39, 39, 39,
  668.          39,
  669. };
  670.  
  671.  
  672. /*  P R O T O  --  Protocol entry function  */
  673.  
  674. proto()
  675. {
  676.  
  677.      extern int     sigint();
  678.      int     x;
  679.  
  680.      conint(sigint);                     /* Enable console interrupts */
  681.  
  682.      /* Set up the communication line for file transfer. */
  683.  
  684.      if (local && (speed < 0)) {
  685.           screen(SCR_EM, 0, 0l, "Sorry, you must 'set speed' first");
  686.           return;
  687.      }
  688.  
  689.      x = -1;
  690.      if (ttopen(ttname, &x, mdmtyp) < 0) {
  691.           if (deblog)
  692.                debug(F111, "failed: proto ttopen local", ttname,
  693.                     local);
  694.           screen(SCR_EM, 0, 0l, "Can't open line");
  695.           return;
  696.      }
  697.      if (x > -1)
  698.           local = x;
  699.      if (deblog)
  700.           debug(F111, "proto ttopen local", ttname, local);
  701.  
  702.      x = (local) ? speed : -1;
  703.      if (ttpkt(x, flow, parity) < 0) {     /* Put line in packet mode, */
  704.           screen(SCR_EM, 0, 0l, "Can't condition line");
  705.           return;
  706.      }
  707.      if (sstate == 'x') {                /* If entering server mode, */
  708.           server = 1;                     /* set flag, */
  709.           if (!quiet) {
  710.                if (!local)                 /* and issue appropriate message. */
  711.                     conol(srvtxt);
  712.                else {
  713.                     conol("Entering server mode on ");
  714.                     conoll(ttname);
  715.                }
  716.           }
  717.      } else
  718.           server = 0;
  719.      if (sstate == 'v' && !local && !quiet)
  720.           conoll("ESC back to local system and give a SEND command...");
  721.      if (sstate == 's' && !local && !quiet)
  722.           conoll("ESC back to local system and give a RECEIVE command...");
  723.      sleep(1);
  724. /*
  725.  The 'wart()' function is generated by the wart program.  It gets a
  726.  character from the input() routine and then based on that character and
  727.  the current state, selects the appropriate action, according to the state
  728.  table above, which is transformed by the wart program into a big case
  729.  statement.  The function is active for one transaction.
  730. */
  731.      wart();                             /* Enter the state table switcher. */
  732.  
  733.      if (server) {                       /* Back from packet protocol. */
  734.           server = 0;
  735.           if (!quiet)                     /* Give appropriate message */
  736. #ifndef MCS_FLAG
  737.                conoll("IVS-Kermit server done");
  738. #else
  739.                conoll("MCS-Kermit server done");
  740. #endif
  741.      }
  742.      ttres();
  743.      screen(SCR_TC, 0, 0l, "");             /* Transaction complete */
  744. }
  745.