ClRcT
clCompAppStateChange(
    ClEoStateT eoState)
{
    switch (eoState)
    {
        case CL_EO_STATE_SUSPEND:
        {
            /*
             * ---BEGIN_APPLICATION_CODE---
             */

            clprintf(CL_LOG_SEV_INFO,"csa102: Suspending...");
            running = 0;

            /*
             * ---END_APPLICATION_CODE---
             */

            break;
        }

        case CL_EO_STATE_RESUME:
        {
            /*
             * ---BEGIN_APPLICATION_CODE---
             */

            clprintf(CL_LOG_SEV_INFO,"csa102: Resuming...");
            running = 1;

            /*
             * ---END_APPLICATION_CODE---
             */

            break;
        }
        
        default:
        {
            break;
        }
    }
 
    return CL_OK;
}
void safRemoveWork(SaInvocationT  invocation,
                   const SaNameT  *compName,
                   const SaNameT  *csiName,
                   SaAmfCSIFlagsT csiFlags)
{
    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Remove Received\n", 
              compName->length, compName->value, mypid);

    clprintf (CL_LOG_SEV_INFO, "   CSI                     : %.*s\n", csiName->length, csiName->value);
    clprintf (CL_LOG_SEV_INFO, "   CSI Flags               : 0x%d\n", csiFlags);

    /*
     * Add application specific logic for removing the work for this CSI.
     */
    AddRemVirtualAddress("down",&gVirtualIp);
    saAmfResponse(amfHandle, invocation, SA_AIS_OK);
}
void* activeLoop(void* p)
{
    while (running)
    {
        clprintf(CL_LOG_SEV_INFO,"csa102: Threaded Hello World! %s", show_progress());
        sleep(2);
    }
    return NULL;
}
void clCompAppAMFCSIRemove(SaInvocationT  invocation,
                           const SaNameT  *compName,
                           const SaNameT  *csiName,
                           SaAmfCSIFlagsT csiFlags)
{
    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Remove Received\n", 
              compName->length, compName->value, mypid);

    clprintf (CL_LOG_SEV_INFO, "   CSI                     : %.*s\n", csiName->length, csiName->value);
    clprintf (CL_LOG_SEV_INFO, "   CSI Flags               : 0x%d\n", csiFlags);

    /*
     * Add application specific logic for removing the work for this CSI.
     */

    saAmfResponse(amfHandle, invocation, SA_AIS_OK);

    return;
}
void
clCompAppTerminate(
    SaInvocationT       invocation,
    const SaNameT       *compName)
{
    SaAisErrorT rc = SA_AIS_OK;

    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminating\n",
              compName->length, compName->value, mypid);
    /*
     * Application should figure out whether the termination request
     * was for the proxy itself or one of its proxied components.
     *
     * In case the termination request was for a proxied component,
     * call the proxied specific termination function and unregister
     * the proxied component.
     * Otherwise, unregister the proxy component and
     * call the client finalize function.
     */


    /*
     * Unregister with AMF and send back a response
     */

    if ( (rc = saAmfComponentUnregister(amfHandle, compName, NULL)) != SA_AIS_OK)
        goto errorexit;

    saAmfResponse(amfHandle, invocation, SA_AIS_OK);

    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminated\n", compName->length, compName->value, mypid);

    unblockNow = CL_TRUE;

    return;

