Example #1
0
void * WRAPI WRCopyResData( WRInfo *info, WResLangNode *lnode )
{
    void        *rdata;
    int         ok;

    rdata = NULL;

    ok = (info != NULL && lnode != NULL);

    if( ok && lnode->data != NULL ) {
        return( WRCopyExistingData( lnode ) );
    }

    if( ok ) {
        ok = (lnode->Info.Length < UINT_MAX);
        if( !ok ) {
            WRDisplayErrorMsg( WR_RESTOOLARGE );
        }
    }

    if( ok ) {
        rdata = WRLoadResData( info->tmp_file, lnode->Info.Offset, lnode->Info.Length );
        ok = (rdata != NULL);
    }

    if( !ok ) {
        if( rdata != NULL ) {
            WRMemFree( rdata );
            rdata = NULL;
        }
    }

    return( rdata );
}
Example #2
0
int WRSaveBitmapResource( WRInfo *info, int backup )
{
    int                 ok;
    WResTypeNode        *tnode;
    WResLangNode        *lnode;
    BYTE                *data;
    uint_32             dsize;

    ok = ( info && info->dir );

    if( ok ) {
        tnode = WRFindTypeNode( info->dir, (uint_16)RT_BITMAP, NULL );
        ok = ( tnode != NULL );
        if( !ok ) {
            WRDisplayErrorMsg( WR_PRJNOBMP );
        }
    }

    if( ok ) {
        ok = ((info->dir->NumTypes == 1) && (info->dir->NumResources == 1));
        if( !ok ) {
            WRDisplayErrorMsg( WR_PRJMORETHANONE );
        }
    }

    if( ok ) {
        lnode = NULL;
        if( tnode->Head && tnode->Head->Head ) {
            lnode = tnode->Head->Head;
        }
        ok = ( lnode != NULL );
    }

    if( ok ) {
        if( lnode->data == NULL ) {
            lnode->data = WRLoadResData( info->file_name, lnode->Info.Offset,
                                         lnode->Info.Length );
        }
        ok = ( lnode->data && lnode->Info.Length );
    }

    if( ok ) {
        data = lnode->data;
        dsize = lnode->Info.Length;
        ok = WRAddBitmapFileHeader( &data, &dsize );
    }

    if( ok ) {
        lnode->data = data;
        lnode->Info.Length = dsize;
        ok = WRSaveImageToFile( info, tnode, backup );
    }

    if( ok ) {
        data = lnode->data;
        dsize = lnode->Info.Length;
        ok = WRStripBitmapFileHeader( &data, &dsize );
    }

    if( ok ) {
        lnode->data = data;
        lnode->Info.Length = dsize;
    }

    return( ok );
}