#include <unistd.h>
#include <stdlib.h>
#include <utmp.h>
-\f
+
+
/* Return the result of ttyname in the buffer pointed to by TTY, which should
be of length BUF_LEN. If it is too long to fit in this buffer, a
sufficiently long buffer is allocated using malloc, and returned in TTY.
__set_errno (ENOMEM);
break;
}
-
buf = new_buf;
}
strncpy (copy.ut_line, ttyp, UT_LINESIZE);
/* Tell that we want to use the UTMP file. */
- if (utmpname (_PATH_UTMP) != 0)
+ if (utmpname (_PATH_UTMP) == 0)
{
struct utmp *old;
}
/* Update the WTMP file. Here we have to add a new entry. */
- if (utmpname (_PATH_WTMP) != 0)
- {
- struct utmp *up;
-
- /* Open the WTMP file. */
- setutent ();
-
- /* Position at end of file. */
- while (! getutent_r (&utbuf, &up));
-
- /* Write the new entry. */
- pututline (©);
-
- /* Close WTMP file. */
- endutent ();
- }
+ updwtmp (_PATH_WTMP, ©);
}