WREResInfo *WRELoadResource( const char *file_name ) { WRFileType file_type; WREResInfo *res_info; Bool ok; WRESetWaitCursor( TRUE ); ok = ((res_info = WREAllocResInfo()) != NULL); if( ok ) { file_type = WRIdentifyFile( file_name ); ok = (file_type != WR_INVALID_FILE); } if( ok ) { res_info->info = WRLoadResource( file_name, file_type ); ok = (res_info->info != NULL); } if( ok ) { file_type = res_info->info->file_type; if( res_info->info->internal_type != WR_DONT_KNOW ) { file_type = res_info->info->internal_type; } res_info->is32bit = WRIs32Bit( file_type ); } if( ok ) { res_info->symbol_table = WRInitHashTable(); ok = (res_info->symbol_table != NULL); } if( !ok ) { if( res_info != NULL ) { WREFreeResInfo( res_info ); res_info = NULL; } } WRESetWaitCursor( FALSE ); return( res_info ); }
Bool WRESaveResourceToFile( WREResInfo *res_info ) { Bool ok; WRESetWaitCursor( TRUE ); ok = (res_info != NULL && res_info->info != NULL); if( ok ) { ok = WRSaveResource( res_info->info, TRUE ); } if( ok ) { WRESetResModified( res_info, FALSE ); } WRESetWaitCursor( FALSE ); return( ok ); }
bool SaveObject( bool save_into ) { WRECurrentResInfo curr; void *rdata; bool ok; WRESetWaitCursor( TRUE ); rdata = NULL; ok = WREGetCurrentResource( &curr ); if( ok ) { ok = (curr.lang->Info.Length != 0); if( !ok ) { WREDisplayErrorMsg( WRE_UPDATEBEFORESAVE1 ); } } if( ok ) { ok = ((rdata = WREGetCurrentResData( &curr )) != NULL); } if( ok ) { if( save_into ) { ok = SaveObjectInto( &curr, rdata ); } else { ok = SaveObjectAs( &curr, rdata ); } } if( rdata != NULL ) { WRMemFree( rdata ); } WRESetWaitCursor( FALSE ); return( ok ); }
static char *WRELoadSymbols( WRHashTable **table, char *file_name, bool prompt ) { char *name; int c; unsigned flags; char *inc_path; WREGetFileStruct gf; unsigned pp_count; unsigned busy_count; char busy_str[2]; bool ret; bool ok; name = NULL; ok = (table != NULL); if( ok ) { WRESetStatusText( NULL, "", FALSE ); WRESetStatusByID( WRE_LOADINGSYMBOLS, -1 ); } if( ok ) { if( file_name == NULL || prompt ) { gf.file_name = file_name; gf.title = WRESymLoadTitle; gf.filter = WRESymSaveFilter; gf.save_ext = FALSE; name = WREGetOpenFileName( &gf ); } else { name = WREStrDup( file_name ); } ok = (name != NULL); } WRESetWaitCursor( TRUE ); if( ok ) { flags = PPFLAG_IGNORE_INCLUDE | PPFLAG_EMIT_LINE; inc_path = NULL; ret = setjmp( SymEnv ); if( ret ) { PP_Fini(); WREDisplayErrorMsg( WRE_SYMOUTOFMEM ); ok = false; } } if( ok ) { ok = !PP_Init( name, flags, inc_path ); if( !ok ) { WREDisplayErrorMsg( WRE_NOLOADHEADERFILE ); } } if( ok ) { pp_count = 0; busy_count = 0; busy_str[1] = '\0'; do { pp_count++; c = PP_Char(); if( pp_count == MAX_PP_CHARS ) { busy_count++; busy_str[0] = WREBusyChars[busy_count % 4]; WRESetStatusText( NULL, busy_str, TRUE ); pp_count = 0; } } while( c != EOF ); if( *table == NULL ) { *table = WRInitHashTable(); } WREAddSymbols( *table ); WRMakeHashTableClean( *table ); PP_Fini(); WRESetStatusText( NULL, " ", TRUE ); } if( !ok ) { if( name != NULL ) { WRMemFree( name ); name = NULL; } } WRESetWaitCursor( FALSE ); WRESetStatusReadyText(); return( name ); }