+2011-02-10 12:03 Christos Zoulas <christos@zoulas.com>
+
+ * add cdf_ctime() that prints a meaningful error when time cannot
+ be converted.
+
2011-02-02 20:40 Christos Zoulas <christos@zoulas.com>
* help and version output to stdout.
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.39 2010/07/22 21:59:42 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.40 2011/02/03 01:43:07 christos Exp $")
#endif
#include <assert.h>
(void)fprintf(stderr, "Right child: %d\n", d->d_right_child);
(void)fprintf(stderr, "Flags: 0x%x\n", d->d_flags);
cdf_timestamp_to_timespec(&ts, d->d_created);
- (void)fprintf(stderr, "Created %s", ctime(&ts.tv_sec));
+ (void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec));
cdf_timestamp_to_timespec(&ts, d->d_modified);
- (void)fprintf(stderr, "Modified %s", ctime(&ts.tv_sec));
+ (void)fprintf(stderr, "Modified %s", cdf_ctime(&ts.tv_sec));
(void)fprintf(stderr, "Stream %d\n", d->d_stream_first_sector);
(void)fprintf(stderr, "Size %d\n", d->d_size);
switch (d->d_type) {
} else {
cdf_timestamp_to_timespec(&ts, tp);
(void)fprintf(stderr, "timestamp %s",
- ctime(&ts.tv_sec));
+ cdf_ctime(&ts.tv_sec));
}
break;
case CDF_CLIPBOARD:
uint16_t cdf_tole2(uint16_t);
uint32_t cdf_tole4(uint32_t);
uint64_t cdf_tole8(uint64_t);
+char *cdf_ctime(const time_t *);
#ifdef CDF_DEBUG
void cdf_dump_header(const cdf_header_t *);
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.8 2009/06/20 20:47:30 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.9 2010/10/02 15:36:15 christos Exp $")
#endif
#include <time.h>
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
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)
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.22 2010/01/20 01:36:55 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.23 2010/02/20 15:19:53 rrt Exp $")
#endif
#include <stdlib.h>
} else {
char *c, *ec;
cdf_timestamp_to_timespec(&ts, tp);
- c = ctime(&ts.tv_sec);
+ c = cdf_ctime(&ts.tv_sec);
if ((ec = strchr(c, '\n')) != NULL)
*ec = '\0';