Exemplo n.º 1
0
/* decoder callbacks */
Ret_t buildMetInfAnchorCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
    XltDecScannerPtr_t pScanner;
    SmlMetInfAnchorPtr_t pAnchor;
    Ret_t rc;

    pScanner = pDecoder->scanner;

    if (*ppElem != NULL)
        return SML_ERR_XLT_INVAL_SYNCML_DOC;

    if ((pAnchor = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t))) == NULL)
        return SML_ERR_NOT_ENOUGH_SPACE;
    smlLibMemset(pAnchor, 0, sizeof(SmlMetInfAnchor_t));

    if (IS_EMPTY(pScanner->curtok)) {
        *ppElem = pAnchor;
        return SML_ERR_OK;
    }

    if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
        smlFreeMetinfAnchor(pAnchor);
        //smlLibFree(pAnchor);
        return rc;
    }

    while (pScanner->curtok->type != TOK_TAG_END) {
        switch (pScanner->curtok->tagid) {
            /* PCDATA elements */
            case TN_METINF_LAST:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->last);
                break;
            case TN_METINF_NEXT:
                rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->next);
                break;
            default:
                rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
        }
        if (rc != SML_ERR_OK) {
            smlFreeMetinfAnchor(pAnchor);
            //smlLibFree(pAnchor);
            return rc;
        }
        if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
            smlFreeMetinfAnchor(pAnchor);
            //smlLibFree(pAnchor);
            return rc;
        }
    }
    *ppElem = pAnchor;

    return SML_ERR_OK;
}
Exemplo n.º 2
0
SML_API SmlMetInfAnchorPtr_t smlAllocMetInfAnchor() {
    SmlMetInfAnchorPtr_t p = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t));
    if (p == NULL) return NULL;
    smlLibMemset(p, 0, sizeof(SmlMetInfAnchor_t));
    p->next = smlAllocPcdata();
    if (p->next == NULL) {
        smlFreeMetinfAnchor(p);
        return NULL;
    }
    return p;
}
Exemplo n.º 3
0
/** Subfunctions to smlFreePcdata, to freeup MetaInf DTD structures **/
SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data) {
    if (!data) return;
	smlFreePcdata(data->format);
	smlFreePcdata(data->type);
	smlFreePcdata(data->mark);
	smlFreePcdata(data->size);
	smlFreePcdata(data->version);
	smlFreePcdata(data->nextnonce);
	smlFreePcdata(data->maxmsgsize);
    /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
	smlFreePcdata(data->maxobjsize);
	smlFreeMetinfAnchor(data->anchor);
	smlFreeMetinfMem(data->mem);
	smlFreePcdataList(data->emi);
	smlLibFree(data);
	return;
}