|
@@ -39,6 +39,7 @@
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <ctype.h>
|
|
|
+#include <time.h>
|
|
|
|
|
|
#define RESULT_OK 0
|
|
|
#define RESULT_GENERAL_ERROR 1
|
|
@@ -121,6 +122,39 @@ static char CalcTolower(char Lower)
|
|
|
return c;
|
|
|
}
|
|
|
|
|
|
+// Fill internal structures with time information
|
|
|
+static void ComputeTimeInformation(PROGRAM *Program)
|
|
|
+{
|
|
|
+ // Get the timestamp.
|
|
|
+ if (time(&Program->LinkTime.LinkTime) != (time_t)-1)
|
|
|
+ {
|
|
|
+ struct tm * broken_down_time;
|
|
|
+
|
|
|
+ broken_down_time = gmtime(&Program->LinkTime.LinkTime);
|
|
|
+ if (broken_down_time != NULL) {
|
|
|
+ // gmtime returns the number of years since 1900.
|
|
|
+ Program->LinkTime.year = broken_down_time->tm_year + 1900;
|
|
|
+ // gmtime returns the month between 0 and 11.
|
|
|
+ Program->LinkTime.month = broken_down_time->tm_mon + 1;
|
|
|
+ Program->LinkTime.day = broken_down_time->tm_mday;
|
|
|
+ // Convert from "seconds since Jan 1, 1970" to "seconds since Jan 1, 1997".
|
|
|
+ // 197x: 8x365 days, 2x366 days (leap years: 1972, 1976) => 315532800 seconds
|
|
|
+ // 198x: 7x365 days, 3x366 days (leap years: 1980, 1984, 1988) => 315619200 seconds
|
|
|
+ // 199x: 5x365 days, 2x366 days (leap years: 1992, 1996) => 220924800 seconds
|
|
|
+ // Total: 852076800 seconds.
|
|
|
+ Program->LinkTime.LinkTime -= (time_t)852076800L;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Failed, so set dummy values.
|
|
|
+ Warning (NULL, "Couldn't get current time, setting dummy values.");
|
|
|
+ Program->LinkTime.LinkTime = (time_t)0,
|
|
|
+ Program->LinkTime.year = 1997,
|
|
|
+ Program->LinkTime.month = 1,
|
|
|
+ Program->LinkTime.day = 1;
|
|
|
+}
|
|
|
+
|
|
|
int main (int ArgCount, const char **Args)
|
|
|
{
|
|
|
OPTIMIZE_INFO _OptimizeInfo;
|
|
@@ -169,6 +203,9 @@ int main (int ArgCount, const char **Args)
|
|
|
|
|
|
// Initialize.
|
|
|
memset (&Program, 0, sizeof (Program));
|
|
|
+
|
|
|
+ ComputeTimeInformation(&Program);
|
|
|
+
|
|
|
Program.EntryPoint.SymbolName = "__entry_point";
|
|
|
#ifdef TARGET_EMBEDDED
|
|
|
ErrorFunction = ErrorMessage;
|