The offset parameter indicates the offset within the message buffer where parsing is to commence. This is necessary because another parser might own a previous portion of the message (for example, an MQMD header will have been parsed by the message broker's internal parser). The offset must be positive and be less than the size of the buffer. It is recommended that the implementation function verifies that the offset is valid, as this could improve problem determination if a previous parser is in error.
The parser must return the size of the remaining buffer for which it takes ownership. This must be less than or equal to the size of the buffer less the current offset.
A parser must not attempt to cause parsing of other portions of the syntax element tree, for example, by navigating to the root element and to another branch. This can cause unpredictable results.
If this implementation function is provided in the CPI_VFT structure, neither cpiParseBufferEncoded() nor cpiParseBufferFormatted() can be specified, because the cpiDefineParserClass() function will fail with a return code of CCI_INVALID_IMPL_FUNCTION.
Defined In | Type | Member |
CPI_VFT | Conditional | iFpParseBuffer |
int cpiParseBuffer( CciParser* parser, CciContext* context, int offset);
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 (lines 428 to 466):
int cpiParseBuffer( CciParser* parser, CciContext* context, int offset, ){ 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 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: <- cpiParseBuffer() retvalue=%d\n", pc->iSize); fflush(pc->tracefile); }
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
as08150_ |