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

Diff for /src/usr.bin/talk/io.c between version 1.4 and 1.5

version 1.4, 1998/04/27 15:45:50 version 1.5, 1998/04/28 22:13:28
Line 47 
Line 47 
  * ctl.c   * ctl.c
  */   */
   
   #include "talk.h"
 #include <sys/ioctl.h>  #include <sys/ioctl.h>
 #include <sys/time.h>  #include <sys/time.h>
 #include <stdio.h>  #include <stdio.h>
 #include <errno.h>  #include <errno.h>
 #include <string.h>  #include <unistd.h>
 #include "talk.h"  
   
 #define A_LONG_TIME 10000000  #define A_LONG_TIME 10000000
 #define STDIN_MASK (1<<fileno(stdin))   /* the bit mask for standard  
                                            input */  
   
 /*  /*
  * The routine to do the actual talking   * The routine to do the actual talking
  */   */
   void
 talk()  talk()
 {  {
         register int read_template, sockt_mask;          fd_set read_template, read_set;
         int read_set, nb;          int nb;
         char buf[BUFSIZ];          char buf[BUFSIZ];
         struct timeval wait;          struct timeval wait;
   
Line 81 
Line 80 
         message("Connection established\007\007\007");          message("Connection established\007\007\007");
 #endif  #endif
         current_line = 0;          current_line = 0;
         sockt_mask = (1<<sockt);  
   
         /*          /*
          * Wait on both the other process (sockt_mask) and           * Wait on both the other process (sockt_mask) and
          * standard input ( STDIN_MASK )           * standard input ( STDIN_MASK )
          */           */
         read_template = sockt_mask | STDIN_MASK;          FD_ZERO(&read_template);
           FD_SET(sockt, &read_template);
           FD_SET(fileno(stdin), &read_template);
         for (;;) {          for (;;) {
                 read_set = read_template;                  read_set = read_template;
                 wait.tv_sec = A_LONG_TIME;                  wait.tv_sec = A_LONG_TIME;
Line 102 
Line 102 
                         p_error("Unexpected error from select");                          p_error("Unexpected error from select");
                         quit();                          quit();
                 }                  }
                 if (read_set & sockt_mask) {                  if (FD_ISSET(sockt, &read_set)) {
                         /* There is data on sockt */                          /* There is data on sockt */
                         nb = read(sockt, buf, sizeof buf);                          nb = read(sockt, buf, sizeof buf);
                         if (nb <= 0) {                          if (nb <= 0) {
Line 111 
Line 111 
                         }                          }
                         display(&his_win, buf, nb);                          display(&his_win, buf, nb);
                 }                  }
                 if (read_set & STDIN_MASK) {                  if (FD_ISSET(fileno(stdin), &read_set)) {
                         /*                          /*
                          * We can't make the tty non_blocking, because                           * We can't make the tty non_blocking, because
                          * curses's output routines would screw up                           * curses's output routines would screw up
Line 125 
Line 125 
         }          }
 }  }
   
 extern  int errno;  
 extern  int sys_nerr;  
   
 /*  /*
  * p_error prints the system error message on the standard location   * p_error prints the system error message on the standard location
  * on the screen and then exits. (i.e. a curses version of perror)   * on the screen and then exits. (i.e. a curses version of perror)
  */   */
   void
 p_error(string)  p_error(string)
         char *string;          char *string;
 {  {
Line 147 
Line 145 
 /*  /*
  * Display string in the standard location   * Display string in the standard location
  */   */
   void
 message(string)  message(string)
         char *string;          char *string;
 {  {

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