Deleted Added
sdiff udiff text old ( 146466 ) new ( 153090 )
full compact
1/*-
2 * Copyright (c) 1993, John Brezak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/usr.bin/rup/rup.c 153090 2005-12-04 18:25:26Z philip $");
37
38#include <sys/param.h>
39#include <sys/socket.h>
40
41#include <rpc/rpc.h>
42#include <rpc/pmap_clnt.h>
43
44#undef FSHIFT /* Use protocol's shift and scale values */

--- 51 unchanged lines hidden (view full) ---

96 struct tm *tmp_time;
97 struct tm host_time;
98 struct tm host_uptime;
99 char days_buf[16];
100 char hours_buf[16];
101 struct hostent *hp;
102 char *host;
103 statstime *host_stat = (statstime *)replyp;
104 time_t tmp_time_t;
105
106 if (search_host(raddrp->sin_addr))
107 return(0);
108
109 hp = gethostbyaddr((char *)&raddrp->sin_addr.s_addr,
110 sizeof(struct in_addr), AF_INET);
111 if (hp)
112 host = hp->h_name;
113 else
114 host = inet_ntoa(raddrp->sin_addr);
115
116 /* truncate hostname to fit nicely into field */
117 if (strlen(host) > HOST_WIDTH)
118 host[HOST_WIDTH] = '\0';
119
120 printf("%-*s\t", HOST_WIDTH, host);
121
122 if (sizeof(time_t) == sizeof(host_stat->curtime.tv_sec)) {
123 tmp_time = localtime((time_t *)&host_stat->curtime.tv_sec);
124 host_time = *tmp_time;
125
126 host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec;
127
128 tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec);
129 host_uptime = *tmp_time;
130 }
131 else { /* non-32-bit time_t */
132 tmp_time_t = host_stat->curtime.tv_sec;
133 tmp_time = localtime(&tmp_time_t);
134 host_time = *tmp_time;
135
136 host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec;
137
138 tmp_time_t = host_stat->curtime.tv_sec;
139 tmp_time = gmtime(&tmp_time_t);
140 host_uptime = *tmp_time;
141 }
142
143 #define updays (host_stat->curtime.tv_sec / 86400)
144 if (host_uptime.tm_yday != 0)
145 sprintf(days_buf, "%3d day%s, ", updays,
146 (updays > 1) ? "s" : "");
147 else
148 days_buf[0] = '\0';
149
150 if (host_uptime.tm_hour != 0)

--- 104 unchanged lines hidden ---