/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
/*************************************************************************/
/*  Definitions                                                          */
/*************************************************************************/

#ifndef _XLT_ENC_COM_H
#define _XLT_ENC_COM_H

#include <smldef.h>
#include <smldtd.h>
#include <sml.h>

#include "xlttags.h" 


#ifdef _cplusplus
extern "C" {
#endif

// flags if a (WB)XML block is required or optional
typedef enum {
  OPTIONAL = 0,
  REQUIRED
} XltRO_t;

/* Tag Types (TT) - begin tags, end tags, ...
 */
typedef enum {
  TT_END = 0,
  TT_BEG,
  TT_ALL
} XltTagType_t;

/* Structure elements which are not directly relied to a tag
*/
typedef enum {
  ITEM_LIST,
  TARGET_LIST,
  SOURCE_LIST,
  META_LIST,
  MAPITEM_LIST,
  TARGETREF_LIST,
  SOURCEREF_LIST
} XltListType_t;

// Type for storing free mem size evaluation information
typedef struct XltSpaceEvaluation_s
{
  MemSize_t written_bytes;
  MemSize_t end_tag_size;
} XltSpaceEvaluation_t, *XltSpaceEvaluationPtr_t;

typedef struct bufferMgmt_s
{
  MemPtr_t smlXltBufferP;
  MemPtr_t smlXltStoreBufP;
  MemSize_t smlXltWrittenBytes;
  MemSize_t smlXltBufferLen;
  XltTagID_t           switchExtTag; 
  SmlPcdataExtension_t smlCurExt;
  SmlPcdataExtension_t smlLastExt;
  SmlPcdataExtension_t smlActiveExt;
  MemSize_t endTagSize;
  Boolean_t spaceEvaluation;
} BufferMgmt_t, *BufferMgmtPtr_t;

/**
 * FUNCTION: xltAddToBuffer
 *
 * Add a string to the global buffer
 *
 * PRE-Condition:  pContent contains some content bytes to write to the (WB) XML buffer
 *
 * POST-Condition: content is written to the buffer 
 *
 * IN:             pContent, the character pointer referencing the content to
 *                           write to the buffer
 *                 size, the content length
 * 
 * IN/OUT:         pBufMgr, pointer to a structure containing buffer management elements
 * 
 * RETURN:         shows error codes of function, 
 *                 0, if OK
 */
Ret_t xltAddToBuffer(const MemPtr_t pContent, MemSize_t size, BufferMgmtPtr_t pBufMgr);

#ifdef _cplusplus
}
#endif

#endif
