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

📄 xltdevinf.c

📁 SyncML ToolKits,学习syncml的参考工具包.非常好用.
💻 C
📖 第 1 页 / 共 3 页
字号:
    SmlDevInfXmitListPtr_t pElem = NULL, pPrev = NULL;    pElem = (SmlDevInfXmitListPtr_t) *ppElem;    /* advance to the end of the list, and create ther an empty list element */    while (pElem != NULL) {	    pPrev = pElem;	    pElem = pPrev->next;    }    if ((pElem = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t))) == NULL)        return SML_ERR_NOT_ENOUGH_SPACE;    smlLibMemset(pElem, 0, sizeof(SmlDevInfXmitList_t));    if (pPrev != NULL) /* we already had some entries in the list */	    pPrev->next = pElem;    else /* nope we created a new list */	    *ppElem = pElem;    pElem->data = NULL;    /* at this point pElem should point to an valid list element */    return buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->data);}Ret_t buildDevInfDataStoreList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {    SmlDevInfDatastoreListPtr_t pElem = NULL, pPrev = NULL;    pElem = (SmlDevInfDatastoreListPtr_t) *ppElem;    /* advance to the end of the list, and create ther an empty list element */    while (pElem != NULL) {	    pPrev = pElem;	    pElem = pPrev->next;    }    if ((pElem = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t))) == NULL)        return SML_ERR_NOT_ENOUGH_SPACE;    smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastoreList_t));    if (pPrev != NULL) /* we already had some entries in the list */	    pPrev->next = pElem;    else /* nope we created a new list */	    *ppElem = pElem;    pElem->data = NULL;    /* at this point pElem should point to an valid list element */    return buildDevInfDataStoreCmd(pDecoder, (VoidPtr_t)&pElem->data);}Ret_t buildDevInfExtList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {    SmlDevInfExtListPtr_t pElem = NULL, pPrev = NULL;    pElem = (SmlDevInfExtListPtr_t) *ppElem;    /* advance to the end of the list, and create ther an empty list element */    while (pElem != NULL) {	    pPrev = pElem;	    pElem = pPrev->next;    }    if ((pElem = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t))) == NULL)        return SML_ERR_NOT_ENOUGH_SPACE;    smlLibMemset(pElem, 0, sizeof(SmlDevInfExtList_t));    if (pPrev != NULL) /* we already had some entries in the list */	    pPrev->next = pElem;    else /* nope we created a new list */	    *ppElem = pElem;    pElem->data = NULL;    /* at this point pElem should point to an valid list element */    return buildDevInfExtCmd(pDecoder, (VoidPtr_t)&pElem->data);}Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {    SmlDevInfCtcapListPtr_t       pCtcap        = NULL, pPrev = NULL;    SmlDevInfCTDataPropListPtr_t  pOldProp      = NULL, pProp = NULL;    SmlDevInfCTDataListPtr_t      pOldParam     = NULL, pParam = NULL;    SmlDevInfCtcapListPtr_t       pElem         = NULL;    XltDecScannerPtr_t            pScanner;    Ret_t rc;    pElem = (SmlDevInfCtcapListPtr_t) *ppElem;    pScanner = pDecoder->scanner;    if (IS_EMPTY(pScanner->curtok)) {        *ppElem = pElem;        return SML_ERR_OK;    }    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {        smlLibFree(pElem);        return rc;    }    while (pScanner->curtok->type != TOK_TAG_END) {        switch (pScanner->curtok->tagid) {        case TN_DEVINF_CTTYPE:                    pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;            /* advance to the end of the list, and create ther an empty list element */            while (pCtcap != NULL) {	            pPrev = pCtcap;	            pCtcap = pPrev->next;            }            if ((pCtcap = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t))) == NULL)                return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pCtcap, 0, sizeof(SmlDevInfCtcapList_t));            if (pPrev != NULL) /* we already had some entries in the list */	            pPrev->next = pCtcap;            else /* nope we created a new list */	            *ppElem = pCtcap;            pCtcap->data = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t));            if (pCtcap->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pCtcap->data, 0, sizeof(SmlDevInfCTCap_t));            rc = buildPCData(pDecoder, (VoidPtr_t)&pCtcap->data->cttype);            break;        case TN_DEVINF_PROPNAME:            pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;            if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            while (pCtcap->next != NULL) {                pPrev = pCtcap;                pCtcap = pCtcap->next;            }            /* here we are at the latest defined DevInfCTCapPtr_t */            /* now we need to create a new DevInfCTDataPtr_t element, tostore the properties name */            pOldProp = NULL;            pProp    = pCtcap->data->prop;            while (pProp != NULL) {                pOldProp = pProp;                pProp = pProp->next;            }            pProp = (SmlDevInfCTDataPropListPtr_t) smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t));            if (pProp == NULL) return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pProp, 0, sizeof(SmlDevInfCTDataPropList_t));            if (pOldProp != NULL)                pOldProp->next = pProp;            else                 pCtcap->data->prop = pProp;            pProp->data = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t));            if (pProp->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pProp->data, 0, sizeof(SmlDevInfCTDataProp_t));            pProp->data->prop = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));            if (pProp->data->prop == NULL) return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pProp->data->prop, 0, sizeof(SmlDevInfCTData_t));            rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->name);            break;        case TN_DEVINF_PARAMNAME:            pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;            if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            while (pCtcap->next != NULL) {                pPrev = pCtcap;                pCtcap = pCtcap->next;            }            /* here we are at the latest defined DevInfCTCapPtr_t */            pProp    = pCtcap->data->prop;            if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            while (pProp->next != NULL) {                pProp = pProp->next;            }            /* here we are at the latest defined PropList Element in the latest defined CTCap element */            /* now lets insert a new Param element into this property */            pOldParam = NULL;            pParam = pProp->data->param;            while (pParam != NULL) {                pOldParam = pParam;                pParam    = pParam->next;            }            pParam = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t));            if (pParam == NULL) return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pParam, 0, sizeof(SmlDevInfCTDataList_t));            if (pOldParam != NULL)                pOldParam->next = pParam;            else                pProp->data->param = pParam;            pParam->data = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));            if (pParam->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;            smlLibMemset(pParam->data, 0, sizeof(SmlDevInfCTData_t));            rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->name);            break;        case TN_DEVINF_DISPLAYNAME:        case TN_DEVINF_VALENUM:        case TN_DEVINF_DATATYPE:        case TN_DEVINF_SIZE:            /* The code for the above 4 is basically the same.             * The hardpart is finding the right SmlDevInfCTDataPtr_t             * struct, as it can be either within a Property or an Parameter.             */            pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;            if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            while (pCtcap->next != NULL) {                pCtcap = pCtcap->next;            }            /* here we are at the latest defined DevInfCTCapPtr_t */            pProp    = pCtcap->data->prop;            if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            while (pProp->next != NULL) {                pProp = pProp->next;            }            if (pProp->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            if (pProp->data->prop == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;            if (pProp->data->param == NULL) {                /* No Param's yet so we have Property fields to fill */                switch(pScanner->curtok->tagid) {                case TN_DEVINF_DISPLAYNAME:                    rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->dname);                    break;                case TN_DEVINF_VALENUM:                    rc = buildPCDataList(pDecoder, (VoidPtr_t)&pProp->data->prop->valenum);                    break;                case TN_DEVINF_DATATYPE:                    rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->datatype);                    break;                case TN_DEVINF_SIZE:                    rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->size);                    break;                default:                    break;                }            } else {                pParam = pProp->data->param;                while (pParam->next != NULL) {                    pParam = pParam->next;                }                if (pParam->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;                switch(pScanner->curtok->tagid) {                case TN_DEVINF_DISPLAYNAME:                    rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->dname);                    break;                case TN_DEVINF_VALENUM:                    rc = buildPCDataList(pDecoder, (VoidPtr_t)&pParam->data->valenum);                    break;                case TN_DEVINF_DATATYPE:                    rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->datatype);                    break;                case TN_DEVINF_SIZE:                    rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->size);                    break;                default:                    break;                }            }            break;        default:            rc = SML_ERR_XLT_INVAL_SYNCML_DOC;        }        if (rc != SML_ERR_OK) {            smlLibFree(pElem);            return rc;        }        if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {            smlLibFree(pElem);            return rc;        }    } /* eof while */    pElem = *ppElem;    return SML_ERR_OK;}Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {    XltDecScannerPtr_t pScanner;    SmlDevInfDSMemPtr_t pElem;    Ret_t rc;    pScanner = pDecoder->scanner;    if (*ppElem != NULL)        return SML_ERR_XLT_INVAL_SYNCML_DOC;    if ((pElem = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t))) == NULL)        return SML_ERR_NOT_ENOUGH_SPACE;    smlLibMemset(pElem, 0, sizeof(SmlDevInfDSMem_t));    if (IS_EMPTY(pScanner->curtok)) {        *ppElem = pElem;        return SML_ERR_OK;    }    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {        smlLibFree(pElem);        return rc;    }    while (pScanner->curtok->type != TOK_TAG_END) {        switch (pScanner->curtok->tagid) {    		    /* PCDATA elements */            case TN_DEVINF_SHAREDMEM:                // %%% luz:2003-04-28: made work as a flag                pElem->flags |= SmlDevInfSharedMem_f;                // rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->shared);                break;            case TN_DEVINF_MAXMEM:                rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxmem);                break;            case TN_DEVINF_MAXID:                rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxid);                break;            default:                rc = SML_ERR_XLT_INVAL_SYNCML_DOC;        }        if (rc != SML_ERR_OK) {            smlLibFree(pElem);            return rc;        }        if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {            smlLibFree(pElem);            return rc;        }    }    *ppElem = pElem;    return SML_ERR_OK;}Ret_t buildDevInfCTCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {    XltDecScannerPtr_t pScanner;    SmlDevInfCTCapPtr_t pElem;    Ret_t rc;    pScanner = pDecoder->scanner;    if (*ppElem != NULL)        return SML_ERR_XLT_INVAL_SYNCML_DOC;    if ((pElem = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t))) == NULL)        return SML_ERR_NOT_ENOUGH_SPACE;    smlLibMemset(pElem, 0, sizeof(SmlDevInfCTCap_t));    if (IS_EMPTY(pScanner->curtok)) {        *ppElem = pElem;        return SML_ERR_OK;    }    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {        smlLibFree(pElem);        return rc;    }

⌨️ 快捷键说明

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