Exemple #1
0
dip_status DIPENTRY DIPImpModInfo( imp_image_handle *ii, imp_mod_handle im,
                                handle_kind hk )
{
    mod_info    *mod;
    static unsigned DmndType[] = {0,DMND_TYPES,DMND_LINES,DMND_LOCALS};

    mod = ModPointer( ii, im );
    return( mod->di[DmndType[hk]].u.entries != 0 ? DS_OK : DS_FAIL );
}
/*
 * InfoSize -- return size of demand info section
 */
unsigned InfoSize( imp_image_handle *ii, imp_mod_handle im,
                        unsigned item, unsigned entry )
{
    demand_info         *dmnd;
    section_info        *inf;

    dmnd = &ModPointer( ii, im )->di[item];
    if( entry >= dmnd->u.entries )
        return( 0 );
    entry += dmnd->info_off;
    inf = FindInfo( ii, im );
    return( DMND_SIZE( inf, entry ) );
}
Exemple #3
0
size_t DIPIMPENTRY( ModName )( imp_image_handle *ii, imp_mod_handle im,
                                char *buff, size_t buff_size )
{
    char        *name;
    char        *start;
    char        *end;
    size_t      len;

    name = ModPointer( ii, im )->name;
    len = (unsigned char)name[0];
    if( len == 0 ) {
        *buff = '\0';
        return( 0 );
    }
    start = name + len;
    ++name;
    end = start + 1;
    if( *start == ')' ) {
        /* library member */
        --end;
        for( ;; ) {
            --start;
            if( *start == '(' ) {
                break;
            }
        }
        ++start;
    } else {
        /* file name */
        start = name;
        for( ; len > 0; --len ) {
            if( IS_PATH_CHAR( *name ) ) {
                start = name + 1;
                end = name + len;
            }
            if( *name == EXT_CHAR )
                end = name;
            ++name;
        }
    }
    len = end - start;
    if( buff_size > 0 ) {
        --buff_size;
        if( buff_size > len )
            buff_size = len;
        memcpy( buff, start, buff_size );
        buff[buff_size] = '\0';
    }
    return( len );
}
Exemple #4
0
unsigned DIPENTRY DIPImpModName( imp_image_handle *ii, imp_mod_handle im,
                                char *buff, unsigned max )
{
    char        *name;
    char        *start;
    char        *end;
    unsigned    len;


    name = ModPointer( ii, im )->name;
    len = name[0];
    if( len == 0 ) {
        *buff = '\0';
        return( 0 );
    }
    start = &name[ len ];
    ++name;
    end = start + 1;
    if( *start == ')' ) {
        /* library member */
        --end;
        for( ;; ) {
            --start;
            if( *start == '(' ) break;
        }
        ++start;
    } else {
        /* file name */
        start = name;
        for( ;; ) {
            if( len == 0 ) break;
            if( IS_PATH_CHAR( *name ) ) {
                start = name + 1;
                end = name + len;
            }
            if( *name == EXT_CHAR ) end = name;
            ++name;
            --len;
        }
    }
    len = end - start;
    if( max > 0 ) {
        --max;
        if( max > len ) max = len;
        memcpy( buff, start, max );
        buff[ max ] = '\0';
    }
    return( len );
}
Exemple #5
0
dip_status DIPIMPENTRY( ModInfo )( imp_image_handle *ii, imp_mod_handle im, handle_kind hk )
{
    mod_info    *mod;
    static unsigned DmndType[MAX_HK] = {
        0,
        DMND_TYPES,
        DMND_LINES,
        DMND_LOCALS
    };

    if( hk == HK_IMAGE )
        return( DS_FAIL );
    mod = ModPointer( ii, im );
    return( mod->di[DmndType[hk]].u.entries != 0 ? DS_OK : DS_FAIL );
}
Exemple #6
0
unsigned PrimaryCueFile( imp_image_handle *ii, imp_cue_handle *ic,
                        char *buff, unsigned max )
{
    unsigned    len;
    char        *name;

    name = ModPointer( ii, ic->im )->name;
    len = name[0];
    if( max > 0 ) {
        --max;
        if( max > len ) max = len;
        memcpy( buff, &name[1], max );
        buff[ max ] = '\0';
    }
    return( len );
}
unsigned PrimaryCueFile( imp_image_handle *ii, imp_cue_handle *ic,
                        char *buff, unsigned buff_size )
{
    unsigned    len;
    char        *name;

    name = ModPointer( ii, ic->im )->name;
    len = (unsigned char)name[0];
    if( buff_size > 0 ) {
        --buff_size;
        if( buff_size > len )
            buff_size = len;
        memcpy( buff, &name[1], buff_size );
        buff[buff_size] = '\0';
    }
    return( len );
}
static walk_result WlkClear( imp_image_handle *ii, imp_mod_handle im, void *d )
{
    unsigned            dmnd;
    mod_info            *mp;
    section_info        *sect;
    int                 entry;
    unsigned            real_entry;
    pointer_int         *lnk;

    d = d;
    mp = ModPointer( ii, im );
    sect = FindInfo( ii, im );
    for( dmnd = DMND_FIRST; dmnd < DMND_NUM; ++dmnd ) {
        for( entry = mp->di[dmnd].u.entries-1; entry >= 0; --entry ) {
            real_entry = entry + mp->di[dmnd].info_off;
            lnk = &GET_LINK( sect, real_entry );
            if( IS_RESIDENT( *lnk ) ) {
                Unload( MK_DMND_PTR( *lnk ) );
            }
        }
    }
    return( WR_CONTINUE );
}
Exemple #9
0
char *DIPENTRY DIPImpModSrcLang( imp_image_handle *ii, imp_mod_handle im )
{
    return( ii->lang + ModPointer( ii, im )->language );
}
void *InfoLoad( imp_image_handle *ii, imp_mod_handle im, unsigned item,
                unsigned entry, void (*clear)(void *, void *) )
{
    demand_ctrl         *section;
    demand_info         *info;
    section_info        *sect;
    unsigned long       tmpoff;
    pointer_int         *lnk;
    unsigned            size;

    ++TimeStamp;
    if( TimeStamp == 0 ) { /* TimeStamp wrapped */
        TimeStamp = 1;
        for(section = DemandList; section != NULL; section = section->link) {
            section->time_stamp = 0;
        }
    }
    info = &ModPointer( ii, im )->di[ item ];
    if( entry >= info->u.entries )
        return( NULL );
    entry += info->info_off;
    sect = FindInfo( ii, im );
    lnk = &GET_LINK( sect, entry );
    if( IS_RESIDENT( *lnk ) ) {
        section = MK_DMND_PTR( *lnk );
    } else {
        /* section not loaded */
        size = DMND_SIZE( sect, entry );
        if( (LastDemand->owner == NULL || LastDemand->size < size)
            && LastDemand->locks == 0 ) {
            /* keep largest section in LastDemand */
            section = LastDemand;
            Unload( LastDemand );
        } else {
            /* allocate some memory */
            section = DCAlloc( _demand_size( size ) );
            if( section == NULL ) {
                if( LastDemand->locks != 0 )
                    return( NULL );
                /* no memory, use last chance */
                section = LastDemand;
                Unload( LastDemand );
            }
        }
        tmpoff = MK_DMND_OFFSET( *lnk );
        if( InfoRead( sect, tmpoff, size, section->buff ) != DS_OK ) {
            if( section != LastDemand )
                DCFree( section );
            return( NULL );
        }
        section->size = size;
        section->locks = 0;
        section->clear = clear;
        section->owner = lnk;
        section->save  = *lnk;
        *lnk = STASH_DMND_PTR( section );
        if( section != LastDemand ) {
            section->link = DemandList;
            DemandList = section;
        }
    }
    section->time_stamp = TimeStamp; /* for removal priority */
    section->locks++;
    return( section->buff );
}