reformatting; convert daemon for inetd; add keywords
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 12 Apr 1984 06:15:23 +0000 (22:15 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 12 Apr 1984 06:15:23 +0000 (22:15 -0800)
SCCS-vsn: libexec/talkd/announce.c 1.2
SCCS-vsn: usr.bin/talk/ctl.c 1.2
SCCS-vsn: include/protocols/talkd.h 1.2
SCCS-vsn: usr.bin/talk/ctl_transact.c 1.2
SCCS-vsn: usr.bin/talk/display.c 1.2
SCCS-vsn: usr.bin/talk/get_addrs.c 1.2
SCCS-vsn: usr.bin/talk/get_names.c 1.2
SCCS-vsn: usr.bin/talk/init_disp.c 1.2
SCCS-vsn: usr.bin/talk/invite.c 1.2
SCCS-vsn: usr.bin/talk/io.c 1.2
SCCS-vsn: usr.bin/talk/look_up.c 1.2
SCCS-vsn: usr.bin/talk/msgs.c 1.2
SCCS-vsn: libexec/talkd/print.c 1.2
SCCS-vsn: libexec/talkd/process.c 1.2
SCCS-vsn: libexec/talkd/table.c 1.2
SCCS-vsn: usr.bin/talk/talk.c 1.2
SCCS-vsn: usr.bin/talk/talk.h 1.2
SCCS-vsn: usr.bin/talk/talk_ctl.h 1.2
SCCS-vsn: libexec/talkd/talkd.c 1.2
SCCS-vsn: libexec/talkd/Makefile 1.2
SCCS-vsn: usr.bin/talk/Makefile 1.2

19 files changed:
usr/src/include/protocols/talkd.h
usr/src/libexec/talkd/announce.c
usr/src/libexec/talkd/print.c
usr/src/libexec/talkd/process.c
usr/src/libexec/talkd/table.c
usr/src/libexec/talkd/talkd.c
usr/src/usr.bin/talk/ctl.c
usr/src/usr.bin/talk/ctl_transact.c
usr/src/usr.bin/talk/display.c
usr/src/usr.bin/talk/get_addrs.c
usr/src/usr.bin/talk/get_names.c
usr/src/usr.bin/talk/init_disp.c
usr/src/usr.bin/talk/invite.c
usr/src/usr.bin/talk/io.c
usr/src/usr.bin/talk/look_up.c
usr/src/usr.bin/talk/msgs.c
usr/src/usr.bin/talk/talk.c
usr/src/usr.bin/talk/talk.h
usr/src/usr.bin/talk/talk_ctl.h

index d21befd..8863b2e 100644 (file)
@@ -1,7 +1,8 @@
-/* $Header: ctl.h 1.4 83/03/28 20:46:27 moore Exp $ */
+/*     @(#)talkd.h     1.2 %G% */
 
 
-/* ctl.h describes the structure that talk and talkd pass back
-   and forth
+/*
+ * ctl.h describes the structure that
+ * talk and talkd pass back and forth.
  */
 
 #include <sys/types.h>
  */
 
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <netdb.h>
 
 #include <netinet/in.h>
 #include <netdb.h>
 
-#define NAME_SIZE 9
-#define TTY_SIZE 16
-#define HOST_NAME_LENGTH 256
-
-#define MAX_LIFE 60 /* maximum time an invitation is saved by the
-                        talk daemons */
-#define RING_WAIT 30  /* time to wait before refreshing invitation 
-                        should be 10's of seconds less than MAX_LIFE */
-
-    /* the values for type */
-
-#define LEAVE_INVITE 0
-#define LOOK_UP 1
-#define DELETE 2
-#define ANNOUNCE 3
-
-    /* the values for answer */
-
-#define SUCCESS 0
-#define NOT_HERE 1
-#define FAILED 2
-#define MACHINE_UNKNOWN 3
+#define        NAME_SIZE       9
+#define        TTY_SIZE        16
+#define        HOST_NAME_LENGTH 256
+
+#define MAX_LIFE       60      /* max time daemon saves invitations */
+/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
+#define RING_WAIT      30      /* time to wait before refreshing invitation */
+
+/* type values */
+#define LEAVE_INVITE   0
+#define LOOK_UP                1
+#define DELETE         2
+#define ANNOUNCE       3
+
+/* answer values */
+#define SUCCESS                0
+#define NOT_HERE       1
+#define FAILED         2
+#define MACHINE_UNKNOWN        3
 #define PERMISSION_DENIED 4
 #define PERMISSION_DENIED 4
-#define UNKNOWN_REQUEST 5
-
-typedef struct ctl_response CTL_RESPONSE;
-
-struct ctl_response {
-    char type;
-    char answer;
-    int id_num;
-    struct sockaddr_in addr;
-};
-
-typedef struct ctl_msg CTL_MSG;
-
-struct ctl_msg {
-    char type;
-    char l_name[NAME_SIZE];
-    char r_name[NAME_SIZE];
-    int id_num;
-    int pid;
-    char r_tty[TTY_SIZE];
-    struct sockaddr_in addr;
-    struct sockaddr_in ctl_addr;
-};
+#define UNKNOWN_REQUEST        5
+
+typedef struct ctl_response {
+       char    type;
+       char    answer;
+       int     id_num;
+       struct  sockaddr_in addr;
+} CTL_RESPONSE;
+
+typedef struct ctl_msg {
+       char    type;
+       char    l_name[NAME_SIZE];
+       char    r_name[NAME_SIZE];
+       int     id_num;
+       int     pid;
+       char    r_tty[TTY_SIZE];
+       struct  sockaddr_in addr;
+       struct  sockaddr_in ctl_addr;
+} CTL_MSG;
index 74baa18..9a71e56 100644 (file)
@@ -1,4 +1,6 @@
-/* $Header: /a/guest/moore/talk/RCS/announce.c,v 1.8 83/07/06 00:16:57 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)announce.c 1.2 (Berkeley) %G%";
+#endif
 
 #include "ctl.h"
 
 
 #include "ctl.h"
 
@@ -23,186 +25,138 @@ int nofork = 0;           /* to be set from the debugger */
  */
 
 announce(request, remote_machine)
  */
 
 announce(request, remote_machine)
-CTL_MSG *request;
-char *remote_machine;
+       CTL_MSG *request;
+       char *remote_machine;
 {
 {
-    int pid, val, status;
-
-    if (nofork) {
-       return(announce_proc(request, remote_machine));
-    }
-
-    if ( pid = fork() ) {
-
-           /* we are the parent, so wait for the child */
-
-       if (pid == -1) {
-               /* the fork failed */
-           return(FAILED);
-       }
-
-       do {
-           val = wait(&status);
-           if (val == -1) {
-               if (errno == EINTR) {
-                   continue;
-               } else {
-                       /* shouldn't happen */
-                   print_error("wait");
-                   return(FAILED);
-               }
-           }
-       } while (val != pid);
-
-       if (status&0377 > 0) {
-               /* we were killed by some signal */
-           return(FAILED);
+       int pid, val, status;
+
+       if (nofork)
+               return(announce_proc(request, remote_machine));
+       if (pid = fork()) {
+               /* we are the parent, so wait for the child */
+               if (pid == -1)          /* the fork failed */
+                       return(FAILED);
+               do {
+                       val = wait(&status);
+                       if (val == -1) {
+                               if (errno == EINTR)
+                                       continue;
+                               /* shouldn't happen */
+                               perror("wait");
+                               return (FAILED);
+                       }
+               } while (val != pid);
+               if (status&0377 > 0)    /* we were killed by some signal */
+                       return (FAILED);
+               /* Get the second byte, this is the exit/return code */
+               return ((status >> 8) & 0377);
        }
        }
-
-           /* Get the second byte, this is the exit/return code */
-
-       return((status>>8)&0377);
-
-    } else {
-           /* we are the child, go and do it */
+       /* we are the child, go and do it */
        _exit(announce_proc(request, remote_machine));
        _exit(announce_proc(request, remote_machine));
-    }
 }
        
 }
        
-
-    /* See if the user is accepting messages. If so, announce that 
-       a talk is requested.
-     */
-
+/*
+ * See if the user is accepting messages. If so, announce that 
+ * a talk is requested.
+ */
 announce_proc(request, remote_machine)
 announce_proc(request, remote_machine)
-CTL_MSG *request;
-char *remote_machine;
+       CTL_MSG *request;
+       char *remote_machine;
 {
 {
-    int pid, status;
-    char full_tty[32];
-    FILE *tf;
-    struct stat stbuf;
-
-
-    (void) sprintf(full_tty, "/dev/%s", request->r_tty);
-
-    if (access(full_tty, 0) != 0) {
-       return(FAILED);
-    }
-
-    if ((tf = fopen(full_tty, "w")) == NULL) {
-       return(PERMISSION_DENIED);
-    }
-
-       /* open gratuitously attaches the talkd to
-          any tty it opens, so disconnect us from the
-          tty before we catch a signal */
-
-    ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0);
-
-    if (fstat(fileno(tf), &stbuf) < 0) {
-       return(PERMISSION_DENIED);
-    }
-
-    if ((stbuf.st_mode&02) == 0) {
-       return(PERMISSION_DENIED);
-    }
-
-    print_mesg(tf, request, remote_machine);
-    fclose(tf);
-    return(SUCCESS);
+       int pid, status;
+       char full_tty[32];
+       FILE *tf;
+       struct stat stbuf;
+
+       (void) sprintf(full_tty, "/dev/%s", request->r_tty);
+       if (access(full_tty, 0) != 0)
+               return (FAILED);
+       if ((tf = fopen(full_tty, "w")) == NULL)
+               return (PERMISSION_DENIED);
+       /*
+        * Open gratuitously attaches the talkd to
+        * any tty it opens, so disconnect us from the
+        * tty before we catch a signal
+        */
+       ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0);
+       if (fstat(fileno(tf), &stbuf) < 0)
+               return (PERMISSION_DENIED);
+       if ((stbuf.st_mode&02) == 0)
+               return (PERMISSION_DENIED);
+       print_mesg(tf, request, remote_machine);
+       fclose(tf);
+       return (SUCCESS);
 }
 
 #define max(a,b) ( (a) > (b) ? (a) : (b) )
 #define N_LINES 5
 #define N_CHARS 120
 
 }
 
 #define max(a,b) ( (a) > (b) ? (a) : (b) )
 #define N_LINES 5
 #define N_CHARS 120
 
-    /*
-     * build a block of characters containing the message. 
-     * It is sent blank filled and in a single block to
-     * try to keep the message in one piece if the recipient
-     * in in vi at the time
-     */
-
+/*
+ * Build a block of characters containing the message. 
+ * It is sent blank filled and in a single block to
+ * try to keep the message in one piece if the recipient
+ * in in vi at the time
+ */
 print_mesg(tf, request, remote_machine)
 print_mesg(tf, request, remote_machine)
-FILE *tf;
-CTL_MSG *request;
-char *remote_machine;
+       FILE *tf;
+       CTL_MSG *request;
+       char *remote_machine;
 {
 {
-    struct timeval clock;
-    struct timezone zone;
-    struct tm *localtime();
-    struct tm *localclock;
-    char line_buf[N_LINES][N_CHARS];
-    int sizes[N_LINES];
-    char big_buf[N_LINES*N_CHARS];
-    char *bptr, *lptr;
-    int i, j, max_size;
-
-    i = 0;
-    max_size = 0;
-
-    gettimeofday(&clock, &zone);
-    localclock = localtime( &clock.tv_sec );
-
-    sprintf(line_buf[i], " ");
-
-    sizes[i] = strlen(line_buf[i]);
-    max_size = max(max_size, sizes[i]);
-    i++;
-
-    sprintf(line_buf[i], "Message from Talk_Daemon@%s at %d:%02d ...",
+       struct timeval clock;
+       struct timezone zone;
+       struct tm *localtime();
+       struct tm *localclock;
+       char line_buf[N_LINES][N_CHARS];
+       int sizes[N_LINES];
+       char big_buf[N_LINES*N_CHARS];
+       char *bptr, *lptr;
+       int i, j, max_size;
+
+       i = 0;
+       max_size = 0;
+       gettimeofday(&clock, &zone);
+       localclock = localtime( &clock.tv_sec );
+       sprintf(line_buf[i], " ");
+       sizes[i] = strlen(line_buf[i]);
+       max_size = max(max_size, sizes[i]);
+       i++;
+       sprintf(line_buf[i], "Message from Talk_Daemon@%s at %d:%02d ...",
        hostname, localclock->tm_hour , localclock->tm_min );
        hostname, localclock->tm_hour , localclock->tm_min );
-
-    sizes[i] = strlen(line_buf[i]);
-    max_size = max(max_size, sizes[i]);
-    i++;
-
-    sprintf(line_buf[i], "talk: connection requested by %s@%s.",
+       sizes[i] = strlen(line_buf[i]);
+       max_size = max(max_size, sizes[i]);
+       i++;
+       sprintf(line_buf[i], "talk: connection requested by %s@%s.",
                request->l_name, remote_machine);
                request->l_name, remote_machine);
-
-    sizes[i] = strlen(line_buf[i]);
-    max_size = max(max_size, sizes[i]);
-    i++;
-
-    sprintf(line_buf[i], "talk: respond with:  talk %s@%s",
+       sizes[i] = strlen(line_buf[i]);
+       max_size = max(max_size, sizes[i]);
+       i++;
+       sprintf(line_buf[i], "talk: respond with:  talk %s@%s",
                request->l_name, remote_machine);
                request->l_name, remote_machine);
-
-    sizes[i] = strlen(line_buf[i]);
-    max_size = max(max_size, sizes[i]);
-    i++;
-
-    sprintf(line_buf[i], " ");
-
-    sizes[i] = strlen(line_buf[i]);
-    max_size = max(max_size, sizes[i]);
-    i++;
-
-    bptr = big_buf;
-    *(bptr++) = '\a';   /* send something to wake them up */
-    *(bptr++) = '\r';  /* add a \r in case of raw mode */
-    *(bptr++) = '\n';
-    for(i = 0; i < N_LINES; i++) {
-
-           /* copy the line into the big buffer */
-
-       lptr = line_buf[i];
-       while (*lptr != '\0') {
-           *(bptr++) = *(lptr++);
-       }
-
-           /* pad out the rest of the lines with blanks */
-
-       for(j = sizes[i]; j < max_size + 2; j++) {
-           *(bptr++) = ' ';
-       }
-
+       sizes[i] = strlen(line_buf[i]);
+       max_size = max(max_size, sizes[i]);
+       i++;
+       sprintf(line_buf[i], " ");
+       sizes[i] = strlen(line_buf[i]);
+       max_size = max(max_size, sizes[i]);
+       i++;
+       bptr = big_buf;
+       *(bptr++) = '\a'; /* send something to wake them up */
        *(bptr++) = '\r';       /* add a \r in case of raw mode */
        *(bptr++) = '\n';
        *(bptr++) = '\r';       /* add a \r in case of raw mode */
        *(bptr++) = '\n';
-    }
-    *bptr = '\0';
-
-    fprintf(tf, big_buf);
-    fflush(tf);
-    ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0);
+       for (i = 0; i < N_LINES; i++) {
+               /* copy the line into the big buffer */
+               lptr = line_buf[i];
+               while (*lptr != '\0')
+                       *(bptr++) = *(lptr++);
+               /* pad out the rest of the lines with blanks */
+               for (j = sizes[i]; j < max_size + 2; j++)
+                       *(bptr++) = ' ';
+               *(bptr++) = '\r';       /* add a \r in case of raw mode */
+               *(bptr++) = '\n';
+       }
+       *bptr = '\0';
+       fprintf(tf, big_buf);
+       fflush(tf);
+       ioctl(fileno(tf), TIOCNOTTY, (struct sgttyb *) 0);
 }
 }
index 0d05d2a..d4ee53e 100644 (file)
@@ -1,4 +1,6 @@
-/* $Header: print.c 1.4 83/03/28 00:34:25 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)print.c    1.2 (Berkeley) %G%";
+#endif
 
 /* debug print routines */
 
 
 /* debug print routines */
 
@@ -6,20 +8,20 @@
 #include "ctl.h"
 
 print_request(request)
 #include "ctl.h"
 
 print_request(request)
-CTL_MSG *request;
+       CTL_MSG *request;
 {
 {
-    
-    printf("type is %d, l_user %s, r_user %s, r_tty %s\n",
-           request->type, request->l_name, request->r_name,
-           request->r_tty);
-    printf("        id = %d\n", request->id_num);
-    fflush(stdout);
+       
+       printf("type is %d, l_user %s, r_user %s, r_tty %s\n",
+               request->type, request->l_name, request->r_name,
+               request->r_tty);
+       printf("                id = %d\n", request->id_num);
+       fflush(stdout);
 }
 
 print_response(response)
 }
 
 print_response(response)
-CTL_RESPONSE *response;
+       CTL_RESPONSE *response;
 {
 {
-    printf("type is %d, answer is %d, id = %d\n\n", response->type, 
-           response->answer, response->id_num);
-    fflush(stdout);
+       printf("type is %d, answer is %d, id = %d\n\n", response->type, 
+               response->answer, response->id_num);
+       fflush(stdout);
 }
 }
index 0075354..9fb213e 100644 (file)
-/* $Header: process.c 1.5 83/03/28 20:16:07 moore Exp $ */
-
-    /* process.c handles the requests, which can be of three types:
-
-               ANNOUNCE - announce to a user that a talk is wanted
-
-               LEAVE_INVITE - insert the request into the table
-               
-               LOOK_UP - look up to see if a request is waiting in
-                         in the table for the local user
-
-               DELETE - delete invitation
-
-     */
+#ifndef lint
+static char sccsid[] = "@(#)process.c  1.2 (Berkeley) %G%";
+#endif
 
 
+/*
+ * process.c handles the requests, which can be of three types:
+ *     ANNOUNCE - announce to a user that a talk is wanted
+ *     LEAVE_INVITE - insert the request into the table
+ *     LOOK_UP - look up to see if a request is waiting in
+ *               in the table for the local user
+ *     DELETE - delete invitation
+ */
 #include "ctl.h"
 #include "ctl.h"
+
 char *strcpy();
 CTL_MSG *find_request();
 CTL_MSG *find_match();
 
 process_request(request, response)
 char *strcpy();
 CTL_MSG *find_request();
 CTL_MSG *find_match();
 
 process_request(request, response)
-CTL_MSG *request;
-CTL_RESPONSE *response;
+       CTL_MSG *request;
+       CTL_RESPONSE *response;
 {
 {
-    CTL_MSG *ptr;
+       CTL_MSG *ptr;
 
 
-    response->type = request->type;
-    response->id_num = 0;
+       response->type = request->type;
+       response->id_num = 0;
 
 
-    switch (request->type) {
+       switch (request->type) {
 
        case ANNOUNCE :
 
        case ANNOUNCE :
-
-           do_announce(request, response);
-           break;
+               do_announce(request, response);
+               break;
 
        case LEAVE_INVITE :
 
        case LEAVE_INVITE :
-
-           ptr = find_request(request);
-           if (ptr != (CTL_MSG *) 0) {
-               response->id_num = ptr->id_num;
-               response->answer = SUCCESS;
-           } else {
-               insert_table(request, response);
-           }
-           break;
+               ptr = find_request(request);
+               if (ptr != (CTL_MSG *) 0) {
+                       response->id_num = ptr->id_num;
+                       response->answer = SUCCESS;
+               } else
+                       insert_table(request, response);
+               break;
 
        case LOOK_UP :
 
        case LOOK_UP :
-
-           ptr = find_match(request);
-           if (ptr != (CTL_MSG *) 0) {
-               response->id_num = ptr->id_num;
-               response->addr = ptr->addr;
-               response->answer = SUCCESS;
-           } else {
-               response->answer = NOT_HERE;
-           }
-           break;
+               ptr = find_match(request);
+               if (ptr != (CTL_MSG *) 0) {
+                       response->id_num = ptr->id_num;
+                       response->addr = ptr->addr;
+                       response->answer = SUCCESS;
+               } else
+                       response->answer = NOT_HERE;
+               break;
 
        case DELETE :
 
        case DELETE :
-
-           response->answer = delete_invite(request->id_num);
-           break;
+               response->answer = delete_invite(request->id_num);
+               break;
 
        default :
 
        default :
-
-           response->answer = UNKNOWN_REQUEST;
-           break;
-
-    }
+               response->answer = UNKNOWN_REQUEST;
+               break;
+       }
 }
 
 struct hostent *gethostbyaddr();
 
 do_announce(request, response)
 }
 
 struct hostent *gethostbyaddr();
 
 do_announce(request, response)
-CTL_MSG *request;
-CTL_RESPONSE *response;
+       CTL_MSG *request;
+       CTL_RESPONSE *response;
 {
 {
-    struct hostent *hp;
-    CTL_MSG *ptr;
-    int result;
+       struct hostent *hp;
+       CTL_MSG *ptr;
+       int result;
 
        /* see if the user is logged */
 
        /* see if the user is logged */
-
-    result = find_user(request->r_name, request->r_tty);
-
-    if (result != SUCCESS) {
-       response->answer = result;
-       return;
-    }
-
-    hp = gethostbyaddr(&request->ctl_addr.sin_addr,
-                         sizeof(struct in_addr), AF_INET);
-
-    if ( hp == (struct hostent *) 0 ) {
-       response->answer = MACHINE_UNKNOWN;
-       return;
-    }
-
-    ptr = find_request(request);
-    if (ptr == (CTL_MSG *) 0) {
-       insert_table(request,response);
-       response->answer = announce(request, hp->h_name);
-    } else if (request->id_num > ptr->id_num) {
-           /*
-            * this is an explicit re-announce, so update the id_num
-            * field to avoid duplicates and re-announce the talk 
-            */
-       ptr->id_num = response->id_num = new_id();
-       response->answer = announce(request, hp->h_name);
-    } else {
-           /* a duplicated request, so ignore it */
+       result = find_user(request->r_name, request->r_tty);
+       if (result != SUCCESS) {
+               response->answer = result;
+               return;
+       }
+       hp = gethostbyaddr(&request->ctl_addr.sin_addr,
+               sizeof(struct in_addr), AF_INET);
+       if (hp == (struct hostent *)0) {
+               response->answer = MACHINE_UNKNOWN;
+               return;
+       }
+       ptr = find_request(request);
+       if (ptr == (CTL_MSG *) 0) {
+               insert_table(request,response);
+               response->answer = announce(request, hp->h_name);
+               return;
+       }
+       if (request->id_num > ptr->id_num) {
+               /*
+                * this is an explicit re-announce, so update the id_num
+                * field to avoid duplicates and re-announce the talk 
+                */
+               ptr->id_num = response->id_num = new_id();
+               response->answer = announce(request, hp->h_name);
+               return;
+       }
+       /* a duplicated request, so ignore it */
        response->id_num = ptr->id_num;
        response->answer = SUCCESS;
        response->id_num = ptr->id_num;
        response->answer = SUCCESS;
-    }
-
-    return;
 }
 
 #include <utmp.h>
 }
 
 #include <utmp.h>
@@ -122,34 +107,32 @@ CTL_RESPONSE *response;
 /*
  * Search utmp for the local user
  */
 /*
  * Search utmp for the local user
  */
-
 find_user(name, tty)
 find_user(name, tty)
-char *name;
-char *tty;
+       char *name;
+       char *tty;
 {
 {
-    struct utmp ubuf;
-
-    int fd;
-
-    if ((fd = open("/etc/utmp", 0)) == -1) {
-       print_error("Can't open /etc/utmp");
-       return(FAILED);
-    }
-
-    while (read(fd, (char *) &ubuf, sizeof ubuf) == sizeof(ubuf)) {
-       if (strncmp(ubuf.ut_name, name, sizeof ubuf.ut_name) == 0) {
-           if (*tty == '\0') {
-                   /* no particular tty was requested */
-               (void) strcpy(tty, ubuf.ut_line);
-               close(fd);
-               return(SUCCESS);
-           } else if (strcmp(ubuf.ut_line, tty) == 0) {
-               close(fd);
-               return(SUCCESS);
-           }
-       }
-    }
+       struct utmp ubuf;
+       int fd, status;
 
 
-    close(fd);
-    return(NOT_HERE);
+       if ((fd = open("/etc/utmp", 0)) == -1) {
+               perror("Can't open /etc/utmp");
+               return (FAILED);
+       }
+#define SCMPN(a, b)    strncmp(a, b, sizeof (a))
+       status = NOT_HERE;
+       while (read(fd, (char *) &ubuf, sizeof ubuf) == sizeof(ubuf))
+               if (SCMPN(ubuf.ut_name, name) == 0) {
+                       if (*tty == '\0') {
+                               /* no particular tty was requested */
+                               (void) strcpy(tty, ubuf.ut_line);
+                               status = SUCCESS;
+                               break;
+                       }
+                       if (strcmp(ubuf.ut_line, tty) == 0) {
+                               status = SUCCESS;
+                               break;
+                       }
+               }
+       close(fd);
+       return (status);
 }
 }
