local ExtUtils = {} local cjson = require "cjson" function ExtUtils.slurpFile( name ) local f = assert( io.open( name, "rb" ) ) local content = f:read( "*all" ) f:close() return content end function ExtUtils.writeFile( name, content ) local f = assert( io.open( name, "w" ) ) local content = f:write( content ) f:close() end function getManifest() local fn = Helix.Core.Server.GetArchDirFileName( "manifest.json" ) return cjson.decode( ExtUtils.slurpFile( fn ) ) end function trim( s ) return ( s:gsub( "^%s*(.-)%s*$", "%1" ) ) end function getICfg() local cfg = {} for k, v in pairs( Helix.Core.Server.GetInstanceConfigData() ) do cfg[ k ] = trim( v ) end return cfg end function ExtUtils.msgHeader() return ExtUtils.manifest[ "name" ] .. "/" .. ExtUtils.manifest[ "key" ] .. "/" .. ExtUtils.manifest[ "version_name" ] .. ": " end ExtUtils.manifest = {} ExtUtils.iCfgData = {} function ExtUtils.init() if ExtUtils.iCfgData[ "specName" ] == nil then ExtUtils.iCfgData = getICfg() -- todo: split the user list into another table end if ExtUtils.manifest[ "key" ] == nil then ExtUtils.manifest = getManifest() end end return ExtUtils