コード例 #1
0
ファイル: psmcli.c プロジェクト: rdkcmf/rdkb-CcspMisc
// Function: process_getallinst
// Get number of instances of an object
unsigned int process_getinstcnt(int const argCnt, char const * const argVars[], char const * const busHandle) {

    int cmd_index = 2;
    int cmd_cnt = argCnt - 2;
    unsigned int func_ret = CCSP_SUCCESS;
    unsigned int ret = 0;
    unsigned int instanceCnt = 0;
    unsigned  int *instanceList = NULL;
    unsigned int i = 0;
    char const func_name[] = "process_getinstcnt";

    while(cmd_cnt--) {
        ret = 0;
        ret = PsmGetNextLevelInstances((void*)busHandle, 
                                       subsys_prefix, // PSMCLI_SUBSYSTEM_PREFIX, 
                                       argVars[cmd_index], 
                                       &instanceCnt, 
                                       &instanceList);
        
        if ( ret == CCSP_SUCCESS) {
            printf("%d\n", instanceCnt);
            if(instanceList != NULL) {
                ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(instanceList); 
                instanceList = NULL;
            }
        } else {
            CcspTraceWarning(("<%s>[%s]: function unsuccessful, return set to %d\n",
                            prog_name, func_name, ret));
            func_ret = ret;
            //                break;  // to accommondate more cmd
        }
        
        cmd_index++;
    }

    if(instanceList != NULL) ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(instanceList); 

    //    CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret));

    return func_ret;
}
コード例 #2
0
ファイル: psmcli.c プロジェクト: rdkcmf/rdkb-CcspMisc
// Function: process_getallinst
// Get all object instance names
unsigned int process_getallinst(int const argCnt, char const * const argVars[], char const * const busHandle) {
    
    int cmd_index = 2;
    int cmd_cnt = argCnt - 2;
    unsigned int func_ret = CCSP_SUCCESS;
    unsigned int instanceCnt = 0;
    unsigned int *instanceList = NULL;
    unsigned int i = 0;
    char const func_name[] = "process_getallinst";

    if(cmd_cnt != 1) {
    	CcspTraceWarning(("<%s>[%s]: arg count = %d is not 1, returning %d CCSP_ERR_INVALID_ARGUMENTS\n", 
                        prog_name, func_name, cmd_cnt, CCSP_ERR_INVALID_ARGUMENTS));
        return CCSP_ERR_INVALID_ARGUMENTS;
    } 
    
    func_ret = PsmGetNextLevelInstances((void*)busHandle, 
                                        subsys_prefix, // PSMCLI_SUBSYSTEM_PREFIX, 
                                        argVars[cmd_index], 
                                        &instanceCnt, 
                                        &instanceList);

    if(func_ret == CCSP_SUCCESS && instanceList != NULL) {
        for(i = 0; i < instanceCnt; i++) {
            printf("%d\n", instanceList[i]);
        }
        ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(instanceList); 
        instanceList = NULL;
    } else {
        CcspTraceWarning(("<%s>[%s]: function unsuccessful, returning %d\n",
                        prog_name, func_name, func_ret));
    }


    if(instanceList != NULL) ((CCSP_MESSAGE_BUS_INFO*)busHandle)->freefunc(instanceList);

    //    CcspTraceDebug(("<%s>[%s]: function finished returing %d\n", prog_name, func_name, func_ret));

    return func_ret; 
}
コード例 #3
0
static int CGre_PsmGetInsNums(const char *obj, unsigned int insList[], unsigned int *insCnt)
{
    unsigned int *list, cnt;
    CCSP_MESSAGE_BUS_INFO *businfo;

    if (PsmGetNextLevelInstances(g_MessageBusHandle, g_GetSubsystemPrefix(g_pDslhDmlAgent), 
                (char *)obj, &cnt, &list) != CCSP_SUCCESS)
        return -1;

    if (cnt > *insCnt) {
        businfo = g_MessageBusHandle;
        businfo->freefunc(list);
        return -1;
    }

    *insCnt = cnt;
    memcpy(insList, list, sizeof(unsigned int) * cnt);

    businfo = g_MessageBusHandle;
    businfo->freefunc(list);
    return 0;
}