diff --git a/lib/download.cpp b/lib/download.cpp index 41761dd..cf035e6 100644 --- a/lib/download.cpp +++ b/lib/download.cpp @@ -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; } diff --git a/lib/log.cpp b/lib/log.cpp index 94b583f..a60d9ba 100644 --- a/lib/log.cpp +++ b/lib/log.cpp @@ -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("Logfile", 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("

ReactOS Package Manager - Log File


\n", file); + fputs("WARNING: This is still pre-alpha software.
\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("
\n", file); + + fputs(version, file); + fputs("
\n", file); + fputs(versionos, file); + fputs("
\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("
\n", file); + time_t now; now = time(NULL); strftime(GTime,sizeof GTime,"%I:%M:%S %p ",localtime(&now)); + + fputs("", file); fputs(GTime, file); + fputs("", file); + fputs(message, file); fclose(file); } diff --git a/lib/log.h b/lib/log.h index d04e29e..a4cda6f 100644 --- a/lib/log.h +++ b/lib/log.h @@ -13,7 +13,7 @@ #include #include -#define LOGFILE "packmgr.log" +#define LOGFILE "logfile.html" extern bool LogCreated;