index 2667921..4ecc378 100644 (file)
-/* $Header: /a/guest/moore/talk/RCS/table.c,v 1.9 83/07/06 00:11:38 moore Exp $ */
-
-/* routines to handle insertion, deletion, etc on the table
-   of requests kept by the daemon. Nothing fancy here, linear
-   search on a double-linked list. A time is kept with each 
-   entry so that overly old invitations can be eliminated.
-
-   Consider this a mis-guided attempt at modularity
+#ifndef lint
+static char sccsid[] = "@(#)table.c    1.2 (Berkeley) %G%";
+#endif
+
+/*
+ * Routines to handle insertion, deletion, etc on the table
+ * of requests kept by the daemon. Nothing fancy here, linear
+ * search on a double-linked list. A time is kept with each 
+ * entry so that overly old invitations can be eliminated.
+ *
+ * Consider this a mis-guided attempt at modularity
  */
  */
+#include <stdio.h>
+#include <sys/time.h>
 
 #include "ctl.h"
 
 #include "ctl.h"
-#include <sys/time.h>
 
 
-#define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */
+#define MAX_ID 16000   /* << 2^15 so I don't have sign troubles */
 
 
-#define NIL ( (TABLE_ENTRY *) 0)
+#define NIL ((TABLE_ENTRY *)0)
 
 
-extern int debug;
-struct timeval tp;
-struct timezone *txp;
+extern int debug;
+struct timeval tp;
+struct timezone *txp;
 
 typedef struct table_entry TABLE_ENTRY;
 
 struct table_entry {
 
 typedef struct table_entry TABLE_ENTRY;
 
 struct table_entry {
-    CTL_MSG request;
-    long time;
-    TABLE_ENTRY *next;
-    TABLE_ENTRY *last;
+       CTL_MSG request;
+       long    time;
+       TABLE_ENTRY *next;
+       TABLE_ENTRY *last;
 };
 
 };
 
-TABLE_ENTRY *table = NIL;
+TABLE_ENTRY    *table = NIL;
 CTL_MSG *find_request();
 CTL_MSG *find_match();
 CTL_MSG *find_request();
 CTL_MSG *find_match();
-char *malloc();
-
-    /*
-     * Look in the table for an invitation that matches the current
-     * request looking for an invitation
-     */
+char   *malloc();
 
 
-CTL_MSG *find_match(request)
-CTL_MSG *request;
+/*
+ * Look in the table for an invitation that matches the current
+ * request looking for an invitation
+ */
+CTL_MSG *
+find_match(request)
+       CTL_MSG *request;
 {
 {
-    TABLE_ENTRY *ptr;
-    long current_time;
-
-    gettimeofday(&tp, &txp);
-    current_time = tp.tv_sec;
-
-    ptr = table;
-
-    if (debug) {
-       printf("Entering Look-Up with : \n");
-       print_request(request);
-    }
-
-    while (ptr != NIL) {
-
-       if ( (ptr->time - current_time) > MAX_LIFE ) {
-               /* the entry is too old */
-           if (debug) printf("Deleting expired entry : \n");
-           if (debug) print_request(&ptr->request);
-           delete(ptr);
-           ptr = ptr->next;
-           continue;
+       TABLE_ENTRY *ptr;
+       long current_time;
+
+       gettimeofday(&tp, &txp);
+       current_time = tp.tv_sec;
+       if (debug) {
+               printf("Entering Look-Up with : \n");
+               print_request(request);
        }
        }
-
-       if (debug) print_request(&ptr->request);
-
-       if ( strcmp(request->l_name, ptr->request.r_name) == 0 &&
-            strcmp(request->r_name, ptr->request.l_name) == 0 &&
-            ptr->request.type == LEAVE_INVITE ) {
-           return(&ptr->request);
+       for (ptr = table; ptr != NIL; ptr = ptr->next) {
+               if ((ptr->time - current_time) > MAX_LIFE) {
+                       /* the entry is too old */
+                       if (debug)
+                               printf("Deleting expired entry : \n");
+                       if (debug)
+                               print_request(&ptr->request);
+                       delete(ptr);
+                       continue;
+               }
+               if (debug)
+                       print_request(&ptr->request);
+               if (strcmp(request->l_name, ptr->request.r_name) == 0 &&
+                   strcmp(request->r_name, ptr->request.l_name) == 0 &&
+                    ptr->request.type == LEAVE_INVITE)
+                       return (&ptr->request);
        }
        }
-       
-       ptr = ptr->next;
-    }
-    
-    return((CTL_MSG *) 0);
+       return ((CTL_MSG *)0);
 }
 
 }
 
-    /*
    * look for an identical request, as opposed to a complimentary
    * one as find_match does 
    */
-
-CTL_MSG *find_request(request)
-CTL_MSG *request;
+/*
* Look for an identical request, as opposed to a complimentary
+ * one as find_match does 
+ */
+CTL_MSG *
+find_request(request)
+       CTL_MSG *request;
 {
 {
-    TABLE_ENTRY *ptr;
-    long current_time;
-
-    gettimeofday(&tp, &txp);
-    current_time = tp.tv_sec;
-
-       /* See if this is a repeated message, and check for
-          out of date entries in the table while we are it.
+       TABLE_ENTRY *ptr;
+       long current_time;
+
+       gettimeofday(&tp, &txp);
+       current_time = tp.tv_sec;
+       /*
+        * See if this is a repeated message, and check for
+        * out of date entries in the table while we are it.
         */
         */
-
-    ptr = table;
-
-    if (debug) {
-       printf("Entering find_request with : \n");
-       print_request(request);
-    }
-
-    while (ptr != NIL) {
-
-       if ( (ptr->time - current_time) > MAX_LIFE ) {
-               /* the entry is too old */
-           if (debug) printf("Deleting expired entry : \n");
-           if (debug) print_request(&ptr->request);
-           delete(ptr);
-           ptr = ptr->next;
-           continue;
+       if (debug) {
+               printf("Entering find_request with : \n");
+               print_request(request);
        }
        }
-
-       if (debug) print_request(&ptr->request);
-
-       if ( strcmp(request->r_name, ptr->request.r_name) == 0 &&
-            strcmp(request->l_name, ptr->request.l_name) == 0 &&
-            request->type == ptr->request.type &&
-            request->pid == ptr->request.pid) {
-           
-               /* update the time if we 'touch' it */
-           ptr->time = current_time;
-           return(&ptr->request);
+       for (ptr = table; ptr != NIL; ptr = ptr->next) {
+               if ((ptr->time - current_time) > MAX_LIFE) {
+                       /* the entry is too old */
+                       if (debug) {
+                               printf("Deleting expired entry : \n");
+                               print_request(&ptr->request);
+                       }
+                       delete(ptr);
+                       continue;
+               }
+               if (debug)
+                       print_request(&ptr->request);
+               if (strcmp(request->r_name, ptr->request.r_name) == 0 &&
+                   strcmp(request->l_name, ptr->request.l_name) == 0 &&
+                   request->type == ptr->request.type &&
+                   request->pid == ptr->request.pid) {
+                       /* update the time if we 'touch' it */
+                       ptr->time = current_time;
+                       return (&ptr->request);
+               }
        }
        }
-
-       ptr = ptr->next;
-    }
-
-    return((CTL_MSG *) 0);
+       return ((CTL_MSG *)0);
 }
 
 insert_table(request, response)
 }
 
 insert_table(request, response)
-CTL_MSG *request;
-CTL_RESPONSE *response;
+       CTL_MSG *request;
+       CTL_RESPONSE *response;
 {
 {
-    TABLE_ENTRY *ptr;
-    long current_time;
-
-    gettimeofday(&tp, &txp);
-    current_time = tp.tv_sec;
-
-    response->id_num = request->id_num = new_id();
+       TABLE_ENTRY *ptr;
+       long current_time;
 
 
+       gettimeofday(&tp, &txp);
+       current_time = tp.tv_sec;
+       response->id_num = request->id_num = new_id();
        /* insert a new entry into the top of the list */
        /* insert a new entry into the top of the list */
-    
-    ptr = (TABLE_ENTRY *) malloc(sizeof(TABLE_ENTRY));
-
-    if (ptr == NIL) {
-       print_error("malloc in insert_table");
-    }
-
-    ptr->time = current_time;
-    ptr->request = *request;
-
-    ptr->next = table;
-    if (ptr->next != NIL) {
-       ptr->next->last = ptr;
-    }
-    ptr->last = NIL;
-    table = ptr;
+       ptr = (TABLE_ENTRY *)malloc(sizeof(TABLE_ENTRY));
+       if (ptr == NIL) {
+               fprintf(stderr, "malloc in insert_table");
+               exit(1);
+       }
+       ptr->time = current_time;
+       ptr->request = *request;
+       ptr->next = table;
+       if (ptr->next != NIL)
+               ptr->next->last = ptr;
+       ptr->last = NIL;
+       table = ptr;
 }
 
 }
 
-    /* generate a unique non-zero sequence number */
-
+/*
+ * Generate a unique non-zero sequence number
+ */
 new_id()
 {
 new_id()
 {
-    static int current_id = 0;
-
-    current_id = (current_id + 1) % MAX_ID;
+       static int current_id = 0;
 
 
+       current_id = (current_id + 1) % MAX_ID;
        /* 0 is reserved, helps to pick up bugs */
        /* 0 is reserved, helps to pick up bugs */
-
-    if (current_id == 0) current_id = 1;
-
-    return(current_id);
+       if (current_id == 0)
+               current_id = 1;
+       return (current_id);
 }
 
 }
 
-    /* delete the invitation with id 'id_num' */
-
+/*
+ * Delete the invitation with id 'id_num'
+ */
 delete_invite(id_num)
 delete_invite(id_num)
-int id_num;
+       int id_num;
 {
 {
-    TABLE_ENTRY *ptr;
-
-    ptr = table;
-
-    if (debug) printf("Entering delete_invite with %d\n", id_num);
-
-    while (ptr != NIL && ptr->request.id_num != id_num) {
-       if (debug) print_request(&ptr->request);
-       ptr = ptr->next;
-    }
-       
-    if (ptr != NIL) {
-       delete(ptr);
-       return(SUCCESS);
-    }
-    
-    return(NOT_HERE);
-}
+       TABLE_ENTRY *ptr;
 
 
-    /* classic delete from a double-linked list */
+       ptr = table;
 
 
+       if (debug)
+               printf("Entering delete_invite with %d\n", id_num);
+       for (ptr = table; ptr != NIL; ptr = ptr->next) {
+               if (ptr->request.id_num == id_num)
+                       break;
+               if (debug)
+                       print_request(&ptr->request);
+       }
+       if (ptr != NIL) {
+               delete(ptr);
+               return (SUCCESS);
+       }
+       return (NOT_HERE);
+}
+
+/*
+ * Classic delete from a double-linked list
+ */
 delete(ptr)
 delete(ptr)
-TABLE_ENTRY *ptr;
+       TABLE_ENTRY *ptr;
 {
 {
-    if (debug) printf("Deleting : ");
-    if (debug) print_request(&ptr->request);
-
-    if (table == ptr) {
-       table = ptr->next;
-    } else if (ptr->last != NIL) {
-       ptr->last->next = ptr->next;
-    }
 
 
-    if (ptr->next != NIL) {
-       ptr->next->last = ptr->last;
-    }
-
-    free((char *) ptr);
+       if (debug) {
+               printf("Deleting : ");
+               print_request(&ptr->request);
+       }
+       if (table == ptr)
+               table = ptr->next;
+       else if (ptr->last != NIL)
+               ptr->last->next = ptr->next;
+       if (ptr->next != NIL)
+               ptr->next->last = ptr->last;
+       free((char *)ptr);
 }
 }
index c5a2a70..b1a3d6a 100644 (file)
-/* $Header: talkd.c 1.5 83/05/10 13:57:29 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)talkd.c    1.2 (Berkeley) %G%";
+#endif
 
 
-/* The top level of the daemon, the format is heavily borrowed
-   from rwhod.c. Basically: find out who and where you are; 
-   disconnect all descriptors and ttys, and then endless
-   loop on waiting for and processing requests
+/*
+ * The top level of the daemon, the format is heavily borrowed
+ * from rwhod.c. Basically: find out who and where you are; 
+ * disconnect all descriptors and ttys, and then endless
+ * loop on waiting for and processing requests
  */
  */
-
-#include "ctl.h"
-
 #include <stdio.h>
 #include <errno.h>
 #include <stdio.h>
 #include <errno.h>
