home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / os9 / os9srv.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  3KB  |  79 lines

  1. /*
  2.  * os9srv.c server functions for os9 kermit
  3.  */
  4.  
  5. #include "os9inc.h"
  6.  
  7. /*
  8.  *      Kermit Host Server Function
  9.  *
  10.  *    11/03/86 ral fix no space alloacated for filnam bug.
  11.  *
  12.  *     File: kermserv.c
  13.  *     04/08/85
  14.  *        3/22  restructure and Directory option
  15.  *        4/08  add test case for rpack return of False
  16.  *        3/12  add I type
  17.  */
  18. servsw()
  19. {
  20.         int     len, num;
  21.         char    rstate;
  22.     char    filnam1[94];
  23.  
  24.         server = TRUE;
  25.         state = 'W';    /* wait initial command from remote */
  26.         n = 0;          /* Initialize packet counter     */
  27.         numtry = 0;     /* Reset retry count      */
  28.  
  29.         for (;;) {
  30.                 if (debug)
  31.                         printf("Server State: %c\n",state);
  32.                 rstate = rpack(&len, &num, packet);
  33.                 if (debug)
  34.                         printf("Server Received State: %c\n", rstate);
  35.  
  36.                 switch (rstate) {
  37.                 case FALSE:  
  38.                         break;          /* Bad packet received.   */
  39.                 case 'I':
  40.                         rpar(packet);   /*  Get parameters  */
  41.                         spar(packet);   /*  Return Parameters  */
  42.                         spack('Y', n, 6, packet);
  43.                         numtry = 0;
  44.                         break;
  45.  
  46.                 case 'S':               /*  Receive File   */
  47.                         state = recsw(); 
  48.                         break;
  49.                 case 'R':               /*  Send File       */
  50.                         if(debug)
  51.                                 printf("filename len of %d, name %s\n",
  52.                                         len, packet);
  53.  
  54.             filnam = filnam1;    /* get somewhere to put name! */
  55.                         strcpy(filnam, packet); /* Get file to send    */
  56.                         oldtry = numtry;        /* Reset counters    */
  57.                         fp = NULL;
  58.                         filecount = 0;          /* One file at a time    */
  59.                         rstate = sendsw();      /* Go send file        */
  60.                         break;                  /* Done with the pass    */
  61.  
  62.                 case 'G':                      /* Generic Command Processor */
  63.                         state = packet[0];      /* Get generic Command    */
  64.  
  65.                         if (debug)
  66.                                 printf("Generic state request %c\n", state);
  67.  
  68.                         switch(state) {
  69.                         case 'F':               /* Finish        */
  70.                         case 'L':               /* Logout (default Finish) */
  71.                                 /* Tell master I quit    */
  72.                                 spack('Y', n, 0, packet);
  73.                                 return(TRUE);
  74.                         }
  75.                 }
  76.                 state = 'W';
  77.         }
  78. }
  79.