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

Diff for /src/usr.bin/write/write.c between version 1.18 and 1.19

version 1.18, 2002/12/09 08:15:29 version 1.19, 2003/03/13 15:47:12
Line 68 
Line 68 
 void done(int sig);  void done(int sig);
 void do_write(char *, char *, uid_t);  void do_write(char *, char *, uid_t);
 void wr_fputs(char *);  void wr_fputs(char *);
 void search_utmp(char *, char *, char *, uid_t);  void search_utmp(char *, char *, int, char *, uid_t);
 int term_chk(char *, int *, time_t *, int);  int term_chk(char *, int *, time_t *, int);
 int utmp_chk(char *, char *);  int utmp_chk(char *, char *);
   
Line 103 
Line 103 
         /* check args */          /* check args */
         switch (argc) {          switch (argc) {
         case 2:          case 2:
                 search_utmp(argv[1], tty, mytty, myuid);                  search_utmp(argv[1], tty, sizeof tty, mytty, myuid);
                 do_write(tty, mytty, myuid);                  do_write(tty, mytty, myuid);
                 break;                  break;
         case 3:          case 3:
Line 165 
Line 165 
  * writing from, unless that's the only terminal with messages enabled.   * writing from, unless that's the only terminal with messages enabled.
  */   */
 void  void
 search_utmp(char *user, char *tty, char *mytty, uid_t myuid)  search_utmp(char *user, char *tty, int ttyl, char *mytty, uid_t myuid)
 {  {
         struct utmp u;          struct utmp u;
         time_t bestatime, atime;          time_t bestatime, atime;
Line 194 
Line 194 
                         ++nttys;                          ++nttys;
                         if (atime > bestatime) {                          if (atime > bestatime) {
                                 bestatime = atime;                                  bestatime = atime;
                                 (void)strcpy(tty, atty);                                  (void)strlcpy(tty, atty, ttyl);
                         }                          }
                 }                  }
   
Line 203 
Line 203 
                 errx(1, "%s is not logged in", user);                  errx(1, "%s is not logged in", user);
         if (nttys == 0) {          if (nttys == 0) {
                 if (user_is_me) {               /* ok, so write to yourself! */                  if (user_is_me) {               /* ok, so write to yourself! */
                         (void)strcpy(tty, mytty);                          (void)strlcpy(tty, mytty, ttyl);
                         return;                          return;
                 }                  }
                 errx(1, "%s has messages disabled", user);                  errx(1, "%s has messages disabled", user);
Line 265 
Line 265 
   
         /* print greeting */          /* print greeting */
         if (gethostname(host, sizeof(host)) < 0)          if (gethostname(host, sizeof(host)) < 0)
                 (void)strcpy(host, "???");                  (void)strlcpy(host, "???", sizeof host);
         now = time((time_t *)NULL);          now = time((time_t *)NULL);
         nows = ctime(&now);          nows = ctime(&now);
         nows[16] = '\0';          nows[16] = '\0';

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19