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

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_TAGS_H
#define _XLT_TAGS_H

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

#define XML_MAX_TAGLEN 35

#ifdef _cplusplus
extern "C" {
#endif

// Tag IDs
typedef enum {
    TN_UNDEF = 0,

    TN_ADD,
    TN_ALERT,
    TN_ARCHIVE,
    TN_ATOMIC,
    TN_ATOMIC_END, /* 5 */
    TN_CHAL,
    TN_CMD,
    TN_CMDID,
    TN_CMDREF,
    TN_COPY,     /* 10 */
    TN_CRED,
    TN_DATA,
    TN_DELETE,
    TN_EXEC,
    TN_FINAL,    /* 15 */
    TN_GET,
    TN_ITEM,
    TN_LANG,
    TN_LOCNAME,
    TN_LOCURI,  /* 20 */
    TN_MAP,
    TN_MAPITEM,
    TN_META,
    TN_MSGID,
    TN_MSGREF,  /* 25 */
    TN_NORESP,
    TN_NORESULTS,
    TN_PUT,
    TN_REPLACE,
    TN_RESPURI, /* 30 */
    TN_RESULTS,
    TN_SEARCH,
    TN_SEQUENCE,
    TN_SEQUENCE_END,
    TN_SESSIONID, /* 35 */
    TN_SFTDEL,
    TN_SOURCE,
    TN_SOURCEREF,
    TN_STATUS,
    TN_SYNC, /* 40 */
    TN_SYNCBODY,
    TN_SYNCHDR,
    TN_SYNCML,
    TN_SYNC_END,
    TN_TARGET, /* 45 */
    TN_TARGETREF,
    TN_VERSION,
    TN_PROTO,
    TN_METINF_ANCHOR,
	TN_METINF_EMI, /* 50 */
	TN_METINF_FORMAT, 
	TN_METINF_FREEID,
	TN_METINF_FREEMEM,		
	TN_METINF_LAST,
	TN_METINF_MARK, /* 55 */
	TN_METINF_MAXMSGSIZE,
	TN_METINF_MEM,
	TN_METINF_METINF,
	TN_METINF_NEXT,
	TN_METINF_NEXTNONCE, /* 60 */
	TN_METINF_SHAREDMEM,
	TN_METINF_SIZE,
	TN_METINF_TYPE,
	TN_METINF_VERSION,
    TN_DEVINF_CTCAP,    /* 65 */
    TN_DEVINF_CTTYPE,
    TN_DEVINF_DATASTORE,
    TN_DEVINF_DATATYPE,
    TN_DEVINF_DEVID,
    TN_DEVINF_DEVINF, /* 70 */
    TN_DEVINF_DEVTYP,
    TN_DEVINF_DISPLAYNAME,
    TN_DEVINF_DSMEM,
    TN_DEVINF_EXT,
    TN_DEVINF_FWV, /* 75 */
    TN_DEVINF_HWV,
    TN_DEVINF_MAN,
    TN_DEVINF_MAXGUIDSIZE,
    TN_DEVINF_MAXID,
    TN_DEVINF_MAXMEM, /* 80 */
    TN_DEVINF_MOD,
    TN_DEVINF_OEM,
    TN_DEVINF_PARAMNAME,
    TN_DEVINF_PROPNAME,
    TN_DEVINF_RX, /* 85 */
    TN_DEVINF_RXPREF,
    TN_DEVINF_SHAREDMEM,
    TN_DEVINF_SIZE,
    TN_DEVINF_SOURCEREF,
    TN_DEVINF_SWV, /* 90 */
    TN_DEVINF_SYNCCAP,
    TN_DEVINF_SYNCTYPE,
    TN_DEVINF_TX,
    TN_DEVINF_TXPREF,
    TN_DEVINF_VALENUM, /* 95 */
    TN_DEVINF_VERCT,
    TN_DEVINF_VERDTD,
    TN_DEVINF_XNAM,
    TN_DEVINF_XVAL,
	TN_NUMBEROFCHANGES, /* 100 */
	TN_MOREDATA,
	/* SCTSTK - 18/03/2002 : SyncML 1.1 */
	TN_METINF_MAXOBJSIZE,
	TN_DEVINF_UTC,
	TN_DEVINF_NOFM,
	TN_DEVINF_LARGEOBJECT, /* 105 */
	TN_CORRELATOR,

    /*
     * Change to support TNDS. 
     */
    /* TNDS tag */
    TN_TNDS_SYNCML,
	TN_TNDS_TREE,
    TN_TNDS_MAN,
    TN_TNDS_MODE,
    TN_TNDS_VERSION,
	TN_TNDS_NODE,
	TN_TNDS_NODENAME,
    TN_TNDS_NODETITLE,
	TN_TNDS_NODEPATH,
    TN_TNDS_NODESIZE,
	TN_TNDS_NODEVALUE,
	TN_TNDS_NODERTPROPERTIES,
	TN_TNDS_RTACL,
	TN_TNDS_RTFORMAT,
	TN_TNDS_RTTSTAMP,
	TN_TNDS_RTTYPE,
	TN_TNDS_RTVERNO,
	TN_TNDS_FMTB64,
	TN_TNDS_FMTBIN,
	TN_TNDS_FMTBOOL,
	TN_TNDS_FMTCHR,
	TN_TNDS_FMTINT,
	TN_TNDS_FMTNODE,
	TN_TNDS_FMTNULL,
	TN_TNDS_FMTXML,
	TN_TNDS_FMTDATE,
	TN_TNDS_FMTTIME,
	TN_TNDS_FMTFLOAT

} XltTagID_t;


typedef struct Dtd_s
{
	String_t	         name;
	SmlPcdataExtension_t ext;
} Dtd_t, *DtdPtr_t;


/**
 * FUNCTION: getTagString
 *
 * Returns a tag string which belongs to a tag ID. 
 * This function is needed for the XML encoding
 *
 * PRE-Condition:   valid tag ID, the tagSring has to be allocated 
 *
 * POST-Condition:  tag string is returned
 *
 * IN:              tagId, the ID for the tag 
 *
 * IN/OUT:          tagString, allocated string into which the XML 
 *                             tag string will be written
 * 
 * RETURN:          0, if OK
 */
Ret_t getTagString(XltTagID_t tagID, String_t tagString, SmlPcdataExtension_t ext);

#ifdef __SML_WBXML__
/**
 * FUNCTION: getTagByte
 *
 * Returns a WBXML byte which belongs to a tag ID in a defined codepage. 
 * This function is needed for the WBXML encoding
 *
 * PRE-Condition:   valid tag ID, valid code page
 *
 * POST-Condition:  tag byte is returned
 *
 * IN:              tagId, the ID for the tag 
 *                  cp, code page group for the tag 
 *                  tagByte, the byte representation of the tag
 * 
 * RETURN:          0, if OK
 */
Ret_t getTagByte(XltTagID_t tagID, SmlPcdataExtension_t ext, Byte_t *tagByte);
#endif

/**
 * FUNCTION: getCodePage
 *
 * Returns the code page which belongs to a certain PCDATA extension type. 
 *
 * PRE-Condition:   valid PCDATA extension type
 *
 * POST-Condition:  the code page is returned
 *
 * IN:              ext, the PCDATA extension type
 * 
 * RETURN:          the code page
 */
Byte_t     getCodePage(SmlPcdataExtension_t ext);

/**
 * FUNCTION: getTagIDByStringAndCodepage
 *
 * Returns the tag ID which belongs to a tag string in a certain codepage
 *
 * PRE-Condition:   valid tag string, valid code page
 *
 * POST-Condition:  tag id is returned
 *
 * IN:              tag, the string representation of the tag 
 *                  cp, code page group for the tag 
 *                  pTagID, the tag id of the tag
 * 
 * RETURN:          0, if OK
 */
Ret_t getTagIDByStringAndExt(String_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID);

#ifdef __SML_WBXML__
/**
 * FUNCTION: getTagIDByByteAndCodepage
 *
 * Returns the tag ID which belongs to a tag byte in a certain codepage
 *
 * PRE-Condition:   valid tag byte, valid code page
 *
 * POST-Condition:  tag id is returned
 *
 * IN:              tag, the byte representation of the tag 
 *                  cp, code page group for the tag  
 *                  pTagID, the tag id of the tag
 * 
 * RETURN:          0, if OK
 */
Ret_t getTagIDByByteAndExt(Byte_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID);
#endif


#ifdef __SML_XML__
/**
 * FUNCTION: getTagIDByStringAndNamespace
 *
 * Returns the tag ID which belongs to a tag string in a certain namespace
 *
 * PRE-Condition:   valid tag string, valid namespace
 *
 * POST-Condition:  tag id is returned
 *
 * IN:              tag, the string representation of the tag 
 *                  ns, namespace group for the tag  
 *                  pTagID, the tag id of the tag
 * 
 * RETURN:          0, if OK
 */
Ret_t getTagIDByStringAndNamespace(String_t tag, String_t ns, XltTagID_t *pTagID);
#endif

/**
 * FUNCTION: getCodePageById
 *
 * Returns the codepage which belongs to a certain tag ID
 *
 * PRE-Condition:   valid tag ID
 *
 * POST-Condition:  the code page is returned
 *
 * IN:              tagID, the ID of the tag 
 *                  pCp, the codepage of the tag
 *
 * RETURN:          0, if OK
 */
Ret_t getExtById(XltTagID_t tagID, SmlPcdataExtension_t *pExt);

Ret_t getExtName(SmlPcdataExtension_t ext, String_t *name);
Ret_t getTagIDByStringAndExt(String_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID);
SmlPcdataExtension_t getExtByName(String_t ns);


#ifdef _cplusplus
}
#endif

#endif
