如果在 CPI_VFT 结构中提供此实施函数,则既不能指定 cpiParseBuffer() 也不能指定 cpiParseBufferEncoded(),因为 cpiDefineParserClass() 函数将失败,返回代码为 CCI_INVALID_IMPL_FUNCTION。
在其中定义 | 类型 | 成员 |
CPI_VFT | 有条件的 | iFpParseBufferFormatted |
int cpiParseBufferFormatted( CciParser* parser, CciContext* context, int encoding, int ccsid, CciChar* set, CciChar* type, CciChar* format);
解析器取得所有权的消息缓冲区的剩余部分的大小(以字节为单位)。
此示例取自样本解析器文件 BipSampPluginParser.c(428 行到 466 行):
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); }