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 Deserialize(void* ppObj, uchar* pszTypeExpected, strm_t* pStrm,
                            rsRetVal (*fFixup)(obj_t*, void*), void* pUsr)
{
    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;
    objInfo_t* pObjInfo;

    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, ustrlen(pszTypeExpected)))
        /* TODO: optimize strlen() - caller shall provide */
        ABORT_FINALIZE(RS_RET_INVALID_OID);

    CHKiRet(FindObjInfo((char*)cstrGetSzStrNoNULL(pstrID), &pObjInfo));

    CHKiRet(pObjInfo->objMethods[objMethod_CONSTRUCT](&pObj));

    /* we got the object, now we need to fill the properties */
    CHKiRet(objDeserializeProperties(
        pObj, pObjInfo->objMethods[objMethod_SETPROPERTY], pStrm));

    /* 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 (objInfoIsImplemented(pObjInfo, objMethod_CONSTRUCTION_FINALIZER))
        CHKiRet(pObjInfo->objMethods[objMethod_CONSTRUCTION_FINALIZER](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);

    RETiRet;
}
/* De-Serialize an object.
 * Params: Pointer to object Pointer (pObj) (like a obj_t**, but can not do that
 * due to compiler warning) expected object ID (to check against), a fixup
 * function that can modify the object before it is finalized and a user pointer
 * that is to be passed to that function in addition to the object. The fixup
 * function pointer may be NULL, in which case none is called. The caller must
 * destruct the created object. rgerhards, 2008-01-07
 */
De-Serialize an object.
Params: Pointer to object Pointer (pObj) (like a obj_t**, but can not do that
due to compiler warning) expected object ID (to check against), a fixup
function that can modify the object before it is finalized and a user pointer
that is to be passed to that function in addition to the object. The fixup
function pointer may be NULL, in which case none is called. The caller must
destruct the created object.
De - Serialize an object . Params : Pointer to object Pointer ( pObj ) ( like a obj_t ** but can not do that due to compiler warning ) expected object ID ( to check against ) a fixup function that can modify the object before it is finalized and a user pointer that is to be passed to that function in addition to the object . The fixup function pointer may be NULL in which case none is called . The caller must destruct the created object .
static rsRetVal Deserialize(void* ppObj, uchar* pszTypeExpected, strm_t* pStrm,
                            rsRetVal (*fFixup)(obj_t*, void*), void* pUsr)
{
    DEFiRet;
    rsRetVal iRetLocal;
    obj_t* pObj = NULL;
    int oVers = 0; 
    cstr_t* pstrID = NULL;
    objInfo_t* pObjInfo;
    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, ustrlen(pszTypeExpected)))
        ABORT_FINALIZE(RS_RET_INVALID_OID);
    CHKiRet(FindObjInfo((char*)cstrGetSzStrNoNULL(pstrID), &pObjInfo));
    CHKiRet(pObjInfo->objMethods[objMethod_CONSTRUCT](&pObj));
    CHKiRet(objDeserializeProperties(
        pObj, pObjInfo->objMethods[objMethod_SETPROPERTY], pStrm));
    if (fFixup != NULL)
        CHKiRet(fFixup(pObj, pUsr));
    if (objInfoIsImplemented(pObjInfo, objMethod_CONSTRUCTION_FINALIZER))
        CHKiRet(pObjInfo->objMethods[objMethod_CONSTRUCTION_FINALIZER](pObj));
    *((obj_t**)ppObj) = pObj;
finalize_it:
    if (iRet != RS_RET_OK && pObj != NULL)
        free(pObj); 
    if (pstrID != NULL)
        rsCStrDestruct(&pstrID);
    RETiRet;
}
static rsRetVal Deserialize ( void * ppObj , uchar * pszTypeExpected , strm_t * pStrm , rsRetVal ( * fFixup ) ( obj_t * , void * ) , void * pUsr ) { DEFiRet ; rsRetVal iRetLocal ; obj_t * pObj = NULL ; int oVers = 0 ; cstr_t * pstrID = NULL ; objInfo_t * pObjInfo ; 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 , ustrlen ( pszTypeExpected ) ) ) ABORT_FINALIZE ( RS_RET_INVALID_OID ) ; CHKiRet ( FindObjInfo ( ( char * ) cstrGetSzStrNoNULL ( pstrID ) , & pObjInfo ) ) ; CHKiRet ( pObjInfo -> objMethods [ objMethod_CONSTRUCT ] ( & pObj ) ) ; CHKiRet ( objDeserializeProperties ( pObj , pObjInfo -> objMethods [ objMethod_SETPROPERTY ] , pStrm ) ) ; if ( fFixup != NULL ) CHKiRet ( fFixup ( pObj , pUsr ) ) ; if ( objInfoIsImplemented ( pObjInfo , objMethod_CONSTRUCTION_FINALIZER ) ) CHKiRet ( pObjInfo -> objMethods [ objMethod_CONSTRUCTION_FINALIZER ] ( pObj ) ) ; * ( ( obj_t * * ) ppObj ) = pObj ; finalize_it : if ( iRet != RS_RET_OK && pObj != NULL ) free ( pObj ) ; if ( pstrID != NULL ) rsCStrDestruct ( & pstrID ) ; RETiRet ; }
De-Serialize an object.
De - Serialize an object .
/* 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
     */ /* TODO: optimize strlen() - caller shall provide */ /* we got the object, now we need to fill the properties */ /* 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 */