WebSphere Message Brokers
File: as08160_
Writer: Lorraine Waitt

Reference topic

This build: July 31, 2007 21:37:56

cpiParseBufferEncoded

Purpose

This function is an extension of the capability provided by the existing cpiParseBuffer() implementation function that provides the encoding and coded character set that the input message is represented in. If this implementation function is provided in the CPI_VFT structure, neither cpiParseBuffer() nor cpiParseBufferFormatted() can be specified, otherwise the cpiDefineParserClass() function will fail with a return code of CCI_INVALID_IMPL_FUNCTION.

Defined In Type Member
CPI_VFT Conditional iFpParseBufferEncoded

Syntax

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

Parameters

parser
The address of the parser object (input).
context
The address of the context owned by the parser object (input).
encoding
The encoding of the message buffer (input).
ccsid
The ccsid of the message buffer (input).

Return values

The size (in bytes) of the remaining portion of the message buffer for which the parser takes ownership.

Sample

This example is taken from the sample parser file BipSampPluginParser.c (lines 428 to 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);
  }
Related concepts
User-defined parsers
User-defined extensions overview
Related tasks
Creating a parser in C
Related reference
cpiParseBuffer
cpiParseBufferFormatted
C parser implementation functions
Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2007Copyright IBM Corporation 1999, 2007. All Rights Reserved.
This build: July 31, 2007 21:37:56

as08160_ This topic's URL is: