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

Diff for /src/usr.bin/talk/invite.c between version 1.3 and 1.4

version 1.3, 1996/06/26 05:40:23 version 1.4, 1998/04/27 15:45:49
Line 46 
Line 46 
 #include <sys/time.h>  #include <sys/time.h>
 #include <signal.h>  #include <signal.h>
 #include <netinet/in.h>  #include <netinet/in.h>
   #include <netdb.h>
 #include <protocols/talkd.h>  #include <protocols/talkd.h>
 #include <errno.h>  #include <errno.h>
 #include <setjmp.h>  #include <setjmp.h>
 #include "talk_ctl.h"  #include "talk_ctl.h"
 #include "talk.h"  #include "talk.h"
   
   #define STRING_LENGTH 158
   
 /*  /*
  * There wasn't an invitation waiting, so send a request containing   * There wasn't an invitation waiting, so send a request containing
  * our sockt address to the remote talk daemon so it can invite   * our sockt address to the remote talk daemon so it can invite
Line 73 
Line 76 
         int nfd, read_mask, template, new_sockt;          int nfd, read_mask, template, new_sockt;
         struct itimerval itimer;          struct itimerval itimer;
         CTL_RESPONSE response;          CTL_RESPONSE response;
           struct sockaddr rp;
           int rplen = sizeof(struct sockaddr);
           struct hostent *rphost;
           char rname[STRING_LENGTH];
   
         itimer.it_value.tv_sec = RING_WAIT;          itimer.it_value.tv_sec = RING_WAIT;
         itimer.it_value.tv_usec = 0;          itimer.it_value.tv_usec = 0;
Line 91 
Line 98 
         announce_invite();          announce_invite();
         /*          /*
          * Shut off the automatic messages for a while,           * Shut off the automatic messages for a while,
          * so we can use the interupt timer to resend the invitation           * so we can use the interrupt timer to resend the invitation.
            * We no longer turn automatic messages back on to avoid a bonus
            * message after we've connected; this is okay even though end_msgs()
            * gets called again in main().
          */           */
         end_msgs();          end_msgs();
         setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);          setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
         message("Waiting for your party to respond");          message("Waiting for your party to respond");
         signal(SIGALRM, re_invite);          signal(SIGALRM, re_invite);
         (void) setjmp(invitebuf);          (void) setjmp(invitebuf);
         while ((new_sockt = accept(sockt, 0, 0)) < 0) {          while ((new_sockt = accept(sockt, &rp, &rplen)) < 0) {
                 if (errno == EINTR)                  if (errno == EINTR)
                         continue;                          continue;
                 p_error("Unable to connect with your party");                  p_error("Unable to connect with your party");
Line 110 
Line 120 
          * Have the daemons delete the invitations now that we           * Have the daemons delete the invitations now that we
          * have connected.           * have connected.
          */           */
         current_state = "Waiting for your party to respond";  
         start_msgs();  
   
         msg.id_num = htonl(local_id);          msg.id_num = htonl(local_id);
         ctl_transact(my_machine_addr, msg, DELETE, &response);          ctl_transact(my_machine_addr, msg, DELETE, &response);
         msg.id_num = htonl(remote_id);          msg.id_num = htonl(remote_id);
         ctl_transact(his_machine_addr, msg, DELETE, &response);          ctl_transact(his_machine_addr, msg, DELETE, &response);
         invitation_waiting = 0;          invitation_waiting = 0;
   
           /*
            * Check to see if the other guy is coming from the machine
            * we expect.
            */
           if (his_machine_addr.s_addr !=
               ((struct sockaddr_in *)&rp)->sin_addr.s_addr) {
                   rphost = gethostbyaddr((char *) &((struct sockaddr_in
                       *)&rp)->sin_addr, sizeof(struct in_addr), AF_INET);
                   if (rphost)
                           snprintf(rname, STRING_LENGTH,
                               "Answering talk request from %s@%s", msg.r_name,
                               rphost->h_name);
                   else
                           snprintf(rname, STRING_LENGTH,
                               "Answering talk request from %s@%s", msg.r_name,
                               inet_ntoa(((struct sockaddr_in *)&rp)->sin_addr));
                   message(rname);
           }
 }  }
   
 /*  /*

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