From 0029e0bd39309aa829c30151e67e9367c4b82436 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 12 Dec 2011 21:33:04 -0800 Subject: [PATCH] hivexml: Increase filetime resolution to sub-second This patch uses nstrftime to increase the resolution of ISO 8601 printing of hive internal mtimes. To include gnulib's strftime header, the bootstrap and generated .gitignore files need to note strftime files. --- bootstrap | 1 + m4/.gitignore | 3 +++ xml/hivexml.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bootstrap b/bootstrap index b2960c1..538d6b7 100755 --- a/bootstrap +++ b/bootstrap @@ -68,6 +68,7 @@ inttypes maintainer-makefile manywarnings progname +strftime strndup vasprintf vc-list-files diff --git a/m4/.gitignore b/m4/.gitignore index c25720c..e68c86c 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -130,3 +130,6 @@ /xalloc.m4 /xsize.m4 /xstrtol.m4 +/strftime.m4 +/time_r.m4 +/tm_gmtoff.m4 diff --git a/xml/hivexml.c b/xml/hivexml.c index d38e9d4..e88994c 100644 --- a/xml/hivexml.c +++ b/xml/hivexml.c @@ -47,6 +47,8 @@ //#define N_(str) str #endif +#include "strftime.h" + static char *filetime_to_8601 (int64_t windows_ticks); /* Callback functions. */ @@ -187,6 +189,7 @@ filetime_to_8601 (int64_t windows_ticks) char *ret; time_t t; struct tm *tm; + int64_t fractional_nanoseconds; if (windows_ticks == 0LL) return NULL; @@ -196,13 +199,15 @@ filetime_to_8601 (int64_t windows_ticks) if (tm == NULL) return NULL; - ret = malloc (TIMESTAMP_BUF_LEN); + fractional_nanoseconds = 100 * (windows_ticks % WINDOWS_TICK); + + ret = calloc (TIMESTAMP_BUF_LEN, sizeof (char)); if (ret == NULL) { - perror ("malloc"); + perror ("calloc"); exit (EXIT_FAILURE); } - if (strftime (ret, TIMESTAMP_BUF_LEN, "%FT%TZ", tm) == 0) { + if (nstrftime (ret, TIMESTAMP_BUF_LEN, "%FT%T.%NZ", tm, 1, fractional_nanoseconds) == 0) { perror ("strftime"); exit (EXIT_FAILURE); } -- 1.7.6.4