PackageManager: HTML Log

svn path=/trunk/rosapps/packmgr/; revision=32
This commit is contained in:
Maarten Bosma 2005-04-24 10:37:17 +00:00
parent be6c0f59df
commit ce1ac762c0
3 changed files with 39 additions and 21 deletions

View File

@ -27,7 +27,7 @@ int FindCount (string What, string Where, int start = 0, int end = -1);
// Download a file
char* PML_Download (pTree tree, const char* url, const char* server = "tree", const char* filename = NULL)
char* PML_Download (pTree tree, const char* url, const char* server = "tree", const char* filename = "packmgr.xml")
{
UINT i;
static char downl [MAX_PATH]; // the full url
@ -43,6 +43,10 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
else if(!strstr(filename, "\\"))
GetTempPathA (200, path);
else
strcpy(path, "");
// create the local file name
if(filename)
@ -51,7 +55,7 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
DeleteFileA (path);
}
else
GetTempFileNameA (path, "pml", 0, path);
GetTempFileNameA (path, "pml", 1, path);
// get the url
if (!server)
@ -76,12 +80,11 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
// is this a file link ?
if (strstr(downl, "file://") || strstr(downl, "File://"))
{/*
if(downl[strlen(downl)] == '\')
downl[strlen(downl)] = '\0';
*/
{
if(!filename)
{
return &downl[7];
}
else
{
@ -90,6 +93,7 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
}
}
// download the file
if(URLDownloadToFileA (NULL, downl, path, 0, NULL) != S_OK)
{
@ -116,7 +120,7 @@ int PML_XmlDownload (pTree tree, const char* url, void* usrdata,
// download the file
if(strstr(url, "file://"))
filename = PML_Download(tree, url, NULL);
filename = PML_Download(tree, url, NULL, NULL);
else
filename = PML_Download(tree, url);
@ -132,8 +136,7 @@ int PML_XmlDownload (pTree tree, const char* url, void* usrdata,
FILE* file = fopen(filename, "r");
if(!file)
{
MessageBoxA(0,filename,0,0);
Log("! ERROR: Could not open the xml file \"");
Log("! ERROR: Could not open the xml file ");
LogAdd(filename);
return ERR_GENERIC;
}

View File

@ -28,10 +28,14 @@ void Log (const char *message)
char version[50];
char versionos[50];
if (!LogCreated) {
if (!LogCreated)
{
file = fopen(LOGFILE, "w");
LogCreated = true;
//HTML Header
fputs("<html><head><title>Logfile</title></head><body>", file);
// date and time
time_t now;
now = time(NULL);
@ -49,32 +53,43 @@ void Log (const char *message)
KERNEL_VERSION_MINOR,
KERNEL_VERSION_PATCH_LEVEL);
fputs("# ReactOS Package Manager - Log File\n#\n# WARNING: This is still pre-alpha software.\n# Date: ", file);
fputs("<h2>ReactOS Package Manager - Log File</h2><br>\n", file);
fputs("WARNING: This is still pre-alpha software.<br>\n", file);
fputs("Date: ", file);
fputs(GTime, file);
fputs("\n#\n#", file);
fputs(version, file);
fputs("\n#", file);
fputs(versionos, file);
fputs("\n#\n", file);
fputs("<br>\n", file);
fputs(version, file);
fputs("<br>\n", file);
fputs(versionos, file);
fputs("<br>\n", file);
}
else
file = fopen(LOGFILE, "a");
if (file == NULL) {
if (file == NULL)
{
if (LogCreated)
LogCreated = false;
return;
return Log(message);
}
else
{
// Save log entry (+ add time)
fputs("\n", file);
fputs("<br>\n", file);
time_t now;
now = time(NULL);
strftime(GTime,sizeof GTime,"%I:%M:%S %p ",localtime(&now));
fputs("<b>", file);
fputs(GTime, file);
fputs("</b>", file);
fputs(message, file);
fclose(file);
}

View File

@ -13,7 +13,7 @@
#include <stdio.h>
#include <string.h>
#define LOGFILE "packmgr.log"
#define LOGFILE "logfile.html"
extern bool LogCreated;