This function extends the capability of the cpiParseBuffer() implementation function, and provides additional information about the input message.
If this implementation function is provided in the CPI_VFT structure, you cannot specify either cpiParseBuffer() or cpiParseBufferEncoded(); if you do, the cpiDefineParserClass() function fails with a return code of CCI_INVALID_IMPL_FUNCTION.
Defined In | Type | Member |
---|---|---|
CPI_VFT | Conditional | iFpParseBufferFormatted |
int cpiParseBufferFormatted(
CciParser* parser,
CciContext* context,
int encoding,
int ccsid,
CciChar* set,
CciChar* type,
CciChar* format);
The size (in bytes) of the remaining portion of the message buffer for which the parser takes ownership.
This example is taken from the sample parser file BipSampPluginParser.c:
int cpiParseBufferFormatted(
CciParser* parser,
CciContext* context,
int encoding,
int ccsid,
CciChar* set,
CciChar* type,
CciChar* format
){
PARSER_CONTEXT_ST* pc = (PARSER_CONTEXT_ST *)context ;
int rc;
/* Get a pointer to the message buffer and set the offset */
pc->iBuffer = (void *)cpiBufferPointer(&rc, parser);
pc->iIndex = 0;
/* Save the format of the buffer */
pc->iEncoding = encoding;
pc->iCcsid = ccsid;
/* Save size of the buffer */
pc->iSize = cpiBufferSize(&rc, parser);
/* Prime the first byte in the stream */
pc->iCurrentCharacter = cpiBufferByte(&rc, parser, pc->iIndex);
/* Set the current element to the root element */
pc->iCurrentElement = cpiRootElement(&rc, parser);
/* Reset flag to ensure parsing is reset correctly */
pc->iInTag = 0;
if (pc->trace) {
fprintf(pc->tracefile, "PLUGIN: <- cpiParseBufferFormatted()
retvalue=%d\n", pc->iSize);
fflush(pc->tracefile);
}