errorexit:

    clprintf (CL_LOG_SEV_ERROR, "Component [%.*s] : PID [%d]. Termination error [0x%x]\n",
              compName->length, compName->value, mypid, rc);

    return;
}
static SaAisErrorT csa113Comp_PublishEvent()
{
    SaEvtEventIdT      eventId         = 0;
    static int      index           = 0;
    SaSizeT         data_len        = 0;
    SaAisErrorT	    rc              = SA_AIS_OK;
    char            *data           = 0;
    typedef void (*Generator)(char **, ClSizeT*);

    //
    // Note: to add a new generator, just define it above and then include
    // the new functions name in the generators list.
    // Next, maybe something that gets disk free info by way of getfsent
    // and statfs?
    static Generator generators[]   =
    {
        generate_time_of_day,
        generate_load_average
    };

    //
    // every time through increment index and then set index to
    // it's value modulo the number of entries in the generators
    // array.  This will cause us to cycle through the list of
    // generators as we're called to publish events.
    (*generators[index++])(&data, &data_len);
    index %= (int)(sizeof generators / sizeof generators[0]);
    if (data == 0 || data_len == 0)
    {
        clprintf(CL_LOG_SEV_ERROR, "No event data generated.");
        return SA_AIS_ERR_NO_MEMORY;
    }
    clprintf(CL_LOG_SEV_INFO,"Publishing Event: %.*s\n",(int)data_len, data);
    rc = saEvtEventPublish(eventHandle, (void *)data, data_len, &eventId);
    if (rc != SA_AIS_OK)
    {
        clprintf(CL_LOG_SEV_ERROR,"Event publish attempt failed with error [%x]", rc);
    }
    clHeapFree(data);

    return SA_AIS_OK;
}
void clPyGlueInit(char* appModule,void (*init_extensions[])(void),int argc, char**argv)
{
  char buf[1024];
  ClRcT rc;
    Py_Initialize();
    PySys_SetArgv(argc, argv);
    PyEval_InitThreads();
    
    if (init_extensions) 
      {
        int i = 0;
        for(i=0; init_extensions[i]!=NULL; i++) (*init_extensions[i])();
      }
    thrdState = PyThreadState_Get();

    rc = clOsalMutexInit(&pyMutex);
    CL_ASSERT(rc==CL_OK); 

    rc = clOsalCondInit(&event);
    CL_ASSERT(rc==CL_OK); 

    rc = clOsalMutexLock(&pyMutex);
    CL_ASSERT(rc==CL_OK); 

    PyThreadState_Swap(thrdState);

    PyRun_SimpleString("import os, os.path, sys\n");
    snprintf(buf,1024,"sys.path.append(os.path.realpath('%s'))\n",CL_APP_BINDIR);
    clprintf(CL_LOG_SEV_INFO, buf);
    PyRun_SimpleString(buf);
    //PyRun_SimpleString("sys.path.append(os.path.realpath('../../bin'))\n");
    snprintf(buf,1024,"from %s import *\n",appModule);
    clprintf(CL_LOG_SEV_INFO, buf);
    PyRun_SimpleString(buf);

    PyThreadState_Swap(NULL);
    PyEval_ReleaseLock();

    rc=clOsalMutexUnlock(&pyMutex);
    CL_ASSERT(rc==CL_OK); 

}
ClRcT
clCompAppTerminate(
    ClInvocationT       invocation,
    const SaNameT       *compName)
{
    ClRcT rc = CL_OK;

    clprintf ("Component [%s] : PID [%d]. Terminating\n",
              compName->value, mypid);

    /*
     * ---BEGIN_APPLICATION_CODE--- 
     */

    // ...

    /*
     * ---END_APPLICATION_CODE---
     */
    
    /*
     * Unregister with AMF and send back a response
     */

    if ( (rc = clCpmComponentUnregister(cpmHandle, compName, NULL)) )
        goto errorexit;
    if ( (rc = clCpmClientFinalize(cpmHandle)) )
        goto errorexit;

    clCpmResponse(cpmHandle, invocation, CL_OK);

    clprintf ("Component [%s] : PID [%d]. Terminated\n", compName->value, mypid);

    return rc;

errorexit:

    clprintf ("Component [%s] : PID [%d]. Termination error [0x%x]\n",
              compName->value, mypid, rc);

    return rc;
}
ClRcT
clCompAppTerminate(
    ClInvocationT       invocation,
    const ClNameT       *compName)
{
    ClRcT rc = CL_OK;

    clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%ld]. Terminating",
              compName->value, mypid);

    /*
     * ---BEGIN_APPLICATION_CODE--- 
     */

    // ...

    /*
     * ---END_APPLICATION_CODE---
     */
    
    /*
     * Unregister with AMF and send back a response
     */

    if ( (rc = clCpmComponentUnregister(cpmHandle, compName, NULL)) )
        goto errorexit;
    if ( (rc = clCpmClientFinalize(cpmHandle)) )
        goto errorexit;

    clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%ld]. Terminated", compName->value, mypid);
    clCpmResponse(cpmHandle, invocation, CL_OK);
    clEvalAppLogStreamClose(gEvalLogStream);

    return rc;

