diff --git a/DependencyResolver.Mod b/DependencyResolver.Mod index 4b8850c..c215a2a 100644 --- a/DependencyResolver.Mod +++ b/DependencyResolver.Mod @@ -39,7 +39,7 @@ BEGIN dependencies.GetTerminalKeys(dependencies, keys); - FOR i := 0 TO dependencies.TerminalNumber - 1 DO (* TODO: rewrite this logic to work with key count *) + FOR i := 0 TO dependencies.TerminalNumber - 1 DO (* TODO: rewrite with working getter everywhere*) keyFound := dependencies.GetTerminal(dependencies, keys[i], version); IF ~keyFound THEN Logger.Log('ERROR while searching key'); Logger.Log(keys[i]); END; @@ -60,7 +60,6 @@ BEGIN Settings.port, filePath, keys[i], - version, Settings.packageFileName, returnedJSON ); @@ -90,30 +89,27 @@ END ResolveVersionFiles; PROCEDURE ResolvePackages*(); VAR - i, j: LONGINT; + i: LONGINT; keyFound: BOOLEAN; jsonRecord, filesRecord: JsonParser.JsonTypePointer; - values: ARRAY ArrayMaxNumber OF JsonParser.TString; - host, port, path, packageName, version: JsonParser.TString; + values: ARRAY 10 OF JsonParser.TString; + host, port, path, packageName, version: ARRAY 50 OF CHAR; BEGIN FOR i := 0 TO j - 1 DO - IF ~Strings.Match(moduleNames[i], "") THEN - jsonRecord := JsonParser.Create(moduleJson[i]); - filesRecord := jsonRecord.GetNonTerminal(jsonRecord, "Files"); - - IF filesRecord = NIL THEN - Logger.Log("Error: no files section found"); - END; - - ASSERT(filesRecord # NIL); - keyFound := jsonRecord.GetTerminal(jsonRecord, "Remote", host); - keyFound := jsonRecord.GetTerminal(jsonRecord, "Port", port); - keyFound := jsonRecord.GetTerminal(jsonRecord, "Path", path); - keyFound := jsonRecord.GetTerminal(jsonRecord, "Package", packageName); - keyFound := jsonRecord.GetTerminal(jsonRecord, "Version", version); - filesRecord.GetTerminalValues(filesRecord, values); - PackageResolver.Resolve(host, port, path, packageName, version, values); + jsonRecord := JsonParser.Create(moduleJson[i]); + filesRecord := jsonRecord.GetNonTerminal(jsonRecord, "Files"); + + IF filesRecord = NIL THEN + Logger.Log("Error: no files section found"); END; + + ASSERT(filesRecord # NIL); + keyFound := jsonRecord.GetTerminal(jsonRecord, "Remote", host); + keyFound := jsonRecord.GetTerminal(jsonRecord, "Port", port); + keyFound := jsonRecord.GetTerminal(jsonRecord, "Path", path); + keyFound := jsonRecord.GetTerminal(jsonRecord, "Package", packageName); + keyFound := jsonRecord.GetTerminal(jsonRecord, "Version", version); + PackageResolver.Resolve(host, port, path, packageName, version, filesRecord.TerminalValues); (* TODO: filesRecord.TerminalValues create working getter for this*) END; END ResolvePackages; diff --git a/JsonParser.Mod b/JsonParser.Mod index 9340d50..2144137 100644 --- a/JsonParser.Mod +++ b/JsonParser.Mod @@ -26,7 +26,7 @@ TYPE GetNonTerminalNumber* : PROCEDURE(self : JsonTypePointer): LONGINT; TerminalKeys : ARRAY ArrayMaxNumber OF TString; - TerminalValues : ARRAY ArrayMaxNumber OF TString; + TerminalValues* : ARRAY ArrayMaxNumber OF TString; TerminalNumber* : LONGINT; NonTerminalKeys : ARRAY ArrayMaxNumber OF TString; @@ -113,7 +113,7 @@ PROCEDURE GetTerminalValues(self : JsonTypePointer; VAR destination : ARRAY OF T VAR i: LONGINT; BEGIN - FOR i := 0 TO LEN(self.TerminalValues) - 1 DO + FOR i := 0 TO self.TerminalNumber - 1 DO Empty(destination[i]); COPY(self.TerminalValues[i], destination[i]); END; diff --git a/PackageFileParser.Mod b/PackageFileParser.Mod index 71ca8b9..f1f816b 100644 --- a/PackageFileParser.Mod +++ b/PackageFileParser.Mod @@ -23,6 +23,10 @@ BEGIN DependencyResolver.ResolveVersionFiles(jsonData); DependencyResolver.ResolvePackages(); + Logger.Log("======================"); + Logger.Log("======================"); + Logger.Log("Installation complete"); + Logger.Log("Thanks for using OPIUM!"); END install; BEGIN diff --git a/PackageResolver.Mod b/PackageResolver.Mod index 8478e87..90cb62a 100644 --- a/PackageResolver.Mod +++ b/PackageResolver.Mod @@ -3,16 +3,24 @@ IMPORT FileManager, http, Strings, Logger, Settings, JsonParser; CONST ArrayMaxNumber = 1000; -PROCEDURE ResolveFile *(host, port, path, packageName, version, fileName : ARRAY OF CHAR; VAR returnValue : ARRAY OF CHAR); +PROCEDURE ResolveFile *(host, port, path, packageName, fileName : ARRAY OF CHAR; VAR returnValue : ARRAY OF CHAR); VAR localPath: ARRAY ArrayMaxNumber OF CHAR; isSuccessfull: BOOLEAN; BEGIN + Logger.Log('path'); + Logger.Log(path); http.get(host, port, path, returnValue); http.getClean(returnValue, returnValue); isSuccessfull := FileManager.CreateDirectory(packageName, Settings.installPath); - + + IF ~isSuccessfull THEN Logger.Log("Something went wrong, while downloading files") END; + ASSERT(isSuccessfull); + Logger.Log(path); + + Logger.Log(packageName); COPY(Settings.installPath, localPath); + Strings.Append("/", localPath); Strings.Append(packageName, localPath); Strings.Append("/", localPath); @@ -25,11 +33,16 @@ END ResolveFile; PROCEDURE Resolve *(host, port, path, packageName, version: ARRAY OF CHAR; files: ARRAY OF JsonParser.TString); VAR i : LONGINT; - returnValue: JsonParser.TString; + helperString: ARRAY 10000 OF CHAR; BEGIN + Strings.Append("/", path); FOR i := 0 TO LEN(files) - 1 DO IF ~Strings.Match(files[i], "") THEN - ResolveFile(host, port, path, packageName, version, files[i], returnValue); + JsonParser.Empty(helperString); + COPY(path, helperString); + Strings.Append(files[i], helperString); + + ResolveFile(host, port, helperString, packageName, files[i], helperString); END; END; END Resolve; diff --git a/http.Mod b/http.Mod index 5f339a1..227c573 100644 --- a/http.Mod +++ b/http.Mod @@ -1,8 +1,8 @@ MODULE http; IMPORT Strings, Internet, Logger, Out; CONST - MAXARRAYNUMBER = 1000; - MAXARRAYNUMBEREXTENDED = 10000; + MAXARRAYNUMBER = 10000; + MAXARRAYNUMBEREXTENDED = 100000; TYPE PSTRING = POINTER TO ARRAY OF CHAR; @@ -131,7 +131,8 @@ BEGIN (* Out.Real(valueContentLength, 6); Out.Ln; Logger.LogIntLn(Strings.Length(buff)); - Logger.Log(buff); *) + *) + Logger.Log(buff); UNTIL ~connectionFlag OR (Strings.Length(buff) > valueContentLength); Internet.Disconnect(socket); END get;