- printf("%-*.*s %-2.2s %-*.*s %s",
- UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name,
- strncmp(ep->utmp.ut_line, "tty", 3) == 0 ?
- ep->utmp.ut_line+3 : ep->utmp.ut_line,
- UT_HOSTSIZE, UT_HOSTSIZE, *ep->utmp.ut_host ?
- ep->utmp.ut_host : "-",
- attime(&ep->utmp.ut_time));
- if (ep->idle >= 36 * 60)
- printf(" %ddays ", (ep->idle + 12 * 60) / (24 * 60));
- else
- prttime(ep->idle, " ");
- printf("%.*s\n", argwidth, ep->args);
+ p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-";
+ if (x = strchr(p, ':'))
+ *x++ = '\0';
+ if (!nflag && isdigit(*p) &&
+ (long)(l = inet_addr(p)) != -1 &&
+ (hp = gethostbyaddr((char *)&l, sizeof(l), AF_INET))) {
+ if (domain[0] != '\0') {
+ p = hp->h_name;
+ p += strlen(hp->h_name);
+ p -= strlen(domain);
+ if (p > hp->h_name && strcmp(p, domain) == 0)
+ *p = '\0';
+ }
+ p = hp->h_name;
+ }
+ if (x) {
+ (void)snprintf(buf, sizeof(buf), "%s:%s", p, x);
+ p = buf;
+ }
+ (void)printf("%-*.*s %-2.2s %-*.*s ",
+ UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name,
+ strncmp(ep->utmp.ut_line, "tty", 3) ?
+ ep->utmp.ut_line : ep->utmp.ut_line + 3,
+ UT_HOSTSIZE, UT_HOSTSIZE, *p ? p : "-");
+ pr_attime(&ep->utmp.ut_time, &now);
+ pr_idle(ep->idle);
+ (void)printf("%.*s\n", argwidth, ep->args);