logwtmp (char *line, char *name, char *host) #endif { struct utmp ut; /* Set information in new entry. */ bzero (&ut, sizeof (ut)); #ifdef HAVE_STRUCT_UTMP_UT_TYPE ut.ut_type = USER_PROCESS; #endif strncpy (ut.ut_line, line, sizeof ut.ut_line); #ifdef HAVE_STRUCT_UTMP_UT_NAME strncpy (ut.ut_name, name, sizeof ut.ut_name); #endif #ifdef HAVE_STRUCT_UTMP_UT_HOST strncpy (ut.ut_host, host, sizeof ut.ut_host); #endif #ifdef HAVE_STRUCT_UTMP_UT_TV gettimeofday (&ut.ut_tv, NULL); #else time (&ut.ut_time); #endif _logwtmp (&ut); }
logwtmp (char *line, char *name, char *host) #endif { #ifdef HAVE_UTMPX_H struct utmpx ut; struct timeval tv; #else /* !HAVE_UTMPX_H */ struct utmp ut; # ifdef HAVE_STRUCT_UTMP_UT_TV struct timeval tv; # endif #endif /* Set information in new entry. */ memset (&ut, 0, sizeof (ut)); #if defined HAVE_STRUCT_UTMP_UT_TYPE || defined HAVE_STRUCT_UTMPX_UT_TYPE if (name && *name) ut.ut_type = USER_PROCESS; else ut.ut_type = DEAD_PROCESS; #endif /* UT_TYPE */ #if defined HAVE_STRUCT_UTMP_UT_PID || defined HAVE_STRUCT_UTMPX_UT_PID ut.ut_pid = getpid (); #endif /* UT_PID */ strncpy (ut.ut_line, line, sizeof ut.ut_line); #if defined HAVE_STRUCT_UTMP_UT_USER || defined HAVE_STRUCT_UTMPX_UT_USER strncpy (ut.ut_user, name, sizeof ut.ut_user); #elif defined HAVE_STRUCT_UTMP_UT_NAME || defined HAVE_STRUCT_UTMPX_UT_NAME strncpy (ut.ut_name, name, sizeof ut.ut_name); #endif #if defined HAVE_STRUCT_UTMP_UT_HOST || defined HAVE_STRUCT_UTMPX_UT_HOST strncpy (ut.ut_host, host, sizeof ut.ut_host); # ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN /* Only utmpx. */ if (strlen (host) < sizeof (ut.ut_host)) ut.ut_syslen = strlen (host) + 1; /* Including NUL. */ else { ut.ut_host[sizeof (ut.ut_host) - 1] = '\0'; ut.ut_syslen = sizeof (ut.ut_host); } # endif /* UT_SYSLEN */ #endif /* UT_HOST */ #if defined HAVE_STRUCT_UTMP_UT_TV || defined HAVE_STRUCT_UTMPX_UT_TV gettimeofday (&tv, NULL); ut.ut_tv.tv_sec = tv.tv_sec; ut.ut_tv.tv_usec = tv.tv_usec; #else time (&ut.ut_time); #endif _logwtmp (&ut); }