--- embedaddon/php/ext/fileinfo/libmagic/cdf_time.c 2012/02/21 23:47:56 1.1.1.1 +++ embedaddon/php/ext/fileinfo/libmagic/cdf_time.c 2012/05/29 12:34:39 1.1.1.2 @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $") +FILE_RCSID("@(#)$File: cdf_time.c,v 1.11 2011/12/13 13:48:41 christos Exp $") #endif #include @@ -108,22 +108,22 @@ cdf_timestamp_to_timespec(struct timeval *ts, cdf_time ts->tv_usec = (t % CDF_TIME_PREC) * CDF_TIME_PREC; t /= CDF_TIME_PREC; - tm.tm_sec = t % 60; + tm.tm_sec = (int)(t % 60); t /= 60; - tm.tm_min = t % 60; + tm.tm_min = (int)(t % 60); t /= 60; - tm.tm_hour = t % 24; + tm.tm_hour = (int)(t % 24); t /= 24; /* XXX: Approx */ - tm.tm_year = CDF_BASE_YEAR + (t / 365); + tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365)); rdays = cdf_getdays(tm.tm_year); - t -= rdays; - tm.tm_mday = cdf_getday(tm.tm_year, t); - tm.tm_mon = cdf_getmonth(tm.tm_year, t); + t -= rdays - 1; + tm.tm_mday = cdf_getday(tm.tm_year, (int)t); + tm.tm_mon = cdf_getmonth(tm.tm_year, (int)t); tm.tm_wday = 0; tm.tm_yday = 0; tm.tm_isdst = 0; @@ -143,10 +143,13 @@ cdf_timestamp_to_timespec(struct timeval *ts, cdf_time } int +/*ARGSUSED*/ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timeval *ts) { +#ifndef __lint__ (void)&t; (void)&ts; +#endif #ifdef notyet struct tm tm; if (gmtime_r(&ts->ts_sec, &tm) == NULL) { @@ -162,7 +165,19 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const st return 0; } +char * +cdf_ctime(const time_t *sec) +{ + static char ctbuf[26]; + char *ptr = ctime(sec); + if (ptr != NULL) + return ptr; + (void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n", + (long long)*sec); + return ctbuf; +} + #ifdef TEST int main(int argc, char *argv[]) @@ -173,7 +188,7 @@ main(int argc, char *argv[]) char *p, *q; cdf_timestamp_to_timespec(&ts, tst); - p = ctime(&ts.tv_sec); + p = cdf_ctime(&ts.tv_sec); if ((q = strchr(p, '\n')) != NULL) *q = '\0'; if (strcmp(ref, p) != 0)