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
rsRetVal objDeserializeWithMethods(void* ppObj, uchar* pszTypeExpected,
                                   int lenTypeExpected, strm_t* pStrm,
                                   rsRetVal (*fFixup)(obj_t*, void*),
                                   void* pUsr, rsRetVal (*objConstruct)(),
                                   rsRetVal (*objConstructFinalize)(),
                                   rsRetVal (*objDeserialize)())
{
    DEFiRet;
    rsRetVal iRetLocal;
    obj_t* pObj = NULL;
    int oVers = 0; /* keep compiler happy, but it is totally useless but takes
                      up some execution time... */
    cstr_t* pstrID = NULL;

    assert(ppObj != NULL);
    assert(pszTypeExpected != NULL);
    ISOBJ_TYPE_assert(pStrm, strm);

    /* we de-serialize the header. if all goes well, we are happy. However, if
     * we experience a problem, we try to recover. We do this by skipping to
     * the next object header. This is defined via the line-start cookies. In
     * worst case, we exhaust the queue, but then we receive EOF return state,
     * from objDeserializeTryRecover(), what will cause us to ultimately give
     * up. rgerhards, 2008-07-08
     */
    do
    {
        iRetLocal = objDeserializeHeader((uchar*)"Obj", &pstrID, &oVers, pStrm);
        if (iRetLocal != RS_RET_OK)
        {
            dbgprintf("objDeserialize error %d during header processing - "
                      "trying to recover\n",
                      iRetLocal);
            CHKiRet(objDeserializeTryRecover(pStrm));
        }
    } while (iRetLocal != RS_RET_OK);

    if (rsCStrSzStrCmp(pstrID, pszTypeExpected, lenTypeExpected))
        ABORT_FINALIZE(RS_RET_INVALID_OID);

    CHKiRet(objConstruct(&pObj));

    /* we got the object, now we need to fill the properties */
    CHKiRet(objDeserialize(pObj, pStrm));
    CHKiRet(objDeserializeTrailer(pStrm)); /* do trailer checks */

    /* check if we need to call a fixup function that modifies the object
     * before it is finalized. -- rgerhards, 2008-01-13
     */
    if (fFixup != NULL)
        CHKiRet(fFixup(pObj, pUsr));

    /* we have a valid object, let's finalize our work and return */
    if (objConstructFinalize != NULL)
    {
        CHKiRet(objConstructFinalize(pObj));
    }

    *((obj_t**)ppObj) = pObj;

finalize_it:
    if (iRet != RS_RET_OK && pObj != NULL)
        free(pObj); /* TODO: check if we can call destructor 2008-01-13 rger */

    if (pstrID != NULL)
        rsCStrDestruct(&pstrID);

    if (Debug && iRet != RS_RET_OK)
    {
        dbgprintf("objDeserializeWithMethods fails with %d, stream state:\n",
                  iRet);
        strmDebugOutBuf(pStrm);
    }

    RETiRet;
}
/* De-Serialize an object, with known constructur and destructor. Params like
 * Deserialize(). Note: this is for the queue subsystem, and optimized for its
 * use. rgerhards, 2012-11-03
 */
