Beispiel #1
0
char *IdentifyObject( file_list *list, unsigned long *loc, unsigned long *size )
/******************************************************************************/
{
    ar_header       *ar_hdr;
    char            *name;
    unsigned long   ar_loc;

    name = NULL;
    *size = 0;
    if( list->status & STAT_AR_LIB ) {
        ar_loc = MAKE_EVEN( *loc );     /* AR headers are word aligned. */
        ar_hdr = CacheRead( list, ar_loc, sizeof( ar_header ) );
        ar_loc += sizeof( ar_header );
        name = GetARName( ar_hdr, list, &ar_loc );
        *size = GetARValue( ar_hdr->size, AR_SIZE_LEN );
        *loc = ar_loc;
    }
    if( !IsORL( list, *loc ) ) {
        if( IsOMF( list, *loc ) ) {
            ObjFormat |= FMT_OMF;
            name = GetOMFName( list, loc );
            if( list->status & STAT_AR_LIB ) {
                *loc = ar_loc;          /* Restore the location. */
            }
        }
    }
    return( name );
}
Beispiel #2
0
void LibWalk( libfile io, char *name, void (*rtn)( arch_header *, libfile io ) )
/******************************************************************************/
{
    ar_header           ar;
    arch_header         arch;
    file_offset         bytes_read;
//    int                 dict_count;
    file_offset         pos;

//    dict_count = 0;
    arch.fnametab = NULL;
    arch.ffnametab = NULL;
    while( (bytes_read = LibRead( io, &ar, AR_HEADER_SIZE )) != 0 ) {
        if( bytes_read != AR_HEADER_SIZE ) {
            BadLibrary( name );
        }
        if( strncmp( ar.header_ident, AR_HEADER_IDENT, AR_HEADER_IDENT_LEN ) ) {
            BadLibrary( name );
        }
        GetARHeaderValues( &ar, &arch );
        pos = LibTell( io );
        if( ar.name[ 0 ] == '/' && ar.name[ 1 ] == ' ' && ar.name[ 2 ] == ' ' ) {
            // Ignore symbol table.
/*
            dict_count++;
            if( dict_count == 2 ) {
                error = readDict( &arch );
            } else {
                error = MoveAheadFrom( &arch );
                updateNewArchive( &arch );
            }
*/
        } else if( ar.name[ 0 ] == '/' && ar.name[ 1 ] == '/' && ar.name[ 2 ] == ' ' ) {
            AllocFNameTab( name, io, &arch );
        } else if( ar.name[ 0 ] == '/' && ar.name[ 1 ] == '/' && ar.name[ 2 ] == '/' ) {
            AllocFFNameTab( name, io, &arch );
        } else {
            arch.name = GetARName( io, &ar, &arch );
            arch.ffname = GetFFName( &arch );
            rtn( &arch, io );
            MemFree( arch.name );
            MemFree( arch.ffname );
        }
        if( arch.size & 1 )
            ++arch.size;
        LibSeek( io, pos + arch.size, SEEK_SET );
    }
    MemFree( arch.fnametab );
    MemFree( arch.ffnametab );
}