Cleanup the mix of styles in this file:

- spaces -> tabs
  - return(0) -> return (0)
  - wrap longlines

Reviewed by:	md5
MFC after:	2 weeks
This commit is contained in:
Mike Heffner 2001-06-19 03:37:21 +00:00
parent 042b6e862b
commit 98f858a6b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78455

View File

@ -37,18 +37,17 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <rpcsvc/rnusers.h>
#include <arpa/inet.h>
#include <err.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <arpa/inet.h>
#include <rpcsvc/rnusers.h>
#define MAX_INT 0x7fffffff
#define HOST_WIDTH 20
@ -67,7 +66,7 @@ search_host(struct in_addr addr)
{
struct host_list *hp;
if (!hosts)
if (hosts == NULL)
return (0);
for (hp = hosts; hp != NULL; hp = hp->next) {
@ -82,7 +81,7 @@ remember_host(struct in_addr addr)
{
struct host_list *hp;
if (!(hp = (struct host_list *)malloc(sizeof(struct host_list))))
if ((hp = (struct host_list *)malloc(sizeof(struct host_list))) == NULL)
errx(1, "no memory");
hp->addr.s_addr = addr.s_addr;
hp->next = hosts;
@ -102,12 +101,12 @@ rusers_reply(caddr_t replyp, struct sockaddr_in *raddrp)
if (search_host(raddrp->sin_addr))
return (0);
if (!allopt && !up->utmpidlearr_len)
if (!allopt && up->utmpidlearr_len == 0)
return (0);
hp = gethostbyaddr((char *)&raddrp->sin_addr.s_addr,
sizeof(struct in_addr), AF_INET);
if (hp)
if (hp != NULL)
host = hp->h_name;
else
host = inet_ntoa(raddrp->sin_addr);
@ -135,8 +134,7 @@ rusers_reply(caddr_t replyp, struct sockaddr_in *raddrp)
minutes = seconds / 60;
seconds %= 60;
if (idle > 60)
sprintf(idle_time, "%d:%02d",
minutes, seconds);
sprintf(idle_time, "%d:%02d", minutes, seconds);
if (idle >= (60 * 60))
sprintf(idle_time, "%d:%02d:%02d",
hours, minutes, seconds);
@ -145,19 +143,18 @@ rusers_reply(caddr_t replyp, struct sockaddr_in *raddrp)
days, hours, minutes, seconds);
}
strncpy(remote, up->utmpidlearr_val[x].ui_utmp.ut_host, sizeof(remote)-1);
strncpy(remote, up->utmpidlearr_val[x].ui_utmp.ut_host,
sizeof(remote) - 1);
if (strlen(remote) != 0)
sprintf(remote, "(%.16s)", up->utmpidlearr_val[x].ui_utmp.ut_host);
sprintf(remote, "(%.16s)",
up->utmpidlearr_val[x].ui_utmp.ut_host);
if (longopt)
printf("%-8.8s %*s:%-*.*s %-12.12s %6s %.18s\n",
up->utmpidlearr_val[x].ui_utmp.ut_name,
HOST_WIDTH, host,
LINE_WIDTH, LINE_WIDTH, up->utmpidlearr_val[x].ui_utmp.ut_line,
date,
idle_time,
remote
);
HOST_WIDTH, host, LINE_WIDTH, LINE_WIDTH,
up->utmpidlearr_val[x].ui_utmp.ut_line, date,
idle_time, remote );
else
printf("%s ",
up->utmpidlearr_val[x].ui_utmp.ut_name);
@ -189,7 +186,8 @@ onehost(char *host)
bzero((char *)&up, sizeof(up));
tv.tv_sec = 15; /* XXX ?? */
tv.tv_usec = 0;
if (clnt_call(rusers_clnt, RUSERSPROC_NAMES, xdr_void, NULL, xdr_utmpidlearr, &up, tv) != RPC_SUCCESS)
if (clnt_call(rusers_clnt, RUSERSPROC_NAMES, xdr_void, NULL,
xdr_utmpidlearr, &up, tv) != RPC_SUCCESS)
errx(1, "%s", clnt_sperror(rusers_clnt, ""));
addr.sin_addr.s_addr = *(int *)hp->h_addr;
rusers_reply((caddr_t)&up, &addr);
@ -202,9 +200,9 @@ allhosts()
enum clnt_stat clnt_stat;
bzero((char *)&up, sizeof(up));
clnt_stat = clnt_broadcast(RUSERSPROG, RUSERSVERS_IDLE, RUSERSPROC_NAMES,
xdr_void, NULL,
xdr_utmpidlearr, (char *)&up, rusers_reply);
clnt_stat = clnt_broadcast(RUSERSPROG, RUSERSVERS_IDLE,
RUSERSPROC_NAMES, xdr_void, NULL, xdr_utmpidlearr, (char *)&up,
rusers_reply);
if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_TIMEDOUT)
errx(1, "%s", clnt_sperrno(clnt_stat));
}
@ -212,6 +210,7 @@ allhosts()
static void
usage()
{
fprintf(stderr, "usage: rusers [-la] [hosts ...]\n");
exit(1);
}