@@ -280,8 +280,50 @@ func (p *PCFParameter) Bytes() []byte {
280280 endian .PutUint32 (buf [offset :], uint32 (len (p .String [0 ])))
281281 offset += 4
282282 copy (buf [offset :], []byte (p .String [0 ]))
283+
284+ case C .MQCFT_STRING_FILTER :
285+ // Use "\000" as the string if you need an empty/null parameter
286+ fv := p .Filter .FilterValue .(string )
287+
288+ buf = make ([]byte , C .MQCFSF_STRUC_LENGTH_FIXED + roundTo4 (int32 (len (fv ))))
289+ offset := 0
290+ endian .PutUint32 (buf [offset :], uint32 (p .Type ))
291+ offset += 4
292+ endian .PutUint32 (buf [offset :], uint32 (len (buf )))
293+ offset += 4
294+ endian .PutUint32 (buf [offset :], uint32 (p .Filter .Parameter ))
295+ offset += 4
296+ endian .PutUint32 (buf [offset :], uint32 (p .Filter .Operator ))
297+ offset += 4
298+ endian .PutUint32 (buf [offset :], uint32 (C .MQCCSI_DEFAULT ))
299+ offset += 4
300+ endian .PutUint32 (buf [offset :], uint32 (len (fv )))
301+ offset += 4
302+ copy (buf [offset :], []byte (fv ))
303+
304+ // Expect to be given a string that can be decoded into bytes. For example, "aabb12".
305+ // Return nil if the bytestring cannot be converted from the hex
306+ case C .MQCFT_BYTE_STRING :
307+ bs , err := hex .DecodeString (p .String [0 ])
308+ if err != nil {
309+ // Can't easily change to return or report the error without breaking existing apps.
310+ logError ("Trying to serialise PCF ByteString parameter \" %s\" : %v\n " , p .String [0 ], err )
311+ return nil
312+ }
313+ buf = make ([]byte , C .MQCFST_STRUC_LENGTH_FIXED + roundTo4 (int32 (len (bs ))))
314+ offset := 0
315+ endian .PutUint32 (buf [offset :], uint32 (p .Type ))
316+ offset += 4
317+ endian .PutUint32 (buf [offset :], uint32 (len (buf )))
318+ offset += 4
319+ endian .PutUint32 (buf [offset :], uint32 (p .Parameter ))
320+ offset += 4
321+ endian .PutUint32 (buf [offset :], uint32 (len (bs )))
322+ offset += 4
323+ copy (buf [offset :], bs )
324+
283325 default :
284- fmt . Printf ("mqiPCF.go: Trying to serialise PCF parameter. Unknown PCF type %d\n " , p .Type )
326+ logError ("mqiPCF.go: Trying to serialise PCF parameter. Unknown PCF type %d\n " , p .Type )
285327 }
286328 return buf
287329}
0 commit comments