#include <hmq.h> MQEINT32 MQeFieldsGetByArrayOfFd( MQEHSESS hSess, MQEHFIELDS hFlds, MQEFIELD pFds[], MQEINT32 nFds, MQEINT32 * pCompCode, MQEINT32 * pReason)
The length of a field name is determined from the fd_name field, the fd_namelen field is ignored.
#include <hmq.h> static MQECHAR const * FieldsType = "com.ibm.mqe.MQeFields"; static const MQECHAR textVal[] = "The Owl and the Pussy Cat went to sea."; /* template for fields */ static const MQEFIELD PFDS[] = { {MQE_TYPE_BYTE, 0, 7, "fooByte", (MQEBYTE *)0, 0, (MQEBYTE *)0}, {MQE_TYPE_SHORT, 0, 8, "fooShort", (MQEBYTE *)0, 0, (MQEBYTE *)0}, {MQE_TYPE_LONG, 0, 7, "fooLong", (MQEBYTE *)0, 0, (MQEBYTE *)0}, {MQE_TYPE_ASCII, 0, 7, "fooText", (MQEBYTE *)0, 0, (MQEBYTE *)0}, }; #define NFDS (sizeof(PFDS)/sizeof(PFDS[0])) MQEHSESS hSess; MQEINT32 compcode; MQEFIELD Fds[NFDS]; MQEINT32 reason; MQEHFIELDS hFlds; MQEBYTE byteVal; MQEINT16 int16Val; MQEINT32 int32Val; MQEBYTE datatype; MQEINT32 rc; MQEINT32 nFlds,i; hSess = MQeInitialize("MyAppsName", &compcode, &reason); hFlds = MQeFieldsAlloc( hSess, FieldsType, &compcode, &reason); /* Put some fields in the fields object using MQeFieldsPutByArrayOfFd() */ byteVal = 0xAE; int16Val = 0x9876; int32Val = 0x12345678; /* Copy template */ memcpy(Fds,PFDS,sizeof(Fds)); Fds[0].fd_data = Fds[0].fd_datalen = 1; Fds[1].fd_data = Fds[1].fd_datalen = 1; Fds[2].fd_data = Fds[2].fd_datalen = 1; Fds[3].fd_data = [0]; Fds[3].fd_datalen = sizeof(textVal); compcode = MQECC_OK, reason = 0; MQFieldsPutByArrayOfFd( hSess, hFlds, Fds, NFDS, &compcode, &reason); /* Copy template */ memcpy(Fds,PFDS,sizeof(Fds)); /* Get data lengths */ rc = MQeFieldsGetByArrayOfFd( hSess, hFlds, Fds, NFDS, &compcode, &reason); /* Get space for each field data */ for( i=0; i<rc; i++) { int len = Fds[i].fd_datalen* MQE_SIZEOF(Fds[i].fd_datatype); if (len > 0) { Fds[i].fd_data = (MQEBYTE *) malloc(len); } } /* Get all the fields defined in field descriptor array in one shot */ compcode = MQECC_OK, reason = 0; MQFieldsGetByArrayOfFd( hSess, hFlds, Fds, NFDS, &compcode, &reason);