-#include <sgtty.h>
-#include <sys/ioctl.h>
-
-#define MAX_ERR 20     /* Number of times to attempt to open the 
-                          control socket */
+#include <signal.h>
 
 
-extern errno;
+#include "ctl.h"
 
 struct sockaddr_in sin = { AF_INET };
 
 
 struct sockaddr_in sin = { AF_INET };
 
-CTL_MSG request;
-CTL_RESPONSE response;
-int sockt;
-char hostname[HOST_NAME_LENGTH];
+CTL_MSG                request;
+CTL_RESPONSE   response;
 
 
-struct hostent *gethostbyname();
-struct servent *getservbyname();
+int    sockt;
+int    debug = 0;
+int    timeout();
+long   lastmsgtime;
 
 
-int debug = 0;
-
-main(argc)
-int argc;
-{
-    struct sockaddr_in from;
-    int from_size;
-    int cc;
-    int name_length = sizeof(hostname);
-    struct servent *sp;
-    struct hostent *hp;
+char   hostname[32];
 
 
+#define TIMEOUT 30
+#define MAXIDLE 120
 
 
-    if ( argc > 1 ) {
-       debug = 1;
-    }
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       struct sockaddr_in from;
+       int fromlen, cc;
 
 
-    if ( !debug ) {
-       if (fork()) {
-           exit(0);
+       if (getuid()) {
+               fprintf(stderr, "Talkd : not super user\n");
+               exit(1);
        }
        }
-    }
-
-    gethostname(hostname, &name_length);
-
-    hp = gethostbyname(hostname);
-    if (hp == (struct hostent *) 0) {
-           fprintf(stderr, "talkd: Cannot obtain local address\n");
-           exit(1);
-    }
-
-#ifdef NTALK
-    sp = getservbyname("ntalk", "udp");
-#else
-    sp = getservbyname("talk", "udp");
-#endif
-
-    if (sp == 0) {
-           fprintf(stderr, "talkd: udp/talk: unknown service\n");
-           exit(1);
-    }
-
-    if (getuid()) {
-       fprintf(stderr, "Talkd : not super user\n");
-       exit(1);
-    }
-
-    setup_desc();
-
-    sin.sin_port = sp->s_port;
-    sockt = socket(AF_INET, SOCK_DGRAM, 0, 0);
-    if (sockt < 0) {
-           print_error("talkd: socket");
-           exit(1);
-    }
-
-    if (bind(sockt, (caddr_t)&sin, sizeof (sin), 0) < 0) {
-       print_error("bind");
-       exit(1);
-    }
-
-    for (;;) {
-
-       from_size = sizeof(from);
-       cc = recvfrom(sockt, (char *)&request, sizeof (request), 0, 
-                     &from, &from_size);
-
-       if (cc != sizeof(request)) {
-           if (cc < 0 && errno != EINTR) {
-               print_error("receive");
-           }
-       } else {
-
-           if (debug) printf("Request received : \n");
-           if (debug) print_request(&request);
-
-           process_request(&request, &response);
-
-           if (debug) printf("Response sent : \n");
-           if (debug) print_response(&response);
-
+       gethostname(hostname, sizeof (hostname));
+       (void) chdir("/dev");
+       signal(SIGALRM, timeout);
+       alarm(TIMEOUT);
+       for (;;) {
+               extern int errno;
+
+               fromlen = sizeof(from);
+               cc = recvfrom(0, (char *)&request, sizeof (request), 0,
+                   &from, &fromlen);
+               if (cc != sizeof(request)) {
+                       if (cc < 0 && errno != EINTR)
+                       perror("recvfrom");
+                       continue;
+               }
+               lastmsgtime = time(0);
+               process_request(&request, &response);
                /* can block here, is this what I want? */
                /* can block here, is this what I want? */
-
-           cc = sendto(sockt, (char *) &response, sizeof(response), 0,
-                       &request.ctl_addr, sizeof(request.ctl_addr));
-
-           if (cc != sizeof(response)) {
-               print_error("Send");
-           }
+               cc = sendto(sockt, (char *) &response,
+                   sizeof (response), 0, &request.ctl_addr,
+                   sizeof (request.ctl_addr));
+               if (cc != sizeof(response))
+                       perror("sendto");
        }
        }
-    }
-}
-
-    /* disconnect all descriptors, remove ourself from the process
-     * group that spawned us
-     */
-
-setup_desc()
-{
-    int s;
-
-    if (debug) return;
-
-    for (s = 0; s < 10; s++) {
-       (void) close(s);
-    }
-
-    (void) open("/dev/null", 0);
-    (void) dup2(0, 1);
-    (void) dup2(0, 2);
-
-    s = open("/dev/tty", 2);
-
-    if (s >= 0) {
-       ioctl(s, TIOCNOTTY, (struct sgttyb *) 0);
-       (void) close(s);
-    }
-
-    (void) chdir("/dev");
 }
 
 }
 
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-print_error(string)
-char *string;
+timeout()
 {
 {
-    FILE *cons;
-    char *err_dev = "/dev/console";
-    char *sys;
-    int val, pid;
 
 
-    if (debug) err_dev = "/dev/tty";
-
-    sys = "Unknown error";
-
-    if(errno < sys_nerr) {
-       sys = sys_errlist[errno];
-    }
-
-       /* don't ever open tty's directly, let a child do it */
-    if ((pid = fork()) == 0) {
-       cons = fopen(err_dev, "a");
-       if (cons != NULL) {
-           fprintf(cons, "Talkd : %s : %s(%d)\n\r", string, sys,
-                   errno);
-           fclose(cons);
-       }
-       exit(0);
-    } else {
-           /* wait for the child process to return */
-       do {
-           val = wait(0);
-           if (val == -1) {
-               if (errno == EINTR) {
-                   continue;
-               } else if (errno == ECHILD) {
-                   break;
-               }
-           }
-       } while (val != pid);
-    }
+       if (time(0) - lastmsgtime >= MAXIDLE)
+               exit(0);
+       alarm(TIMEOUT);
 }
 }
index 2a0378d..ba54696 100644 (file)
@@ -1,25 +1,28 @@
-/* $Header: ctl.c 1.4 83/06/09 23:37:01 moore Exp $ */
-
-/* This file handles haggling with the various talk daemons to
-   get a socket to talk to. sockt is opened and connected in
-   the progress
+#ifndef lint
+static char sccsid[] = "@(#)ctl.c      1.2 (Berkeley) %G%";
+#endif
+
+/*
+ * This file handles haggling with the various talk daemons to
+ * get a socket to talk to. sockt is opened and connected in
+ * the progress
  */
 
 #include "talk_ctl.h"
 
  */
 
 #include "talk_ctl.h"
 
-struct sockaddr_in daemon_addr = { AF_INET };
-struct sockaddr_in ctl_addr = { AF_INET };
-struct sockaddr_in my_addr = { AF_INET };
+struct sockaddr_in daemon_addr = { AF_INET };
+struct sockaddr_in ctl_addr = { AF_INET };
+struct sockaddr_in my_addr = { AF_INET };
 
     /* inet addresses of the two machines */
 
     /* inet addresses of the two machines */
-struct in_addr my_machine_addr;
-struct in_addr his_machine_addr;
+struct in_addr my_machine_addr;
+struct in_addr his_machine_addr;
 
 u_short daemon_port;   /* port number of the talk daemon */
 
 
 u_short daemon_port;   /* port number of the talk daemon */
 
-int ctl_sockt;
-int sockt;
-int invitation_waiting = 0;
+int    ctl_sockt;
+int    sockt;
+int    invitation_waiting = 0;
 
 CTL_MSG msg;
 
 
 CTL_MSG msg;
 
@@ -29,51 +32,34 @@ open_sockt()
 
     my_addr.sin_addr = my_machine_addr;
     my_addr.sin_port = 0;
 
     my_addr.sin_addr = my_machine_addr;
     my_addr.sin_port = 0;
-
-    sockt = socket(AF_INET, SOCK_STREAM, 0, 0);
-
-    if (sockt <= 0) {
+    sockt = socket(AF_INET, SOCK_STREAM, 0);
+    if (sockt <= 0)
        p_error("Bad socket");
        p_error("Bad socket");
-    }
-
-    if ( bind(sockt, &my_addr, sizeof(my_addr)) != 0) {
+    if (bind(sockt, &my_addr, sizeof(my_addr)) != 0)
        p_error("Binding local socket");
        p_error("Binding local socket");
-    }
-
     length = sizeof(my_addr);
     length = sizeof(my_addr);
-
-    if (getsockname(sockt, &my_addr, &length) == -1) {
+    if (getsockname(sockt, &my_addr, &length) == -1)
        p_error("Bad address for socket");
        p_error("Bad address for socket");
-    }
 }
 
 }
 
-    /* open the ctl socket */
-
+/* open the ctl socket */
 open_ctl() 
 {
     int length;
 
     ctl_addr.sin_port = 0;
     ctl_addr.sin_addr = my_machine_addr;
 open_ctl() 
 {
     int length;
 
     ctl_addr.sin_port = 0;
     ctl_addr.sin_addr = my_machine_addr;
-
-    ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0, 0);
-
-    if (ctl_sockt <= 0) {
+    ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0);
+    if (ctl_sockt <= 0)
        p_error("Bad socket");
        p_error("Bad socket");
-    }
-
-    if (bind(ctl_sockt, &ctl_addr, sizeof(ctl_addr), 0) != 0) {
+    if (bind(ctl_sockt, &ctl_addr, sizeof(ctl_addr), 0) != 0)
        p_error("Couldn't bind to control socket");
        p_error("Couldn't bind to control socket");
-    }
-
     length = sizeof(ctl_addr);
     length = sizeof(ctl_addr);
-    if (getsockname(ctl_sockt, &ctl_addr, &length) == -1) {
+    if (getsockname(ctl_sockt, &ctl_addr, &length) == -1)
        p_error("Bad address for ctl socket");
        p_error("Bad address for ctl socket");
-    }
 }
 
 /* print_addr is a debug print routine */
 }
 
 /* print_addr is a debug print routine */
-
 print_addr(addr)
 struct sockaddr_in addr;
 {
 print_addr(addr)
 struct sockaddr_in addr;
 {
@@ -81,9 +67,7 @@ struct sockaddr_in addr;
 
     printf("addr = %x, port = %o, family = %o zero = ",
            addr.sin_addr, addr.sin_port, addr.sin_family);
 
     printf("addr = %x, port = %o, family = %o zero = ",
            addr.sin_addr, addr.sin_port, addr.sin_family);
-
-    for (i = 0; i<8;i++) {
+    for (i = 0; i<8;i++)
        printf("%o ", (int)addr.sin_zero[i]);
        printf("%o ", (int)addr.sin_zero[i]);
-    }
     putchar('\n');
 }
     putchar('\n');
 }
index cda3433..21f2857 100644 (file)
@@ -1,97 +1,77 @@
+#ifndef lint
+static char sccsid[] = "@(#)ctl_transact.c     1.2 (Berkeley) %G%";
+#endif
+
 #include "talk_ctl.h"
 #include <sys/time.h>
 
 #include "talk_ctl.h"
 #include <sys/time.h>
 
-#define CTL_WAIT 2     /* the amount of time to wait for a 
-                          response, in seconds */
-
-
-    /*
-     * SOCKDGRAM is unreliable, so we must repeat messages if we have
-     * not recieved an acknowledgement within a reasonable amount
-     * of time
-     */
+#define CTL_WAIT 2     /* time to wait for a response, in seconds */
 
 
+/*
+ * SOCKDGRAM is unreliable, so we must repeat messages if we have
+ * not recieved an acknowledgement within a reasonable amount
+ * of time
+ */
 ctl_transact(target, msg, type, response)
 ctl_transact(target, msg, type, response)
