version 1.12, 2001/06/18 22:19:04 |
version 1.13, 2001/10/11 03:06:32 |
|
|
*/ |
*/ |
|
|
#ifndef lint |
#ifndef lint |
static char rcsid[] = "$OpenBSD$"; |
static const char rcsid[] = "$OpenBSD$"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <rpc/rpc.h> |
#include <rpc/rpc.h> |
#include <rpc/pmap_clnt.h> |
#include <rpc/pmap_clnt.h> |
#include <arpa/inet.h> |
#include <arpa/inet.h> |
#include <utmp.h> |
|
#include <stdlib.h> |
#include <stdlib.h> |
|
|
/* |
/* |
|
|
rusers_reply(char *replyp, struct sockaddr_in *raddrp) |
rusers_reply(char *replyp, struct sockaddr_in *raddrp) |
{ |
{ |
int x, idle, i; |
int x, idle, i; |
char date[32], idle_time[64], remote[UT_HOSTSIZE + 1]; |
char date[32], idle_time[64], remote[RNUSERS_MAXHOSTLEN + 1]; |
char local[HOST_WIDTH + LINE_WIDTH + 2]; |
char local[HOST_WIDTH + LINE_WIDTH + 2]; |
char utline[UT_LINESIZE + 1]; |
char utline[RNUSERS_MAXLINELEN + 1]; |
struct hostent *hp; |
struct hostent *hp; |
utmpidlearr *up = (utmpidlearr *)replyp; |
utmpidlearr *up = (utmpidlearr *)replyp; |
char *host, *tmp; |
char *host, *tmp; |
|
|
sizeof(remote)-1); |
sizeof(remote)-1); |
remote[sizeof(remote) - 1] = '\0'; |
remote[sizeof(remote) - 1] = '\0'; |
if (strlen(remote) != 0) |
if (strlen(remote) != 0) |
snprintf(remote, UT_HOSTSIZE + 1, "(%.16s)", |
snprintf(remote, sizeof(remote), "(%.16s)", |
up->uia_arr[x]->ui_utmp.ut_host); |
up->uia_arr[x]->ui_utmp.ut_host); |
|
|
if (longopt) { |
if (longopt) { |
strncpy(local, host, sizeof(local)); |
strncpy(local, host, sizeof(local)); |
strncpy(utline, up->uia_arr[x]->ui_utmp.ut_line, |
strncpy(utline, up->uia_arr[x]->ui_utmp.ut_line, |
UT_LINESIZE); |
sizeof(utline) - 1); |
utline[sizeof(utline) - 1] = '\0'; |
utline[sizeof(utline) - 1] = '\0'; |
i = sizeof(local) - strlen(utline) - 2; |
i = sizeof(local) - strlen(utline) - 2; |
if (i < 0) |
if (i < 0) |
|
|
strlcat(local, utline, sizeof(local)); |
strlcat(local, utline, sizeof(local)); |
|
|
printf("%-*.*s %-*.*s %-12.12s %8s %.18s\n", |
printf("%-*.*s %-*.*s %-12.12s %8s %.18s\n", |
NAME_WIDTH, UT_NAMESIZE, |
NAME_WIDTH, RNUSERS_MAXUSERLEN, |
up->uia_arr[x]->ui_utmp.ut_name, |
up->uia_arr[x]->ui_utmp.ut_name, |
HOST_WIDTH+LINE_WIDTH+1, HOST_WIDTH+LINE_WIDTH+1, |
HOST_WIDTH+LINE_WIDTH+1, HOST_WIDTH+LINE_WIDTH+1, |
local, date, idle_time, remote); |
local, date, idle_time, remote); |
} else |
} else |
printf("%.*s ", UT_NAMESIZE, |
printf("%.*s ", RNUSERS_MAXUSERLEN, |
up->uia_arr[x]->ui_utmp.ut_name); |
up->uia_arr[x]->ui_utmp.ut_name); |
} |
} |
if (!longopt) |
if (!longopt) |