errorexit:

    clprintf (CL_LOG_SEV_ERROR, "Component [%s] : PID [%ld]. Termination error [0x%x]",
              compName->value, mypid, rc);

    return rc;
}
static void csa112Comp_appEventCallback(SaEvtSubscriptionIdT subscriptionId, SaEvtEventHandleT eventHandle, SaSizeT eventDataSize)
{
    SaAisErrorT     rc = SA_AIS_OK;
    static ClPtrT   resTest = 0;
    
    clprintf(CL_LOG_SEV_INFO,"We've got an event to receive\n");

    /* A high performance implementation would keep the buffer
       if it was big enough for the next event, OR even faster
       preallocate buffer(s) of the the maximum event size which
       can be known by controlling what processes publish to
       a particular event channel.

       This tutorial will simply free an realloc the event buffer.
    */
    if (resTest != 0)
    {
        clHeapFree((char *)resTest);
        resTest = 0;
    }
    resTest = clHeapAllocate(eventDataSize + 1);
    if (resTest == 0)
    {
        clprintf(CL_LOG_SEV_ERROR, "Failed to allocate space for event");
        return;
    }

    /* This API can be used outside of the callback routine, which is why
       you need to pass the size of the buffer you've allocated. */
    rc = saEvtEventDataGet(eventHandle, resTest, &eventDataSize);
    if (rc!= SA_AIS_OK)
    {
        clprintf(CL_LOG_SEV_ERROR, "Failed to get event data [0x%x]",rc);
        return;
    }
    
    /* This tutorial just prints the event.  Rather then rely on the correct
       null termination at the publisher side, I'm going to append a 0 at
       the end before printing it. */
    *(((char *)resTest) + eventDataSize) = 0;
    clprintf(CL_LOG_SEV_INFO,"received event: %s\n", (char *)resTest);
}
static void clCompAppTerminate(SaInvocationT invocation, const SaNameT *compName)
{
    SaAisErrorT rc = SA_AIS_OK;

    clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. Terminating\n",
              compName->value, mypid);

    /*
     * ---BEGIN_APPLICATION_CODE--- 
     */

    //clPyGlueTerminate();

    /*
     * ---END_APPLICATION_CODE---
     */
    
    /*
     * Unregister with AMF and respond to AMF saying whether the
     * termination was successful or not.
     */

    if ( (rc = saAmfComponentUnregister(amfHandle, compName, NULL)) != SA_AIS_OK)
        goto errorexit;

    saAmfResponse(amfHandle, invocation, SA_AIS_OK);

    clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. Terminated\n",
              compName->value, mypid);

    unblockNow = CL_TRUE;
    
    return;

errorexit:

    clprintf (CL_LOG_SEV_ERROR, "Component [%s] : PID [%d]. Termination error [0x%x]\n",
              compName->value, mypid, rc);

    return;
}
/**
 * This function is called by the provisioning library before forwarding any of the
 * transaction requests to this application on this managed resource. Please refer the file
 * clamfMgmtSAAMFSITABLEOAMPConfig.h for detailed documentation for this function.
 */
void clamfMgmtSAAMFSITABLEProvObjectStart(ClCorMOIdPtrT pMoId, ClHandleT txnHandle)
{
    /*
     * ---BEGIN_APPLICATION_CODE---
    */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
    */
}
/**
 * This function is called by the provisioning library after all the transaction requests
 * for this managed resource are forwarded to this application. Please refer the file
 * clcsa105CompCSA105RESOAMPConfig.h for detailed documentation for this function.
 */
void clcsa105CompCSA105RESProvObjectEnd(ClCorMOIdPtrT pMoId, ClHandleT txnHandle)
{
    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */
}
/**
 * This function is called by the provisioning library after all the transaction requests
 * for this managed resource are forwarded to this application. Please refer the file
 * clProvisioningTIMESETTABLEOAMPConfig.h for detailed documentation for this function.
 */
