From 3a9774c8eb797a2800927f973cdc25aa29306961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 15 Apr 2008 15:54:49 +0000 Subject: [PATCH] Reorder to avoid prototype. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22983 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/login/utmp_login.c | 68 ++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/appl/login/utmp_login.c b/appl/login/utmp_login.c index cd05e2c80..55c13a547 100644 --- a/appl/login/utmp_login.c +++ b/appl/login/utmp_login.c @@ -86,41 +86,6 @@ void utmp_login(char *tty, const char *username, const char *hostname) /* update utmp and wtmp - the BSD way */ -static void prepare_utmp (struct utmp *, char *, const char *, const char *); - -void utmp_login(char *tty, const char *username, const char *hostname) -{ - struct utmp utmp; - int fd; - - prepare_utmp (&utmp, tty, username, hostname); - -#ifdef HAVE_SETUTENT - utmpname(_PATH_UTMP); - setutent(); - pututline(&utmp); - endutent(); -#else - -#ifdef HAVE_TTYSLOT - { - int ttyno; - ttyno = ttyslot(); - if (ttyno > 0 && (fd = open(_PATH_UTMP, O_WRONLY, 0)) >= 0) { - lseek(fd, (long)(ttyno * sizeof(struct utmp)), SEEK_SET); - write(fd, &utmp, sizeof(struct utmp)); - close(fd); - } - } -#endif /* HAVE_TTYSLOT */ -#endif /* HAVE_SETUTENT */ - - if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { - write(fd, &utmp, sizeof(struct utmp)); - close(fd); - } -} - static void prepare_utmp (struct utmp *utmp, char *tty, const char *username, const char *hostname) @@ -162,4 +127,37 @@ prepare_utmp (struct utmp *utmp, char *tty, # endif } +void utmp_login(char *tty, const char *username, const char *hostname) +{ + struct utmp utmp; + int fd; + + prepare_utmp (&utmp, tty, username, hostname); + +#ifdef HAVE_SETUTENT + utmpname(_PATH_UTMP); + setutent(); + pututline(&utmp); + endutent(); +#else + +#ifdef HAVE_TTYSLOT + { + int ttyno; + ttyno = ttyslot(); + if (ttyno > 0 && (fd = open(_PATH_UTMP, O_WRONLY, 0)) >= 0) { + lseek(fd, (long)(ttyno * sizeof(struct utmp)), SEEK_SET); + write(fd, &utmp, sizeof(struct utmp)); + close(fd); + } + } +#endif /* HAVE_TTYSLOT */ +#endif /* HAVE_SETUTENT */ + + if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { + write(fd, &utmp, sizeof(struct utmp)); + close(fd); + } +} + #endif /* !HAVE_UTMPX_H */