Ejemplo n.º 1
0
SML_API SmlAlertPtr_t smlAllocAlert() {
    SmlAlertPtr_t p = (SmlAlertPtr_t)smlLibMalloc(sizeof(SmlAlert_t));
    if (p == NULL) return NULL;
    smlLibMemset(p, 0, sizeof(SmlAlert_t));
    p->elementType = SML_PE_ALERT;
    p->cmdID = smlAllocPcdata();
    if (p->cmdID == NULL) {
        smlFreeAlert(p);
        return NULL;
    }
    p->itemList = smlAllocItemList();
    if (p->itemList == NULL) {
        smlFreeAlert(p);
        return NULL;
    }
    return p;
}
Ejemplo n.º 2
0
/**
 * FUNCTION: smlFreeProtoElement
 *
 * frees all allocated memory of a smlProtoElement
 *
 * IN:              VoidPtr_t
 *                  Element to free
 *
 * RETURN:          Ret_t
 *                  Return Code
 */
SML_API Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement)
{
	if (! pProtoElement)
		return(SML_ERR_OK);

	switch (((SmlUnknownProtoElementPtr_t)pProtoElement)->elementType) {

		case SML_PE_HEADER:
			smlFreeSyncHdr((SmlSyncHdrPtr_t)pProtoElement);
			break;

		case SML_PE_SYNC_START:
			smlFreeSync((SmlSyncPtr_t)pProtoElement);
			break;

		case SML_PE_ADD:
		case SML_PE_COPY:
		case SML_PE_REPLACE:
		case SML_PE_DELETE:
		case SML_PE_GENERIC:
			smlFreeGeneric((SmlGenericCmdPtr_t)pProtoElement);
			break;

		case SML_PE_ALERT:
			smlFreeAlert((SmlAlertPtr_t)pProtoElement);
			break;

    case SML_PE_ATOMIC_START:
    case SML_PE_SEQUENCE_START:
		case SML_PE_CMD_GROUP:
			smlFreeAtomic((SmlAtomicPtr_t)pProtoElement);
			break;

#if (defined EXEC_SEND || defined EXEC_RECEIVE)
		case SML_PE_EXEC:
			smlFreeExec((SmlExecPtr_t)pProtoElement);
			break;
#endif

    case SML_PE_PUT:
    case SML_PE_GET:
		case SML_PE_PUT_GET:
			smlFreeGetPut((SmlPutPtr_t)pProtoElement);
			break;

		case SML_PE_MAP:
			smlFreeMap((SmlMapPtr_t)pProtoElement);
			break;

		case SML_PE_RESULTS:
			smlFreeResults((SmlResultsPtr_t)pProtoElement);
			break;

#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
		case SML_PE_SEARCH:
			smlFreeSearch((SmlSearchPtr_t)pProtoElement);
			break;
#endif
		case SML_PE_STATUS:
			smlFreeStatus((SmlStatusPtr_t)pProtoElement);
			break;

		default:
			return(SML_ERR_A_UTI_UNKNOWN_PROTO_ELEMENT);
	}

	return(SML_ERR_OK);
}
Ejemplo n.º 3
0
dmclt_err_t omadmclient_add_generic_alert(dmclt_session sessionH,
										  char * correlator,
                                          dmclt_item_t * itemP)
{
    internals_t * internP = (internals_t *)sessionH;
    SmlAlertPtr_t alertP;
    
    if (!internP || !itemP || !itemP->type || !itemP->format || !itemP->data)
    {
        return DMCLT_ERR_USAGE;
    }

    alertP = smlAllocAlert();
    if (NULL == alertP)
    {
        return DMCLT_ERR_MEMORY;
    }
    
    alertP->data = smlString2Pcdata("1226");
    if (NULL == alertP->data)
    {
        smlFreeAlert(alertP);
        return DMCLT_ERR_MEMORY;
    }

    if (correlator)
    {
        alertP->correlator = smlString2Pcdata(correlator);
        if (NULL == alertP->correlator)
        {
            smlFreeAlert(alertP);
            return DMCLT_ERR_MEMORY;
        }
    }

    if (itemP->source)
    {
        alertP->itemList->item->source = smlAllocSource();
        if (NULL == alertP->itemList->item->source)
        {
            smlFreeAlert(alertP);
            return DMCLT_ERR_MEMORY;
        }
        alertP->itemList->item->source->locURI = smlString2Pcdata(itemP->source);
    }
    
    if (itemP->target)
    {
        alertP->itemList->item->target = smlAllocTarget();
        if (NULL == alertP->itemList->item->target)
        {
            smlFreeAlert(alertP);
            return DMCLT_ERR_MEMORY;
        }
        alertP->itemList->item->target->locURI = smlString2Pcdata(itemP->target);
    }

    alertP->itemList->item->meta = convert_to_meta(itemP->format, itemP->type);
    alertP->itemList->item->data = smlString2Pcdata(itemP->data);
    if (NULL == alertP->itemList->item->meta || NULL == alertP->itemList->item->data)
    {
        smlFreeAlert(alertP);
        return DMCLT_ERR_MEMORY;
    }

    add_element(internP, (basicElement_t *)alertP);

    return DMCLT_ERR_NONE;
}