3.1.1.1.3.9 Decompress

Decompresses a buffer of data.

Parameters

  • in UCHAR input: A buffer of compressed data.

  • in ULONG outputSize: The size of the original (uncompressed) data in bytes.

  • inout UCHAR output[outputSize]: A buffer into which the procedure writes the decompressed data.

Return Value

None

Remarks

While many of the FrsTransport methods are capable of compressing returned data, it is not always desirable or even possible to compress the returned data. FrsTransport methods that are capable of returning compressed data will always return information specifying the size of the original data. It is the caller’s responsibility to determine if the returned data is compressed. If the size of the compressed data buffer that is returned by the server in bytes is equal to the size in bytes of the original (uncompressed) data, then the buffer returned by the server contains uncompressed data.

Algorithm

 ULONG i := 0
 ULONG stopIndex := i + outputSize
 ULONG symbol
 ULONG length
 LONG offset
 PREFIX_CODE_NODE root
 PREFIX_CODE_NODE prefixCodeTreeNodes[1024]
 BITSTRING bstr
  
 root := PrefixCodeTreeRebuild(input, prefixCodeTreeNodes)
  
 BitstringInit(bstr, input, 256)
  
 while i < stopIndex
     symbol := PrefixCodeTreeDecodeSymbol(bstr, root)
     if symbol < 256
         output[i] := (symbol as a UCHAR)
         i := i + 1
     else
         symbol := symbol – 256
         length := symbol & 15
         symbol := symbol >> 4
  
         offset := (1 << symbol) + BitstringLookup(bstr, symbol)
         offset := –1 * offset
  
         if length = 15
             length := bstr.source[bstr.index] + 15
             bstr.index := bstr.index + 1
  
             if length = 270
                 length := 
                     (16 bits starting at bstr.source[bstr.index] as a USHORT)
                 bstr.index := bstr.index + 2
             endif
         endif
         
         BitstringSkip(bstr, symbol)
  
         length := length + 3
         do
             output[i] := output[i + offset]
             i := i + 1
             length := length – 1
         while length <> 0
     endif
 endwhile
  
Show: