version 1.10, 2003/06/10 22:20:50 |
version 1.11, 2003/06/25 21:18:47 |
|
|
|
|
time_t now; |
time_t now; |
int rflg = 1; |
int rflg = 1; |
int hscmp(), ucmp(), lcmp(), tcmp(); |
int hscmp(const void *, const void *); |
|
int ucmp(const void *, const void *); |
|
int lcmp(const void *, const void *); |
|
int tcmp(const void *, const void *); |
|
|
void morehosts(void); |
void morehosts(void); |
|
|
|
|
struct dirent *dp; |
struct dirent *dp; |
int aflg, cc, ch, f, i, maxloadav; |
int aflg, cc, ch, f, i, maxloadav; |
char buf[sizeof(struct whod)]; |
char buf[sizeof(struct whod)]; |
int (*cmp)() = hscmp; |
int (*cmp)(const void *, const void *) = hscmp; |
time_t time(); |
char *interval(time_t, char *); |
char *interval(); |
|
|
|
aflg = 0; |
aflg = 0; |
while ((ch = getopt(argc, argv, "alrut")) != -1) |
while ((ch = getopt(argc, argv, "alrut")) != -1) |
|
|
|
|
/* alphabetical comparison */ |
/* alphabetical comparison */ |
int |
int |
hscmp(void *a1, void *a2) |
hscmp(const void *a1, const void *a2) |
{ |
{ |
struct hs *h1 = a1, *h2 = a2; |
const struct hs *h1 = a1, *h2 = a2; |
|
|
return(rflg * strcmp(h1->hs_wd->wd_hostname, h2->hs_wd->wd_hostname)); |
return(rflg * strcmp(h1->hs_wd->wd_hostname, h2->hs_wd->wd_hostname)); |
} |
} |
|
|
/* load average comparison */ |
/* load average comparison */ |
int |
int |
lcmp(void *a1, void *a2) |
lcmp(const void *a1, const void *a2) |
{ |
{ |
struct hs *h1 = a1, *h2 = a2; |
const struct hs *h1 = a1, *h2 = a2; |
|
|
if (ISDOWN(h1)) |
if (ISDOWN(h1)) |
if (ISDOWN(h2)) |
if (ISDOWN(h2)) |
|
|
|
|
/* number of users comparison */ |
/* number of users comparison */ |
int |
int |
ucmp(void *a1, void *a2) |
ucmp(const void *a1, const void *a2) |
{ |
{ |
struct hs *h1 = a1, *h2 = a2; |
const struct hs *h1 = a1, *h2 = a2; |
|
|
if (ISDOWN(h1)) |
if (ISDOWN(h1)) |
if (ISDOWN(h2)) |
if (ISDOWN(h2)) |
|
|
|
|
/* uptime comparison */ |
/* uptime comparison */ |
int |
int |
tcmp(void *a1, void *a2) |
tcmp(const void *a1, const void *a2) |
{ |
{ |
struct hs *h1 = a1, *h2 = a2; |
const struct hs *h1 = a1, *h2 = a2; |
|
|
return(rflg * ( |
return(rflg * ( |
(ISDOWN(h2) ? h2->hs_wd->wd_recvtime - now |
(ISDOWN(h2) ? h2->hs_wd->wd_recvtime - now |