Rework Configuration Load, it is possible to set directly a xml String or a file
This commit is contained in:
parent
e8651f7602
commit
beef8490f5
3 changed files with 17 additions and 9 deletions
|
@ -53,20 +53,28 @@
|
|||
EndIf
|
||||
EndProcedure
|
||||
|
||||
Procedure server_initial(ConfigFile.s)
|
||||
Procedure server_initial(ConfigOptions.s)
|
||||
;Initialize Webserver from the Config File(s)
|
||||
|
||||
Protected FileHandle.i, XMLHandle.i, DirectoryHandle.i
|
||||
Protected XMLReaded.s
|
||||
Protected XMLReaded.s, ConfigFile.s
|
||||
If Left(ConfigOptions, 5) = "file:"
|
||||
ConfigFile = RemoveString(ConfigOptions, "file:")
|
||||
FileHandle = ReadFile(#PB_Any, ConfigFile)
|
||||
If IsFile(FileHandle)
|
||||
XMLReaded = ReadString(FileHandle, #PB_File_IgnoreEOL)
|
||||
CloseFile(FileHandle)
|
||||
EndIf
|
||||
Else
|
||||
XMLReaded = ConfigOptions
|
||||
EndIf
|
||||
|
||||
If Len(XMLReaded) > 0
|
||||
XMLHandle = ParseXML(#PB_Any, XMLReaded)
|
||||
If XMLStatus(XMLHandle) = #PB_XML_Success
|
||||
ExtractXMLStructure(MainXMLNode(XMLHandle), @configuration, server, #PB_XML_NoCase)
|
||||
FreeXML(XMLHandle)
|
||||
;Now we need to load
|
||||
;Now we need to load additional Config Files
|
||||
ResetMap(configuration\config_file())
|
||||
While NextMapElement(configuration\config_file())
|
||||
Debug configuration\config_file()\configtype
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
;* Configuration functions.
|
||||
;*
|
||||
|
||||
Declare server_initial(ConfigFile.s)
|
||||
Declare server_initial(ConfigOptions.s)
|
||||
Declare.s server_get_config(Type.s, UUID.s = "")
|
|
@ -49,7 +49,7 @@ PrintN("Read Configuration:")
|
|||
;*
|
||||
;* Read Configuration http & https Server
|
||||
;*
|
||||
If lhs_web::server_initial("cfg/server_config.xml")
|
||||
If lhs_web::server_initial("file:cfg/server_config.xml")
|
||||
ldl::Logging("config succesfully loaded.")
|
||||
Else
|
||||
ldl::Logging("config load failed.")
|
||||
|
|
Loading…
Reference in a new issue