void clProvisioningTIMESETTABLEProvObjectEnd(ClCorMOIdPtrT pMoId, ClHandleT txnHandle)
{
    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */
}
SaAisErrorT checkpoint_read_seq(ClUint32T *seq)
{
    SaAisErrorT rc = SA_AIS_OK;
    ClUint32T err_idx; /* Error index in ioVector */
    ClUint32T seq_no = 0xffffffff;
    SaCkptIOVectorElementT iov = {
        .sectionId  = ckpt_sid,
        .dataBuffer = (ClPtrT)&seq_no,
        .dataSize   = sizeof(ClUint32T),
        .dataOffset = (ClOffsetT)0,
        .readSize   = sizeof(ClUint32T)
    };
        
    rc = saCkptCheckpointRead(ckpt_handle, &iov, 1, &err_idx);
    if (rc != SA_AIS_OK)
    {
        if (rc != SA_AIS_ERR_NOT_EXIST)  /* NOT_EXIST is ok, just means no active has written */
            return SA_AIS_OK;
        
        clprintf(CL_LOG_SEV_ERROR,"Error: [0x%x] from checkpoint read, err_idx = %u", rc, err_idx);
    }

    *seq = ntohl(seq_no);
    
    return SA_AIS_OK;
}

SaAisErrorT checkpoint_replica_activate(void)
{
    SaAisErrorT rc = SA_AIS_OK;

    if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)
    {
        clprintf(CL_LOG_SEV_ERROR, "checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet", rc);
    }
    else rc = SA_AIS_OK;

    return rc;
}
/*
 * clCompAppTxnEnd
 * ---------------
 * This function is invoked after all the transaction requests for this application
 * are completed. Please refer the detailed documentation for this function
 * in clCompAppProv.h file.
 */
void
clCompAppProvTxnEnd(ClHandleT txnHandle)
{
    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "**** Inside the function : [%s] ****", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */
}
int main(int argc, char *argv[])
{
    SaAisErrorT rc = SA_AIS_OK;

    /* Connect to the SAF cluster */
    initializeAmf();

    /* Do the application specific initialization here. */
    
    /* Block on AMF dispatch file descriptor for callbacks.
       When this function returns its time to quit. */
    dispatchLoop();
    
    /* Do the application specific finalization here. */

    /* Now finalize my connection with the SAF cluster */
    if((rc = saAmfFinalize(amfHandle)) != SA_AIS_OK)
      clprintf (CL_LOG_SEV_ERROR, "AMF finalization error[0x%X]", rc);
    else
      clprintf (CL_LOG_SEV_INFO, "AMF Finalized");   

    return 0;
}
ClRcT 
alarm_event_subscribe_callback(const ClAlarmHandleInfoT* pAlarmInfo)
{
    ClRcT   rc = CL_OK;
    SaNameT moIdName = {0};
    ClCorMOIdT  moId = pAlarmInfo->alarmInfo.moId;
    ClAlarmUtilPayLoadListPtrT pPayloadList = NULL;

    rc = clCorMoIdToMoIdNameGet(&moId, &moIdName);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"[%s]:Failed while getting the moId from MOId Name. rc[0x%x] ", 
                appname, rc);
        return rc;
    }

    rc = clAlarmUtilPayLoadExtract((ClUint8T *)pAlarmInfo->alarmInfo.buff, 
            pAlarmInfo->alarmInfo.len, &pPayloadList);
    if (CL_OK != rc)
    {
        clprintf(CL_LOG_SEV_ERROR,"[%s]: Failed while extracting the payload information. rc[0x%x] ", 
                appname, rc);
        return rc;
    }
        
    clprintf(CL_LOG_SEV_INFO,"______________________________________________________");
    clprintf(CL_LOG_SEV_INFO,"The alarm is [%s] ", pAlarmInfo->alarmInfo.alarmState ?"RAISED":"CLEARED");
    clprintf(CL_LOG_SEV_INFO,"The alarm Raised on the resource [%s]  ", moIdName.value);
    clprintf(CL_LOG_SEV_INFO,"Component which has raised the alarm  is [%s] ", pAlarmInfo->alarmInfo.compName.value);
    clprintf(CL_LOG_SEV_INFO,"Probable cause of the alarm is [%d] ", pAlarmInfo->alarmInfo.probCause);
    clprintf(CL_LOG_SEV_INFO,"Severity of the alarm is [%d] ", pAlarmInfo->alarmInfo.severity);
    clprintf(CL_LOG_SEV_INFO,"The payload information : [%s] ", (char*)pPayloadList->pPayload[0].pTlv[0].value);
    clprintf(CL_LOG_SEV_INFO,"______________________________________________________");

    clAlarmUtilPayloadListFree(pPayloadList);
    return rc;
}
static SaAisErrorT checkpoint_read_seq(ClUint32T *seq)
{
    SaAisErrorT rc = SA_AIS_OK;
    SaUint32T err_idx; /* Error index in ioVector */
    SaUint32T seq_no = 0xffffffff;
    SaCkptIOVectorElementT iov = {
        .sectionId  = ckpt_sid,
        .dataBuffer = (void *)&seq_no,
        .dataSize   = sizeof(SaUint32T),
        .dataOffset = (SaSizeT)0,
        .readSize   = sizeof(SaUint32T)
    };
        
    rc = saCkptCheckpointRead(ckpt_handle, &iov, 1, &err_idx);
    if (rc != SA_AIS_OK )
    {
        clprintf(CL_LOG_SEV_ERROR,"Error: [0x%x] from checkpoint read, err_idx = %u\n", rc, err_idx);
    }

    /* FIXME: How to process this err_idx? */
    *seq = ntohl(seq_no);
//    clOsalPrintf("checkpoint_read_seq: seq_no = %lu, seq = %lu\n", seq_no, *seq); fflush(stdout);
    
    return rc;
}