-struct in_addr target;
-CTL_MSG msg;
-int type;
-CTL_RESPONSE *response;
+       struct in_addr target;
+       CTL_MSG msg;
+       int type;
+       CTL_RESPONSE *response;
 {
 {
-    struct sockaddr junk;
-    int read_mask;
-    int ctl_mask;
-    int nready;
-    int cc;
-    int junk_size;
-    struct timeval wait;
-
-    wait.tv_sec = CTL_WAIT;
-    wait.tv_usec = 0;
-
-    msg.type = type;
-
-    daemon_addr.sin_addr = target;
-    daemon_addr.sin_port = daemon_port;
-
-    ctl_mask = 1 << ctl_sockt;
+       struct sockaddr junk;
+       int read_mask;
+       int ctl_mask;
+       int nready;
+       int cc;
+       int junk_size;
+       struct timeval wait;
+
+       wait.tv_sec = CTL_WAIT;
+       wait.tv_usec = 0;
+       msg.type = type;
+       daemon_addr.sin_addr = target;
+       daemon_addr.sin_port = daemon_port;
+       ctl_mask = 1 << ctl_sockt;
 
        /*
         * keep sending the message until a response of the right
         * type is obtained
         */
 
        /*
         * keep sending the message until a response of the right
         * type is obtained
         */
-    do {
-           /* keep sending the message until a response is obtained */
-
-       do {
-           cc = sendto(ctl_sockt, (char *)&msg, sizeof(CTL_MSG), 0,
-                       &daemon_addr, sizeof(daemon_addr));
-
-           if (cc != sizeof(CTL_MSG)) {
-               if (errno == EINTR) {
-                       /* we are returning from an interupt */
-                   continue;
-               } else {
-                   p_error("Error on write to talk daemon");
-               }
-           }
-
-           read_mask = ctl_mask;
-
-           while ((nready = select(32, &read_mask, 0, 0, &wait)) < 0) {
-               if (errno == EINTR) {
-                       /* we are returning from an interupt */
-                   continue;
-               } else {
-                   p_error("Error on waiting for response from daemon");
-               }
-           }
-       } while (nready == 0);
-
-           /* keep reading while there are queued messages 
-              (this is not necessary, it just saves extra
-              request/acknowledgements being sent)
-            */
-
        do {
        do {
-
-           junk_size = sizeof(junk);
-           cc = recvfrom(ctl_sockt, (char *) response,
-                          sizeof(CTL_RESPONSE), 0, &junk, &junk_size );
-           if (cc < 0) {
-               if (errno == EINTR) {
-                   continue;
-               }
-               p_error("Error on read from talk daemon");
-           }
-
-           read_mask = ctl_mask;
-
-               /* an immediate poll */
-
-           timerclear(&wait);
-           nready = select(32, &read_mask, 0, 0, &wait);
-
-       } while ( nready > 0 && response->type != type);
-
-    } while (response->type != type);
+               /* keep sending the message until a response is obtained */
+               do {
+                       cc = sendto(ctl_sockt, (char *)&msg, sizeof(CTL_MSG), 0,
+                               &daemon_addr, sizeof(daemon_addr));
+                       if (cc != sizeof(CTL_MSG)) {
+                               if (errno == EINTR)
+                                       continue;
+                               p_error("Error on write to talk daemon");
+                       }
+                       read_mask = ctl_mask;
+                       nready = select(32, &read_mask, 0, 0, &wait);
+                       while (nready < 0) {
+                               if (errno == EINTR)
+                                       continue;
+                               p_error("Error waiting for daemon response");
+                       }
+               } while (nready == 0);
+               /* keep reading while there are queued messages 
+                  (this is not necessary, it just saves extra
+                  request/acknowledgements being sent)
+                */
+               do {
+                       junk_size = sizeof(junk);
+                       cc = recvfrom(ctl_sockt, (char *)response,
+                           sizeof (CTL_RESPONSE), 0, &junk, &junk_size);
+                       if (cc < 0) {
+                               if (errno == EINTR)
+                                       continue;
+                               p_error("Error on read from talk daemon");
+                       }
+                       read_mask = ctl_mask;
+                       /* an immediate poll */
+                       timerclear(&wait);
+                       nready = select(32, &read_mask, 0, 0, &wait);
+               } while (nready > 0 && response->type != type);
+       } while (response->type != type);
 }
 }
index 22615a0..5efeebf 100644 (file)
-/* $Header: display.c 1.2 83/04/23 02:09:33 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)display.c  1.2 (Berkeley) %G%";
+#endif
 
 
-/* The window 'manager', initializes curses and handles the actual
+/*
+ * The window 'manager', initializes curses and handles the actual
  * displaying of text
  */
  * displaying of text
  */
-
 #include "talk.h"
 
 #include "talk.h"
 
-xwin_t my_win;
-xwin_t his_win;
-WINDOW *line_win;
+xwin_t my_win;
+xwin_t his_win;
+WINDOW *line_win;
 
 
-int curses_initialized = 0;
-
-    /* max HAS to be a function, it is called with
-     * a argument of the form --foo at least once.
-     */
+int    curses_initialized = 0;
 
 
+/*
+ * max HAS to be a function, it is called with
+ * a argument of the form --foo at least once.
+ */
 max(a,b)
 max(a,b)
-int a, b;
+       int a, b;
 {
 {
-    if (a > b) {
-       return(a);
-    } else {
-       return(b);
-    }
+
+       return (a > b ? a : b);
 }
 
 /*
  * Display some text on somebody's window, processing some control
  * characters while we are at it.
  */
 }
 
 /*
  * Display some text on somebody's window, processing some control
  * characters while we are at it.
  */
-
 display(win, text, size)
 display(win, text, size)
-register xwin_t *win;
-register char *text;
-int size;
+       register xwin_t *win;
+       register char *text;
+       int size;
 {
 {
-    register int i;
-    char cch;
-
-    for (i = 0; i < size; i++) {
-
-       if (*text == '\n') {
-           xscroll(win, 0);
-           text++;
-           continue;
-       }
-
-           /* erase character */
-
-       if (*text == win->cerase) {
-           wmove(win->x_win, win->x_line, max(--win->x_col, 0));
-           getyx(win->x_win, win->x_line, win->x_col);
-           waddch(win->x_win, ' ');
-           wmove(win->x_win, win->x_line, win->x_col);
-           getyx(win->x_win, win->x_line, win->x_col);
-           text++;
-           continue;
-       }
-       /*
-        * On word erase search backwards until we find
-        * the beginning of a word or the beginning of
-        * the line.
-        */
-       if (*text == win->werase) {
-           int endcol, xcol, i, c;
-
-           endcol = win->x_col;
-           xcol = endcol - 1;
-           while (xcol >= 0) {
-               c = readwin(win->x_win, win->x_line, xcol);
-               if (c != ' ')
-                       break;
-               xcol--;
-           }
-           while (xcol >= 0) {
-               c = readwin(win->x_win, win->x_line, xcol);
-               if (c == ' ')
-                       break;
-               xcol--;
-           }
-           wmove(win->x_win, win->x_line, xcol + 1);
-           for (i = xcol + 1; i < endcol; i++)
-               waddch(win->x_win, ' ');
-           wmove(win->x_win, win->x_line, xcol + 1);
-           getyx(win->x_win, win->x_line, win->x_col);
-           continue;
-       }
-           /* line kill */
-       if (*text == win->kill) {
-           wmove(win->x_win, win->x_line, 0);
-           wclrtoeol(win->x_win);
-           getyx(win->x_win, win->x_line, win->x_col);
-           text++;
-           continue;
+       register int i;
+       char cch;
+
+       for (i = 0; i < size; i++) {
+               if (*text == '\n') {
+                       xscroll(win, 0);
+                       text++;
+                       continue;
+               }
+               /* erase character */
+               if (*text == win->cerase) {
+                       wmove(win->x_win, win->x_line, max(--win->x_col, 0));
+                       getyx(win->x_win, win->x_line, win->x_col);
+                       waddch(win->x_win, ' ');
+                       wmove(win->x_win, win->x_line, win->x_col);
+                       getyx(win->x_win, win->x_line, win->x_col);
+                       text++;
+                       continue;
+               }
+               /*
+                * On word erase search backwards until we find
+                * the beginning of a word or the beginning of
+                * the line.
+                */
+               if (*text == win->werase) {
+                       int endcol, xcol, i, c;
+
+                       endcol = win->x_col;
+                       xcol = endcol - 1;
+                       while (xcol >= 0) {
+                               c = readwin(win->x_win, win->x_line, xcol);
+                               if (c != ' ')
+                                       break;
+                               xcol--;
+                       }
+                       while (xcol >= 0) {
+                               c = readwin(win->x_win, win->x_line, xcol);
+                               if (c == ' ')
+                                       break;
+                               xcol--;
+                       }
+                       wmove(win->x_win, win->x_line, xcol + 1);
+                       for (i = xcol + 1; i < endcol; i++)
+                               waddch(win->x_win, ' ');
+                       wmove(win->x_win, win->x_line, xcol + 1);
+                       getyx(win->x_win, win->x_line, win->x_col);
+                       continue;
+               }
+               /* line kill */
+               if (*text == win->kill) {
+                       wmove(win->x_win, win->x_line, 0);
+                       wclrtoeol(win->x_win);
+                       getyx(win->x_win, win->x_line, win->x_col);
+                       text++;
+                       continue;
+               }
+               if (*text == '\f') {
+                       if (win == &my_win)
+                               wrefresh(curscr);
+                       text++;
+                       continue;
+               }
+               if (win->x_col == COLS-1) {
+                       /* check for wraparound */
+                       xscroll(win, 0);
+               }
+               if (*text < ' ' && *text != '\t') {
+                       waddch(win->x_win, '^');
+                       getyx(win->x_win, win->x_line, win->x_col);
+                       if (win->x_col == COLS-1) /* check for wraparound */
+                               xscroll(win, 0);
+                       cch = (*text & 63) + 64;
+                       waddch(win->x_win, cch);
+               } else
+                       waddch(win->x_win, *text);
+               getyx(win->x_win, win->x_line, win->x_col);
+               text++;
        }
        }
-       if (*text == '\f') {
-           if (win == &my_win)
-               wrefresh(curscr);
-           text++;
-           continue;
-       }
-
-       if (win->x_col == COLS-1) {
-               /* check for wraparound */
-           xscroll(win, 0);
-       }
-
-       if (*text < ' ' && *text != '\t') {
-           waddch(win->x_win, '^');
-           getyx(win->x_win, win->x_line, win->x_col);
-
-           if (win->x_col == COLS-1) {
-                   /* check for wraparound */
-               xscroll(win, 0);
-           }
-
-           cch = (*text & 63) + 64;
-           waddch(win->x_win, cch);
-       } else {
-           waddch(win->x_win, *text);
-       }
-
-       getyx(win->x_win, win->x_line, win->x_col);
-       text++;
-
-    }
-wrefresh(win->x_win);
+       wrefresh(win->x_win);
 }
 
 /*
 }
 
 /*
-* Read the character at the indicated position in win
-*/
+ * Read the character at the indicated position in win
+ */
 readwin(win, line, col)
 readwin(win, line, col)
-WINDOW *win;
+       WINDOW *win;
 {
 {
-int oldline, oldcol;
-register int c;
-
-getyx(win, oldline, oldcol);
-wmove(win, line, col);
-c = winch(win);
-wmove(win, oldline, oldcol);
-return(c);
+       int oldline, oldcol;
+       register int c;
+
+       getyx(win, oldline, oldcol);
+       wmove(win, line, col);
+       c = winch(win);
+       wmove(win, oldline, oldcol);
+       return (c);
 }
 
 /*
 }
 
 /*
-* Scroll a window, blanking out the line following the current line
-* so that the current position is obvious
-*/
-
+ * Scroll a window, blanking out the line following the current line
+ * so that the current position is obvious
+ */
 xscroll(win, flag)
 xscroll(win, flag)
-register xwin_t *win;
-int flag;
+       register xwin_t *win;
+       int flag;
 {
 {
-    if (flag == -1) {
-       wmove(win->x_win, 0, 0);
-       win->x_line = 0;
+
+       if (flag == -1) {
+               wmove(win->x_win, 0, 0);
+               win->x_line = 0;
+               win->x_col = 0;
+               return;
+       }
+       win->x_line = (win->x_line + 1) % win->x_nlines;
        win->x_col = 0;
        win->x_col = 0;
-       return;
-    }
-    win->x_line = (win->x_line + 1) % win->x_nlines;
-    win->x_col = 0;
-    wmove(win->x_win, win->x_line, win->x_col);
-    wclrtoeol(win->x_win);
-    wmove(win->x_win, (win->x_line + 1) % win->x_nlines, win->x_col);
-    wclrtoeol(win->x_win);
-    wmove(win->x_win, win->x_line, win->x_col);
+       wmove(win->x_win, win->x_line, win->x_col);
+       wclrtoeol(win->x_win);
+       wmove(win->x_win, (win->x_line + 1) % win->x_nlines, win->x_col);
+       wclrtoeol(win->x_win);
+       wmove(win->x_win, win->x_line, win->x_col);
 }
 }
index 0a57e71..8203087 100644 (file)
@@ -1,77 +1,46 @@
-/* $Header: get_addrs.c 1.5 83/04/01 17:55:41 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)get_addrs.c        1.2 (Berkeley) %G%";
+#endif
 
 #include "talk_ctl.h"
 
 
 #include "talk_ctl.h"
 
-struct hostent *gethostbyname();
-struct servent *getservbyname();
+struct hostent *gethostbyname();
+struct servent *getservbyname();
 
 get_addrs(my_machine_name, his_machine_name)
 
 get_addrs(my_machine_name, his_machine_name)
-char *my_machine_name;
-char *his_machine_name;
+       char *my_machine_name;
+       char *his_machine_name;
 {
 {
-    struct hostent *hp;
-    struct servent *sp;
-
-    msg.pid = getpid();
+       struct hostent *hp;
+       struct servent *sp;
 
 
+       msg.pid = getpid();
        /* look up the address of the local host */
        /* look up the address of the local host */
-
-    hp = gethostbyname(my_machine_name);
-
-    if (hp == (struct hostent *) 0) {
-       printf("This machine doesn't exist. Boy, am I confused!\n");
-       exit(-1);
-    }
-
-    if (hp->h_addrtype != AF_INET) {
-       printf("Protocal mix up with local machine address\n");
-       exit(-1);
-    }
-
-    bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
-
-       /* if he is on the same machine, then simply copy */
-
-    if ( bcmp((char *)&his_machine_name, (char *)&my_machine_name,
-               sizeof(his_machine_name)) == 0) {
-       bcopy((char *)&my_machine_addr, (char *)&his_machine_addr,
-               sizeof(his_machine_name));
-    } else {
-
-       /* look up the address of the recipient's machine */
-
-       hp = gethostbyname(his_machine_name);
-
-       if (hp == (struct hostent *) 0 ) {
-           printf("%s is an unknown host\n", his_machine_name);
-           exit(-1);
+       hp = gethostbyname(my_machine_name);
+       if (hp == (struct hostent *) 0) {
+               printf("This machine doesn't exist. Boy, am I confused!\n");
+               exit(-1);
        }
        }
-
-       if (hp->h_addrtype != AF_INET) {
-           printf("Protocol mix up with remote machine address\n");
-           exit(-1);
+       bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
+       /* if he is on the same machine, then simply copy */
+       if (bcmp((char *)&his_machine_name, (char *)&my_machine_name,
+           sizeof(his_machine_name)) == 0)
+               bcopy((char *)&my_machine_addr, (char *)&his_machine_addr,
+                   sizeof(his_machine_name));
+       else {
+               /* look up the address of the recipient's machine */
+               hp = gethostbyname(his_machine_name);
+               if (hp == (struct hostent *) 0 ) {
+                       printf("%s is an unknown host\n", his_machine_name);
+                       exit(-1);
+               }
+               bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
        }
        }
-
-       bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
-    }
-
        /* find the daemon portal */
        /* find the daemon portal */
-
-#ifdef NTALK
-    sp = getservbyname("ntalk", "udp");
-#else
-    sp = getservbyname("talk", "udp");
-#endif
-
-    if (strcmp(sp->s_proto, "udp") != 0) {
-       printf("Protocol mix up with talk daemon\n");
-       exit(-1);
-    }
-
-    if (sp == 0) {
-           p_error("This machine doesn't support a tcp talk daemon");
-           exit(-1);
-    }
-
-    daemon_port = sp->s_port;
+       sp = getservbyname("talk", "udp");
+       if (sp == 0) {
+               p_error("This machine doesn't support talk");
+               exit(-1);
+       }
+       daemon_port = sp->s_port;
 }
 }
index 71dd4b7..31df536 100644 (file)
@@ -1,4 +1,6 @@
-/* $Header: get_names.c 1.2 83/03/26 14:35:54 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)get_names.c        1.2 (Berkeley) %G%";
+#endif
 
 #include "talk.h"
 #include "ctl.h"
 
 #include "talk.h"
 #include "ctl.h"
@@ -7,97 +9,71 @@ char *getlogin(), *ttyname(), *rindex();
 
 extern CTL_MSG msg;
 
 
 extern CTL_MSG msg;
 
+struct hostent *gethostbyname();
+
 /*
  * Determine the local and remote user, tty, and machines
  */
 /*
  * Determine the local and remote user, tty, and machines
  */
-
-struct hostent *gethostbyname();
-
 get_names(argc, argv)
 get_names(argc, argv)
-int argc;
-char *argv[];
+       int argc;
+       char *argv[];
 {
 {
-    char hostname[HOST_NAME_LENGTH];
-    char *his_name;
-    char *my_name;
-    char *my_machine_name;
-    char *his_machine_name;
-    char *my_tty;
-    char *his_tty;
-    char *ptr;
-    int name_length;
-
-    if (argc < 2 ) {
-       printf("Usage:  talk user [ttyname]\n");
-       exit(-1);
-    }
-    if ( !isatty(0) ) {
-       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);
-    }
-
-    name_length = HOST_NAME_LENGTH;
-    gethostname(hostname, &name_length);
-    my_machine_name = hostname;
-
-    my_tty = rindex(ttyname(0), '/') + 1;
-
-       /* check for, and strip out, the machine name 
-           of the target */
-
-    for (ptr = argv[1]; *ptr != '\0' &&
-                        *ptr != '@' &&
-                        *ptr != ':' &&
-                        *ptr != '!' &&
-                        *ptr != '.'     ; ptr++) {
-    }
-
-    if (*ptr == '\0') {
-
-           /* this is a local to local talk */
-
-       his_name = argv[1];
-       his_machine_name = my_machine_name;
-
-    } else {
-
-       if (*ptr == '@') {
-               /* user@host */
-           his_name = argv[1];
-           his_machine_name = ptr + 1;
+       char hostname[HOST_NAME_LENGTH];
+       char *his_name;
+       char *my_name;
+       char *my_machine_name;
+       char *his_machine_name;
+       char *my_tty;
+       char *his_tty;
+       char *ptr;
+
+       if (argc < 2 ) {
+               printf("Usage:  talk user [ttyname]\n");
+               exit(-1);
+       }
+       if (!isatty(0)) {
+               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);
+       }
+       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 (ptr = argv[1]; *ptr != '\0' && *ptr != '@' && *ptr != ':' &&
+           *ptr != '!' && *ptr != '.'; ptr++)
+               ;
+       if (*ptr == '\0') {
+               /* this is a local to local talk */
+               his_name = argv[1];
+               his_machine_name = my_machine_name;
        } else {
        } else {
-               /* host.user or host!user or host:user */
-           his_name = ptr + 1;
-           his_machine_name = argv[1];
+               if (*ptr == '@') {
+                       /* user@host */
+                       his_name = argv[1];
+                       his_machine_name = ptr + 1;
+               } else {
+                       /* host.user or host!user or host:user */
+                       his_name = ptr + 1;
+                       his_machine_name = argv[1];
+               }
+               *ptr = '\0';
        }
        }
-       *ptr = '\0';
-    }
-
-
-    if (argc > 2) {
-       his_tty = argv[2];      /* tty name is arg 2 */
-    } else {
-       his_tty = (char *) 0;
-    }
-
-    get_addrs(my_machine_name, his_machine_name);
-
+       if (argc > 2)
+               his_tty = argv[2];      /* tty name is arg 2 */
+       else
+               his_tty = "";
+       get_addrs(my_machine_name, his_machine_name);
        /* Load these useful values into the standard message header */
        /* Load these useful values into the standard message header */
-
-    msg.id_num = 0;
-
-    strncpy(msg.l_name, my_name, NAME_SIZE);
-    msg.l_name[NAME_SIZE - 1] = '\0';
-
-    strncpy(msg.r_name, his_name, NAME_SIZE);
-    msg.r_name[NAME_SIZE - 1] = '\0';
-
-    strncpy(msg.r_tty, his_tty, TTY_SIZE);
-    msg.r_tty[TTY_SIZE - 1] = '\0';
+       msg.id_num = 0;
+       strncpy(msg.l_name, my_name, NAME_SIZE);
+       msg.l_name[NAME_SIZE - 1] = '\0';
+       strncpy(msg.r_name, his_name, NAME_SIZE);
+       msg.r_name[NAME_SIZE - 1] = '\0';
+       strncpy(msg.r_tty, his_tty, TTY_SIZE);
+       msg.r_tty[TTY_SIZE - 1] = '\0';
 }
 }
index fd39039..b8fc2f6 100644 (file)
-/* $Header: init_disp.c 1.2 83/06/23 02:01:11 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)init_disp.c        1.2 (Berkeley) %G%";
+#endif
 
 /*
 
 /*
- * init_disp contains the initialization code for the display package,
- * as well as the signal handling routines
+ * Initialization code for the display package,
+ * as well as the signal handling routines.
  */
 
 #include "talk.h"
 #include <signal.h>
 
 /* 
  */
 
 #include "talk.h"
 #include <signal.h>
 
 /* 
- * set up curses, catch the appropriate signals, and build the
- * various windows
+ * Set up curses, catch the appropriate signals,
+ * and build the various windows.
  */
  */
-
 init_display()
 {
 init_display()
 {
-    void sig_sent();
-
-    initscr();
-    curses_initialized = 1;
-
-    clear();
-    refresh();
-
-    noecho();
-    crmode();
-
-    signal(SIGINT, sig_sent);
-    signal(SIGPIPE, sig_sent);
-
+       void sig_sent();
+
+       initscr();
+       curses_initialized = 1;
+       clear();
+       refresh();
+       noecho();
+       crmode();
+       signal(SIGINT, sig_sent);
+       signal(SIGPIPE, sig_sent);
        /* curses takes care of ^Z */
        /* curses takes care of ^Z */
-
-    my_win.x_nlines = LINES / 2;
-    my_win.x_ncols = COLS;
-    my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0);
-    scrollok(my_win.x_win, FALSE);
-    wclear(my_win.x_win);
-
-    his_win.x_nlines = LINES / 2 - 1;
-    his_win.x_ncols = COLS;
-    his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols,
-                                            my_win.x_nlines+1, 0);
-    scrollok(his_win.x_win, FALSE);
-    wclear(his_win.x_win);
-
-    line_win = newwin(1, COLS, my_win.x_nlines, 0);
-    box(line_win, '-', '-');
-    wrefresh(line_win);
-
+       my_win.x_nlines = LINES / 2;
+       my_win.x_ncols = COLS;
+       my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0);
+       scrollok(my_win.x_win, FALSE);
+       wclear(my_win.x_win);
+
+       his_win.x_nlines = LINES / 2 - 1;
+       his_win.x_ncols = COLS;
+       his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols,
+           my_win.x_nlines+1, 0);
+       scrollok(his_win.x_win, FALSE);
+       wclear(his_win.x_win);
+
+       line_win = newwin(1, COLS, my_win.x_nlines, 0);
+       box(line_win, '-', '-');
+       wrefresh(line_win);
        /* let them know we are working on it */
        /* let them know we are working on it */
-
-    current_state = "No connection yet";
+       current_state = "No connection yet";
 }
 
 }
 
-    /* trade edit characters with the other talk. By agreement
-     * the first three characters each talk transmits after
-     * connection are the three edit characters
-     */
-
+/*
+ * Trade edit characters with the other talk. By agreement
+ * the first three characters each talk transmits after
+ * connection are the three edit characters.
+ */
 set_edit_chars()
 {
 set_edit_chars()
 {
-    char buf[3];
-    int cc;
-    struct sgttyb tty;
-    struct ltchars ltc;
-    
-    gtty(0, &tty);
-
-    ioctl(0, TIOCGLTC, (struct sgttyb *) &ltc);
+       char buf[3];
+       int cc;
+       struct sgttyb tty;
+       struct ltchars ltc;
        
        
-    my_win.cerase = tty.sg_erase;
-    my_win.kill = tty.sg_kill;
-
-    if (ltc.t_werasc == (char) -1) {
-       my_win.werase = '\027';  /* control W */
-    } else {
-       my_win.werase = ltc.t_werasc;
-    }
-
-    buf[0] = my_win.cerase;
-    buf[1] = my_win.kill;
-    buf[2] = my_win.werase;
-
-    cc = write(sockt, buf, sizeof(buf));
-
-    if (cc != sizeof(buf) ) {
-       p_error("Lost the connection");
-    }
-
-    cc = read(sockt, buf, sizeof(buf));
-
-    if (cc != sizeof(buf) ) {
-       p_error("Lost the connection");
-    }
-
-    his_win.cerase = buf[0];
-    his_win.kill = buf[1];
-    his_win.werase = buf[2];
+       ioctl(0, TIOCGETP, &tty);
+       ioctl(0, TIOCGLTC, (struct sgttyb *)&ltc);
+       my_win.cerase = tty.sg_erase;
+       my_win.kill = tty.sg_kill;
+       if (ltc.t_werasc == (char) -1)
+               my_win.werase = '\027';  /* control W */
+       else
+               my_win.werase = ltc.t_werasc;
+       buf[0] = my_win.cerase;
+       buf[1] = my_win.kill;
+       buf[2] = my_win.werase;
+       cc = write(sockt, buf, sizeof(buf));
+       if (cc != sizeof(buf) )
+               p_error("Lost the connection");
+       cc = read(sockt, buf, sizeof(buf));
+       if (cc != sizeof(buf) )
+               p_error("Lost the connection");
+       his_win.cerase = buf[0];
+       his_win.kill = buf[1];
+       his_win.werase = buf[2];
 }
 
 }
 
