int l = ntohl(p->avl[i]);
printf(" %2d.%02d", l/100, l%100);
}
- putchar('\n');
+ printf(" %3d users\n", (int) ntohl(p->num_users));
}
static void
for(u=0; u<m; u++)
{
i = &p->users[u];
- printf("%-8s %-3s %c %-16s ", i->name, i->con, (i->mesg_y ? ' ' : '-'), name);
+ printf("%-8.8s %-3s %c %-16s ", i->name, i->con, (i->mesg_y ? ' ' : '-'), name);
puttime(ntohl(i->login_time));
putchar(' ');
puttime(ntohl(i->idle_time));
}
r = read(fd, &pkt, sizeof(pkt));
close(fd);
- if (r <= sizeof(struct rywho_pkt) - MAX_USERS*sizeof(struct userinfo)
+ if (r < sizeof(struct rywho_pkt) - MAX_USERS*sizeof(struct userinfo)
|| r != sizeof(struct rywho_pkt) - (MAX_USERS - ntohl(pkt.num_users))*sizeof(struct userinfo))
{
fprintf(stderr, "%s: Malformed record\n", e->d_name);