local ExtUtils = {} local cjson = require "cjson" function getManifest() local fn = Helix.Core.Server.GetArchDirFileName( "manifest.json" ) local fh = assert( io.open( fn, "r" ) ) local m = cjson.decode( fh:read( "*all" ) ) fh:close() return m end function trim( s ) return ( s:gsub( "^%s*(.-)%s*$", "%1" ) ) end function getGCfg() local cfg = {} -- There's also GetInstanceConfigData() for k, v in pairs( Helix.Core.Server.GetGlobalConfigData() ) do cfg[ k ] = trim( v ) end return cfg end function ExtUtils.getID() return ExtUtils.manifest[ "name" ] .. "/" .. ExtUtils.manifest[ "key" ] .. "/" .. ExtUtils.manifest[ "version_name" ] end function ExtUtils.msgHeader() return ExtUtils.getID() .. ": " end ExtUtils.manifest = {} ExtUtils.gCfgData = {} function ExtUtils.init() if ExtUtils.gCfgData[ "Swarm-URL" ] == nil then ExtUtils.gCfgData = getGCfg() end if ExtUtils.manifest[ "key" ] == nil then ExtUtils.manifest = getManifest() end end return ExtUtils