/*
* Principal Author: Brian Wellington
- * $Id: dst_api.c,v 1.49 2010/01/11 23:48:37 tbox Exp $
+ * $Id: dst_api.c,v 1.50 2010/05/12 23:49:40 marka Exp $
*/
/*! \file */
#include <isc/lex.h>
#include <isc/mem.h>
#include <isc/once.h>
+#include <isc/platform.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/string.h>
static void
printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
isc_result_t result;
+#ifdef ISC_PLATFORM_USETHREADS
+ char output[26]; /* Minimum buffer as per ctime_r() specification. */
+#else
const char *output;
+#endif
isc_stdtime_t when;
time_t t;
+ char utc[sizeof("YYYYMMDDHHSSMM")];
+ isc_buffer_t b;
+ isc_region_t r;
result = dst_key_gettime(key, type, &when);
if (result == ISC_R_NOTFOUND)
/* time_t and isc_stdtime_t might be different sizes */
t = when;
+#ifdef ISC_PLATFORM_USETHREADS
+#ifdef WIN32
+ if (ctime_s(output, sizeof(output), &t) != 0)
+ goto error;
+#else
+ if (ctime_r(&t, outout) == NULL)
+ goto error;
+#endif
+#else
output = ctime(&t);
- fprintf(stream, "%s: %s", tag, output);
+#endif
+
+ isc_buffer_init(&b, utc, sizeof(utc));
+ result = dns_time32_totext(when, &b);
+ if (result != ISC_R_SUCCESS)
+ goto error;
+
+ isc_buffer_usedregion(&b, &r);
+ fprintf(stream, "%s: %.*s (%.*s)\n", tag, (int)r.length, r.base,
+ strlen(output) - 1, output);
+ return;
+
+ error:
+ fprintf(stream, "%s: (set, unable to display)\n", tag);
}
/*%