cpiParseBufferFormatted

用途

此函数是现有 cpiParseBuffer() 实施函数提供的能力扩展,它提供:
  1. 在其中表示输入消息的编码和编码字符集。
  2. 消息的消息集、类型和格式。

如果在 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); 

参数

parser
解析器对象的地址(输入)。
context
解析器对象拥有的上下文的地址(输入)。
encoding
消息缓冲区的编码(输入)。
ccsid
消息缓冲区的 ccsid(输入)。
set
消息(输入)所属的消息集。
type
消息类型(输入)。
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);
  }
相关概念
用户定义的解析器
用户定义的扩展
相关任务
使用 C 创建解析器
相关参考
cpiParseBuffer
cpiParseBufferEncoded
C 解析器实施函数
声明 | 商标 | 下载 | 书库 | 支持 | 反馈
Copyright IBM Corporation 1999, 2006 最后一次更新时间:2006/08/14
as08170_