Example #1
0
static int DumpDir( WResDir dir, WResFileID handle )
/**************************************************/
{
    int             retcode;
    bool            error;
    WResDirWindow   wind;
    uint_16         os;

    retcode = 0;

    if( WResIsEmpty( dir ) ) {
        printf( "Directory in file %s is empty\n", CmdLineParms.FileName );
    } else {
        os = WResGetTargetOS( dir );
        wind = WResFirstResource( dir );
        while( !WResIsLastResource( wind, dir ) ) {
            error = DumpResource( wind, handle, os );
            if( error ) {
                retcode = 2;
            }
            wind = WResNextResource( wind, dir );
        }
        error = DumpResource( wind, handle, os );
        if( error ) {
            retcode = 2;
        }
    }

    return( retcode );
}
Example #2
0
/* Build OS/2 NE style resource table. Each resource gets one entry, and
 * resources > 64K will get an additional entry for each 64K chunk.
 */
static void buildOS2ResTable( OS2ResTable *res_tbl, WResDir dir )
/***************************************************************/
{
    WResDirWindow   wind;
    WResLangInfo    *lang;
    OS2ResEntry     *entry;
    WResTypeInfo    *res_type;
    WResResInfo     *resinfo;
    uint_16         type;
    uint_16         id;
    int_32          length;

    entry = res_tbl->resources;

    /* Walk through the WRes directory */
    for( wind = WResFirstResource( dir ); !WResIsEmptyWindow( wind ); wind = WResNextResource( wind, dir ) ) {
        lang = WResGetLangInfo( wind );
        res_type = WResGetTypeInfo( wind );
        resinfo  = WResGetResInfo( wind );

        // RT_DEFAULTICON is not written into the executable, ignore
        if( res_type->TypeName.ID.Num == OS2_RT_DEFAULTICON ) {
            wind = WResNextResource( wind, dir );
            continue;
        }

        if( res_type->TypeName.IsName )
            type = 0;
        else
            type = res_type->TypeName.ID.Num;

        if( resinfo->ResName.IsName )
            id = 0;
        else
            id = resinfo->ResName.ID.Num;

        /* Fill in resource entries */
        entry->res_type   = type;
        entry->res_id     = id;
        entry->wind       = wind;
        entry->mem_flags  = lang->MemoryFlags;
        entry->seg_length = 0;  /* Zero means 64K */
        entry->first_part = true;

        for( length = lang->Length; length > 0x10000; length -= 0x10000 ) {
            entry++;
            entry->res_type   = type;
            entry->res_id     = id;
            entry->wind       = wind;
            entry->mem_flags  = lang->MemoryFlags;
            entry->seg_length = 0;
            entry->first_part = false;
        }
        entry->seg_length = lang->Length % 0x10000;
        entry++;
    }
}
Example #3
0
static bool copyResourcesFromRes( const char *full_filename )
/***********************************************************/
{
    WResFileID          fid;
    WResDir             dir;
    bool                dup_discarded;
    WResDirWindow       wind;
    char                *buffer;
    bool                error;

    buffer = NULL;
    dir = WResInitDir();
    fid = RcIoOpenInput( full_filename, false );
    if( fid == WRES_NIL_HANDLE ) {
        RcError( ERR_CANT_OPEN_FILE, full_filename, strerror( errno ) );
        goto HANDLE_ERROR;
    }

    error = WResReadDir( fid, dir, &dup_discarded );
    if( error ) {
        switch( LastWresStatus() ) {
        case WRS_BAD_SIG:
            RcError( ERR_INVALID_RES, full_filename );
            break;
        case WRS_BAD_VERSION:
            RcError( ERR_BAD_RES_VER, full_filename );
            break;
        default:
            RcError( ERR_READING_RES, full_filename, LastWresErrStr() );
            break;
        }
        goto HANDLE_ERROR;
    }

    if( WResGetTargetOS( dir ) != WResGetTargetOS( CurrResFile.dir ) ) {
        RcError( ERR_RES_OS_MISMATCH, full_filename );
        goto HANDLE_ERROR;
    }
    buffer = RESALLOC( BUFFER_SIZE );
    wind = WResFirstResource( dir );
    while( !WResIsEmptyWindow( wind ) ) {
        copyAResource( fid, &wind, buffer, full_filename );
        wind = WResNextResource( wind, dir );
    }
    RESFREE( buffer );
    WResFreeDir( dir );
    RESCLOSE( fid );
    return( false );

HANDLE_ERROR:
    ErrorHasOccured = true;
    WResFreeDir( dir );
    if( fid != WRES_NIL_HANDLE )
        RESCLOSE( fid );
    return( true );
}
Example #4
0
int CompareResources( WResFileID fid1, WResDir dir1,
                        WResFileID fid2, WResDir dir2 )
/*****************************************************/
{
    int             retcode;
    int             oldretcode;
    WResDirWindow   wind1;
    WResDirWindow   wind2;

    oldretcode = 0;

    if (WResIsEmpty( dir1 )) {
        if (WResIsEmpty( dir2 )) {
            return( 0 );
        } else {
            return( 1 );
        }
    } else {
        wind1 = WResFirstResource( dir1 );
        while( !WResIsEmptyWindow( wind1 ) ) {
            /* find the window in dir2 over the same resource */
            wind2 = LookUpResource( wind1, dir2 );

            if ( !WResIsEmptyWindow( wind2 ) ) {
                /* compare the contents of the actual resource */
                retcode = CompareOneResource( fid1, wind1, fid2, wind2 );
                switch (retcode) {
                case -1:
                    return( -1 );
                    break;
                case 1:
                    if (!CmdLineParms.CheckAll) {
                        return( 1 );
                    } else {
                        oldretcode = 1;
                    }
                    break;
                }
            } else {
                if (!CmdLineParms.CheckAll) {
                    return( 1 );
                } else {
                    oldretcode = 1;
                }
            }

            wind1 = WResNextResource( wind1, dir1 );
        } /* while */
    } /* if dir is empty */

    return( oldretcode );
}
Example #5
0
extern uint_32 ComputeWINResourceSize( WResDir dir )
/**************************************************/
{
    uint_32         length;
    WResDirWindow   wind;
    WResLangInfo    *res;

    length = 0;
    for( wind = WResFirstResource( dir ); !WResIsEmptyWindow( wind ); wind = WResNextResource( wind, dir ) ) {
        res = WResGetLangInfo( wind );
        length += res->Length;
    }
    return( length );
} /* ComputeWINResourceSize */
Example #6
0
/* Compute the number of resource segments in an OS/2 NE module. Each
 * resource gets its own segment and resources > 64K will be split into
 * as many segments as necessary.
 */
extern uint_32 ComputeOS2ResSegCount( WResDir dir )
/*************************************************/
{
    uint_32         length;
    WResDirWindow   wind;
    WResTypeInfo    *res_type;
    WResLangInfo    *res;
    uint_32         num_res_segs;

    num_res_segs = 0;
    for( wind = WResFirstResource( dir ); !WResIsEmptyWindow( wind ); wind = WResNextResource( wind, dir ) ) {
        res = WResGetLangInfo( wind );
        res_type = WResGetTypeInfo( wind );

        // RT_DEFAULTICON is not written into the executable, ignore
        if( res_type->TypeName.ID.Num != OS2_RT_DEFAULTICON ) {
            ++num_res_segs;
            for( length = res->Length; length > 0x10000; length -= 0x10000 ) {
                ++num_res_segs;
            }
        }
    }
    return( num_res_segs );
} /* ComputeOS2ResSegCount */