-void sig_sent()
+void
+sig_sent()
 {
 {
-    message("Connection closing. Exiting");
-    quit();
+
+       message("Connection closing. Exiting");
+       quit();
 }
 
 /*
  * All done talking...hang up the phone and reset terminal thingy's
  */
 }
 
 /*
  * All done talking...hang up the phone and reset terminal thingy's
  */
-
 quit()
 {
 quit()
 {
-       if (curses_initialized) {
-           wmove(his_win.x_win, his_win.x_nlines-1, 0);
-           wclrtoeol(his_win.x_win);
-           wrefresh(his_win.x_win);
-           endwin();
-       }
 
 
-       if (invitation_waiting) {
-           send_delete();
+       if (curses_initialized) {
+               wmove(his_win.x_win, his_win.x_nlines-1, 0);
+               wclrtoeol(his_win.x_win);
+               wrefresh(his_win.x_win);
+               endwin();
        }
        }
-
+       if (invitation_waiting)
+               send_delete();
        exit(0);
 }
        exit(0);
 }
index fca96f2..ccae1aa 100644 (file)
-/* $Header: /a/guest/moore/talk/RCS/invite.c,v 1.7 83/07/06 00:17:32 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)invite.c   1.2 (Berkeley) %G%";
+#endif
 
 #include "talk_ctl.h"
 #include <sys/time.h>
 #include <signal.h>
 #include <setjmp.h>
 
 #include "talk_ctl.h"
 #include <sys/time.h>
 #include <signal.h>
 #include <setjmp.h>
-    
-    /*
-     * there wasn't an invitation waiting, so send a request containing
-     * our sockt address to the remote talk daemon so it can invite
-     * him 
-     */
-
-int local_id, remote_id;       /* the msg.id's for the invitations
-                                  on the local and remote machines.
-                                  These are used to delete the 
-                                  invitations. */
-void re_invite();
-jmp_buf        invitebuf;
+
+/*
+ * There wasn't an invitation waiting, so send a request containing
+ * our sockt address to the remote talk daemon so it can invite
+ * him 
+ */
+
+/*
+ * The msg.id's for the invitations
+ * on the local and remote machines.
+ * These are used to delete the 
+ * invitations.
+ */
+int    local_id, remote_id;
+void   re_invite();
+jmp_buf invitebuf;
 
 invite_remote()
 {
 
 invite_remote()
 {
-    int nfd, read_mask, template, new_sockt;
-    struct itimerval itimer;
-    CTL_RESPONSE response;
-
-    itimer.it_value.tv_sec = RING_WAIT;
-    itimer.it_value.tv_usec = 0;
-    itimer.it_interval = itimer.it_value;
-
-    if (listen(sockt, 5) != 0) {
-       p_error("Error on attempt to listen for caller");
-    }
-
-    msg.addr = my_addr;
-    msg.id_num = -1;           /* an impossible id_num */
-
-    invitation_waiting = 1;
-
-    announce_invite();
-
+       int nfd, read_mask, template, new_sockt;
+       struct itimerval itimer;
+       CTL_RESPONSE response;
+
+       itimer.it_value.tv_sec = RING_WAIT;
+       itimer.it_value.tv_usec = 0;
+       itimer.it_interval = itimer.it_value;
+       if (listen(sockt, 5) != 0)
+               p_error("Error on attempt to listen for caller");
+       msg.addr = my_addr;
+       msg.id_num = -1;                /* an impossible id_num */
+       invitation_waiting = 1;
+       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 interupt timer to resend the invitation
         */
-
-    end_msgs();
-    setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
-    message("Waiting for your party to respond");
-    signal(SIGALRM, re_invite);
-    (void) setjmp(invitebuf);
-
-    while ((new_sockt = accept(sockt, 0, 0)) < 0) {
-       if (errno != EINTR) {
-           p_error("Unable to connect with your party");
-       } else {
-           /* we just returned from a interupt, keep trying */
-           continue;
+       end_msgs();
+       setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+       message("Waiting for your party to respond");
+       signal(SIGALRM, re_invite);
+       (void) setjmp(invitebuf);
+       while ((new_sockt = accept(sockt, 0, 0)) < 0) {
+               if (errno == EINTR)
+                       continue;
+               p_error("Unable to connect with your party");
        }
        }
-    }
+       close(sockt);
+       sockt = new_sockt;
 
 
-    close(sockt);
-    sockt = new_sockt;
-
-       /* have the daemons delete the invitations now that we
-          have connected.
+       /*
+        * Have the daemons delete the invitations now that we
+        * have connected.
         */
         */
-
-    current_state = "Waiting for your party to respond";
-    start_msgs();
-
-    msg.id_num = local_id;
-    ctl_transact(my_machine_addr, msg, DELETE, &response);
-    msg.id_num = remote_id;
-    ctl_transact(his_machine_addr, msg, DELETE, &response);
-    invitation_waiting = 0;
+       current_state = "Waiting for your party to respond";
+       start_msgs();
+
+       msg.id_num = local_id;
+       ctl_transact(my_machine_addr, msg, DELETE, &response);
+       msg.id_num = remote_id;
+       ctl_transact(his_machine_addr, msg, DELETE, &response);
+       invitation_waiting = 0;
 }
 
 }
 
-    /* routine called on interupt to re-invite the callee */
-
-void re_invite()
+/*
+ * Routine called on interupt to re-invite the callee
+ */
+void
+re_invite()
 {
 {
-    message("Ringing your party again");
-    current_line++;
+
+       message("Ringing your party again");
+       current_line++;
        /* force a re-announce */
        /* force a re-announce */
-    msg.id_num = remote_id + 1;
-    announce_invite();
-    longjmp(invitebuf, 1);
+       msg.id_num = remote_id + 1;
+       announce_invite();
+       longjmp(invitebuf, 1);
 }
 
 }
 
-    /* transmit the invitation and process the response */
-
+/*
+ * Transmit the invitation and process the response
+ */
 announce_invite()
 {
 announce_invite()
 {
-    CTL_RESPONSE response;
-
-    current_state = "Trying to connect to your party's talk daemon";
-
-    ctl_transact(his_machine_addr, msg, ANNOUNCE, &response);
-    remote_id = response.id_num;
-
-    if (response.answer != SUCCESS) {
-
-       switch (response.answer) {
-           
-           case NOT_HERE :
-               message("Your party is not logged on");
-               break;
-
-           case MACHINE_UNKNOWN :
-               message("Target machine does not recognize us");
-               break;
-
-           case UNKNOWN_REQUEST :
-               message("Target machine can not handle remote talk");
-               break;
-
-           case FAILED :
-               message("Target machine is too confused to talk to us");
-               break;
-
-           case PERMISSION_DENIED :
-               message("Your party is refusing messages");
-               break;
+       CTL_RESPONSE response;
+
+       current_state = "Trying to connect to your party's talk daemon";
+       ctl_transact(his_machine_addr, msg, ANNOUNCE, &response);
+       remote_id = response.id_num;
+       if (response.answer != SUCCESS) {
+               switch (response.answer) {
+                       
+               case NOT_HERE :
+                       message("Your party is not logged on");
+                       break;
+
+               case MACHINE_UNKNOWN :
+                       message("Target machine does not recognize us");
+                       break;
+
+               case UNKNOWN_REQUEST :
+                       message("Target machine can not handle remote talk");
+                       break;
+
+               case FAILED :
+                       message("Target machine is too confused to talk to us");
+                       break;
+
+               case PERMISSION_DENIED :
+                       message("Your party is refusing messages");
+                       break;
+               }
+               quit();
        }
        }
-
-       quit();
-    }
-
        /* leave the actual invitation on my talk daemon */
        /* leave the actual invitation on my talk daemon */
-
-    ctl_transact(my_machine_addr, msg, LEAVE_INVITE, &response);
-    local_id = response.id_num;
+       ctl_transact(my_machine_addr, msg, LEAVE_INVITE, &response);
+       local_id = response.id_num;
 }
 }
-    
+       
+/*
+ * Tell the daemon to remove your invitation
+ */
 send_delete()
 {
 send_delete()
 {
-       /* tell the daemon to remove your invitation */
-
-    msg.type = DELETE;
-
-       /* this is just a extra clean up, so just send it
-          and don't wait for an answer */
-
-    msg.id_num = remote_id;
-    daemon_addr.sin_addr = his_machine_addr;
-    if (sendto(ctl_sockt, &msg, sizeof(CTL_MSG), 0, &daemon_addr,
-                   sizeof(daemon_addr)) != sizeof(CTL_MSG)) {
-           perror("send_delete remote");
-    }
-
-    msg.id_num = local_id;
-    daemon_addr.sin_addr = my_machine_addr;
-    if (sendto(ctl_sockt, &msg, sizeof(CTL_MSG), 0, &daemon_addr,
-                   sizeof(daemon_addr)) != sizeof(CTL_MSG)) {
-           perror("send_delete local");
-    }
+
+       msg.type = DELETE;
+       /*
+        * This is just a extra clean up, so just send it
+        * and don't wait for an answer
+        */
+       msg.id_num = remote_id;
+       daemon_addr.sin_addr = his_machine_addr;
+       if (sendto(ctl_sockt, &msg, sizeof(CTL_MSG), 0, &daemon_addr,
+           sizeof(daemon_addr)) != sizeof(CTL_MSG))
+               perror("send_delete remote");
+       msg.id_num = local_id;
+       daemon_addr.sin_addr = my_machine_addr;
+       if (sendto(ctl_sockt, &msg, sizeof(CTL_MSG), 0, &daemon_addr,
+           sizeof(daemon_addr)) != sizeof(CTL_MSG))
+               perror("send_delete local");
 }
 }
index 4baee7f..57a65eb 100644 (file)
@@ -1,8 +1,11 @@
-/* $Header: /a/guest/moore/talk/RCS/io.c,v 1.3 83/07/06 00:17:15 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)io.c       1.2 (Berkeley) %G%";
+#endif
 
 
-/* this file contains the I/O handling and the exchange of 
-   edit characters. This connection itself is established in
-   ctl.c
+/*
+ * This file contains the I/O handling and the exchange of 
+ * edit characters. This connection itself is established in
+ * ctl.c
  */
 
 #include "talk.h"
  */
 
 #include "talk.h"
@@ -18,112 +21,91 @@ extern int errno;
 /*
  * The routine to do the actual talking
  */
 /*
  * The routine to do the actual talking
  */
