#required V8.sbsl #required Sql.sbsl #required BracketsParser.sbsl #required BytesHelper.sbsl #required V8BracketsHelper.sbsl #required AnotherFuckingOneCFormatReader.sbsl #required ConfigInfo.sbsl @Global structure Class req val Connection: SqlConnection @Global method GetConfigInfo(): ConfigInfo.Class val Root = GetConfigFileDataAsBracketsNode("root") val Conf = GetConfigFileDataAsBracketsNode(Root.GetChildNode([1]).Value) return new ConfigInfo.Class( Conf.GetChildNode([3, 1, 1, 1, 1, 2]).AsString(), V8BracketsHelper.GetSysonym(Conf.GetChildNode([3, 1, 1, 1, 1, 3])), Conf.GetChildNode([3, 1, 1, 15]).AsString(), V8BracketsHelper.GetCompatibilityMode(Conf.GetChildNode([3, 1, 1, 26])) ) ; @Global method HasExtension(ExtensionName: String): Boolean val Query = Connection.CreateQueryWithSelect("SELECT Count(*) as Count FROM [dbo].[_ExtensionsInfo] WITH(NOLOCK) WHERE [_ExtName] = N'%ExtensionName'") use QResult = Query.Execute() QResult.Next() return (QResult.Get("Count") as Number) > 0 ; @Global method GetExtensionInfo(ExtensionName: String): ConfigInfo.Class val RawData = GetExtensionZippedInfo(ExtensionName) val Reader = AnotherFuckingOneCFormatReader.NewInstance(RawData, 2) Reader.ReadString() // FileName Reader.ReadByte() // Protect from danger actions " == Bytes {A2}" - is true Reader.ReadVarbinary() // Generation version Reader.ReadBoolean() // safe mode Reader.ReadBoolean() // unknown flag val BracketsNode = Reader.ReadBracketsNode() val Synonym = V8BracketsHelper.GetSysonym(BracketsNode.GetChildNode([2])) var Version = "0.0.0.0" if not BytesHelper.Contains(Bytes{8182}, Reader.Peek()) // extension version is specified Version = new String(Reader.ReadVarbinary()) ; return new ConfigInfo.Class( ExtensionName, Synonym, Version, "") ; method GetParamsFileDataAsBracketsNode(FileName: String): BracketsParser.BracketsNode return GetFileDataAsBracketsNode("Params", FileName) ; method GetConfigCASFileDataAsBracketsNode(FileName: String): Array return GetFileDataAsBracketsNodes("ConfigCAS", FileName) ; method GetConfigFileDataAsBracketsNode(FileName: String): BracketsParser.BracketsNode return GetFileDataAsBracketsNode("Config", FileName) ; method GetFileDataAsBracketsNodes(TableName: String, FileName: String): Array val Data = GetFileDataAsString(TableName, FileName) return BracketsParser.ParseList(Data) ; method GetFileDataAsBracketsNode(TableName: String, FileName: String): BracketsParser.BracketsNode val Data = GetFileDataAsString(TableName, FileName) return BracketsParser.Parse(Data) ; method GetFileDataAsString(TableName: String, FileName: String): String return new String(GetFileData(TableName, FileName), Encoding.Utf8) ; method GetFileData(TableName: String, FileName: String): Bytes val Query = Connection.CreateQueryWithSelect("SELECT CAST(DECOMPRESS(0x1F8B0800000000000400 + [BinaryData]) AS VARBINARY(MAX)) as Data FROM [dbo].[%TableName] WITH(NOLOCK) WHERE [FileName] = N'%FileName'") use QResult = Query.Execute() QResult.Next() val Result = QResult.Get("Data") as Bytes if Result.Length() > 3 and Result.GetRange(0, 3) == Bytes{EF BB BF} return Result.GetRange(3) else return Result ; ; method GetExtensionZippedInfo(ExtensionName: String): Bytes val Query = Connection.CreateQueryWithSelect("SELECT [_ExtensionZippedInfo] as Data FROM [dbo].[_ExtensionsInfo] WITH(NOLOCK) WHERE [_ExtName] = N'%ExtensionName'") use QResult = Query.Execute() QResult.Next() return QResult.Get("Data") as Bytes ; ; @Global method NewInstance(Connection: SqlConnection): Class return new Class(Connection) ;