if (getutline_r (real_tty_path, &ut, &utmp_data) < 0)
strncpy (line.ut_line, real_tty_path, sizeof line.ut_line); if (getutline_r (&line, &ut, &utmp_data) < 0)
getlogin_r (name, name_len)     char *name;     size_t name_len;{  char tty_pathname[2 + 2 * NAME_MAX];  char *real_tty_path = tty_pathname;  int result = 0;  struct utmp_data utmp_data;  struct utmp *ut;  {    int err;    int d = __open ("/dev/tty", 0);    if (d < 0)      return errno;    result = ttyname_r (d, real_tty_path, sizeof (tty_pathname));    err = errno;    (void) close (d);    if (result < 0)      {	errno = err;	return err;      }  }  real_tty_path += 5;		/* Remove "/dev/".  */  setutent_r (&utmp_data);  if (getutline_r (real_tty_path, &ut, &utmp_data) < 0)    {      if (errno == ESRCH)	/* The caller expects ENOENT if nothing is found.  */	result = ENOENT;      else	result = errno;    }  else    {      strncpy (name, ut->ut_line, name_len);      result = 0;    }  endutent_r (&utmp_data);  return result;}