use getpwuid in addition to getlogin to get user name, and some cleanup
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 21 May 1988 03:11:01 +0000 (19:11 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 21 May 1988 03:11:01 +0000 (19:11 -0800)
SCCS-vsn: usr.bin/talk/get_names.c 5.3
SCCS-vsn: usr.bin/talk/msgs.c 5.2
SCCS-vsn: usr.bin/talk/talk.c 5.2
SCCS-vsn: usr.bin/talk/talk.h 5.2

usr/src/usr.bin/talk/get_names.c
usr/src/usr.bin/talk/msgs.c
usr/src/usr.bin/talk/talk.c
usr/src/usr.bin/talk/talk.h

index 2b20c95..0f3e70f 100644 (file)
@@ -5,17 +5,17 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)get_names.c        5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)get_names.c        5.3 (Berkeley) %G%";
 #endif not lint
 
 #include "talk.h"
 #include <sys/param.h>
 #include <protocols/talkd.h>
 #endif not lint
 
 #include "talk.h"
 #include <sys/param.h>
 #include <protocols/talkd.h>
+#include <pwd.h>
 
 char   *getlogin();
 char   *ttyname();
 char   *rindex();
 
 char   *getlogin();
 char   *ttyname();
 char   *rindex();
-static any();
 extern CTL_MSG msg;
 
 /*
 extern CTL_MSG msg;
 
 /*
@@ -39,14 +39,17 @@ get_names(argc, argv)
                printf("Standard input must be a tty, not a pipe or a file\n");
                exit(-1);
        }
                printf("Standard input must be a tty, not a pipe or a file\n");
                exit(-1);
        }
-       my_name = getlogin();
-       if (my_name == NULL) {
-               printf("You don't exist. Go away.\n");
-               exit(-1);
+       if ((my_name = getlogin()) == NULL) {
+               struct passwd *pw;
+
+               if ((pw = getpwuid(getuid())) == NULL) {
+                       printf("You don't exist. Go away.\n");
+                       exit(-1);
+               }
+               my_name = pw->pw_name;
        }
        gethostname(hostname, sizeof (hostname));
        my_machine_name = hostname;
        }
        gethostname(hostname, sizeof (hostname));
        my_machine_name = hostname;
-       my_tty = rindex(ttyname(0), '/') + 1;
        /* check for, and strip out, the machine name of the target */
        for (cp = argv[1]; *cp && !any(*cp, "@:!."); cp++)
                ;
        /* check for, and strip out, the machine name of the target */
        for (cp = argv[1]; *cp && !any(*cp, "@:!."); cp++)
                ;
index 1fc2be1..ab4d548 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)msgs.c     5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)msgs.c     5.2 (Berkeley) %G%";
 #endif not lint
 
 /* 
 #endif not lint
 
 /* 
@@ -19,15 +19,10 @@ static char sccsid[] = "@(#)msgs.c  5.1 (Berkeley) %G%";
 #include "talk.h"
 
 #define MSG_INTERVAL 4
 #include "talk.h"
 
 #define MSG_INTERVAL 4
-#define LONG_TIME 100000
 
 char   *current_state;
 int    current_line = 0;
 
 
 char   *current_state;
 int    current_line = 0;
 
-static struct itimerval itimer;
-static struct timeval wait = { MSG_INTERVAL , 0};
-static struct timeval undo = { LONG_TIME, 0};
-       
 disp_msg()
 {
 
 disp_msg()
 {
 
@@ -36,18 +31,21 @@ disp_msg()
 
 start_msgs()
 {
 
 start_msgs()
 {
+       struct itimerval itimer;
 
        message(current_state);
        signal(SIGALRM, disp_msg);
 
        message(current_state);
        signal(SIGALRM, disp_msg);
-       itimer.it_value = itimer.it_interval = wait;
+       itimer.it_value.tv_sec = itimer.it_interval.tv_sec = MSG_INTERVAL;
+       itimer.it_value.tv_usec = itimer.it_interval.tv_usec = 0;
        setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
 }
 
 end_msgs()
 {
        setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
 }
 
 end_msgs()
 {
+       struct itimerval itimer;
 
 
-       signal(SIGALRM, SIG_IGN);
        timerclear(&itimer.it_value);
        timerclear(&itimer.it_interval);
        setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
        timerclear(&itimer.it_value);
        timerclear(&itimer.it_interval);
        setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
+       signal(SIGALRM, SIG_DFL);
 }
 }
index f786153..70fe186 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)talk.c     5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)talk.c     5.2 (Berkeley) %G%";
 #endif not lint
 
 #include "talk.h"
 #endif not lint
 
 #include "talk.h"
@@ -34,13 +34,12 @@ main(argc, argv)
        int argc;
        char *argv[];
 {
        int argc;
        char *argv[];
 {
-
        get_names(argc, argv);
        init_display();
        open_ctl();
        open_sockt();
        start_msgs();
        get_names(argc, argv);
        init_display();
        open_ctl();
        open_sockt();
        start_msgs();
-       if (!check_local() )
+       if (!check_local())
                invite_remote();
        end_msgs();
        set_edit_chars();
                invite_remote();
        end_msgs();
        set_edit_chars();
index bc8d219..96f6b7b 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)talk.h      5.1 (Berkeley) %G%
+ *     @(#)talk.h      5.2 (Berkeley) %G%
  */
 
 #include <curses.h>
  */
 
 #include <curses.h>
 
 #define forever                for(;;)
 
 
 #define forever                for(;;)
 
-#define BUF_SIZE       512
-
-FILE   *popen();
 int    quit();
 int    quit();
-int    sleeper();
 
 extern int sockt;
 extern int curses_initialized;
 
 extern int sockt;
 extern int curses_initialized;