I struggled to decode PCF output; for example decode PCF type 1203 and its value 20. MQ provide most of what you need, there is just one little link in the chain which is missing
In the MQ provided CMQSTRC header file are routines for converting the values to strings
For example
char *MQSYSP_STR (MQLONG v) { char *c; switch (v) { case 0: c = "MQSYSP_NO"; break; case 1: c = "MQSYSP_YES"; break; case 2: c = "MQSYSP_EXTENDED"; break; case 10: c = "MQSYSP_TYPE_INITIAL"; break; case 11: c = "MQSYSP_TYPE_SET"; break; case 12: c = "MQSYSP_TYPE_LOG_COPY"; break; case 13: c = "MQSYSP_TYPE_LOG_STATUS"; break; case 14: c = "MQSYSP_TYPE_ARCHIVE_TAPE"; break; case 20: c = "MQSYSP_ALLOC_BLK"; break;
so if you know this your type is a System Parameter, you can use MQSYSP_STR(20) to get back the data item MQSYSP_ALLOC_BLK.
The bit that is missing is the mapping between PCF type and the function call.
In GitHub I’ve created this mapping for all of the PCF types (MQMAP.h). This has for example
MQMAP(MQIA_APPL_TYPE, MQAT_STR), // 1 MQMAP(MQIA_DEF_INPUT_OPEN_OPTION, MQOO_STR), // 4 MQMAP(MQIA_DEF_PERSISTENCE, MQPER_STR), // 5 MQMAP(MQIA_DEFINITION_TYPE, MQQDT_STR), // 7
I also provide some routines to help you call this and prettify the value.
I’ve also provided some code so you just need to issue
getPCFValue(MQLONG what,
MQLONG value,
char **pWhat,
char **pValue,
char **pPValue);
Where
- what is the PCF data type (MQIA_TRIGGER_TYPE)
- value is the PCF value (for example 3)
- pWhat gets the name of the PCF data type (“Trigger_Type”)
- pValue gets the value returned from the MQ provided function(“MQTT_DEPTH”)
- pPValue gets the prettified value, with the prefix removed, and the remained made more readable(“Depth”)
This will allow you to run along PCF data and display all the data and values in a similar manner to a display command.
The data in MQMAP.h is in numerical sequence, so I can use a binary search to quickly find the mapping function. I also provide a small C function which takes the MQMAP.h file, checks it is in order and displays it, so it can be sorted.
I gotta ask – why strdup? Why not just return pointer to the already existing string?
LikeLike
Good question – thank you.
formatConstant(..) modified the string, for example changing _ to blank, so this needs its own copy of the string.
For the others strings, I think I wanted to isolate the data, in case it got changed.
I’ll clean it up and see if it still works.
Thank you for pointing it out
Colin
LikeLike
I remember… I thought it would be easier for the end user to free all of the strings, instead of just the pretty one.
LikeLike