Don't assume that time_t is long.

This commit is contained in:
bde 1998-06-29 18:09:59 +00:00
parent 8d79264e17
commit 5ce7f7bbb5
3 changed files with 18 additions and 9 deletions

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: master.c,v 1.3 1997/10/22 06:19:48 charnier Exp $";
"$Id: master.c,v 1.4 1997/10/29 07:32:28 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -83,6 +83,7 @@ master()
#define POLLRATE 4
int polls;
struct timeval wait, ntime;
time_t tsp_time_sec;
struct tsp *msg, *answer, to;
char newdate[32];
struct sockaddr_in taddr;
@ -179,7 +180,8 @@ master()
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
tsp_time_sec = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tsp_time_sec));
#endif /* sgi */
if (!good_host_name(msg->tsp_name)) {
syslog(LOG_NOTICE,
@ -200,7 +202,8 @@ master()
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
tsp_time_sec = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tsp_time_sec));
#endif /* sgi */
htp = findhost(msg->tsp_name);
if (htp == 0) {

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)readmsg.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: readmsg.c,v 1.2 1997/10/22 06:19:48 charnier Exp $";
"$Id: readmsg.c,v 1.3 1997/10/29 07:32:29 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -435,6 +435,7 @@ print(msg, addr)
struct sockaddr_in *addr;
{
char tm[26];
time_t tsp_time_sec;
switch (msg->tsp_type) {
case TSP_LOOP:
@ -453,7 +454,8 @@ print(msg, addr)
#ifdef sgi
(void)cftime(tm, "%D %T", &msg->tsp_time.tv_sec);
#else
strncpy(tm, ctime(&msg->tsp_time.tv_sec)+3+1, sizeof(tm));
tsp_time_sec = msg->tsp_time.tv_sec;
strncpy(tm, ctime(&tsp_time_sec)+3+1, sizeof(tm));
tm[15] = '\0'; /* ugh */
#endif /* sgi */
fprintf(fd, "%s %d %-6u %s %-15s %s\n",

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: slave.c,v 1.4 1997/10/29 07:32:29 charnier Exp $";
"$Id: slave.c,v 1.5 1997/10/31 12:33:06 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -77,6 +77,7 @@ slave()
char tname[MAXHOSTNAMELEN];
struct tsp *msg, to;
struct timeval ntime, wait;
time_t tsp_time_sec;
struct tsp *answer;
int timeout();
char olddate[32];
@ -266,7 +267,8 @@ slave()
* calling ctime() which clobbers the static buffer
*/
(void)strcpy(olddate, date());
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
tsp_time_sec = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tsp_time_sec));
#endif /* sgi */
if (!good_host_name(msg->tsp_name)) {
@ -357,7 +359,8 @@ slave()
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
tsp_time_sec = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tsp_time_sec));
#endif /* sgi */
schgdate(msg, newdate);
break;
@ -368,7 +371,8 @@ slave()
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
tsp_time_sec = msg->tsp_time.tv_sec;
(void)strcpy(newdate, ctime(&tsp_time_sec));
#endif /* sgi */
htp = findhost(msg->tsp_name);
if (0 == htp) {