📄 xlttags.c
字号:
{_TOKEN(TN_DEVINF_MAXGUIDSIZE, 0x12, "MaxGUIDSize")}, {_TOKEN(TN_DEVINF_MAXID, 0x13, "MaxID")}, {_TOKEN(TN_DEVINF_MAXMEM, 0x14, "MaxMem")}, {_TOKEN(TN_DEVINF_MOD, 0x15, "Mod")}, {_TOKEN(TN_DEVINF_OEM, 0x16, "OEM")}, {_TOKEN(TN_DEVINF_PARAMNAME, 0x17, "ParamName")}, {_TOKEN(TN_DEVINF_PROPNAME, 0x18, "PropName")}, {_TOKEN(TN_DEVINF_RX, 0x19, "Rx")}, {_TOKEN(TN_DEVINF_RXPREF, 0x1A, "Rx-Pref")}, {_TOKEN(TN_DEVINF_SHAREDMEM, 0x1B, "SharedMem")}, {_TOKEN(TN_DEVINF_SIZE, 0x1C, "Size")}, {_TOKEN(TN_DEVINF_SOURCEREF, 0x1D, "SourceRef")}, {_TOKEN(TN_DEVINF_SWV, 0x1E, "SwV")}, {_TOKEN(TN_DEVINF_SYNCCAP, 0x1F, "SyncCap")}, {_TOKEN(TN_DEVINF_SYNCTYPE, 0x20, "SyncType")}, {_TOKEN(TN_DEVINF_TX, 0x21, "Tx")}, {_TOKEN(TN_DEVINF_TXPREF, 0x22, "Tx-Pref")}, {_TOKEN(TN_DEVINF_VALENUM, 0x23, "ValEnum")}, {_TOKEN(TN_DEVINF_VERCT, 0x24, "VerCT")}, {_TOKEN(TN_DEVINF_VERDTD, 0x25, "VerDTD")}, {_TOKEN(TN_DEVINF_XNAM, 0x26, "XNam")}, {_TOKEN(TN_DEVINF_XVAL, 0x27, "XVal")}, // %%% luz:2003-04-28 : added these, they were missing {_TOKEN(TN_DEVINF_UTC, 0x28, "UTC")}, {_TOKEN(TN_DEVINF_NOFM, 0x29, "SupportNumberOfChanges")}, {_TOKEN(TN_DEVINF_LARGEOBJECT, 0x2A, "SupportLargeObjs")}, // %%% end luz { _TOKEN(TN_UNDEF, 0x00, NULL)} }; #endif #ifndef NOWSM _tmpTagPtr = NULL; pGA = mgrGetSyncMLAnchor(); if (pGA == NULL) return NULL; #endif /* get the correct codepage */ if (ext == SML_EXT_UNDEFINED) { #ifndef NOWSM _tmpTagPtr = pGA->tokTbl->SyncML; if (_tmpTagPtr == NULL) { mySize = sizeof(syncml); pGA->tokTbl->SyncML = (TagPtr_t)smlLibMalloc(mySize); if (pGA->tokTbl->SyncML == NULL) return NULL; smlLibMemcpy(pGA->tokTbl->SyncML, &syncml, mySize); _tmpTagPtr = pGA->tokTbl->SyncML; } #else _tmpTagPtr=(TagPtr_t)syncml; #endif } #ifdef __USE_METINF__ else if (ext == SML_EXT_METINF) { #ifndef NOWSM _tmpTagPtr = pGA->tokTbl->MetInf; if (_tmpTagPtr == NULL) { mySize = sizeof(metinf); pGA->tokTbl->MetInf = (TagPtr_t)smlLibMalloc(mySize); if (pGA->tokTbl->MetInf == NULL) return NULL; smlLibMemcpy(pGA->tokTbl->MetInf, &metinf, mySize); _tmpTagPtr = pGA->tokTbl->MetInf; } #else _tmpTagPtr=(TagPtr_t)metinf; #endif } #endif #ifdef __USE_DEVINF__ else if (ext == SML_EXT_DEVINF) { #ifndef NOWSM _tmpTagPtr = pGA->tokTbl->DevInf; if (_tmpTagPtr == NULL) { mySize = sizeof(devinf); pGA->tokTbl->DevInf = (TagPtr_t)smlLibMalloc(mySize); if (pGA->tokTbl->DevInf == NULL) return NULL; smlLibMemcpy(pGA->tokTbl->DevInf, &devinf, mySize); _tmpTagPtr = pGA->tokTbl->DevInf; } #else _tmpTagPtr=(TagPtr_t)devinf; #endif } #endif return _tmpTagPtr; }#undef _TOKEN // we don't need that macro any longer /** * 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 */#ifdef __SML_XML__ Ret_t getTagString(XltTagID_t tagID, String_t tagString, SmlPcdataExtension_t ext){ int i = 0; TagPtr_t pTags = getTagTable(ext); if (pTags == NULL) { tagString[0] = '\0'; return SML_ERR_NOT_ENOUGH_SPACE; } while (((pTags+i)->id) != TN_UNDEF) { if ((((pTags+i)->id) == tagID)) { String_t _tmp = (pTags+i)->xml; smlLibStrcpy(tagString, _tmp); return SML_ERR_OK; } i++; } //smlLibStrcpy(tagString, '\0'); tagString[0] = '\0'; return SML_ERR_XLT_INVAL_PROTO_ELEM;}#endif/** * 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 * pTagByte, the byte representation of the tag * * RETURN: 0, if OK */Ret_t getTagByte(XltTagID_t tagID, SmlPcdataExtension_t ext, Byte_t *pTagByte){ int i = 0; TagPtr_t pTags = getTagTable(ext); if (pTags == NULL) { return SML_ERR_NOT_ENOUGH_SPACE; } while (((pTags+i)->id) != TN_UNDEF) { if (((pTags+i)->id) == tagID) { *pTagByte = (pTags+i)->wbxml; return SML_ERR_OK; } i++; } *pTagByte = 0; return SML_ERR_XLT_INVAL_PROTO_ELEM;}/** * 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){ #ifdef __USE_METINF__ if (ext == SML_EXT_METINF) return 1; #endif #ifdef __USE_DEVINF__ if (ext == SML_EXT_DEVINF) return 0; #endif return 0;}/** * 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/extention of the tag * * RETURN: 0, if OK */Ret_t getExtById(XltTagID_t tagID, SmlPcdataExtension_t *pExt){ int i = 0; SmlPcdataExtension_t ext; /* Iterate over all defined extensions to find the corresponding TAG. * Empty extensions, e.g. not defined numbers will be skipped. */ for (ext = SML_EXT_UNDEFINED; ext < SML_EXT_LAST; ext++) { TagPtr_t pTags = getTagTable(ext); if (pTags == NULL) { continue; /* skip empty codepage */ } i = 0; while (((pTags+i)->id) != TN_UNDEF) { if ((((pTags+i)->id) == tagID)){ *pExt = ext; return SML_ERR_OK; } i++; } } /* tag not found in any extension */ *pExt = (SmlPcdataExtension_t)255; return SML_ERR_XLT_INVAL_PROTO_ELEM;}/** * 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){ int i = 0; TagPtr_t pTags = getTagTable(ext); if (pTags == NULL) { return SML_ERR_NOT_ENOUGH_SPACE; } for (i=0;((pTags+i)->id) != TN_UNDEF; i++) { if (*(pTags+i)->xml != *tag) continue; // if the first char doesn't match we skip the strcmp to speed things up if (smlLibStrcmp(((pTags+i)->xml), tag) == 0) { *pTagID = (pTags+i)->id; return SML_ERR_OK; } } *pTagID = TN_UNDEF; return SML_ERR_XLT_INVAL_PROTO_ELEM;}/** * 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){ int i = 0; TagPtr_t pTags = getTagTable(ext); if (pTags == NULL) { return SML_ERR_NOT_ENOUGH_SPACE; } while (((pTags+i)->id) != TN_UNDEF) { if (((pTags+i)->wbxml) == tag) { *pTagID = (pTags+i)->id; return SML_ERR_OK; } i++; } *pTagID = TN_UNDEF; return SML_ERR_XLT_INVAL_PROTO_ELEM;}/** * 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 */#ifdef __SML_XML__ Ret_t getTagIDByStringAndNamespace(String_t tag, String_t ns, XltTagID_t *pTagID){ int i = 0; TagPtr_t pTags = getTagTable(getExtByName(ns)); if (pTags == NULL) { return SML_ERR_NOT_ENOUGH_SPACE; } while (((pTags+i)->id) != TN_UNDEF) { if ((smlLibStrcmp(((pTags+i)->xml), tag) == 0)) { *pTagID = (pTags+i)->id; return SML_ERR_OK; } i++; } *pTagID = TN_UNDEF; return SML_ERR_XLT_INVAL_PROTO_ELEM;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -