cpiParseBufferEncoded

目的

此函数是提供在其中表示输入消息的编码和编码字符集的现有的 cpiParseBuffer() 实施函数所提供的能力扩展。如果在 CPI_VFT 结构中提供此实施函数,则既不能指定 cpiParseBuffer() 也不能指定 cpiParseBufferFormatted(),否则 cpiDefineParserClass() 函数将失败,附带返回码 CCI_INVALID_IMPL_FUNCTION。

在其中定义 类型 成员
CPI_VFT 有条件的 iFpParseBufferEncoded

语法

int cpiParseBufferEncoded(
  CciParser*  parser,
  CciContext* context,                
  int         encoding,
  int          ccsid); 

参数

parser
解析器对象的地址(输入)。
context
解析器对象拥有的上下文的地址(输入)。
encoding
消息缓冲区的编码(输入)。
ccsid
消息缓冲区的 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);
}
相关概念
用户定义的解析器
用户定义的扩展
相关任务
使用 C 创建解析器
相关参考
cpiParseBuffer
cpiParseBufferFormatted
C 解析器实施函数
声明 | 商标 | 下载 | | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后更新:2006/05/19
as08160_