De-Serialize an object, with known constructur and destructor. Params like
Deserialize(). Note: this is for the queue subsystem, and optimized for its
use.
De - Serialize an object with known constructur and destructor . Params like Deserialize () . Note : this is for the queue subsystem and optimized for its use .
rsRetVal objDeserializeWithMethods(void* ppObj, uchar* pszTypeExpected,
                                   int lenTypeExpected, strm_t* pStrm,
                                   rsRetVal (*fFixup)(obj_t*, void*),
                                   void* pUsr, rsRetVal (*objConstruct)(),
                                   rsRetVal (*objConstructFinalize)(),
                                   rsRetVal (*objDeserialize)())
{
    DEFiRet;
    rsRetVal iRetLocal;
    obj_t* pObj = NULL;
    int oVers = 0; 
    cstr_t* pstrID = NULL;
    assert(ppObj != NULL);
    assert(pszTypeExpected != NULL);
    ISOBJ_TYPE_assert(pStrm, strm);
    do
    {
        iRetLocal = objDeserializeHeader((uchar*)"Obj", &pstrID, &oVers, pStrm);
        if (iRetLocal != RS_RET_OK)
        {
            dbgprintf("objDeserialize error %d during header processing - "
                      "trying to recover\n",
                      iRetLocal);
            CHKiRet(objDeserializeTryRecover(pStrm));
        }
    } while (iRetLocal != RS_RET_OK);
    if (rsCStrSzStrCmp(pstrID, pszTypeExpected, lenTypeExpected))
        ABORT_FINALIZE(RS_RET_INVALID_OID);
    CHKiRet(objConstruct(&pObj));
    CHKiRet(objDeserialize(pObj, pStrm));
    CHKiRet(objDeserializeTrailer(pStrm)); 
    if (fFixup != NULL)
        CHKiRet(fFixup(pObj, pUsr));
    if (objConstructFinalize != NULL)
    {
        CHKiRet(objConstructFinalize(pObj));
    }
    *((obj_t**)ppObj) = pObj;
finalize_it:
    if (iRet != RS_RET_OK && pObj != NULL)
        free(pObj); 
    if (pstrID != NULL)
        rsCStrDestruct(&pstrID);
    if (Debug && iRet != RS_RET_OK)
    {
        dbgprintf("objDeserializeWithMethods fails with %d, stream state:\n",
                  iRet);
        strmDebugOutBuf(pStrm);
    }
    RETiRet;
}
rsRetVal objDeserializeWithMethods ( void * ppObj , uchar * pszTypeExpected , int lenTypeExpected , strm_t * pStrm , rsRetVal ( * fFixup ) ( obj_t * , void * ) , void * pUsr , rsRetVal ( * objConstruct ) ( ) , rsRetVal ( * objConstructFinalize ) ( ) , rsRetVal ( * objDeserialize ) ( ) ) { DEFiRet ; rsRetVal iRetLocal ; obj_t * pObj = NULL ; int oVers = 0 ; cstr_t * pstrID = NULL ; assert ( ppObj != NULL ) ; assert ( pszTypeExpected != NULL ) ; ISOBJ_TYPE_assert ( pStrm , strm ) ; do { iRetLocal = objDeserializeHeader ( ( uchar * ) " " , & pstrID , & oVers , pStrm ) ; if ( iRetLocal != RS_RET_OK ) { dbgprintf ( " " " \n " , iRetLocal ) ; CHKiRet ( objDeserializeTryRecover ( pStrm ) ) ; } } while ( iRetLocal != RS_RET_OK ) ; if ( rsCStrSzStrCmp ( pstrID , pszTypeExpected , lenTypeExpected ) ) ABORT_FINALIZE ( RS_RET_INVALID_OID ) ; CHKiRet ( objConstruct ( & pObj ) ) ; CHKiRet ( objDeserialize ( pObj , pStrm ) ) ; CHKiRet ( objDeserializeTrailer ( pStrm ) ) ; if ( fFixup != NULL ) CHKiRet ( fFixup ( pObj , pUsr ) ) ; if ( objConstructFinalize != NULL ) { CHKiRet ( objConstructFinalize ( pObj ) ) ; } * ( ( obj_t * * ) ppObj ) = pObj ; finalize_it : if ( iRet != RS_RET_OK && pObj != NULL ) free ( pObj ) ; if ( pstrID != NULL ) rsCStrDestruct ( & pstrID ) ; if ( Debug && iRet != RS_RET_OK ) { dbgprintf ( " \n " , iRet ) ; strmDebugOutBuf ( pStrm ) ; } RETiRet ; }
De-Serialize an object, with known constructur and destructor.
De - Serialize an object with known constructur and destructor .
/* keep compiler happy, but it is totally useless but takes
                      up some execution time... */ /* we de-serialize the header. if all goes well, we are happy. However, if
     * we experience a problem, we try to recover. We do this by skipping to
     * the next object header. This is defined via the line-start cookies. In
     * worst case, we exhaust the queue, but then we receive EOF return state,
     * from objDeserializeTryRecover(), what will cause us to ultimately give
     * up. rgerhards, 2008-07-08
     */ /* we got the object, now we need to fill the properties */ /* do trailer checks */ /* check if we need to call a fixup function that modifies the object
     * before it is finalized. -- rgerhards, 2008-01-13
     */ /* we have a valid object, let's finalize our work and return */ /* TODO: check if we can call destructor 2008-01-13 rger */