2005-04-03 19:06:49 +00:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// log.cpp
|
|
|
|
//
|
|
|
|
// Script Functions
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Klemens Friedl, 19.03.2005
|
|
|
|
// frik85@hotmail.com
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "package.hpp" // for Package Manager version
|
|
|
|
#include <reactos/version.h> // ReactOS version: \reactos\include\reactos\version.h
|
|
|
|
|
|
|
|
bool LogCreated = false;
|
|
|
|
|
|
|
|
void Log (const char *message)
|
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
char GTime[80];
|
|
|
|
char version[50];
|
|
|
|
char versionos[50];
|
|
|
|
|
2005-04-24 10:37:17 +00:00
|
|
|
if (!LogCreated)
|
|
|
|
{
|
2005-04-03 19:06:49 +00:00
|
|
|
file = fopen(LOGFILE, "w");
|
|
|
|
LogCreated = true;
|
|
|
|
|
2005-04-24 10:37:17 +00:00
|
|
|
//HTML Header
|
2005-05-16 10:53:46 +00:00
|
|
|
fputs("<html><head><title>Logfile</title></head><body>\n", file);
|
2005-04-24 10:37:17 +00:00
|
|
|
|
2005-04-03 19:06:49 +00:00
|
|
|
// date and time
|
|
|
|
time_t now;
|
|
|
|
now = time(NULL);
|
|
|
|
strftime(GTime,sizeof GTime,"%Y-%m-%d",localtime(&now));
|
|
|
|
|
|
|
|
// package manager version information
|
|
|
|
wsprintfA(version, " Package Manager %d.%d.%d",
|
|
|
|
PACKMGR_VERSION_MAJOR,
|
|
|
|
PACKMGR_VERSION_MINOR,
|
|
|
|
PACKMGR_VERSION_PATCH_LEVEL);
|
|
|
|
|
|
|
|
// operating system version information
|
|
|
|
wsprintfA(versionos, " ReactOS %d.%d.%d",
|
|
|
|
KERNEL_VERSION_MAJOR,
|
|
|
|
KERNEL_VERSION_MINOR,
|
|
|
|
KERNEL_VERSION_PATCH_LEVEL);
|
|
|
|
|
2005-05-16 10:53:46 +00:00
|
|
|
// write the head
|
|
|
|
fputs("<h2>ReactOS Package Manager - Log File</h2>\n", file);
|
|
|
|
//fputs("WARNING: This is still pre-alpha software.<br>\n", file);
|
2005-04-24 10:37:17 +00:00
|
|
|
|
|
|
|
fputs("Date: ", file);
|
2005-04-03 19:06:49 +00:00
|
|
|
fputs(GTime, file);
|
2005-04-24 10:37:17 +00:00
|
|
|
fputs("<br>\n", file);
|
|
|
|
|
2005-05-16 10:53:46 +00:00
|
|
|
fputs("Version: ", file);
|
2005-04-24 10:37:17 +00:00
|
|
|
fputs(version, file);
|
|
|
|
fputs("<br>\n", file);
|
2005-05-16 10:53:46 +00:00
|
|
|
|
|
|
|
fputs("OS: ", file);
|
2005-04-24 10:37:17 +00:00
|
|
|
fputs(versionos, file);
|
|
|
|
fputs("<br>\n", file);
|
2005-04-03 19:06:49 +00:00
|
|
|
}
|
2005-04-24 10:37:17 +00:00
|
|
|
|
2005-04-03 19:06:49 +00:00
|
|
|
else
|
|
|
|
file = fopen(LOGFILE, "a");
|
|
|
|
|
2005-04-24 10:37:17 +00:00
|
|
|
if (file == NULL)
|
|
|
|
{
|
2005-04-03 19:06:49 +00:00
|
|
|
if (LogCreated)
|
|
|
|
LogCreated = false;
|
|
|
|
|
2005-04-24 10:37:17 +00:00
|
|
|
return Log(message);
|
2005-04-03 19:06:49 +00:00
|
|
|
}
|
2005-04-24 10:37:17 +00:00
|
|
|
|
2005-04-03 19:06:49 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Save log entry (+ add time)
|
2005-04-24 10:37:17 +00:00
|
|
|
fputs("<br>\n", file);
|
|
|
|
|
2005-04-03 19:06:49 +00:00
|
|
|
time_t now;
|
|
|
|
now = time(NULL);
|
2005-05-16 10:53:46 +00:00
|
|
|
strftime(GTime,sizeof GTime,"%I:%M:%S %p",localtime(&now));
|
2005-04-24 10:37:17 +00:00
|
|
|
|
|
|
|
fputs("<b>", file);
|
2005-04-03 19:06:49 +00:00
|
|
|
fputs(GTime, file);
|
2005-05-16 10:53:46 +00:00
|
|
|
fputs("</b> ", file);
|
2005-04-24 10:37:17 +00:00
|
|
|
|
2005-04-03 19:06:49 +00:00
|
|
|
fputs(message, file);
|
|
|
|
fclose(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
fclose(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogAdd (const char *message)
|
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
|
|
|
|
file = fopen(LOGFILE, "a");
|
|
|
|
|
|
|
|
// Save log entry
|
|
|
|
fputs(message, file);
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
fclose(file);
|
|
|
|
}
|