static SaAisErrorT checkpoint_replica_activate(void)
{
    SaAisErrorT     rc = SA_AIS_OK;

    if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)
    {
        clprintf( CL_LOG_SEV_ERROR, "checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet", rc);
    }

    return rc;
}
void clCompAppTerminate(SaInvocationT invocation, const SaNameT *compName)
{
    SaAisErrorT rc = SA_AIS_OK;

    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminating\n",
              compName->length, compName->value, mypid);


    alarmClockFinalize();
 
    alarmClockCkptFinalize();
 
    /*
     * Unregister with AMF and respond to AMF saying whether the
     * termination was successful or not.
     */

    if ( (rc = saAmfComponentUnregister(amfHandle, compName, NULL)) != SA_AIS_OK)
        goto errorexit;

    saAmfResponse(amfHandle, invocation, SA_AIS_OK);

    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminated\n",
              compName->length, compName->value, mypid);

    unblockNow = CL_TRUE;
    
    return;

errorexit:

    clprintf (CL_LOG_SEV_ERROR, "Component [%.*s] : PID [%d]. Termination error [0x%x]\n",
              compName->length, compName->value, mypid, rc);

    return;
}
static void* amfDispatcher(void *param)
{
    SaSelectionObjectT dispatch_fd;
    fd_set read_fds;
    ClRcT rc;

    FD_ZERO(&read_fds);

    /*
     * Get the AMF dispatch FD for the callbacks
     */
    if ( (rc = saAmfSelectionObjectGet(amfHandle, &dispatch_fd)) != SA_AIS_OK)
    {
        clprintf (CL_LOG_SEV_ERROR, "Error getting selection object -- unable to dispatch AMF events");
        return NULL;        
    }
    
    
    FD_SET(dispatch_fd, &read_fds);

    /*
     * Block on AMF dispatch file descriptor for callbacks
     */
    do
    {
        if( select(dispatch_fd + 1, &read_fds, NULL, NULL, NULL) < 0)
        {
		    clprintf (CL_LOG_SEV_ERROR, "Error in select() -- unable to dispatch AMF events");
			perror("");
            break;
        }
        saAmfDispatch(amfHandle, SA_DISPATCH_ALL);
    }while(!unblockNow);      

    return NULL;
}
/**
 * This function is called by the provisioning library whenever the object 
 * modification operation is done on the resource being managed. For a single job 
 * request, this function is called if the validate function is failed. For a 
 * multiple job request, on encountering a validate failure, this function is 
 * called to rollback all the jobs before the one (including) on which the 
 * validation failure is reported.
 *
 * The pThis is a pointer to the provisioning class. 
 * The txnHandle is the unique handle for all the jobs which are part of same session. So for
 * a session containing multiple jobs, then it is unique of all the jobs and it can be used
 * to identify them.
 * 
 * The pProvTxnData is a pointer to the ClProvTxnDataT structure which contains 
 * the information about the job being performed on the managed resource. 
 * The pProvTxnData->provCmd stores the operation type which can be 
 * CL_COR_OP_CREATE_AND_SET, CL_COR_OP_CREATE, CL_COR_OP_SET or CL_COR_OP_DELETE
 * based on what is the operation happening on the resource.
 * In the case of set operation, the various fields of pProvTxnData provide the
 * the details about the operation which is happening on the resource. It contain 
 * MOID of the managed resource and information about the attribute on which set
 * operation is done. For a create, create-set and delete operation, the pProvTxnData 
 * contains the MOID of the resource on which the given operation is done.
 *
 * ** Note : This function is being deprecated, if clProvObjectRollback() callback 
 * is filled in the constructor, then that callback function will be called 
 * instead of this to group rollback all the requests.
 */
ClRcT clamfMgmtSAAMFSITABLEProvRollback(CL_OM_PROV_CLASS* pThis, ClHandleT txnHandle, ClProvTxnDataT* pProvTxnData)
{
    ClRcT rc = CL_OK;

    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */

    return rc;
}
/**
 * Read all the transient attributes values in an object in a single request.
 * Please refer protptype of this function in the file clProvisioningTIMESETTABLEOAMPConfig.h
 * for detailed documentation for this function.
 */
ClRcT clProvisioningTIMESETTABLEProvObjectRead(CL_OM_PROV_CLASS* pThis, ClHandleT txnHandle, ClProvTxnDataT* pProvTxnDataList, ClUint32T txnDataEntries)
{
    ClRcT rc = CL_OK;
	
	/*
	 * ---BEGIN_APPLICATION_CODE$objectRead$---
	 */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);
 	
	/*
	 * ---END_APPLICATION_CODE---
	 */
 	 
    return rc;
}
/**
 * This function is called by the provisioning library when the managed resource 
 * is deleted. This can have logic of deleting the resources which might have 
 * been allocated in the constructor function.
 */ 
ClRcT clProvisioningTIMESETTABLEProvDestructor ( void *pThis , void  *pUsrData, ClUint32T usrDataLen )
{
    ClRcT rc = CL_OK;
    
    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */

    return rc;  
}
/**
 * Rollback all the jobs of an object whose validation failed.
 * Please refer protptype of this function in the file clcsa105CompCSA105RESOAMPConfig.h
 * for detailed documentation for this function.
 */
ClRcT clcsa105CompCSA105RESProvObjectRollback(CL_OM_PROV_CLASS* pThis, ClHandleT txnHandle, ClProvTxnDataT* pProvTxnDataList, ClUint32T txnDataEntries)
{
    ClRcT rc = CL_OK;
	
	/*
	 * ---BEGIN_APPLICATION_CODE$objectRollback$---
	 */
 	
    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

	/*
	 * ---END_APPLICATION_CODE---
	 */
 	 
    return rc;
}
/**
 * This function is called to perform a get operation on the transient attribute
 * which is owned by the primary object implementer (OI). As the COR doesn't have
 * the latest value of the transient attribute, it is obtained from the OI. This
 * function is called in the OI's context which it can use to fill the latest
 * value of the runtime or transient attribute.
 *
 * The pThis is pointer to the provisioning class.
 * The txnHandle is used to identify the jobs which are part of same bundle request.
 * For single request this field is of not much significance, but for a multiple job
 * request, this feild is used to identify all the jobs which are part of same
 * bundle request sent by COR.
 *
 * The pProvTxnData contains the information about the attribute jobs. It contains 
 * the MOId of the managed resource, the attribute identifier, its type (array or 
 * simple), its basic type (data type), index (in case it is array attriubte), 
 * size and the pointer (allocated by the library) to the memory on which the 
 * data can be copied.
 *
 * For a request containing only single job, this function is called only once. But
 * for a multiple job request, this is called for all the attributes one at a time.
 *
 * ** Note : This function is being deprecated, if clProvObjectRead() callback is filled 
 * in the constructor, then that callback function will be called instead of this 
 * to group read all the requests.
 */ 
ClRcT clcsa105CompCSA105RESProvRead(CL_OM_PROV_CLASS* pThis, ClHandleT txnHandle, ClProvTxnDataT* pProvTxnData)
{
    ClRcT rc = CL_OK;

    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */

    return rc;
}
/**
 * This function is called by the provisioning library when the managed resource 
 * is deleted. This can have logic of deleting the resources which might have 
 * been allocated in the constructor function.
 */ 
