Пример #1
0
Bool WREProcessArgs( char **argv, int argc )
{
    int     i;
    Bool    ok;

    ok = TRUE;

    for( i = 1; i < argc; i++ ) {
        if( !stricmp( argv[i], CREATE_NEW_FLAG ) ) {
            WRECreateNewFiles = TRUE;
        } else if( !stricmp( argv[i], NO_IFACE_FLAG ) ) {
            WRENoInterface = TRUE;
        } else {
            if( WRFileExists( argv[i] ) ) {
                ok = WREOpenResource( argv[i] ) && ok;
            } else if( WRECreateNewFiles ) {
                ok = (WRECreateNewResource( argv[i] ) != NULL && ok);
            } else {
                ok = FALSE;
            }
        }
    }

    if( !ok ) {
        WREDisplayErrorMsg( WRE_INPUTFILESNOTLOADED );
    }

    return( ok );
}
Пример #2
0
bool WdeProcessArgs( char **argv, int argc )
{
    int     i;
    bool    ok;

    ok = true;

    for( i = 1; i < argc; i++ ) {
        if( !stricmp( argv[i], CREATE_NEW_FLAG ) ) {
            WdeCreateNewFiles = TRUE;
        } else if( stricmp( argv[i], DDE_OPT ) ) {
            if( WRFileExists( argv[i] ) ) {
                ok = (WdeOpenResource( argv[i] ) && ok);
            } else if( WdeCreateNewFiles ) {
                ok = (WdeCreateNewResource( argv[i] ) != NULL && ok);
            } else {
                ok = false;
            }
        }
    }

    if( !ok ) {
        WdeSetStatusByID( -1, WDE_INPUTFILENOTFOUND );
    }

    return( ok );
}
Пример #3
0
void WR_EXPORT WRFreeWRInfo( WRInfo *info )
{
    if( info != NULL ) {
        if( info->file_name != NULL ) {
            WRMemFree( info->file_name );
        }
        if( info->save_name != NULL ) {
            WRMemFree( info->save_name );
        }
        if( info->internal_filename != NULL ) {
            WRMemFree( info->internal_filename );
        }
        if( info->tmp_file != NULL ) {
            if( WRFileExists( info->tmp_file ) ) {
                WRDeleteFile( info->tmp_file );
            }
            WRMemFree( info->tmp_file );
        }
        if( info->dir != NULL ) {
            WRFreeWResDirData( info->dir );
            WResFreeDir( info->dir );
        }
        WRMemFree( info );
    }
}
Пример #4
0
int WRCopyFileToTemp( WRInfo *info, char *filename )
{
    if( filename == NULL ) {
        return( FALSE );
    }

    if( !WRFileExists( filename ) ) {
        return( FALSE );
    }

    if( info->tmp_file == NULL ) {
        info->tmp_file = WRGetTempFileName( NULL );
        if( info->tmp_file == NULL ) {
            return( FALSE );
        }
    }

    if( !WRCopyFile( info->tmp_file, filename ) ) {
        WRPrintErrorMsg( WR_BACKUPFAILED, filename, info->tmp_file,
                         strerror( WRGetLastError() ) );
        return( FALSE );
    }

    return( TRUE );
}
Пример #5
0
static bool WSaveObjectToRC( WAccelEditInfo *einfo, char *filename,
                             bool shadow, bool append )
{
    char        fn_path[ _MAX_PATH ];
    char        fn_drive[_MAX_DRIVE];
    char        fn_dir[_MAX_DIR];
    char        fn_name[_MAX_FNAME];
    char        fn_ext[_MAX_EXT + 1];

    if( einfo == NULL || filename == NULL ) {
        return( false );
    }

    if( shadow ) {
        _splitpath( filename, fn_drive, fn_dir, fn_name, fn_ext );
        strcpy( fn_ext, ".acc" );
        _makepath( fn_path, fn_drive, fn_dir, fn_name, fn_ext );
    } else {
        strcpy( fn_path, filename );
    }

    if( WRFileExists( fn_path ) ) {
        WRBackupFile( fn_path, true );
    }

    if( !WWriteAccToRC( einfo, fn_path, append ) ) {
        return( false );
    }

    return( true );
}
Пример #6
0
int WRSaveResourceToEXE ( WRInfo *info, int backup, WRFileType ttype )
{
    int        ok;
    char       *tmp_res;
    char       *sname;
    WRFileType  stype;

    sname = NULL;

    ok = ( info->file_name != NULL );

    ok = ( ok && ( ( tmp_res = WRGetTempFileName ( "res" ) ) != NULL ) );

    if ( ok ) {
        sname = info->save_name;
        stype = info->save_type;
        info->save_name = tmp_res;
        info->save_type = ttype;
        ok = WRSaveResource ( info, FALSE );
    }

    if ( ok ) {
        if ( backup && WRFileExists ( sname ) ) {
            ok = WRBackupFile ( sname, FALSE );
        }
    }

    if ( ok ) {
        memset ( &CmdLineParms, 0, sizeof ( CmdLineParms ) );
        CmdLineParms.Pass2Only    = TRUE;
        CmdLineParms.VersionStamp = VERSION_31_STAMP;
        if ( ttype == WR_WINNTW_RES ) {
            CmdLineParms.TargetOS = RC_TARGET_OS_WIN32;
        } else {
            CmdLineParms.TargetOS = RC_TARGET_OS_WIN16;
        }
        strcpy ( CmdLineParms.InFileName, tmp_res );
        strcpy ( CmdLineParms.InExeFileName, info->file_name );
        if ( stricmp ( sname, info->file_name ) ) {
            strcpy ( CmdLineParms.OutExeFileName, sname );
        } else {
            strcpy ( CmdLineParms.OutExeFileName, info->file_name );
        }
        ok = WRExecRCPass2 ();
    }

    if ( tmp_res ) {
        WRDeleteFile ( tmp_res );
        WRMemFree ( tmp_res );
    }

    if ( sname ) {
        info->save_name = sname;
        info->save_type = stype;
    }

    return ( ok );
}
Пример #7
0
int WRSaveIconResource( WRInfo *info, int backup )
{
    WResTypeNode        *tnode;
    WResResNode         *rnode;
    WResLangNode        *lnode;
    WResLangType        lang;
    BYTE                *data;
    uint_32             size;
    int                 use_rename;
    int                 ok;

    data = NULL;
    lang.lang = DEF_LANG;
    lang.sublang = DEF_SUBLANG;

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

    if( ok ) {
        if( backup && WRFileExists ( info->save_name ) ) {
            use_rename = ( info->file_name &&
                           stricmp( info->file_name, info->save_name ) );
            ok = WRBackupFile( info->save_name, use_rename );
        }
    }

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

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

    if( ok ) {
        lnode = WRFindLangNodeFromLangType( rnode, &lang );
        ok = ( lnode != NULL );
    }

    if( ok ) {
        ok = WRCreateIconData( info, lnode, &data, &size );
    }

    if( ok ) {
        ok = WRSaveDataToFile( info->save_name, data, size );
    }

    if( data ) {
        WRMemFree( data );
    }

    return( ok );
}
Пример #8
0
Bool WREOpenResource( char *fn )
{
    char                *name;
    WREResInfo          *res_info;
    WREGetFileStruct    gf;
    Bool                ok, got_name;

    res_info = NULL;
    name = NULL;
    got_name = FALSE;

    if( fn != NULL ) {
        if( WRFileExists( fn ) ) {
            ok = ((name = WREStrDup( fn )) != NULL);
        } else {
            ok = FALSE;
        }
    } else {
        gf.file_name = NULL;
        gf.title = WREResOpenTitle;
        gf.filter = WREResFilter;
        gf.save_ext = TRUE;
        ok = ((name = WREGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        got_name = TRUE;
        ok = ((res_info = WRELoadResource( name )) != NULL);
    }

    if( ok ) {
        WREFindAndLoadSymbols( res_info );
        ok = WRECreateResourceWindow( res_info );
    }

    if( ok ) {
        ListAddElt( &WREResList, (void *)res_info );
    } else {
        if( res_info != NULL ) {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
        if( got_name ) {
            WREDisplayErrorMsg( WRE_RESOURCESNOTLOADED );
        }
    }

    if( name != NULL ) {
        WREMemFree( name );
    }

    return( ok );
}
Пример #9
0
bool WREFindAndLoadSymbols( WREResInfo *rinfo )
{
    char        inc_path[_MAX_PATH];
    char        fn_path[_MAX_PATH];
    char        fn_drive[_MAX_DRIVE];
    char        fn_dir[_MAX_DIR];
    char        fn_name[_MAX_FNAME];
    char        *symbol_file;
    bool        prompt;
    bool        ret;

    if( rinfo == NULL || rinfo->info == NULL ||
        (rinfo->info->file_name == NULL && rinfo->info->save_name == NULL) ) {
        return( FALSE );
    }

    symbol_file = WREFindDLGInclude( rinfo->info );
    if( symbol_file == NULL ) {
        if( rinfo->info->file_name ) {
            _splitpath( rinfo->info->file_name, fn_drive, fn_dir, fn_name, NULL );
        } else {
            _splitpath( rinfo->info->save_name, fn_drive, fn_dir, fn_name, NULL );
        }
        _makepath( fn_path, fn_drive, fn_dir, fn_name, "h" );
        _makepath( inc_path, fn_drive, fn_dir, "", "" );
        WRESetInitialDir( inc_path );
        prompt = TRUE;
    } else {
        strcpy( fn_path, symbol_file );
        WRMemFree( symbol_file );
        symbol_file = NULL;
        prompt = FALSE;
    }

    ret = TRUE;

    if( WRFileExists( fn_path ) ) {
        symbol_file = WRELoadSymbols( &rinfo->symbol_table, fn_path, prompt );
        ret = (symbol_file != NULL);
        if( ret ) {
            if( rinfo->symbol_file != NULL ) {
                WRMemFree( rinfo->symbol_file );
            }
            rinfo->symbol_file = symbol_file;
        }
    }

    return( ret );
}
Пример #10
0
static bool saveResourceToRES( WRInfo *info, bool backup, const char *save_name, const char *file_name )
{
    WResFileID  src_fid;
    WResFileID  dst_fid;
    bool        is_wres;
    bool        ok;
    bool        use_rename;
    WRFileType  save_type;

    src_fid = WRES_NIL_HANDLE;
    dst_fid = WRES_NIL_HANDLE;

    ok = true;

    if( ok ) {
        save_type = info->save_type;
        if( save_type != WR_WIN16M_RES && save_type != WR_WIN16W_RES &&
            save_type != WR_WINNTM_RES && save_type != WR_WINNTW_RES ) {
            if( info->internal_type != WR_DONT_KNOW ) {
                save_type = info->internal_type;
            }
        }
#ifndef __NT__
        ok = !WRIs32Bit( save_type );
        if( !ok ) {
            WRDisplayErrorMsg( WR_NOSAVE32IN16 );
        }
#endif
    }

    if( ok ) {
        if( backup && WRFileExists( save_name ) ) {
            use_rename = (file_name != NULL && stricmp( file_name, save_name ));
            ok = WRBackupFile( save_name, use_rename );
        }
    }

    if( ok ) {
        if( file_name != NULL ) {
            ok = ((src_fid = ResOpenFileRO( info->tmp_file )) != WRES_NIL_HANDLE);
        }
    }

    is_wres = (save_type == WR_WIN16W_RES || save_type == WR_WINNTW_RES);

    if( ok ) {
        ok = ((dst_fid = ResOpenNewFile( save_name )) != WRES_NIL_HANDLE);
        if( ok && is_wres ) {
            ok = !WResFileInit( dst_fid );
        }
    }

    if( ok ) {
        if( is_wres ) {
            ok = WRSaveResourceToWRES( info, src_fid, dst_fid );
        } else {
            ok = WRSaveResourceToMRES( info, src_fid, dst_fid );
        }
    }

    if( src_fid != WRES_NIL_HANDLE ) {
        ResCloseFile( src_fid );
    }

    if( dst_fid != WRES_NIL_HANDLE ) {
        ResCloseFile( dst_fid );
    }

    if( !ok ) {
        if( dst_fid != WRES_NIL_HANDLE ) {
            WRDeleteFile( save_name );
        }
    }

    return( ok );
}
Пример #11
0
static int WRSaveImageToFile( WRInfo *info, WResTypeNode *tnode, int backup )
{
    WResFileID          src;
    WResFileID          dest;
    int                 ok;
    int                 use_rename;
    WResLangNode        *lnode;

    src   = -1;
    dest  = -1;
    lnode = NULL;

    ok = ( info && tnode );

    if( ok ) {
        if( backup && WRFileExists ( info->save_name ) ) {
            use_rename = ( info->file_name &&
                           stricmp( info->file_name, info->save_name ) );
            ok = WRBackupFile( info->save_name, use_rename );
        }
    }

    if( ok ) {
        if( info->file_name ) {
            ok = ( ( src = ResOpenFileRO( info->tmp_file ) ) != -1 );
        }
    }

    if( ok ) {
        dest = open( info->save_name, O_CREAT | O_WRONLY | O_TRUNC |
                                      O_BINARY, S_IWRITE | S_IREAD );
        ok = ( dest  != -1 );
    }

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

    if( ok ) {
        if ( lnode->data ) {
            ok = WRCopyResFromDataToFile( lnode->data,
                                          lnode->Info.Length, dest );
        } else {
            ok = WRCopyResFromFileToFile( src, lnode->Info.Offset,
                                          lnode->Info.Length, dest );
        }
    }

    if ( src != -1 ) {
        ResCloseFile( src );
    }

    if ( dest != -1 ) {
        ResCloseFile( dest );
    }

    if ( !ok ) {
        if ( dest != -1 ) {
            WRDeleteFile ( info->save_name );
        }
    }

    return ( ok );
}