bool WRESaveSymbols( WRHashTable *table, char **file_name, bool prompt ) { char *name; WREGetFileStruct gf; bool ok; if( table == NULL || file_name == NULL ) { return( FALSE ); } if( WRIsDefaultHashTable( table ) ) { return( TRUE ); } ok = true; WRESetStatusText( NULL, "", FALSE ); WRESetStatusByID( WRE_SAVEINGSYMBOLS, -1 ); if( prompt || *file_name == NULL ) { gf.file_name = *file_name; gf.title = WRESymSaveTitle; gf.filter = WRESymSaveFilter; gf.save_ext = FALSE; name = WREGetSaveFileName( &gf ); ok = (name != NULL); if( ok ) { if( *file_name != NULL ) { WRMemFree( *file_name ); } *file_name = name; } } else { name = *file_name; } if( ok ) { ok = WRWriteSymbolsToFile( table, name ); } if( ok ) { WRMakeHashTableClean( table ); } WRESetStatusReadyText(); 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 ); }
bool WRECreateStatusLine( HWND main, HINSTANCE inst ) { RECT rect; LOGFONT lf; TEXTMETRIC tm; HFONT old_font; HDC dc; status_block_desc sbd; char *font_facename; char *cp; int font_pointsize; bool use_default; memset( &lf, 0, sizeof( LOGFONT ) ); dc = GetDC( main ); lf.lfWeight = FW_BOLD; use_default = true; font_facename = AllocRCString( WRE_STATUSFONT ); if( font_facename != NULL ) { cp = (char *)_mbschr( (unsigned char const *)font_facename, '.' ); if( cp != NULL ) { *cp = '\0'; strcpy( lf.lfFaceName, font_facename ); cp++; font_pointsize = atoi( cp ); use_default = false; } FreeRCString( font_facename ); } if( use_default ) { strcpy( lf.lfFaceName, STATUS_FONTFACENAME ); font_pointsize = STATUS_FONTPOINTSIZE; } lf.lfHeight = -MulDiv( font_pointsize, GetDeviceCaps( dc, LOGPIXELSY ), 72 ); WREStatusFont = CreateFontIndirect( &lf ); old_font = SelectObject( dc, WREStatusFont ); GetTextMetrics( dc, &tm ); SelectObject( dc, old_font ); ReleaseDC( main, dc ); GetClientRect( main, &rect ); WREStatusDepth = tm.tmHeight + STATUS_LINE_PAD + VERT_BORDER * 2; rect.top = rect.bottom - WREStatusDepth; StatusWndInit( inst, WREStatusHookProc, 0, (HCURSOR)NULL ); WREStatusBar = StatusWndStart(); sbd.separator_width = STATUS_LINE_PAD; sbd.width = STATUS1_WIDTH; sbd.width_is_percent = FALSE; sbd.width_is_pixels = TRUE; StatusWndSetSeparators( WREStatusBar, 1, &sbd ); WREStatusWindow = StatusWndCreate( WREStatusBar, main, &rect, inst, NULL ); if( WREStatusWindow == NULL ) { WREDisplayErrorMsg( WRE_NOCREATESTATUS ); return( false ); } /* set the text in the status window */ WRESetStatusReadyText(); GetWindowRect( WREStatusWindow, &rect ); WREStatusDepth = rect.bottom - rect.top; return( true ); }