⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xlttags.c

📁 SyncML ToolKits,学习syncml的参考工具包.非常好用.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************//* module:          Definition of WBXML/XML tags for the en-/decoder     *//* file:            XLTTags.c                                            *//* target system:   all                                                  *//* target OS:       all                                                  */   /*************************************************************************//* * Copyright Notice * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication  * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,  * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). * All Rights Reserved. * Implementation of all or part of any Specification may require  * licenses under third party intellectual property rights,  * including without limitation, patent rights (such a third party  * may or may not be a Supporter). The Sponsors of the Specification  * are not responsible and shall not be held responsible in any  * manner for identifying or failing to identify any or all such  * third party intellectual property rights. *  * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED  * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,  * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,  * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML  * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING  * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION  * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT  * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,  * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY  * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF  * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF  * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,  * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH  * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED  * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. *  * The above notice and this paragraph must be included on all copies  * of this document that are made. *  */#include "syncml_tk_prefix_file.h" // %%% luz: needed for precompiled headers in eVC++#include "xlttags.h"#include <libstr.h>#include <smlerr.h>#include <libmem.h>#include <libutil.h>#include <mgr.h>#include "xltmetinf.h"#include "xltdevinf.h"#include "xlttagtbl.h"// %%% luz:2003-07-31: added SyncML namespace tablesconst char * const SyncMLNamespaces[SML_NUM_VERS] = {  "???",  "SYNCML:SYNCML1.0",  "SYNCML:SYNCML1.1"};/* local prototypes */#ifdef NOWSMconst // without WSM, the tag table is a global read-only constant#endifTagPtr_t getTagTable(SmlPcdataExtension_t ext);//SmlPcdataExtension_t   getByName(String_t ns);void freeDtdTable(DtdPtr_t tbl);#ifdef NOWSMconst // without WSM, the DTD table is a global read-only constant#endifDtdPtr_t getDtdTable();// free table obtained with getDtdTable()void freeDtdTable(DtdPtr_t tbl){  #ifndef NOWSM  // only with WSM this is an allocated table  smlLibFree(tbl);  #endif}/** * FUNCTION: getDtdTable * * Returns a copy of the table containing all known (sub) dtd's * On error a NULL pointer is returned */#ifdef NOWSMconst // without WSM, the DTD table is a global read-only constant#endifDtdPtr_t getDtdTable() {  #ifdef NOWSM  // NOWSM method, table is const, just return a pointer	static const Dtd_t XltDtdTbl[] = {		{ "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED}, // %%% note that this is the default, will be override by syncml version specific string from 		{ "syncml:metinf",    SML_EXT_METINF},    { "syncml:devinf",    SML_EXT_DEVINF},		{ NULL,               SML_EXT_LAST}	};	return (DtdPtr_t)XltDtdTbl;  #else  // WSM method wasting a lot of memory	DtdPtr_t _tmpPtr;	Dtd_t XltDtdTbl[] = {		{ "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED},		{ "syncml:metinf",    SML_EXT_METINF},    { "syncml:devinf",    SML_EXT_DEVINF},		{ NULL,               SML_EXT_LAST}	};	_tmpPtr = NULL; 	_tmpPtr = (DtdPtr_t)smlLibMalloc(sizeof(XltDtdTbl));	if (_tmpPtr == NULL) return NULL;	smlLibMemcpy(_tmpPtr, &XltDtdTbl, sizeof(XltDtdTbl));	return _tmpPtr;	#endif}/** * FUNCTION: getExtName * * Returns the official name for a given extention/sub-DTD * and stored it in 'name'. If not found name isn't modified */// %%% luz:2003-04-24: added syncmlvers parameter// %%% luz:2003-07-31: changed to vers enumRet_t getExtName(SmlPcdataExtension_t ext, String_t *name, SmlVersion_t vers) {	DtdPtr_t dtdhead = getDtdTable();	DtdPtr_t dtd = dtdhead;	const char *dtdname;	if (!dtdhead) return -1;	for (;dtd->ext != SML_EXT_LAST; dtd++) {		if (!dtd->name) continue; /* skip empty names (should not appear but better be on the safe side) */		if (dtd->ext == ext) {		  String_t _tmp;		  // this is the default		  dtdname=dtd->name;		  // %%% luz:2003-04-24: added dynamic generation of namespace according to SyncML version		  if (ext==SML_EXT_UNDEFINED && vers!=SML_VERS_UNDEF) {		    // this requests SyncML namespace		    dtdname=SyncMLNamespaces[vers];		  }			_tmp = smlLibMalloc(smlLibStrlen(dtdname)+1);			if (!_tmp) {				freeDtdTable(dtdhead);				return SML_ERR_NOT_ENOUGH_SPACE;			}			smlLibStrcpy(_tmp, dtdname);			freeDtdTable(dtdhead);			*name = _tmp;						return SML_ERR_OK;		}	}	freeDtdTable(dtdhead);	return -1;}/** * FUNCTION: getCpByName * * Returns the codepage constant assoziated with the name stored in 'ns' * * RETURN:             a SmlPcdataExtension_t representing the corresponding codepage id. *                     If no corresponding codepage is found -1 is returned. */SmlPcdataExtension_t getExtByName(String_t ns) {	DtdPtr_t dtdhead = getDtdTable();	DtdPtr_t dtd = dtdhead;	SmlPcdataExtension_t ext = (SmlPcdataExtension_t) 255;	if (!dtdhead) return SML_EXT_UNDEFINED;	for (;dtd->ext != SML_EXT_LAST; dtd++) {	  const char *dtdname=dtd->name;		if (!dtdname) continue; /* skip empty names (should not appear but better be on the safe side) */		if (dtd->ext==SML_EXT_UNDEFINED && smlLibStrncmp("SYNCML:SYNCML",ns,13)==0) {		  // SyncML namespace is ok without checking version!			ext = SML_EXT_UNDEFINED;			break;		}		else if (smlLibStrcmp(dtdname,ns) == 0) {			ext = dtd->ext;			break;		}	}	freeDtdTable(dtdhead);	return ext;}/* if the commands are not defined we let the functions point to NULL */#ifndef RESULT_RECEIVE#define buildResults NULL#endif#ifndef MAP_RECEIVE#define buildMap NULL#endif#ifndef EXEC_RECEIVE#define buildExec NULL#endif#if !defined(ATOM_RECEIVE) && !defined(SEQUENCE_RECEIVE)#define buildAtomOrSeq NULL#endif#ifndef SEARCH_RECEIVE#define buildSearch NULL#endif/** * FUNCTION: getTagTable * * Returns the tag table - this function is used to avoid a global * tag table variable * * RETURN:             a pointer to the tag table containing tag ids,  *                     codepages, wbxml tags and xml tags *//* T.K. initialized the structure via _TOKEN Macro, to take * out the XML name tags when not compiled with XML support. * In addtion removed the (unused) pointer for the build functions  */#ifdef __SML_XML__#define _TOKEN(id, wbxml, xml) (id), (wbxml), (xml)#else#define _TOKEN(id, wbxml, xml) (id), (wbxml), ""#endif#ifdef NOWSMconst // without WSM, the tag table is a global read-only constant#endifTagPtr_t getTagTable(SmlPcdataExtension_t ext){  #ifndef NOWSM  int mySize = 0;  TagPtr_t _tmpTagPtr;  SyncMLInfoPtr_t pGA = NULL;  #else  TagPtr_t _tmpTagPtr=NULL;  #endif  /* standard SyncML codepage */  static const Tag_t syncml[] =  {    { _TOKEN(TN_ADD,            0x05,    "Add")},    { _TOKEN(TN_ALERT,          0x06,    "Alert")},    { _TOKEN(TN_ARCHIVE,        0x07,    "Archive")},    { _TOKEN(TN_ATOMIC,         0x08,    "Atomic")},    { _TOKEN(TN_CHAL,           0x09,    "Chal")},    { _TOKEN(TN_CMD,            0x0A,    "Cmd")},    { _TOKEN(TN_CMDID,          0x0B,    "CmdID")},    { _TOKEN(TN_CMDREF,         0x0C,    "CmdRef")},    { _TOKEN(TN_COPY,           0x0D,    "Copy")},    { _TOKEN(TN_CRED,           0x0E,    "Cred")},    { _TOKEN(TN_DATA,           0x0F,    "Data")},    { _TOKEN(TN_DELETE,         0x10,    "Delete")},    { _TOKEN(TN_EXEC,           0x11,    "Exec")},    { _TOKEN(TN_FINAL,          0x12,    "Final")},    { _TOKEN(TN_GET,            0x13,    "Get")},    { _TOKEN(TN_ITEM,           0x14,    "Item")},    { _TOKEN(TN_LANG,           0x15,    "Lang")},    { _TOKEN(TN_LOCNAME,        0x16,    "LocName")},    { _TOKEN(TN_LOCURI,         0x17,    "LocURI")},    { _TOKEN(TN_MAP,            0x18,    "Map")},    { _TOKEN(TN_MAPITEM,        0x19,    "MapItem")},    { _TOKEN(TN_META,           0x1A,    "Meta")},    { _TOKEN(TN_MSGID,          0x1B,    "MsgID")},    { _TOKEN(TN_MSGREF,         0x1C,    "MsgRef")},    { _TOKEN(TN_NORESP,         0x1D,    "NoResp")},    { _TOKEN(TN_NORESULTS,      0x1E,    "NoResults")},    { _TOKEN(TN_PUT,            0x1F,    "Put")},    { _TOKEN(TN_REPLACE,        0x20,    "Replace")},    { _TOKEN(TN_RESPURI,        0x21,    "RespURI")},    { _TOKEN(TN_RESULTS,        0x22,    "Results")},    { _TOKEN(TN_SEARCH,         0x23,    "Search")},    { _TOKEN(TN_SEQUENCE,       0x24,    "Sequence")},    { _TOKEN(TN_SESSIONID,      0x25,    "SessionID")},    { _TOKEN(TN_SFTDEL,         0x26,    "SftDel")},    { _TOKEN(TN_SOURCE,         0x27,    "Source")},    { _TOKEN(TN_SOURCEREF,      0x28,    "SourceRef")},    { _TOKEN(TN_STATUS,         0x29,    "Status")},    { _TOKEN(TN_SYNC,           0x2A,    "Sync")},    { _TOKEN(TN_SYNCBODY,       0x2B,    "SyncBody")},    { _TOKEN(TN_SYNCHDR,        0x2C,    "SyncHdr")},    { _TOKEN(TN_SYNCML,         0x2D,    "SyncML")},    { _TOKEN(TN_TARGET,         0x2E,    "Target")},    { _TOKEN(TN_TARGETREF,      0x2F,    "TargetRef")},    { _TOKEN(TN_VERSION,        0x31,    "VerDTD")},    { _TOKEN(TN_PROTO,          0x32,    "VerProto")},    { _TOKEN(TN_NUMBEROFCHANGES,0x33,    "NumberOfChanges")},		{ _TOKEN(TN_MOREDATA,       0x34,    "MoreData")},    { _TOKEN(TN_UNDEF,          0x00,    NULL)}  };  #ifdef __USE_METINF__	static const Tag_t metinf[] =  {    { _TOKEN(TN_METINF_ANCHOR,      0x05,	"Anchor")},    { _TOKEN(TN_METINF_EMI,		      0x06,   "EMI")},    { _TOKEN(TN_METINF_FORMAT,		  0x07,	"Format")},    { _TOKEN(TN_METINF_FREEID,		  0x08,	"FreeID")},    { _TOKEN(TN_METINF_FREEMEM,	    0x09,	"FreeMem")},    { _TOKEN(TN_METINF_LAST,     	  0x0A,	"Last")},    { _TOKEN(TN_METINF_MARK,		    0x0B,	"Mark")},    { _TOKEN(TN_METINF_MAXMSGSIZE,  0x0C,	"MaxMsgSize")},    { _TOKEN(TN_METINF_MEM,		      0x0D,	"Mem")},    { _TOKEN(TN_METINF_METINF,		  0x0E,	"MetInf")},    { _TOKEN(TN_METINF_NEXT,		    0x0F,	"Next")},    { _TOKEN(TN_METINF_NEXTNONCE,	  0x10,	"NextNonce")},    { _TOKEN(TN_METINF_SHAREDMEM,	  0x11,	"SharedMem")},    { _TOKEN(TN_METINF_SIZE,		    0x12,	"Size")},    { _TOKEN(TN_METINF_TYPE,		    0x13,	"Type")},    { _TOKEN(TN_METINF_VERSION,	    0x14,	"Version")},		/* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */    { _TOKEN(TN_METINF_MAXOBJSIZE,	0x15,	"MaxObjSize")},    { _TOKEN(TN_UNDEF,				      0x00,	NULL)}	};  #endif  #ifdef __USE_DEVINF__  static const Tag_t devinf[] = {    {_TOKEN(TN_DEVINF_CTCAP,       0x05,   "CTCap")},    {_TOKEN(TN_DEVINF_CTTYPE,      0x06,   "CTType")},    {_TOKEN(TN_DEVINF_DATASTORE,   0x07,   "DataStore")},    {_TOKEN(TN_DEVINF_DATATYPE,    0x08,   "DataType")},    {_TOKEN(TN_DEVINF_DEVID,       0x09,   "DevID")},    {_TOKEN(TN_DEVINF_DEVINF,      0x0A,   "DevInf")},    {_TOKEN(TN_DEVINF_DEVTYP,      0x0B,   "DevTyp")},    {_TOKEN(TN_DEVINF_DISPLAYNAME, 0x0C,   "DisplayName")},    {_TOKEN(TN_DEVINF_DSMEM,       0x0D,   "DSMem")},    {_TOKEN(TN_DEVINF_EXT,         0x0E,   "Ext")},    {_TOKEN(TN_DEVINF_FWV,         0x0F,   "FwV")},    {_TOKEN(TN_DEVINF_HWV,         0x10,   "HwV")},    {_TOKEN(TN_DEVINF_MAN,         0x11,   "Man")},

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -