home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / wattcp.zip / TCPPORT.C < prev    next >
C/C++ Source or Header  |  1992-07-09  |  18KB  |  671 lines

  1. #define OLD 1       /* new changes not complete */
  2.  
  3. /*
  4.  * TCPPORT - make tcp connections from virtual serial ports
  5.  *
  6.  * Copyright (C) 1989, 1990, 1991, University of Waterloo
  7.  * Portions Copyright (C) 1991, Trustees of Columbia University
  8.  *    in the City of New York.  Permission is granted to any
  9.  *    individual or institution to use, copy, or redistribute
  10.  *    this software as long as it is not sold for profit, provided
  11.  *    this copyright notice is retained.
  12.  *
  13.  *   This program is distributed in the hope that it will be useful,
  14.  *   but without any warranty; without even the implied warranty of
  15.  *   merchantability or fitness for a particular purpose.
  16.  *
  17.  * Authors:
  18.  * Erick Engelke (erick@development.watstar.uwaterloo.ca),
  19.  *     Engineering Computing, University of Waterloo.
  20.  * Bruce Campbell (bruce@development.watstar.uwaterloo.ca),
  21.  *      Engineering Computing, University of Waterloo
  22.  * Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),
  23.  *    Columbia University Center for Computing Activities.
  24.  *
  25.  *   1.00 - May 13, 1991 : E. Engelke - stole negotiations from Frank's
  26.  *             & F. Da Cruz   telnet portion of C-KERMIT
  27.  *   0.04 - May  7, 1991 : E. Engelke - got echo/no echo working
  28.  *   0.03 - Apr 24, 1991 : E. Engelke - hacked terminal negotiation
  29.  *   0.02 - Mar 24, 1991 : E. Engelke - convert \r to \n for UNIX compatibility
  30.  *   0.01 - Feb   , 1991 : E. Engelke - converted Bruce's program to TCP
  31.  * - 1.00 -              : B. Campbell- created original program
  32.  *
  33.  *  To force a particular terminal type, set the environment variable
  34.  *  tcpterm to something like vt102, vt100, etc.
  35.  *
  36.  *  To decrease the size of the executable I have used outs rather than
  37.  *  printf.  outs is used by the Waterloo TCP kernal for displaying error
  38.  *  messages through the BIOS services.
  39.  *
  40.  */
  41.  
  42. #include <stdio.h>
  43. #include <string.h>
  44. #include <ctype.h>
  45. #include <dos.h>
  46. #include <tcp.h>
  47.  
  48.  
  49. typedef struct stk {
  50.     word bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,flgs;
  51. };
  52.  
  53. extern outhexes( byte far *p, int n );
  54.  
  55.  
  56. #define IAC     255
  57. #define DONT    254
  58. #define DO      253
  59. #define WONT    252
  60. #define WILL    251
  61. #define SB      250
  62. #define BREAK   243
  63. #define SE      240
  64.  
  65. #define TELOPT_ECHO     1
  66. #define TELOPT_SGA      3
  67. #define TELOPT_STATUS   5
  68. #define TELOPT_TTYPE    24
  69. #define NTELOPTS        24
  70.  
  71. #define TCPTERM    "TCPTERM"    /* environment variable */
  72.  
  73. char termtype[ 32 ];    /* from the environment, used in negotiations */
  74. int echo = 1;            /* default on, but hate it */
  75.  
  76.  
  77. #define TRANSMIT_TICKS      1        /* do the transmit after this many ticks */
  78. #define TRANSMIT_BUF_SIZE 4096
  79. #define TRANSMIT_MAX      256       /* most to transmit at a time */
  80.  
  81. #define RECEIVE_TICKS    1
  82. #define RECEIVE_BUF_SIZE 4096
  83.  
  84. extern unsigned long rdvct();
  85. extern unsigned long get_general();
  86.  
  87. void far serial_2();
  88. void far serial_t();
  89.  
  90. unsigned char transmit_buffer[ TRANSMIT_BUF_SIZE ];
  91. unsigned char receive_buffer[ RECEIVE_BUF_SIZE ];
  92. unsigned int tran_in = 0;
  93. unsigned int tran_out = 0;
  94. unsigned int rec_in = 0;
  95. unsigned int rec_out = 0;
  96. int transmit_clock = TRANSMIT_TICKS;
  97. int receive_clock = RECEIVE_TICKS;
  98.  
  99. void interrupt far (*old14)();
  100. void interrupt far (*old8)();
  101.  
  102.  
  103. word oldsp, oldss;
  104. char stack[ 8192 ];
  105. char bigbuf[ 8192 ];    /* used to speed up tcp recvs */
  106. longword host;
  107. tcp_Socket *s, socketdata;
  108. int moved_vectors = 0;
  109. int sock_status = 0;
  110.  
  111.  
  112. int sem_stack = 0;
  113.  
  114. struct stk far *stkptr;
  115. longword recvtimeout;
  116.  
  117.  
  118.  
  119. /* TCP/IP Telnet negotiation support code */
  120.  
  121. static int sgaflg = 0;                      /* telnet SGA flag */
  122.  
  123. #ifndef TELCMDS
  124. char *telcmds[] = {
  125.     "SE", "NOP", "DMARK", "BRK",  "IP",   "AO", "AYT",  "EC",
  126.     "EL", "GA",  "SB",    "WILL", "WONT", "DO", "DONT", "IAC",
  127. };
  128. #endif /* TELCMDS */
  129.  
  130. char *telopts[] = {
  131.         "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
  132.         "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
  133.         "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
  134.         "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
  135.         "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
  136.     "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
  137.     "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME",
  138.     "X.3 PAD", "NAWS", "TSPEED", "LFLOW", "LINEMODE"
  139. };
  140.  
  141. int ntelopts = sizeof(telopts) / sizeof(char *);
  142.  
  143. /*
  144.  * send_iac - send interupt character and pertanent stuff
  145.  *        - return 0 on success
  146.  */
  147.  
  148. send_iac( cmd, opt)
  149. char cmd, opt;
  150. {
  151.     byte io_data[3];
  152.     io_data[0] = IAC;
  153.     io_data[1] = cmd;
  154.     io_data[2] = opt;
  155.     sock_fastwrite( s, io_data, 3 );
  156.     return( !tcp_tick( s ));
  157. }
  158.  
  159.  
  160. /* Initialize a telnet connection. */
  161. /* Returns -1 on error, 0 is ok */
  162.  
  163. int tn_ini()
  164. {
  165.     sgaflg = 0;                         /* SGA flag starts out this way. */
  166.     if (send_iac( WILL, TELOPT_TTYPE )) return( -1 );
  167.     if (send_iac( DO, TELOPT_SGA )) return( -1 );
  168.  
  169. /*
  170.  *  The ECHO negotiations are not necessary for talking to full-duplex
  171.  *  systems, and they don't seem to do any good when sent to half-duplex
  172.  *  ones -- they still refuse to echo, and what's worse, they get into
  173.  *  prolonged negotiation loops.  Real telnet sends only the two above
  174.  *  at the beginning of a connection.
  175.  */
  176.  
  177.     if (send_iac(WONT,TELOPT_ECHO)) return( -1 );  /* I won't echo. */
  178.     if (send_iac(DO,TELOPT_ECHO)) return( -1 );       /* Please, you echo. */
  179.     return(0);
  180. }
  181.  
  182. /*
  183.  * Process in-band Telnet negotiation characters from the remote host.
  184.  * Call with the telnet IAC character and the current duplex setting
  185.  * (0 = remote echo, 1 = local echo).
  186.  * Returns:
  187.  *   0 on success
  188.  *  -1 on failure (= internal or i/o error)
  189.  */
  190.  
  191. #define TSBUFSIZ 41
  192. char sb[TSBUFSIZ];                      /* Buffer for subnegotiations */
  193.  
  194. int tn_doop(int c)
  195. {
  196.     int x, y, n, flag;
  197.  
  198.  
  199.     x = ttinc(0) & 0xff;                /* Read command character */
  200.  
  201.     switch (x) {
  202.       case TELOPT_ECHO:                 /* ECHO negotiation. */
  203.         if (c == WILL) {                /* Host says it will echo. */
  204.         if (echo) {                 /* Only reply if change required */
  205.         echo = 0;
  206.         if (send_iac(DO,x))      /* Please do. */
  207.             return(-1);
  208.         }
  209.         return(0);
  210.     }
  211.  
  212.         if (c == WONT) {                /* Host says it won't echo. */
  213.             if (!echo) {                /* If I'm not echoing already */
  214.         if (send_iac(DONT,x)) /* agree to echo. */
  215.             return(-1);
  216.         echo = 1;
  217.         }
  218.         return(0);
  219.     }
  220.  
  221.         if (c == DO) {                  /* Host wants me to echo */
  222.         if (send_iac(WONT,x))    /* I say I won't, */
  223.         return(-1);
  224.         if (send_iac(DO,x))        /* and ask the host to echo. */
  225.         return(-1);
  226.         echo = 0;
  227.         return( 0 );
  228.         }
  229.         if (c == DONT) {                /* Host wants me not to echo */
  230.         if (send_iac(WONT,x))    /* I say I won't. */
  231.         return(-1);
  232.         echo = 0;
  233.         return( 0 );
  234.         }
  235.         return(0);
  236.  
  237.  
  238.       case TELOPT_SGA:                  /* Suppress Go-Ahead */
  239.         if (c == WONT) {                /* Host says it won't. */
  240.             sgaflg = 1;                 /* Remember. */
  241.             if (!echo) {                /* If we're not echoing, */
  242.         if (send_iac(DONT,x)) /* acknowledge, */
  243.             return(-1);
  244.         echo = 1;        /* and switch to local echo. */
  245.         }
  246.         }
  247.         if (c == WILL) {                /* Host says it will. */
  248.             sgaflg = 0;                 /* Remember. */
  249.             if (echo) {                 /* If I'm echoing now, */
  250.         if (send_iac(DO,x))    /* this is a change, so ACK. */
  251.             return(-1);
  252.         if (send_iac(DO,TELOPT_ECHO)) /* Request remote echo */
  253.             return(-1);
  254.             }
  255.         }
  256.         return(0);
  257.  
  258.  
  259.       case TELOPT_TTYPE:                /* Terminal Type */
  260.         switch (c) {
  261.           case DO:                      /* DO terminal type. */
  262.         if (send_iac(WILL,x))    /* Say I'll send it if asked. */
  263.         return(-1);
  264.         return(0);
  265.  
  266.       /* enter subnegociations */
  267.           case SB:
  268.             n = flag = 0;               /* Flag for when done reading SB */
  269.             while (n < TSBUFSIZ) {      /* Loop looking for IAC SE */
  270.                 if ((y = ttinc(0)) < 0)
  271.           return(-1);
  272.         y &= 0xff;              /* Make sure it's just 8 bits. */
  273.         sb[n++] = y;            /* Save what we got in buffer. */
  274.  
  275.                 if (y == IAC) {         /* If this is an IAC */
  276.                     flag = 1;           /* set the flag. */
  277.                 } else {                /* Otherwise, */
  278.                     if (flag && y == SE) /* if this is SE which immediately */
  279.                       break;            /* follows IAC, we're done. */
  280.                     else flag = 0;      /* Otherwise turn off flag. */
  281.                 }
  282.         }
  283.         if (!flag)
  284.            return(-1);      /* Make sure we got a valid SB */
  285.  
  286.  
  287.         if ( *sb == 1 ) {
  288.         if ( tn_sttyp() )
  289.                   return(-1);
  290.         };
  291.  
  292.  
  293.           default:                      /* Others, ignore */
  294.             return(0);
  295.         }
  296.  
  297.       default:                          /* All others: refuse */
  298.         switch(c) {
  299.           case WILL:                    /* You will? */
  300.         if (send_iac(DONT,x))    /* Please don't. */
  301.         return(-1);
  302.             break;
  303.           case DO:                      /* You want me to? */
  304.         if (send_iac(WONT,x))    /* I won't. */
  305.         return(-1);
  306.         if (send_iac(DONT,x))    /* Don't you either. */
  307.         return(-1);
  308.             break;
  309.           case DONT:                    /* (fall thru...) */
  310.         if (send_iac(WONT,x))    /* I won't. */
  311.         return(-1);
  312.           case WONT:                    /* You won't? */
  313.             break;                      /* Good. */
  314.           }
  315.         return(0);
  316.     }
  317. }
  318.  
  319.  
  320. /*
  321.  * serial port portion
  322.  *
  323.  */
  324.  
  325.  
  326. /* Telnet send terminal type */
  327. /* Returns -1 on error, 0 on success */
  328.  
  329. int tn_sttyp()
  330. {                            /* Send telnet terminal type. */
  331.     char *ttn;
  332.     int ttl;                 /* Name & length of terminal type. */
  333.  
  334.     ttn = termtype;        /* we already got this from environment */
  335.     if ((*ttn == 0) || ((ttl = strlen(ttn)) >= TSBUFSIZ)) {
  336.         ttn = "UNKNOWN";
  337.         ttl = 7;
  338.     }
  339.     ttn = strcpy(&sb[1],ttn);        /* Copy to subnegotiation buffer */
  340.     ttn = strchr( strupr(ttn), 0 );
  341.  
  342.     *sb    = 0;                /* 'is'... */
  343.     *ttn++ = IAC;
  344.     *ttn   = SE;
  345.  
  346.     if (send_iac(SB,TELOPT_TTYPE))    /* Send: Terminal Type */
  347.     return(-1);
  348.  
  349.     sock_fastwrite( s, sb, ttl+3 );
  350.     return(0);
  351. }
  352.  
  353.  
  354. /*
  355.  * ttinc   - destructively read a character from our buffer
  356.  *       - if fast = 0, never times out
  357.  */
  358. int ttinc( int fast )
  359. {
  360.     char ch;
  361.  
  362.     /* organized to reduce number of set_timeouts when data waiting */
  363.     while ( rec_in == rec_out ) {
  364.         if ( !tcp_tick( s )) {
  365.         sock_status = 0;
  366.             s = NULL;
  367.             return( -1 );
  368.         }
  369.  
  370.         /* do processing */
  371.     kbhit();
  372.         do_transmission();
  373.         do_reception();
  374.  
  375.         if (fast) break;
  376.     }
  377.     ch = receive_buffer[ rec_out ];
  378.     if ( ++rec_out >= RECEIVE_BUF_SIZE ) rec_out = 0;
  379.     return( (word)(ch) & 0x00ff );
  380. }
  381.  
  382.  
  383.  
  384.  
  385.  
  386. void interrupt ourhandler(bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,flgs)
  387. {
  388.     stkptr = &bp;
  389.  
  390.     oldss = _SS;
  391.     oldsp = _SP;
  392.     _SS = FP_SEG(stack);
  393.     _SP = FP_OFF(&stack[ sizeof( stack ) - 2 ]);
  394.     backgroundoff();
  395.     stkptr->ax = sytek_int( stkptr->ax, stkptr->dx );
  396.     backgroundon();
  397.     _SS = oldss;
  398.     _SP = oldsp;
  399. }
  400.  
  401. stuff_char( char ch )
  402. {
  403.     transmit_buffer[ tran_in ] = ch;
  404.     tran_in = (tran_in + 1) % TRANSMIT_BUF_SIZE;
  405. }
  406.  
  407. sytek_int( ax, dx )
  408. unsigned int ax;
  409. unsigned int dx;
  410. {
  411.     unsigned char ah;
  412.     unsigned char ch;
  413.     int sent;
  414.     unsigned int status;
  415.  
  416.  
  417.     if ( !s ) {
  418.         return( 0x1000 );   /* timeout */
  419.     }
  420.  
  421.     if (chk_timeout( recvtimeout )) {
  422.         do_reception();
  423.         recvtimeout = set_ttimeout( 2 );    /* 10 ms */
  424.     }
  425.  
  426.     /* disable(); receive_clock = RECEIVE_TICKS; enable(); } */
  427.  
  428.     ah = ax >> 8;
  429.  
  430.     if( ah == 1 ) {            /* send char in AL */
  431.     ch = ax & 0x0FF;
  432. /*    if (ch == '\r') ch = '\n'; */
  433.  
  434.     if( ((tran_in + 1) % TRANSMIT_BUF_SIZE) == tran_out ) {
  435.         outs( "?tr_buf_full?" );
  436.         status = 0x08000 | ch;
  437.     } else {
  438.         if ((ch == '\r') && echo ) stuff_char( '\n' );
  439.         else stuff_char( ch );
  440.  
  441.         status = 0x06000 | ch;
  442.  
  443.         /* local echoing if requested */
  444.         if ( echo ) {
  445.         receive_buffer[ rec_in ] = ch;
  446.         rec_in = (rec_in + 1) % RECEIVE_BUF_SIZE;
  447.         if (ch == '\r') {
  448.             receive_buffer[ rec_in ] = '\n';
  449.             rec_in = (rec_in + 1) % RECEIVE_BUF_SIZE;
  450.         }
  451.         }
  452.     }
  453.     } else if( ah == 2 ) {        /* receive char into AL */
  454.         do {
  455.             ch = 0;
  456.             if( rec_in == rec_out )
  457.             status = 0x08000;
  458.             else {
  459.         status = ch = (ttinc( 0 ) & 0xff);
  460.                 if ( ch == IAC ) {
  461.                     /* process this stuff */
  462.             ch = ttinc( 0 );
  463.                     if ( ch == IAC ) ch = 0; /* let it pass through */
  464.             else tn_doop(ch);
  465.                 }
  466.             }
  467.     } while ( ch == IAC );
  468.     /* status = 0x0800; timeout */
  469.     }
  470.     else if( ah == 3 ) {        /* get status */
  471.     if( rec_in == rec_out )
  472.         status = 0x06010;
  473.     else {
  474.         status = 0x06110;
  475.     }
  476.  
  477.     } else if( ah == 0 ) {        /* init port */
  478.     status = 0x06010;
  479.     } else {
  480.     status = ax;
  481.     outs( "?command_err?" );
  482.     }
  483.  
  484.     /* here we do the io */
  485.     if( transmit_clock <= 0 ) {
  486.         do_transmission();
  487.         disable();
  488.         transmit_clock = TRANSMIT_TICKS;
  489.         enable();
  490.     }
  491.  
  492.  
  493.     return( status );
  494. }
  495.  
  496. sytek_tick()
  497. {
  498.     if( transmit_clock ) transmit_clock--;
  499.     if( receive_clock ) receive_clock--;
  500. }
  501.  
  502. void interrupt tcpport_tick()
  503. {
  504.     (*old8)();
  505.     if( transmit_clock ) transmit_clock--;
  506.     if( receive_clock ) receive_clock--;
  507. }
  508.  
  509. do_reception()
  510. {
  511.     int status;
  512.     unsigned int maxtransfer, newtransfer;
  513.     unsigned int chars_avail, i;
  514.  
  515.  
  516.     sock_tick( s, &status );
  517.  
  518. #ifdef OLD
  519.     if ( sock_dataready( s )) {
  520.     if (rec_out > rec_in ) {
  521.         /* we can fill intermediate portion of buffer */
  522.         maxtransfer = rec_out - rec_in;
  523.     } else {
  524.         /* we fill end of buffer and leave start for next attempt */
  525.         maxtransfer = RECEIVE_BUF_SIZE - rec_in;
  526.     }
  527.     if (maxtransfer) {
  528.         rec_in += sock_fastread( s, &receive_buffer[ rec_in ], maxtransfer );
  529.         if ( rec_in >= RECEIVE_BUF_SIZE )
  530.         rec_in -= RECEIVE_BUF_SIZE;
  531.     }
  532.     }
  533. #else
  534.     maxtransfer = RECEIVE_BUF_SIZE - rec_in;
  535.     if (rec_out > rec_in) maxtransfer = rec_out - rec_in;
  536.     maxtransfer = sock_recv( s, &receive_buffer[ rec_in ], maxtransfer );
  537.     if (maxtransfer)
  538.     rec_in = (rec_in + maxtransfer) % RECEIVE_BUF_SIZE ;
  539. #endif OLD
  540.     return( 0 );
  541.  
  542. sock_err:
  543.     switch (status) {
  544.     case 1 : outs("\n\r\7[??Host closed connection??]\n\r");
  545.          break;
  546.     case-1 : outs("\n\r\7[??Host reset connection??]\n\r");
  547.          break;
  548.     }
  549.     s = NULL;
  550.     sock_status = 0;
  551. }
  552.  
  553. do_transmission()
  554. {
  555.     unsigned int send_chars;
  556.     int status;
  557.  
  558.     if( tran_in == tran_out ) return(0);
  559.  
  560.     if( tran_in > tran_out )
  561.     send_chars = tran_in - tran_out;
  562.     else
  563.     send_chars = TRANSMIT_BUF_SIZE - tran_out;
  564.  
  565.     if( send_chars > TRANSMIT_MAX ) send_chars = TRANSMIT_MAX;
  566.  
  567.     sock_flushnext( s );
  568.     send_chars = sock_fastwrite( s, &transmit_buffer[ tran_out], send_chars );
  569.  
  570.     /* this only changes it by the number of bytes we have emptied out */
  571.     tran_out = (tran_out + send_chars) % TRANSMIT_BUF_SIZE;
  572.  
  573.     return(0);
  574. }
  575.  
  576.  
  577. main( argc, argv )
  578. int argc;
  579. char *argv[];
  580. {
  581.     int i;
  582.     int status = 0;
  583.     char *temp;
  584.  
  585.     if (argc < 4 ) {
  586.     outs("SERTN host port program options\n\r");
  587.     exit(1);
  588.     }
  589.  
  590.     dbuginit();
  591.     sock_init();
  592.  
  593.     if (!( host = resolve( argv[1] ))) {
  594.     outs( "Bad Host\n\r" );
  595.     exit(1);
  596.     }
  597.  
  598.     if ( temp = getenv( TCPTERM )) {
  599.     /* deal with strncpy limitation */
  600.     movmem( temp, termtype, sizeof( termtype ));
  601.     termtype[ sizeof(termtype) -1 ] = 0;
  602.     outs("TERMINAL EMULATION :");
  603.     outs( termtype );
  604.     outs("\n\r");
  605.     } else
  606.     strcpy(termtype, "UNKNOWN");
  607.  
  608.  
  609.     s = &socketdata;
  610.     if ( host == my_ip_addr ) {
  611.     outs("Incomming sessions not supported...\n\r");
  612.     sock_wait_established( s, 0, NULL, &status );
  613.     exit( -3 );
  614.     }
  615.  
  616.     if (! tcp_open( s, 0, host, atoi( argv[2]), NULL )) {
  617. #ifndef OLD
  618.     sock_recv_init( s, bigbuf, sizeof( bigbuf ), 0);
  619. #endif OLD
  620.     outs( "Unable to open\n\r");
  621.     exit(1);
  622.     }
  623.  
  624.     sock_wait_established( s, sock_delay, NULL, &status );
  625.  
  626.     sock_mode( s, TCP_MODE_NAGLE );
  627.  
  628.     sock_status = 1;        /* allow interrupts */
  629.  
  630.     /* move vectors */
  631.     moved_vectors = 1;
  632.     old8 =  getvect( 0x08 );
  633.     old14 =  getvect( 0x014 );
  634. /*
  635.     setvect( 0x08, (void interrupt (*)())serial_t );
  636. */
  637.     setvect( 0x08, tcpport_tick );
  638.     setvect( 0x014,ourhandler);  /* was serial_2 */
  639.     recvtimeout = set_ttimeout( 1 );
  640.  
  641.     outs("Running...");
  642.     outs( argv[3] );
  643.     outs( "\n\r");
  644.     system( argv[ argc-1 ] );
  645.  
  646.     outs("Done, now closing session\n\r");
  647.  
  648.     setvect( 0x014, old14 );
  649.     setvect( 0x08, old8 );
  650.     moved_vectors = 0;
  651.  
  652.     if ( s ) {
  653.     sock_close( s );
  654.     sock_wait_closed( s, sock_delay, NULL, &status );
  655.     }
  656.  
  657. sock_err:
  658.     switch (status) {
  659.     case 1 : outs("Done.\n\r");
  660.          break;
  661.     case -1: outs("Remote host reset connection.");
  662.          break;
  663.     }
  664.     if (moved_vectors) {
  665.     setvect( 0x014, old14 );
  666.     setvect( 0x08, old8 );
  667.     }
  668.  
  669.     exit( (status)? 2 : 0);
  670. }
  671.