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/obj.c
static rsRetVal UseObj(const char* srcFile, uchar* pObjName, uchar* pObjFile,
                       interface_t* pIf)
{
    DEFiRet;
    objInfo_t* pObjInfo;

    /* DEV debug only: dbgprintf("source file %s requests object '%s',
    ifIsLoaded %d\n", srcFile, pObjName, pIf->ifIsLoaded); */
    pthread_mutex_lock(&mutObjGlobalOp);

    if (pIf->ifIsLoaded == 1)
    {
        ABORT_FINALIZE(RS_RET_OK); /* we are already set */
    }
    if (pIf->ifIsLoaded == 2)
    {
        ABORT_FINALIZE(
            RS_RET_LOAD_ERROR); /* we had a load error and can not continue */
    }

    /* we must be careful that we do not enter in infinite loop if an error
     * occurs during loading a module. ModLoad emits an error message in such
     * cases and that potentially can trigger the same code here. So we
     * initially set the module state to "load error" and set it to "fully
     * initialized" when the load succeeded. It's a bit hackish, but looks like
     * a good solution. -- rgerhards, 2008-03-07
     */
    pIf->ifIsLoaded = 2;

    iRet = FindObjInfo((const char*)pObjName, &pObjInfo);
    if (iRet == RS_RET_NOT_FOUND)
    {
        /* in this case, we need to see if we can dynamically load the object */
        if (pObjFile == NULL)
        {
            FINALIZE; /* no chance, we have lost... */
        }
        else
        {
            CHKiRet(module.Load(pObjFile, 0, NULL));
            /* NOW, we must find it or we have a problem... */
            CHKiRet(FindObjInfo((const char*)pObjName, &pObjInfo));
        }
    }
    else if (iRet != RS_RET_OK)
    {
        FINALIZE; /* give up */
    }

    /* if we reach this point, we have a valid pObjInfo */
    if (pObjFile != NULL)
    {                                            /* NULL means core module */
        module.Use(srcFile, pObjInfo->pModInfo); /* increase refcount */
    }

    CHKiRet(pObjInfo->QueryIF(pIf));
    pIf->ifIsLoaded = 1; /* we are happy */

finalize_it:
    pthread_mutex_unlock(&mutObjGlobalOp);
    RETiRet;
}
/* This function shall be called by anyone who would like to use an object. It
 * will try to locate the object, load it into memory if not already present and
 * return a pointer to the objects interface. rgerhards, 2008-02-29
 */
This function shall be called by anyone who would like to use an object. It
will try to locate the object, load it into memory if not already present and
return a pointer to the objects interface.
This function shall be called by anyone who would like to use an object . It will try to locate the object load it into memory if not already present and return a pointer to the objects interface .
static rsRetVal UseObj(const char* srcFile, uchar* pObjName, uchar* pObjFile,
                       interface_t* pIf)
{
    DEFiRet;
    objInfo_t* pObjInfo;
    pthread_mutex_lock(&mutObjGlobalOp);
    if (pIf->ifIsLoaded == 1)
    {
        ABORT_FINALIZE(RS_RET_OK); 
    }
    if (pIf->ifIsLoaded == 2)
    {
        ABORT_FINALIZE(
            RS_RET_LOAD_ERROR); 
    }
    pIf->ifIsLoaded = 2;
    iRet = FindObjInfo((const char*)pObjName, &pObjInfo);
    if (iRet == RS_RET_NOT_FOUND)
    {
        if (pObjFile == NULL)
        {
            FINALIZE; 
        }
        else
        {
            CHKiRet(module.Load(pObjFile, 0, NULL));
            CHKiRet(FindObjInfo((const char*)pObjName, &pObjInfo));
        }
    }
    else if (iRet != RS_RET_OK)
    {
        FINALIZE; 
    }
    if (pObjFile != NULL)
    {                                            
        module.Use(srcFile, pObjInfo->pModInfo); 
    }
    CHKiRet(pObjInfo->QueryIF(pIf));
    pIf->ifIsLoaded = 1; 
finalize_it:
    pthread_mutex_unlock(&mutObjGlobalOp);
    RETiRet;
}
static rsRetVal UseObj ( const char * srcFile , uchar * pObjName , uchar * pObjFile , interface_t * pIf ) { DEFiRet ; objInfo_t * pObjInfo ; pthread_mutex_lock ( & mutObjGlobalOp ) ; if ( pIf -> ifIsLoaded == 1 ) { ABORT_FINALIZE ( RS_RET_OK ) ; } if ( pIf -> ifIsLoaded == 2 ) { ABORT_FINALIZE ( RS_RET_LOAD_ERROR ) ; } pIf -> ifIsLoaded = 2 ; iRet = FindObjInfo ( ( const char * ) pObjName , & pObjInfo ) ; if ( iRet == RS_RET_NOT_FOUND ) { if ( pObjFile == NULL ) { FINALIZE ; } else { CHKiRet ( module . Load ( pObjFile , 0 , NULL ) ) ; CHKiRet ( FindObjInfo ( ( const char * ) pObjName , & pObjInfo ) ) ; } } else if ( iRet != RS_RET_OK ) { FINALIZE ; } if ( pObjFile != NULL ) { module . Use ( srcFile , pObjInfo -> pModInfo ) ; } CHKiRet ( pObjInfo -> QueryIF ( pIf ) ) ; pIf -> ifIsLoaded = 1 ; finalize_it : pthread_mutex_unlock ( & mutObjGlobalOp ) ; RETiRet ; }
This function shall be called by anyone who would like to use an object.
This function shall be called by anyone who would like to use an object .
/* DEV debug only: dbgprintf("source file %s requests object '%s',
    ifIsLoaded %d\n", srcFile, pObjName, pIf->ifIsLoaded); */ /* we are already set */ /* we had a load error and can not continue */ /* we must be careful that we do not enter in infinite loop if an error
     * occurs during loading a module. ModLoad emits an error message in such
     * cases and that potentially can trigger the same code here. So we
     * initially set the module state to "load error" and set it to "fully
     * initialized" when the load succeeded. It's a bit hackish, but looks like
     * a good solution. -- rgerhards, 2008-03-07
     */ /* in this case, we need to see if we can dynamically load the object */ /* no chance, we have lost... */ /* NOW, we must find it or we have a problem... */ /* give up */ /* if we reach this point, we have a valid pObjInfo */ /* NULL means core module */ /* increase refcount */ /* we are happy */