示例#1
0
static bool CanResolveAccessions( void )
{
    bool res = false;
    SRAPath *sra_path;
    rc_t rc = SRAPathMake( &sra_path, NULL );
    if ( rc == 0 )
    {
        res = true;
        SRAPathRelease( sra_path );
    }
    return res;
}
示例#2
0
/* Whack
 *  will not refuse request, and ignores errors
 */
static
rc_t SRAMgrWhack ( const SRAMgr *that )
{
    SRAMgr *self = ( SRAMgr* ) that;

    VSchemaRelease ( self -> schema );
    VDBManagerRelease ( self -> vmgr );

    /* must check here for NULL because
       SRAPathRelease is weak-linked */
    if ( self -> _pmgr != NULL )
    {
#if OLD_SRAPATH_MGR
        SRAPathRelease ( self -> _pmgr );
#else
        VResolverRelease ( ( const VResolver* ) self -> _pmgr );
#endif
    }

    free ( self );
    return 0;
}
示例#3
0
static rc_t resolve_accession( const KDirectory *my_dir, char ** path )
{
    SRAPath *my_sra_path;
    rc_t rc = 0;

    if ( strchr ( *path, '/' ) != NULL )
        return 0;

    rc = SRAPathMake( &my_sra_path, my_dir );
    if ( rc != 0 )
    {
        if ( GetRCState ( rc ) != rcNotFound || GetRCTarget ( rc ) != rcDylib )
        {
            if ( rc != 0 )
            {
                LOGERR( klogInt, rc, "SRAPathMake() failed" );
            }
        }
        else
            rc = 0;
    }
    else
    {
        if ( !SRAPathTest( my_sra_path, *path ) )
        {
            char *buf = translate_accession( my_sra_path, *path, 64 );
            if ( buf != NULL )
            {
                free( (char*)(*path) );
                *path = buf;
            }
        }
        SRAPathRelease( my_sra_path );
    }
    return rc;
}
示例#4
0
rc_t CC KMain ( int argc, char *argv [] )
{
    Args *args;
    rc_t rc = ArgsMakeAndHandle ( & args, argc, argv, 0 );
    if ( rc != 0 )
        LogErr ( klogErr, rc, "failed to parse arguments" );
    else
    {
        uint32_t paramc;
        rc = ArgsParamCount ( args, & paramc );
        if ( rc != 0 )
            LogErr ( klogInt, rc, "failed to obtain param count" );
        else
        {
            if ( paramc == 0 )
            {
                rc = RC ( rcExe, rcArgv, rcParsing, rcParam, rcInsufficient );
                LogErr ( klogErr, rc, "missing target object" );
                MiniUsage ( args );
            }
            else if ( paramc > 1 )
            {
                rc = RC ( rcExe, rcArgv, rcParsing, rcParam, rcExcessive );
                LogErr ( klogErr, rc, "expected single target object" );
                MiniUsage ( args );
            }
            else
            {
                const char *target;
                rc = ArgsParamValue ( args, 0, & target );
                if ( rc != 0 )
                    LogErr ( klogInt, rc, "failed to obtain param value" );
                else
                {
                    VDBManager *mgr;

#if TOOLS_USE_SRAPATH != 0
                    char full [ 4096 ];
                    SRAPath *sra_path;
                    rc = SRAPathMake ( & sra_path, NULL );
                    if ( rc == 0 )
                    {
                        if ( ! SRAPathTest ( sra_path, target ) )
                        {
                            rc = SRAPathFind ( sra_path, target, full, sizeof full );
                            if ( rc == 0 )
                                target = full;
                        }
                        SRAPathRelease ( sra_path );
                    }
#endif

                    rc = VDBManagerMakeUpdate ( & mgr, NULL );
                    if ( rc != 0 )
                        LogErr ( klogInt, rc, "failed to open VDB manager" );
                    else
                    {
                        rc = VDBManagerLock ( mgr, target );
                        if ( rc == 0 )
                            pLogMsg ( klogInfo, "locked '$(target)'", "target=%s", target );
                        else switch ( GetRCState ( rc ) )
                        {
                        case rcLocked:
                            pLogMsg ( klogInfo, "'$(target)' was already locked", "target=%s", target );
                            break;
                        default:
                            pLogErr ( klogErr, rc, "failed to lock '$(target)'", "target=%s", target );
                        }

                        VDBManagerRelease ( mgr );
                    }
                }
            }
        }

        ArgsWhack ( args );
    }

    return rc;
}
示例#5
0
 inline rc_t Release () const  throw()
 {
     return SRAPathRelease ( this );
 }