コード例 #1
0
ファイル: sysdll.c プロジェクト: gconcepcion/sratoolkit
/* AddLib
 *  adds a dynamic library to end of ordered set
 *
 *  "lib" [ IN ] - library returned from KDyldLoadLib
 */
static
rc_t KDlsetAddLibInt ( KDlset *self, KDylib *lib )
{
    uint32_t idx;
    rc_t rc = VectorAppend ( & self -> ord, & idx, lib );
    if ( rc == 0 )
    {
        void *ignore;
        
        rc = VectorInsertUnique ( & self -> name,
            lib, NULL, KDylibSort );
        if ( rc == 0 )
            return 0;

        VectorSwap ( & self -> ord, idx, NULL, & ignore );
    }

    return rc;
}
コード例 #2
0
rc_t VProdResolveColumn ( const VProdResolve *self,
    VProduction **out, const SColumn *scol, bool alt )
{
    rc_t rc;
    VColumn *vcol;
    WColumn *wcol;
    VCursor *curs = self -> curs;

    /* decide upon behavior */
    if ( curs -> read_only )
    {
        if ( alt )
        {
            /* TODO: Generate warning message */
            return RC ( rcVDB, rcCursor, rcOpening, rcSchema, rcInvalid );
        }
        vcol = VCursorCacheGet ( & curs -> col, & scol -> cid );
        if ( vcol == NULL )
        {
            rc = VCursorMakeColumn ( curs, & vcol, scol );
            if ( rc != 0 )
                return rc;

#if OPEN_COLUMN_ALTERS_ROW
            rc = VectorAppend ( & curs -> row, & vcol -> ord, vcol );
            if ( rc != 0 )
            {
                VColumnWhack ( vcol, NULL );
                return rc;
            }
#endif
            rc = VCursorCacheSet ( & curs -> col, & scol -> cid, vcol );
            if ( rc != 0 )
            {
#if OPEN_COLUMN_ALTERS_ROW
                void *ignore;
                VectorSwap ( & curs -> row, vcol -> ord, NULL, & ignore );
                vcol -> ord = 0;
#endif
                VColumnWhack ( vcol, NULL );
                return rc;
            }
        }

        return VProdResolveColumnRead ( self, out, scol );
    }

    /* write cursor but read side */
    if ( self -> chain == chainDecoding )
    {
        if ( alt )
        {
            /* TODO: Generate warning message */
            return RC ( rcVDB, rcCursor, rcOpening, rcSchema, rcInvalid );
        }

        return VProdResolveColumnRead ( self, out, scol );
    }

    /* get existing column */
    wcol = VCursorCacheGet ( & curs -> col, & scol -> cid );
    if ( wcol == NULL )
    {
        /* normally write-only cursor must have existing column */
        if ( ! self -> discover_writable_columns )
            return 0;

        /* auto-create writable column for purposes of discovery */
        if ( scol -> read_only )
            return 0;
        rc = VCursorMakeColumn ( curs, & vcol, scol );
        if ( rc != 0 )
            return rc;

        /* add it to the row as if user had done it */
        rc = VectorAppend ( & curs -> row, & vcol -> ord, vcol );
        if ( rc == 0 )
        {
            /* add it to the indexed vector */
            rc = VCursorCacheSet ( & curs -> col, & scol -> cid, vcol );
            if ( rc != 0 )
            {
                void *ignore;
                VectorSwap ( & curs -> row, vcol -> ord, NULL, & ignore );
                vcol -> ord = 0;
            }
        }

        if ( rc != 0 )
        {
            VColumnWhack ( vcol, NULL );
            return rc;
        }

        wcol = ( WColumn* ) vcol;
    }

    /* create output production as required */
    if ( wcol -> out == NULL )
    {
        const char *name = scol -> name -> name . addr;
        rc = VColumnProdMake ( & wcol -> out, self -> owned,
            & wcol -> dad, prodColumnOut, name );
        if ( rc != 0 )
            return rc;
    }
    if ( alt )
    {
        * out = wcol -> dad . in;
        assert ( * out != NULL );
    }
    else
    {
        * out = wcol -> out;
    }
    return 0;
}