mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
PackageManager: HTML Log
svn path=/trunk/; revision=14791
This commit is contained in:
parent
88d6fe5cb4
commit
63b33dd9b3
3 changed files with 39 additions and 21 deletions
|
@ -27,7 +27,7 @@ int FindCount (string What, string Where, int start = 0, int end = -1);
|
||||||
|
|
||||||
|
|
||||||
// Download a file
|
// 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;
|
UINT i;
|
||||||
static char downl [MAX_PATH]; // the full url
|
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, "\\"))
|
else if(!strstr(filename, "\\"))
|
||||||
GetTempPathA (200, path);
|
GetTempPathA (200, path);
|
||||||
|
|
||||||
|
else
|
||||||
|
strcpy(path, "");
|
||||||
|
|
||||||
|
|
||||||
// create the local file name
|
// create the local file name
|
||||||
if(filename)
|
if(filename)
|
||||||
|
@ -51,7 +55,7 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
|
||||||
DeleteFileA (path);
|
DeleteFileA (path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GetTempFileNameA (path, "pml", 0, path);
|
GetTempFileNameA (path, "pml", 1, path);
|
||||||
|
|
||||||
// get the url
|
// get the url
|
||||||
if (!server)
|
if (!server)
|
||||||
|
@ -76,12 +80,11 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
|
||||||
|
|
||||||
// is this a file link ?
|
// is this a file link ?
|
||||||
if (strstr(downl, "file://") || strstr(downl, "File://"))
|
if (strstr(downl, "file://") || strstr(downl, "File://"))
|
||||||
{/*
|
{
|
||||||
if(downl[strlen(downl)] == '\')
|
|
||||||
downl[strlen(downl)] = '\0';
|
|
||||||
*/
|
|
||||||
if(!filename)
|
if(!filename)
|
||||||
|
{
|
||||||
return &downl[7];
|
return &downl[7];
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -90,6 +93,7 @@ char* PML_Download (pTree tree, const char* url, const char* server = "tree", co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// download the file
|
// download the file
|
||||||
if(URLDownloadToFileA (NULL, downl, path, 0, NULL) != S_OK)
|
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
|
// download the file
|
||||||
if(strstr(url, "file://"))
|
if(strstr(url, "file://"))
|
||||||
filename = PML_Download(tree, url, NULL);
|
filename = PML_Download(tree, url, NULL, NULL);
|
||||||
|
|
||||||
else
|
else
|
||||||
filename = PML_Download(tree, url);
|
filename = PML_Download(tree, url);
|
||||||
|
@ -132,8 +136,7 @@ int PML_XmlDownload (pTree tree, const char* url, void* usrdata,
|
||||||
FILE* file = fopen(filename, "r");
|
FILE* file = fopen(filename, "r");
|
||||||
if(!file)
|
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);
|
LogAdd(filename);
|
||||||
return ERR_GENERIC;
|
return ERR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,14 @@ void Log (const char *message)
|
||||||
char version[50];
|
char version[50];
|
||||||
char versionos[50];
|
char versionos[50];
|
||||||
|
|
||||||
if (!LogCreated) {
|
if (!LogCreated)
|
||||||
|
{
|
||||||
file = fopen(LOGFILE, "w");
|
file = fopen(LOGFILE, "w");
|
||||||
LogCreated = true;
|
LogCreated = true;
|
||||||
|
|
||||||
|
//HTML Header
|
||||||
|
fputs("<html><head><title>Logfile</title></head><body>", file);
|
||||||
|
|
||||||
// date and time
|
// date and time
|
||||||
time_t now;
|
time_t now;
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
@ -49,32 +53,43 @@ void Log (const char *message)
|
||||||
KERNEL_VERSION_MINOR,
|
KERNEL_VERSION_MINOR,
|
||||||
KERNEL_VERSION_PATCH_LEVEL);
|
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(GTime, file);
|
||||||
fputs("\n#\n#", file);
|
fputs("<br>\n", file);
|
||||||
fputs(version, file);
|
|
||||||
fputs("\n#", file);
|
fputs(version, file);
|
||||||
fputs(versionos, file);
|
fputs("<br>\n", file);
|
||||||
fputs("\n#\n", file);
|
fputs(versionos, file);
|
||||||
|
fputs("<br>\n", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
file = fopen(LOGFILE, "a");
|
file = fopen(LOGFILE, "a");
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL)
|
||||||
|
{
|
||||||
if (LogCreated)
|
if (LogCreated)
|
||||||
LogCreated = false;
|
LogCreated = false;
|
||||||
|
|
||||||
return;
|
return Log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Save log entry (+ add time)
|
// Save log entry (+ add time)
|
||||||
fputs("\n", file);
|
fputs("<br>\n", file);
|
||||||
|
|
||||||
time_t now;
|
time_t now;
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
strftime(GTime,sizeof GTime,"%I:%M:%S %p ",localtime(&now));
|
strftime(GTime,sizeof GTime,"%I:%M:%S %p ",localtime(&now));
|
||||||
|
|
||||||
|
fputs("<b>", file);
|
||||||
fputs(GTime, file);
|
fputs(GTime, file);
|
||||||
|
fputs("</b>", file);
|
||||||
|
|
||||||
fputs(message, file);
|
fputs(message, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define LOGFILE "packmgr.log"
|
#define LOGFILE "logfile.html"
|
||||||
|
|
||||||
extern bool LogCreated;
|
extern bool LogCreated;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue