[BACK]Return to sys_bsd.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / telnet

Diff for /src/usr.bin/telnet/sys_bsd.c between version 1.5 and 1.6

version 1.5, 1998/03/12 04:57:40 version 1.6, 1998/12/28 11:13:51
Line 88 
Line 88 
 # endif  # endif
 #endif  /* USE_TERMIO */  #endif  /* USE_TERMIO */
   
 static fd_set ibits, obits, xbits;  fd_set *ibitsp, *obitsp, *xbitsp;
   int fdsn;
   
   
     void      void
 init_sys()  init_sys()
 {  {
     tout = fileno(stdout);      tout = fileno(stdout);
     tin = fileno(stdin);      tin = fileno(stdin);
     FD_ZERO(&ibits);  
     FD_ZERO(&obits);  
     FD_ZERO(&xbits);  
   
     errno = 0;      errno = 0;
 }  }
Line 969 
Line 966 
                  */                   */
     int returnValue = 0;      int returnValue = 0;
     static struct timeval TimeValue = { 0 };      static struct timeval TimeValue = { 0 };
       int maxfd = -1;
       int tmp;
   
     if (netout) {      if ((netout || netin || netex) && net > maxfd)
         FD_SET(net, &obits);          maxfd = net;
       if (ttyout && tout > maxfd)
           maxfd = tout;
       if (ttyin && tin > maxfd)
           maxfd = tin;
       tmp = howmany(maxfd+1, NFDBITS) * sizeof(fd_mask);
       if (tmp > fdsn) {
           if (ibitsp)
               free(ibitsp);
           if (obitsp)
               free(obitsp);
           if (xbitsp)
               free(xbitsp);
           fdsn = tmp;
           if ((ibitsp = (fd_set *)malloc(fdsn)) == NULL)
               err(1, "malloc");
           if ((obitsp = (fd_set *)malloc(fdsn)) == NULL)
               err(1, "malloc");
           if ((xbitsp = (fd_set *)malloc(fdsn)) == NULL)
               err(1, "malloc");
           memset(ibitsp, 0, fdsn);
           memset(obitsp, 0, fdsn);
           memset(xbitsp, 0, fdsn);
     }      }
     if (ttyout) {  
         FD_SET(tout, &obits);      if (netout)
     }          FD_SET(net, obitsp);
 #if     defined(TN3270)      if (ttyout)
     if (ttyin) {          FD_SET(tout, obitsp);
         FD_SET(tin, &ibits);      if (ttyin)
     }          FD_SET(tin, ibitsp);
 #else   /* defined(TN3270) */      if (netin)
     if (ttyin) {          FD_SET(net, ibitsp);
         FD_SET(tin, &ibits);      if (netex)
     }          FD_SET(net, xbitsp);
 #endif  /* defined(TN3270) */  
 #if     defined(TN3270)      if ((c = select(maxfd+1, ibitsp, obitsp, xbitsp,
     if (netin) {        (poll == 0)? (struct timeval *)0 : &TimeValue)) < 0) {
         FD_SET(net, &ibits);  
     }  
 #   else /* !defined(TN3270) */  
     if (netin) {  
         FD_SET(net, &ibits);  
     }  
 #   endif /* !defined(TN3270) */  
     if (netex) {  
         FD_SET(net, &xbits);  
     }  
     if ((c = select(16, &ibits, &obits, &xbits,  
                         (poll == 0)? (struct timeval *)0 : &TimeValue)) < 0) {  
         if (c == -1) {          if (c == -1) {
                     /*                      /*
                      * we can get EINTR if we are in line mode,                       * we can get EINTR if we are in line mode,
Line 1019 
Line 1028 
                          * to make sure we are selecting on the right                           * to make sure we are selecting on the right
                          * ones.                           * ones.
                         */                          */
                 FD_ZERO(&ibits);                  memset(ibitsp, 0, fdsn);
                 FD_ZERO(&obits);                  memset(obitsp, 0, fdsn);
                 FD_ZERO(&xbits);                  memset(xbitsp, 0, fdsn);
                 return 0;                  return 0;
             }              }
 #           endif /* defined(TN3270) */  #           endif /* defined(TN3270) */
Line 1035 
Line 1044 
     /*      /*
      * Any urgent data?       * Any urgent data?
      */       */
     if (FD_ISSET(net, &xbits)) {      if (FD_ISSET(net, xbitsp)) {
         FD_CLR(net, &xbits);          FD_CLR(net, xbitsp);
         SYNCHing = 1;          SYNCHing = 1;
         (void) ttyflush(1);     /* flush already enqueued data */          (void) ttyflush(1);     /* flush already enqueued data */
     }      }
Line 1044 
Line 1053 
     /*      /*
      * Something to read from the network...       * Something to read from the network...
      */       */
     if (FD_ISSET(net, &ibits)) {      if (FD_ISSET(net, ibitsp)) {
         int canread;          int canread;
   
         FD_CLR(net, &ibits);          FD_CLR(net, ibitsp);
         canread = ring_empty_consecutive(&netiring);          canread = ring_empty_consecutive(&netiring);
 #if     !defined(SO_OOBINLINE)  #if     !defined(SO_OOBINLINE)
             /*              /*
Line 1157 
Line 1166 
     /*      /*
      * Something to read from the tty...       * Something to read from the tty...
      */       */
     if (FD_ISSET(tin, &ibits)) {      if (FD_ISSET(tin, ibitsp)) {
         FD_CLR(tin, &ibits);          FD_CLR(tin, ibitsp);
         c = TerminalRead(ttyiring.supply, ring_empty_consecutive(&ttyiring));          c = TerminalRead(ttyiring.supply, ring_empty_consecutive(&ttyiring));
         if (c < 0 && errno == EIO)          if (c < 0 && errno == EIO)
             c = 0;              c = 0;
Line 1182 
Line 1191 
         returnValue = 1;                /* did something useful */          returnValue = 1;                /* did something useful */
     }      }
   
     if (FD_ISSET(net, &obits)) {      if (FD_ISSET(net, obitsp)) {
         FD_CLR(net, &obits);          FD_CLR(net, obitsp);
         returnValue |= netflush();          returnValue |= netflush();
     }      }
     if (FD_ISSET(tout, &obits)) {      if (FD_ISSET(tout, obitsp)) {
         FD_CLR(tout, &obits);          FD_CLR(tout, obitsp);
         returnValue |= (ttyflush(SYNCHing|flushout) > 0);          returnValue |= (ttyflush(SYNCHing|flushout) > 0);
     }      }
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6