此函数是提供在其中表示输入消息的编码和编码字符集的现有的 cpiParseBuffer() 实施函数所提供的能力扩展。如果在 CPI_VFT 结构中提供此实施函数,则既不能指定 cpiParseBuffer() 也不能指定 cpiParseBufferFormatted(),否则 cpiDefineParserClass() 函数将失败,返回代码为 CCI_INVALID_IMPL_FUNCTION。
在其中定义 | 类型 | 成员 |
CPI_VFT | 有条件的 | iFpParseBufferEncoded |
int cpiParseBufferEncoded( CciParser* parser, CciContext* context, int encoding, int ccsid);
解析器取得所有权的消息缓冲区的剩余部分的大小(以字节为单位)。
此示例取自样本解析器文件 BipSampPluginParser.c(428 行到 466 行):
int cpiParseBufferEncoded( CciParser* parser, CciContext* context, int encoding, int ccsid ){ 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: <- cpiParseBufferEncoded() retvalue=%d\n", pc->iSize); fflush(pc->tracefile); }