ut = get_current_utmp(main_pid);
#if defined(HAVE_STRUCT_UTMPX_UT_HOST)
- if ((ut != NULL) && (ut->ut_host[0] != '\0')) {
+ if ((ut != NULL) && strncmp(ut->ut_host, "", countof(ut->ut_host)) != 0) {
*out = XSTRNDUP(ut->ut_host);
} else {
*out = NULL;
if (NULL != host && !streq(host, ""))
hostname = xstrdup(host);
#if defined(HAVE_STRUCT_UTMPX_UT_HOST)
- else if (NULL != ut && '\0' != ut->ut_host[0])
+ else if (NULL != ut && strncmp(ut->ut_host, "", countof(ut->ut_host)) != 0)
hostname = XSTRNDUP(ut->ut_host);
#endif
if (USER_PROCESS != ut->ut_type) {
continue;
}
- if ('\0' == ut->ut_user[0]) {
+ if (strncmp(ut->ut_user, "", countof(ut->ut_user)) == 0)
continue;
- }
- if (strncmp (name, ut->ut_user, sizeof (ut->ut_user)) != 0) {
+
+ if (strncmp(ut->ut_user, name, countof(ut->ut_user)) != 0)
continue;
- }
+
count++;
if (count > limit) {
break;
printf (_("Last login: %s on %s"),
ptime, ll.ll_line);
#ifdef HAVE_LL_HOST /* __linux__ || SUN4 */
- if ('\0' != ll.ll_host[0]) {
+ if (strncmp(ll.ll_host, "", countof(ll.ll_host)) != 0) {
printf (_(" from %.*s"),
(int) sizeof ll.ll_host, ll.ll_host);
}
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <utmpx.h>
if (ut->ut_type != USER_PROCESS) {
continue;
}
- if (ut->ut_user[0] == '\0') {
+ if (strncmp(ut->ut_user, "", countof(ut->ut_user)) == 0)
continue;
- }
+
if (check_login (ut)) {
continue;
}