-
 talk()
 {
 talk()
 {
-    register int read_template, sockt_mask;
-    int read_set, nb;
-    char buf[BUFSIZ];
-    struct timeval wait;
+       register int read_template, sockt_mask;
+       int read_set, nb;
+       char buf[BUFSIZ];
+       struct timeval wait;
 
 
-    message("Connection established\007\007\007");
-    current_line = 0;
-
-    sockt_mask = (1<<sockt);
+       message("Connection established\007\007\007");
+       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;
-
-    forever {
-
-       read_set = read_template;
-
-       wait.tv_sec = A_LONG_TIME;
-       wait.tv_usec = 0;
-
-       nb = select(32, &read_set, 0, 0, &wait);
-
-       if (nb <= 0) {
-
-               /* We may be returning from an interupt handler */
-
-           if (errno == EINTR) {
+       read_template = sockt_mask | STDIN_MASK;
+       forever {
                read_set = read_template;
                read_set = read_template;
-               continue;
-           } else {
-                   /* panic, we don't know what happened */
-               p_error("Unexpected error from select");
-               quit();
-           }
-       }
-
-       if ( read_set & sockt_mask ) { 
-
-               /* There is data on sockt */
-           nb = read(sockt, buf, sizeof buf);
-
-           if (nb <= 0) {
-               message("Connection closed. Exiting");
-               quit();
-           } else {
-               display(&his_win, buf, nb);
-           }
+               wait.tv_sec = A_LONG_TIME;
+               wait.tv_usec = 0;
+               nb = select(32, &read_set, 0, 0, &wait);
+               if (nb <= 0) {
+                       if (errno == EINTR) {
+                               read_set = read_template;
+                               continue;
+                       }
+                       /* panic, we don't know what happened */
+                       p_error("Unexpected error from select");
+                       quit();
+               }
+               if (read_set & sockt_mask) { 
+                       /* There is data on sockt */
+                       nb = read(sockt, buf, sizeof buf);
+                       if (nb <= 0) {
+                               message("Connection closed. Exiting");
+                               quit();
+                       }
+                       display(&his_win, buf, nb);
+               }
+               if (read_set & STDIN_MASK) {
+                       /*
+                        * We can't make the tty non_blocking, because
+                        * curses's output routines would screw up
+                        */
+                       ioctl(0, FIONREAD, (struct sgttyb *) &nb);
+                       nb = read(0, buf, nb);
+                       display(&my_win, buf, nb);
+                       /* might lose data here because sockt is non-blocking */
+                       write(sockt, buf, nb);
+               }
        }
        }
-       
-       if ( read_set & STDIN_MASK ) {
-
-               /* we can't make the tty non_blocking, because
-                  curses's output routines would screw up */
-
-           ioctl(0, FIONREAD, (struct sgttyb *) &nb);
-           nb = read(0, buf, nb);
-
-           display(&my_win, buf, nb);
-           write(sockt, buf, nb);      /* We might lose data here
-                                          because sockt is non-blocking
-                                        */
-
-       }
-    }
 }
 
 }
 
-extern int     errno;
-extern int     sys_nerr;
-extern char    *sys_errlist[];
-
-    /* p_error prints the system error message on the standard location
-       on the screen and then exits. (i.e. a curses version of perror)
-     */
+extern int errno;
+extern int sys_nerr;
+extern char *sys_errlist[];
 
 
+/*
+ * p_error prints the system error message on the standard location
+ * on the screen and then exits. (i.e. a curses version of perror)
+ */
 p_error(string) 
 p_error(string) 
-char *string;
+       char *string;
 {
 {
-    char *sys;
-
-    sys = "Unknown error";
-    if(errno < sys_nerr) {
-       sys = sys_errlist[errno];
-    }
-
-
-    wmove(my_win.x_win, current_line%my_win.x_nlines, 0);
-    wprintw(my_win.x_win, "[%s : %s (%d)]\n", string, sys, errno);
-    wrefresh(my_win.x_win);
-    move(LINES-1, 0);
-    refresh();
-    quit();
+       char *sys;
+
+       sys = "Unknown error";
+       if (errno < sys_nerr)
+               sys = sys_errlist[errno];
+       wmove(my_win.x_win, current_line%my_win.x_nlines, 0);
+       wprintw(my_win.x_win, "[%s : %s (%d)]\n", string, sys, errno);
+       wrefresh(my_win.x_win);
+       move(LINES-1, 0);
+       refresh();
+       quit();
 }
 
 }
 
-    /* display string in the standard location */
-
+/*
+ * Display string in the standard location
+ */
 message(string)
 message(string)
-char *string;
+       char *string;
 {
 {
-    wmove(my_win.x_win, current_line%my_win.x_nlines, 0);
-    wprintw(my_win.x_win, "[%s]\n", string);
-    wrefresh(my_win.x_win);
+
+       wmove(my_win.x_win, current_line%my_win.x_nlines, 0);
+       wprintw(my_win.x_win, "[%s]\n", string);
+       wrefresh(my_win.x_win);
 }
 }
index fe9087c..17e9f14 100644 (file)
@@ -1,78 +1,65 @@
-/* $Header: look_up.c 1.2 83/03/28 00:34:22 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)look_up.c  1.2 (Berkeley) %G%";
+#endif
 
 #include "talk_ctl.h"
 
 
 #include "talk_ctl.h"
 
-    /* see if the local daemon has a invitation for us */
-
+/*
+ * See if the local daemon has a invitation for us
+ */
 check_local()
 {
 check_local()
 {
-    CTL_RESPONSE response;
+       CTL_RESPONSE response;
 
        /* the rest of msg was set up in get_names */
 
        /* the rest of msg was set up in get_names */
-
-    msg.ctl_addr = ctl_addr;
-
-    if (!look_for_invite(&response)) {
-
-           /* we must be initiating a talk */
-
-       return(0);
-    }
-
-        /*
-        * there was an invitation waiting for us, 
+       msg.ctl_addr = ctl_addr;
+       if (!look_for_invite(&response))        /* must be initiating a talk */
+               return (0);
+       /*
+        * There was an invitation waiting for us, 
         * so connect with the other (hopefully waiting) party 
         */
         * so connect with the other (hopefully waiting) party 
         */
-
-    current_state = "Waiting to connect with caller";
-
-    while (connect(sockt, &response.addr, sizeof(response.addr)) != 0) {
+       current_state = "Waiting to connect with caller";
+again:
+       if (connect(sockt, &response.addr, sizeof(response.addr)) != -1)
+               return (1);
+       if (errno == EINTR)
+               goto again;
        if (errno == ECONNREFUSED) {
        if (errno == ECONNREFUSED) {
-
-               /* the caller gave up, but his invitation somehow
+               /*
+                * The caller gave up, but his invitation somehow
                 * was not cleared. Clear it and initiate an 
                 * invitation. (We know there are no newer invitations,
                 * the talkd works LIFO.)
                 */
                 * was not cleared. Clear it and initiate an 
                 * invitation. (We know there are no newer invitations,
                 * the talkd works LIFO.)
                 */
-
-           ctl_transact(his_machine_addr, msg, DELETE, &response);
-           close(sockt);
-           open_sockt();
-           return(0);
-       } else if (errno == EINTR) {
-               /* we have returned from an interupt handler */
-           continue;
-       } else {
-           p_error("Unable to connect with initiator");
+               ctl_transact(his_machine_addr, msg, DELETE, &response);
+               close(sockt);
+               open_sockt();
+               return (0);
        }
        }
-    }
-
-    return(1);
+       p_error("Unable to connect with initiator");
+       /*NOTREACHED*/
 }
 
 }
 
-    /* look for an invitation on 'machine' */
-
+/*
+ * Look for an invitation on 'machine'
+ */
 look_for_invite(response)
 look_for_invite(response)
-CTL_RESPONSE *response;
+       CTL_RESPONSE *response;
 {
 {
-    struct in_addr machine_addr;
-
-    current_state = "Checking for invitation on caller's machine";
+       struct in_addr machine_addr;
 
 
-    ctl_transact(his_machine_addr, msg, LOOK_UP, response);
-
-       /* the switch is for later options, such as multiple 
-          invitations */
-
-    switch (response->answer) {
+       current_state = "Checking for invitation on caller's machine";
+       ctl_transact(his_machine_addr, msg, LOOK_UP, response);
+       /* the switch is for later options, such as multiple invitations */
+       switch (response->answer) {
 
        case SUCCESS:
 
        case SUCCESS:
-
-           msg.id_num = response->id_num;
-           return(1);
+               msg.id_num = response->id_num;
+               return (1);
 
        default :
                /* there wasn't an invitation waiting for us */
 
        default :
                /* there wasn't an invitation waiting for us */
-           return(0);
-    }
+               return (0);
+       }
 }
 }
index ce813d4..2acf2ca 100644 (file)
@@ -1,7 +1,9 @@
-/* $Header: /a/guest/moore/talk/RCS/msgs.c,v 1.4 83/07/06 00:17:22 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)msgs.c     1.2 (Berkeley) %G%";
+#endif
 
 /* 
 
 /* 
- * a package to display what is happening every MSG_INTERVAL seconds
+ * A package to display what is happening every MSG_INTERVAL seconds
  * if we are slow connecting.
  */
 
  * if we are slow connecting.
  */
 
 #define MSG_INTERVAL 4
 #define LONG_TIME 100000
 
 #define MSG_INTERVAL 4
 #define LONG_TIME 100000
 
-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};
-    
+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()
 {
-    message(current_state);
+
+       message(current_state);
 }
 
 start_msgs()
 {
 }
 
 start_msgs()
 {
-    message(current_state);
-    signal(SIGALRM, disp_msg);
-    itimer.it_value = itimer.it_interval = wait;
-    setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
+
+       message(current_state);
+       signal(SIGALRM, disp_msg);
+       itimer.it_value = itimer.it_interval = wait;
+       setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
 }
 
 end_msgs()
 {
 }
 
 end_msgs()
 {
-    signal(SIGALRM, SIG_IGN);
-    timerclear(&itimer.it_value);
-    timerclear(&itimer.it_interval);
-    setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
+
+       signal(SIGALRM, SIG_IGN);
+       timerclear(&itimer.it_value);
+       timerclear(&itimer.it_interval);
+       setitimer(ITIMER_REAL, &itimer, (struct timerval *)0);
 }
 }
index 6f625ea..43753e8 100644 (file)
@@ -1,4 +1,6 @@
-/* $Header: talk.c 1.3 83/04/23 02:08:25 moore Exp $ */
+#ifndef lint
+static char sccsid[] = "@(#)talk.c     1.2 (Berkeley) %G%";
+#endif
 
 #include "talk.h"
 
 
 #include "talk.h"
 
  */
 
 main(argc, argv)
  */
 
 main(argc, argv)
-int argc;
-char *argv[];
+       int argc;
+       char *argv[];
 {
 {
-       get_names(argc, argv);
 
 
+       get_names(argc, argv);
        init_display();
        init_display();
-
        open_ctl();
        open_sockt();
        open_ctl();
        open_sockt();
-
        start_msgs();
        start_msgs();
-
-       if ( !check_local() ) {
-           invite_remote();
-       }
-
+       if (!check_local() )
+               invite_remote();
        end_msgs();
        end_msgs();
-
        set_edit_chars();
        set_edit_chars();
-
        talk();
 }
        talk();
 }
index c998662..8c7fc9f 100644 (file)
@@ -1,33 +1,34 @@
-/* $Header: talk.h 1.2 83/04/23 02:15:12 moore Exp $ */
+/*     @(#)talk.h      1.2 %G% */
 
 #include <curses.h>
 #include <utmp.h>
 
 
 #include <curses.h>
 #include <utmp.h>
 
-#define        forever         for(;;)
+#define forever                for(;;)
 
 
-#define        BUF_SIZE        512
+#define BUF_SIZE       512
 
 
-FILE *popen();
-int quit(), sleeper();
+FILE   *popen();
+int    quit();
+int    sleeper();
 
 
-extern int sockt;
-extern int curses_initialized;
-extern int invitation_waiting;
+extern int sockt;
+extern int curses_initialized;
+extern int invitation_waiting;
 
 
-extern char *current_state;
-extern int current_line;
+extern char *current_state;
+extern int current_line;
 
 typedef struct xwin {
 
 typedef struct xwin {
-       WINDOW *x_win;
-       int x_nlines;
-       int x_ncols;
-       int x_line;
-       int x_col;
-       char kill;
-       char cerase;
-       char werase;
+       WINDOW  *x_win;
+       int     x_nlines;
+       int     x_ncols;
+       int     x_line;
+       int     x_col;
+       char    kill;
+       char    cerase;
+       char    werase;
 } xwin_t;
 
 } xwin_t;
 
-extern xwin_t my_win;
-extern xwin_t his_win;
-extern WINDOW *line_win;
+extern xwin_t my_win;
+extern xwin_t his_win;
+extern WINDOW *line_win;
index d9b6f6f..3d6e4e5 100644 (file)
@@ -1,16 +1,16 @@
-/* $Header: talk_ctl.h 1.1 83/03/26 14:36:39 moore Exp $ */
+/*     @(#)talk_ctl.h  1.2 %G% */
 
 #include "ctl.h"
 #include "talk.h"
 #include <errno.h>
 
 
 #include "ctl.h"
 #include "talk.h"
 #include <errno.h>
 
-extern int errno;
+extern int errno;
 
 
-extern struct sockaddr_in daemon_addr;
-extern struct sockaddr_in ctl_addr;
-extern struct sockaddr_in my_addr;
-extern struct in_addr my_machine_addr;
-extern struct in_addr his_machine_addr;
-extern u_short daemon_port;
-extern int ctl_sockt;
-extern CTL_MSG msg;
+extern struct sockaddr_in daemon_addr;
+extern struct sockaddr_in ctl_addr;
+extern struct sockaddr_in my_addr;
+extern struct in_addr my_machine_addr;
+extern struct in_addr his_machine_addr;
+extern u_short daemon_port;
+extern int ctl_sockt;
+extern CTL_MSG msg;