summaryrefslogtreecommitdiffstats
path: root/src/misc.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-04-24 22:36:38 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2011-04-24 22:36:38 +0200
commitf92fc3aee0da23384af76ac4022bbd50b38c5e64 (patch)
tree7551d2e9b7cca4ae5de0bb99dd226cc93995b902 /src/misc.c
parentc8802ff4cdebc1de318f22d490d2f124abd6138e (diff)
Try to convert the compilation date to the ISO format
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/misc.c b/src/misc.c
index 8dbd213..2c92804 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -35,6 +35,12 @@
#ifdef HAVE_SYS_UTSNAME_H
# include <sys/utsname.h>
#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
#ifdef HAVE_CYGWIN_VERSION_H
#include <cygwin/version.h>
#endif
@@ -154,11 +160,12 @@ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/ge
return "DOS";
#elif defined(HAVE_SYS_UTSNAME_H)
{
- struct utsname Ver;
+ struct utsname Ver;
if(uname(&Ver)==0)
{
static char buffer[100] = {0x00};
- snprintf(buffer, sizeof(buffer) - 1, "%s, kernel %s (%s) %s", Ver.sysname, Ver.release, Ver.version, Ver.machine);
+ snprintf(buffer, sizeof(buffer) - 1, "%s, kernel %s (%s) %s",
+ Ver.sysname, Ver.release, Ver.version, Ver.machine);
return buffer;
}
}
@@ -253,11 +260,23 @@ const char *get_compilation_date(void)
{
static char buffer[100] = {0x00};
#ifdef __DATE__
+#ifdef HAVE_STRPTIME
+ struct tm tm;
+ memset(&tm,0,sizeof(tm));
+ if(strptime(__DATE__, "%b %d %Y", &tm)!=NULL)
+ sprintf(buffer, "%4d-%02d-%02dT", tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday);
+ else
+ strcpy(buffer, __DATE__);
+#ifdef __TIME__
+ strcat(buffer, __TIME__);
+#endif
+#else
strcpy(buffer, __DATE__);
#ifdef __TIME__
strcat(buffer, " ");
strcat(buffer, __TIME__);
#endif
#endif
+#endif
return buffer;
}