[comp.os.minix] Login.c again

TEMARI%ECAMV1.dnet.ge.com@vm1.nodak.edu (10/23/90)

Here is login.c again, sorry I had TurboC on my mind when I did it. Itoa
takes an integer argument and returns a pointer to a static buffer.
Thanks to Bruce for pointing that out.


Michael Temari                                    temari@ecamv1.dnet.ge.com
---------------------------------------------------------------------------

*** /usr/src/commands/login.c.old	Sat Oct 13 23:16:42 1990
--- /usr/src/commands/login.c	Mon Oct 22 21:19:14 1990
***************
*** 38,43 ****
--- 38,46 ----
   *
   * Andy Tanenbaum April 1990
   * - if /bin/sh cannot be located, try /usr/bin/sh
+  *
+  * Michael A. Temari	October 1990
+  *  - handle more than single digit tty devices
   */

  #include <sys/types.h>
***************
*** 51,59 ****
  #include <utmp.h>
  #include <stdio.h>

! #define DIGIT 			      3
! #define MOTD 		    "/etc/motd"
! #define TTY  		         "tty?"
  #define CONS 		         "tty0"

  static char *Version = "@(#) LOGIN 1.13 (02/10/90)";
--- 54,61 ----
  #include <utmp.h>
  #include <stdio.h>

! #define MOTD 		    "/etc/motd"
! #define TTY  		         "tty"
  #define CONS 		         "tty0"

  static char *Version = "@(#) LOGIN 1.13 (02/10/90)";
***************
*** 76,81 ****
--- 78,84 ----
  extern long time();
  extern long lseek();
  void Time_out();
+ extern char *itoa();

  void wtmp(line, user)
  char *line;			/* tty device name */
***************
*** 220,226 ****
  	strcpy(ttyname, CONS);	/* system console */
    else {
  	strcpy(ttyname, TTY);
! 	ttyname[DIGIT] = '0' + ttynr;
    }

    /* Get login name and passwd. */
--- 223,229 ----
  	strcpy(ttyname, CONS);	/* system console */
    else {
  	strcpy(ttyname, TTY);
! 	strcat(ttyname,itoa(ttynr));
    }

    /* Get login name and passwd. */