98 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| function rti_decompress_string(inString, status)
 | |
| *#!Precompile
 | |
| /*
 | |
| *  This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without
 | |
| *  written permission from Revelation Technologies, Inc.
 | |
| !
 | |
| *  No warranties, express or implied, are conveyed by the use of this routine
 | |
| !
 | |
| *  VERSION    : 1.0
 | |
| *
 | |
| *
 | |
| *  AUTHOR     : Bryan Shumsky
 | |
| *
 | |
| *  CREATED    : February 16, 2022
 | |
| *
 | |
| *
 | |
| !
 | |
| *
 | |
| *  REVISION HISTORY           (Most CURRENT first) :
 | |
| *
 | |
| *    DATE       IMPLEMENTOR     FUNCTION
 | |
| *  --------     -----------     --------
 | |
| *
 | |
| */
 | |
| 
 | |
| $Insert RevDotNetEquates
 | |
| 
 | |
| If Assigned(inString) Else inString = ""
 | |
| Status = 0
 | |
| rslt = ""
 | |
| 
 | |
| If inString = "" Then
 | |
|      Status = "-2"
 | |
|      Return rslt
 | |
| End
 | |
| 
 | |
| dotNetHandle = ""
 | |
| dotNetVersion = "4.0"
 | |
| oNet = StartDotNet("", dotNetVersion, dotNetHandle)
 | |
| if Get_Status(errcode) Then
 | |
|      Goto returnErr
 | |
| End
 | |
| netLocn = CheckDotNet(dotNetVersion)
 | |
| If netLocn <> "0" And netLocn <> "" Then
 | |
|      If netLocn[-1,1] <> "\" Then netLocn := "\"
 | |
| End Else netLocn = ""
 | |
| oiLocn = drive()
 | |
| If oiLocn[-1,1] <> "\" Then oiLocn := "\"
 | |
| x = set_property.net(oNet, "AssemblyName", netLocn:"System.dll":@fm:netLocn:"mscorlib.dll", dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| 
 | |
| * step 1: convert from base64 string to an array of bytes
 | |
| oConverter = create_class.net(oNet, "System.Convert", 0, "", "", dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| oBytes = send_message.net(oConverter, "FromBase64String", inString, "", 1, dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| 
 | |
| * step 2: make a "memory stream" from that byte array
 | |
| oInputStream = create_class.net(oNet, "System.IO.MemoryStream", 0, oBytes, "", dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| 
 | |
| * step 3: use gzipstream to decompress the incoming memory stream to an outgoing memory stream
 | |
| oOutputStream = create_class.net(oNet, "System.IO.MemoryStream", 0, "", "", dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| oCompressor = create_class.net(oNet, "System.IO.Compression.GZipStream", 0, oInputStream:@FM:"0":@FM:"True", "":@FM:"System.IO.Compression.CompressionMode":@FM:"System.Boolean", dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| dummy = send_message.net(oCompressor, "CopyTo", oOutputStream, "", 0, dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| * note: must close the gzipstream to "flush" the contents
 | |
| dummy = send_message.net(oCompressor, "Close", "", "", 0, dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| 
 | |
| * step 4: turn the outgoing memory stream into an array of bytes
 | |
| oDecompressed = send_message.net(oOutputStream, "ToArray", "", "", 1, dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| * note: must close the streams
 | |
| dummy = send_message.net(oOutputStream, "Close", "", "", 0, dotNetHandle)
 | |
| dummy = send_message.net(oInputStream, "Close", "", "", 0, dotNetHandle)
 | |
| 
 | |
| * step 5: turn the array of bytes into a UTF8 string
 | |
| oEncoding = create_class.net(oNet, "System.Text.UTF8Encoding", 0, "", "", dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| rslt = send_message.net(oEncoding, "GetString", oDecompressed, "", 0, dotNetHandle)
 | |
| If Get_Status(errcode) Then Goto returnErr
 | |
| 
 | |
| Goto wrapup
 | |
| 
 | |
| returnErr:
 | |
| * error handling here
 | |
| * Do something With errcode
 | |
| Status = "-1"
 | |
| 
 | |
| 
 | |
| wrapup:
 | |
| free_class.net("", dotNetHandle)
 | |
| 
 | |
| Return rslt
 |