/***** showinfo */ static void showinfo(utmp_t *u, int formtype, int maxcmd, int from) { int jcpu, i, ut_pid_found; char uname[USERSZ + 1] = "", tty[5 + sizeof u->ut_line + 1] = "/dev/"; proc_t *best; for (i=0; i < sizeof u->ut_line; i++) /* clean up tty if garbled */ if (isalnum(u->ut_line[i]) || (u->ut_line[i]=='/')) tty[i+5] = u->ut_line[i]; else tty[i+5] = '\0'; best = getproc(u, tty + 5, &jcpu, &ut_pid_found); /* just skip if stale utmp entry (i.e. login proc doesn't exist). If there * is a desire a cmdline flag could be added to optionally show it with a * prefix of (stale) in front of cmd or something like that. */ if (!ut_pid_found) return; strncpy(uname, u->ut_user, USERSZ); /* force NUL term for printf */ if (formtype) { printf("%-9.8s%-9.8s", uname, u->ut_line); if (from) print_host(u->ut_host, sizeof u->ut_host); print_logintime(u->ut_time, stdout); if (*u->ut_line == ':') /* idle unknown for xdm logins */ printf(" ? "); else print_time_ival7(idletime(u, tty), 0, stdout); print_time_ival7(jcpu/Hertz, (jcpu%Hertz)*(100./Hertz), stdout); if (best) { int pcpu = best->utime + best->stime; print_time_ival7(pcpu/Hertz, (pcpu%Hertz)*(100./Hertz), stdout); } else printf(" ? "); } else { printf("%-9.8s%-9.8s", u->ut_user, u->ut_line); if (from) print_host(u->ut_host, sizeof u->ut_host); if (*u->ut_line == ':') /* idle unknown for xdm logins */ printf(" ? "); else print_time_ival7(idletime(u, tty), 0, stdout); } fputs(" ", stdout); if (best) { if (best->cmdline) print_strlist(stdout, best->cmdline, " ", maxcmd); else printf("%*.*s", -maxcmd, maxcmd, best->cmd); } else { printf("-"); } fputc('\n', stdout); }
static void print_searchdomain(struct Cveinfo *p, int index) { print_strlist(p->searchdomain); }
static void print_nameserver(struct Cveinfo *p, int index) { print_strlist(p->nameserver); }
static void print_ip(struct Cveinfo *p, int index) { print_strlist(p->ip); }