Esempio n. 1
0
static
rc_t ConfigRepoSet(DLList* repos, KConfig * kfg, const char* kfgPath, const char *dflt, uint8_t type)
{
    const KConfigNode *node;

    rc_t rc = KConfigOpenNodeRead ( kfg, & node, kfgPath );
    if ( rc == 0 )
    {
        KNamelist* children;
        rc = KConfigNodeListChild ( node, &children );
        if ( rc == 0 )
        {
            uint32_t count;
            rc = KNamelistCount ( children, &count );
            if ( rc == 0 )
            {
                uint32_t i;
                for (i = 0; i < count; ++i)
                {
                    const char* name;
                    rc = KNamelistGet ( children, i, &name );
                    if ( rc == 0 )
                    {
                        #define BufSize 4096
                        char buf[ BufSize ];
                        size_t bSize = string_size(kfgPath);
                        string_copy(buf, BufSize, kfgPath, bSize);
                        if (bSize + string_size(name) < sizeof(buf))
                        {
                            NCBIRepository* repo;
                            string_copy(buf + bSize, sizeof(buf) - bSize, name, string_size(name) + 1);
                            rc = ConfigRepo( kfg, dflt, buf, buf, type, &repo );
                            DLListPushTail( repos, (DLNode*) repo );
                        }
                        #undef BufSize
                    }
                    else
                    {
                        rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive );
                    }
                    if ( rc != 0 )
                    {
                        break;
                    }
                }
            }
            KNamelistRelease ( children );
        }

        KConfigNodeRelease ( node );
    }
    if (GetRCState(rc) == rcNotFound)
    {
        return 0;
    }
    return rc;
}
Esempio n. 2
0
/* Make
 */
static
rc_t SRAPathStringMake ( DLList *list, const char *path, size_t sz, uint8_t alg )
{
    SRAPathString *s = (SRAPathString*) malloc ( sizeof * s + sz );
    if ( s == NULL )
        return RC ( rcSRA, rcMgr, rcUpdating, rcMemory, rcExhausted );

    s -> alg = alg;
    string_copy ( s -> path, sz + 1, path, sz );
    DLListPushTail ( list, & s -> n );

    return 0;
}
Esempio n. 3
0
static rc_t make_pi_ref( pi_ref ** pr, DLList * list, const char * name )
{
    rc_t rc = 0;
    *pr = calloc( 1, sizeof ** pr );
    if ( *pr == NULL )
        rc = RC( rcAlign, rcIterator, rcConstructing, rcMemory, rcExhausted );
    else
    {
        (*pr)->name = string_dup_measure ( name, NULL );
        DLListInit( &( (*pr)->pi_windows ) );
        DLListPushTail ( list, ( DLNode * )(*pr) );
    }
    return rc;
}
Esempio n. 4
0
static rc_t add_to_spot_groups( DLList * list, const PlacementRecord *rec )
{
    rc_t rc = 0;
    spot_group * sg = find_spot_group( list, rec->spot_group, rec->spot_group_len );
    if ( sg == NULL )
    {
        rc = make_spot_group( &sg, list, rec->spot_group, rec->spot_group_len );
    }
    if ( rc == 0 )
    {
        DLListPushTail ( &sg->records, ( DLNode * )(rec) );
    }
    return rc;
}
Esempio n. 5
0
static rc_t make_pi_window( pi_window ** pw, DLList * list, window * w )
{
    rc_t rc = 0;
    *pw = calloc( 1, sizeof ** pw );
    if ( *pw == NULL )
        rc = RC( rcAlign, rcIterator, rcConstructing, rcMemory, rcExhausted );
    else
    {
        (*pw)->w.first = w->first;
        (*pw)->w.len = w->len;
        DLListInit( &( (*pw)->pi_entries ) );
        DLListPushTail ( list, ( DLNode * )(*pw) );
    }
    return rc;
}
Esempio n. 6
0
static rc_t make_spot_group( spot_group ** sg, DLList * list, const char * name, size_t len )
{
    rc_t rc = 0;
    *sg = calloc( 1, sizeof ** sg );
    if ( *sg == NULL )
        rc = RC( rcAlign, rcIterator, rcConstructing, rcMemory, rcExhausted );
    else
    {
        if ( len > 0 && name != NULL )
        {
            (*sg)->name = string_dup( name, len );
            if ( (*sg)->name != NULL )
            {
                (*sg)->len = len;
            }
        }
        /* if name is NULL, the spot-group is initialized with 0 via calloc() */
        DLListInit( &( (*sg)->records ) );
        DLListPushTail ( list, ( DLNode * )(*sg) );
    }
    return rc;
}
Esempio n. 7
0
static rc_t add_to_pi_window( pi_window * pw, PlacementIterator *pi )
{
    rc_t rc = 0;
    pi_entry * pie = calloc( 1, sizeof *pie );
    if ( pie == NULL )
        rc = RC( rcAlign, rcIterator, rcConstructing, rcMemory, rcExhausted );
    else
    {
        rc = PlacementIteratorNextAvailPos ( pi, &(pie->nxt_avail.first), &(pie->nxt_avail.len) );
        if ( rc == 0 )
        {
            pie->pi = pi;  /* store the placement-iterator in it's entry-struct */
            DLListPushTail ( &pw->pi_entries, ( DLNode * )pie );
            pw->count += 1;
        }
        else
        {
            free( pie );
            ALIGN_DBG( "PlacementIter has no placements...", 0 );
        }
    }
    return rc;
}