4.1.10.5.20 TransformOutput

 procedure TransformOutput(
   msgOut: DRS_MSG_GETCHGREPLY_NATIVE,
   flags: DRS_OPTIONS,
   pdwOutVersion: ADDRESS OF DWORD,
   pmsgOut: ADDRESS OF DRS_MSG_GETCHGREPLY): ULONG

Informative summary of behavior: The TransformOutput procedure transforms the native reply (a superset of all supported reply messages) into the reply version supported by the client, optionally compressing it. The compression algorithms used for the DRS_COMP_ALG_WIN2K3 algorithm type are specified in section 4.1.10.5.21. The compression algorithm used for the DRS_COMP_ALG_MSZIP algorithm type is specified in [RFC1951].

 pickled: sequence of BYTE
 compressed: sequence of BYTE
 allowedAlgs: set of DRS_COMP_ALG_TYPE
 compressAlg: DRS_COMP_ALG_TYPE
 compress: boolean
  
 /* The SMTP transport [MS-SRPL] performs its own compression. */
 compress := DRS_USE_COMPRESSION in flags 
             and not DRS_MAIL_REP in flags
  
 if pdwOutVersion^ < dc.minimumGetChangesReplyVersion
     return ERROR_REVISION_MISMATCH
  
 if pdwOutVersion^ = 9 or pdwOutVesion^ = 6 then
   if pdwOutVersion^ = 9 then
     /* Convert to V9.*/
     pdwOutVersion^ := 9
     pmsgOut^.V9 := msgOut
   else if pdwOutVersion^ = 6 then
     /* Convert to V6. */         
     pdwOutVersion^ := 6
     pmsgOut^.V6 := msgOut
     pmsgOut^.V6.rgValues := ReplValInfV1ListFromReplValInfNativeList(msgOut.rgValues) 
   endif
  
   if compress then
     /* Note that the only difference between the compression processing of a V2 and  */
     /* a V7 message is that a V7 message can use the DRS_COMP_ALG_WIN2K3 compression */
     /* algorithm and a V2 message can not.                                           */
     /* Return V7 (compressed V6 or V9). */
     if not DRS_EXT_GETCHGREPLY_V7 in ext.dwFlags then
       return ERROR_REVISION_MISMATCH
     endif
  
     /* Serialize msgOut into a byte stream. */
     pickled := Pickling of pmsgOut^.V6 or pmsgOut^.V9, as specified by
         [C311] Part 2, "IDL/NDR Pickles", and
         [MS-RPCE] sections 2.2.6 and 2.2.7, "Type Serialization
         Version 1" and "Type Serialization Version 2"
  
     /* Select a compression algorithm. */
     allowedAlgs := {DRS_COMP_ALG_NONE, DRS_COMP_ALG_MSZIP}
     if DRS_EXT_W2K3_DEFLATE in ext.dwFlags then
       allowedAlgs := allowedAlgs + {DRS_COMP_ALG_WIN2K3}
     endif
     compressAlg := One of allowedAlgs, selected by an
         implementation-defined policy.
  
     /* Compress the serialized msgOut. */
     if (compressionAlg = DRS_COMP_ALG_MSZIP) then
       compressed :=
         Compress pickled in accordance
         with [RFC1951].
     else
       CompressOrDecompressWin2k3(pickled, compressed, pickled.length, TRUE)
     endif
     pmsgOut^.V7.dwCompressedVersion := pdwOutVersion^
     pmsgOut^.V7.CompressionAlg := compressAlg
     pmsgOut^.V7.CompressedAny.cbUncompressedSize := pickled.length
     pmsgOut^.V7.CompressedAny.cbCompressedSize := compressed.length
     pmsgOut^.V7.CompressedAny.pbCompressedData := bytes in compressed
     pdwOutVersion^ := 7
   endif
 else
   /* Return V1 (uncompressed) or V2 (compressed V1). */ 
   /* First, convert to V1. */
   pdwOutVersion^ := 1
   pmsgOut^.V1 := msgOut
   pmsgOut^.V1.pUpToDateVecSrc := Convert msgOut.pUpToDateVecSrc (of
       type UPTODATE_VECTOR_V1_EXT) to UPTODATE_VECTOR_V2_EXT by
       creating a new UPTODATE_VECTOR_V1_EXT with a V1 cursor for each
       V2 cursor, sans the timeLastSyncSuccess field.
   /* V1 has the NC size in the ulExtendedRet field. */
   if msgOut.cNumNcSizeObjects > 0 then
     pmsgOut^.V1.ulExtendedRet := msgOut.cNumNcSizeObjects
   endif
  
   if compress then
     /* Serialize msgOut into a byte stream. */
     pickled := Pickling of pmsgOut^.V1, as specified by
         [C311] Part 2, "IDL/NDR Pickles" and
         [MS-RPCE] sections 2.2.6 and 2.2.7, "Type Serialization
         Version 1" and "Type Serialization Version 2"
  
     /* Select a compression algorithm. */
     allowedAlgs := {DRS_COMP_ALG_NONE, DRS_COMP_ALG_MSZIP}
     compressAlg := One of allowedAlgs, selected by an 
                    implementation-defined policy.
  
     /* Compress the serialized msgOut. */
     if (compressionAlg = DRS_COMP_ALG_MSZIP) then
       compressed :=
         Compress pickled in accordance
         with [RFC1951].
     else
       CompressOrDecompressWin2k3(pickled, compressed, pickled.length, TRUE)
     endif
     pdwOutVersion^ := 2
     pmsgOut^.V2.CompressedV1.cbUncompressedSize := pickled.length
     pmsgOut^.V2.CompressedV1.cbCompressedSize := compressed.length
     pmsgOut^.V2.CompressedV1.pbCompressedData := bytes in compressed
   endif
 endif
  
 return 0