openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/runtime/msg.c
rsRetVal msgGetJSONPropJSON(smsg_t* const pMsg, msgPropDescr_t* pProp,
                                struct json_object** pjson)
    {
        struct json_object** jroot;
        uchar* leaf;
        struct json_object* parent;
        pthread_mutex_t* mut = NULL;
        DEFiRet;

        *pjson = NULL;

        CHKiRet(getJSONRootAndMutex(pMsg, pProp->id, &jroot, &mut));
        pthread_mutex_lock(mut);

        if (!strcmp((char*)pProp->name, "!"))
        {
            *pjson = *jroot;
            FINALIZE;
        }
        leaf = jsonPathGetLeaf(pProp->name, pProp->nameLen);
        CHKiRet(jsonPathFindParent(*jroot, pProp->name, leaf, &parent, 1));
        if (jsonVarExtract(parent, (char*)leaf, pjson) == FALSE)
        {
            ABORT_FINALIZE(RS_RET_NOT_FOUND);
        }

    finalize_it:
        /* we need a deep copy, as another thread may modify the object */
        if (*pjson != NULL)
            *pjson = jsonDeepCopy(*pjson);
        if (mut != NULL)
            pthread_mutex_unlock(mut);
        RETiRet;
    }
/* Get a JSON-based-variable as native json object */
Get a JSON-based-variable as native json object
Get a JSON - based - variable as native json object
rsRetVal msgGetJSONPropJSON(smsg_t* const pMsg, msgPropDescr_t* pProp,
                                struct json_object** pjson)
    {
        struct json_object** jroot;
        uchar* leaf;
        struct json_object* parent;
        pthread_mutex_t* mut = NULL;
        DEFiRet;
        *pjson = NULL;
        CHKiRet(getJSONRootAndMutex(pMsg, pProp->id, &jroot, &mut));
        pthread_mutex_lock(mut);
        if (!strcmp((char*)pProp->name, "!"))
        {
            *pjson = *jroot;
            FINALIZE;
        }
        leaf = jsonPathGetLeaf(pProp->name, pProp->nameLen);
        CHKiRet(jsonPathFindParent(*jroot, pProp->name, leaf, &parent, 1));
        if (jsonVarExtract(parent, (char*)leaf, pjson) == FALSE)
        {
            ABORT_FINALIZE(RS_RET_NOT_FOUND);
        }
    finalize_it:
        if (*pjson != NULL)
            *pjson = jsonDeepCopy(*pjson);
        if (mut != NULL)
            pthread_mutex_unlock(mut);
        RETiRet;
    }
rsRetVal msgGetJSONPropJSON ( smsg_t * const pMsg , msgPropDescr_t * pProp , struct json_object * * pjson ) { struct json_object * * jroot ; uchar * leaf ; struct json_object * parent ; pthread_mutex_t * mut = NULL ; DEFiRet ; * pjson = NULL ; CHKiRet ( getJSONRootAndMutex ( pMsg , pProp -> id , & jroot , & mut ) ) ; pthread_mutex_lock ( mut ) ; if ( ! strcmp ( ( char * ) pProp -> name , " " ) ) { * pjson = * jroot ; FINALIZE ; } leaf = jsonPathGetLeaf ( pProp -> name , pProp -> nameLen ) ; CHKiRet ( jsonPathFindParent ( * jroot , pProp -> name , leaf , & parent , 1 ) ) ; if ( jsonVarExtract ( parent , ( char * ) leaf , pjson ) == FALSE ) { ABORT_FINALIZE ( RS_RET_NOT_FOUND ) ; } finalize_it : if ( * pjson != NULL ) * pjson = jsonDeepCopy ( * pjson ) ; if ( mut != NULL ) pthread_mutex_unlock ( mut ) ; RETiRet ; }
Get a JSON-based-variable as native json object
Get a JSON - based - variable as native json object
/* we need a deep copy, as another thread may modify the object */