ClRcT clcsa105CompCSA105RESProvDestructor ( void *pThis , void  *pUsrData, ClUint32T usrDataLen )
{
    ClRcT rc = CL_OK;
    
    /*
     * ---BEGIN_APPLICATION_CODE---
     */

    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

    /*
     * ---END_APPLICATION_CODE---
     */

    return rc;  
}
/**
 * Validate all the jobs in an object sent from northbound as a single request.
 * Please refer protptype of this function in the file clamfMgmtSAAMFSITABLEOAMPConfig.h
 * for detailed documentation for this function.
 */
ClRcT clamfMgmtSAAMFSITABLEProvObjectValidate(CL_OM_PROV_CLASS* pThis, ClHandleT txnHandle, ClProvTxnDataT* pProvTxnDataList, ClUint32T txnDataEntries)
{
    ClRcT rc = CL_OK;
	
	/*
	 * ---BEGIN_APPLICATION_CODE$objectValidate$---
	 */
 	
    clprintf(CL_LOG_SEV_INFO, "Inside the function %s", __FUNCTION__);

	/*
	 * ---END_APPLICATION_CODE---
	 */
 	 
    return rc;
}
void
clProxiedCompInstantiate(
    SaInvocationT       invocation,
    const SaNameT       *proxiedCompName)
{
    SaNameT appName;
    ClRcT               rc = SA_AIS_OK; 

    /*
     * Add code for proxied component instatiation below. 
     * The code is specific to proxied component being instantiated 
     * and is defined by the protocol/interface between proxy and 
     * proxied component.
     */

    /*
     * ---BEGIN_APPLICATION_CODE---
     */
    

    /*
     * ---END_APPLICATION_CODE---
     */

    /*
     * If the instantiation of the proxied component was successful,
     * then register the proxied component with the AMF.
     */

    if ( (rc = saAmfComponentNameGet(amfHandle, &appName)) != SA_AIS_OK) 
        goto errorexit;
    if ( (rc = saAmfComponentRegister(amfHandle, proxiedCompName, &appName)) != SA_AIS_OK) 
        goto errorexit;

    saAmfResponse(amfHandle, invocation, SA_AIS_OK);

    return;

errorexit:

    clprintf (CL_LOG_SEV_ERROR, "Component [%.*s] : PID [%d]. Initialization error [0x%x]\n",
              appName.length, appName.value, mypid, rc);

    return;
}
void dispatchLoop(void)
{        
  SaAisErrorT         rc = SA_AIS_OK;
  SaSelectionObjectT amf_dispatch_fd;
  int maxFd;
  fd_set read_fds;

  /* This boilerplate code includes an example of how to simultaneously
     dispatch for 2 services (in this case AMF and CKPT).  But since checkpoint
     is not initialized or used, it is commented out */
  /* SaSelectionObjectT ckpt_dispatch_fd; */

  /*
   * Get the AMF dispatch FD for the callbacks
   */
  if ( (rc = saAmfSelectionObjectGet(amfHandle, &amf_dispatch_fd)) != SA_AIS_OK)
    errorExit(rc);
  /* if ( (rc = saCkptSelectionObjectGet(ckptLibraryHandle, &ckpt_dispatch_fd)) != SA_AIS_OK)
       errorExit(rc); */
    
  maxFd = amf_dispatch_fd;  /* maxFd = max(amf_dispatch_fd,ckpt_dispatch_fd); */
  do
    {
      FD_ZERO(&read_fds);
      FD_SET(amf_dispatch_fd, &read_fds);
      /* FD_SET(ckpt_dispatch_fd, &read_fds); */
        
      if( select(maxFd + 1, &read_fds, NULL, NULL, NULL) < 0)
        {
          char errorStr[80];
          int err = errno;
          if (EINTR == err) continue;

          errorStr[0] = 0; /* just in case strerror does not fill it in */
          strerror_r(err, errorStr, 79);
          clprintf (CL_LOG_SEV_ERROR, "Error [%d] during dispatch loop select() call: [%s]",err,errorStr);
          break;
        }
      if (FD_ISSET(amf_dispatch_fd,&read_fds)) saAmfDispatch(amfHandle, SA_DISPATCH_ALL);
      /* if (FD_ISSET(ckpt_dispatch_fd,&read_fds)) saCkptDispatch(ckptLibraryHandle, SA_DISPATCH_ALL); */
    }while(!unblockNow);      
}