⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwconfig.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include <stdlib.h>
#include <direct.h>
#include <string.h>
#include "heapwalk.h"
#include "watini.h"
#include "jdlg.h"

#define         SECT_NAME       "WATCOM heapwalker"
#define         LSORT           "LSortType"
#define         GSORT           "GSortType"
#define         GSAVE           "GSaveName"
#define         LSAVE           "LSaveName"
#define         DISP_TYPE       "display_type"
#define         DISP_RES        "display_resources"
#define         GLOB_XPOS       "glob_wnd_x_pos"
#define         GLOB_YPOS       "glob_wnd_y_pos"
#define         GLOB_XSIZE      "glob_wnd_x_size"
#define         GLOB_YSIZE      "glob_wnd_y_size"
#define         SAVE_GLOB_POS   "save_glob_wnd_pos"
#define         SAVE_MW_POS     "save_mem_wnd_pos"
#define         MW_XPOS         "memwnd_xpos"
#define         MW_YPOS         "memwnd_ypos"
#define         MW_XSIZE        "memwnd_xsize"
#define         MW_YSIZE        "memwnd_ysize"
#define         MW_FNAME        "memwnd_fname"
#define         MW_MAX          "memwnd_max"
#define         MW_DISP_INFO    "memwnd_disp_info"
#define         MW_AUTOPOS      "memwnd_autopos"
#define         MW_NO_UPDT      "memwnd_no_update"
#define         MW_1_WND        "memwnd_single_wnd"
#define         MW_DISP_TYPE    "memwnd_disp_type"
#define         MW_CODE_TYPE    "memwnd_code_type"


/*
 * ValidateFName - ensure that the path specified by 'path' actually exists
 */
static BOOL ValidateFName( char *path ) {

    char        drive[_MAX_DRIVE];
    char        dir[_MAX_DIR];
    char        name[_MAX_PATH];
    DIR         *info;

    _splitpath( path, drive, dir, NULL, NULL );
    _makepath( name, drive, dir, "*", "*" );
    info = opendir( name );
    if( info == NULL ) {
        return( FALSE );
    } else {
        closedir( info );
        return( TRUE );
    }
} /* ValidateFName */

/*
 * PutProfileBool - write a boolean value to the configuration file
 */
static void PutProfileBool( char *id, BOOL val ) {

    char        buf[15];

    if( val ) {
        itoa( TRUE, buf, 10 );
    } else {
        itoa( FALSE, buf, 10 );
    }
    WritePrivateProfileString( SECT_NAME, id, buf, WATCOM_INI );
} /* PutProfileBool */

/*
 * GetDefaults - set 'info' to the default configuration values
 */
static void GetDefaults( HeapConfigInfo *info ) {

    WORD        x;
    WORD        y;
    char        *str;

    info->save_glob_pos = TRUE;
    info->save_mem_pos = TRUE;
    info->disp_res = TRUE;
    x = GetSystemMetrics( SM_CXSCREEN );
    y = GetSystemMetrics( SM_CYSCREEN );
    info->glob_xpos = x / 32;
    info->glob_ypos = y / 8;
    info->glob_xsize = 15 * ( x / 16 );
    info->glob_ysize = 3 * ( y / 4 );
    str = GetRCString( STR_DEF_GLOB_HEAP_FNAME );
    strcpy( info->gfname, str );
    str = GetRCString( STR_DEF_LCL_HEAP_FNAME );
    strcpy( info->lfname, str );
} /* GetDefaults */

/*
 * ReadConfig - read configuration information from the .ini file
 */
void ReadConfig( void ) {

    MemWndConfig        info;

    GetDefaults( &Config );
    LSortType = GetPrivateProfileInt( SECT_NAME, LSORT,
                                HEAPMENU_SORT_HANDLE, WATCOM_INI );
    GSortType = GetPrivateProfileInt( SECT_NAME, GSORT,
                                HEAPMENU_SORT_HANDLE, WATCOM_INI );
    HeapType = GetPrivateProfileInt( SECT_NAME, DISP_TYPE,
                                HEAPMENU_DISPLAY_ENTIRE, WATCOM_INI );
    Config.disp_res = GetPrivateProfileInt( SECT_NAME, DISP_RES,
                                        Config.disp_res, WATCOM_INI );
    Config.save_glob_pos = GetPrivateProfileInt( SECT_NAME, SAVE_GLOB_POS,
                                        Config.save_glob_pos, WATCOM_INI );
    Config.save_mem_pos = GetPrivateProfileInt( SECT_NAME, SAVE_MW_POS,
                                        Config.save_mem_pos, WATCOM_INI );
    Config.glob_xpos = GetPrivateProfileInt( SECT_NAME, GLOB_XPOS,
                                        Config.glob_xpos, WATCOM_INI );
    Config.glob_ypos = GetPrivateProfileInt( SECT_NAME, GLOB_YPOS,
                                        Config.glob_ypos, WATCOM_INI );
    Config.glob_xsize = GetPrivateProfileInt( SECT_NAME, GLOB_XSIZE,
                                        Config.glob_xsize, WATCOM_INI );
    Config.glob_ysize = GetPrivateProfileInt( SECT_NAME, GLOB_YSIZE,
                                        Config.glob_ysize, WATCOM_INI );
    GetPrivateProfileString( SECT_NAME, GSAVE, Config.gfname,
                        Config.gfname, _MAX_PATH, WATCOM_INI );
    GetPrivateProfileString( SECT_NAME, LSAVE, Config.lfname,
                        Config.lfname, _MAX_PATH, WATCOM_INI );

    /* read information about the memory window */

    GetMemWndConfig( &info );
    info.xpos = GetPrivateProfileInt( SECT_NAME, MW_XPOS,
                                        info.xpos, WATCOM_INI );
    info.ypos = GetPrivateProfileInt( SECT_NAME, MW_YPOS,
                                        info.ypos, WATCOM_INI );
    info.xsize = GetPrivateProfileInt( SECT_NAME, MW_XSIZE,
                                        info.xsize, WATCOM_INI );
    info.ysize = GetPrivateProfileInt( SECT_NAME, MW_YSIZE,
                                        info.ysize, WATCOM_INI );
    GetPrivateProfileString( SECT_NAME, MW_FNAME, info.fname, info.fname,
                                        _MAX_PATH, WATCOM_INI );
    info.maximized = GetPrivateProfileInt( SECT_NAME, MW_MAX,
                                        info.maximized, WATCOM_INI );
    info.disp_info = GetPrivateProfileInt( SECT_NAME, MW_DISP_INFO,
                                        info.disp_info, WATCOM_INI );
    info.autopos_info = GetPrivateProfileInt( SECT_NAME, MW_AUTOPOS,
                                        info.autopos_info, WATCOM_INI );
    info.forget_pos = GetPrivateProfileInt( SECT_NAME, MW_NO_UPDT,
                                        info.forget_pos, WATCOM_INI );
    info.allowmult = GetPrivateProfileInt( SECT_NAME, MW_1_WND,
                                        info.allowmult, WATCOM_INI );
    info.disp_type = GetPrivateProfileInt( SECT_NAME, MW_DISP_TYPE,
                                        info.disp_type, WATCOM_INI );
    info.code_disp_type = GetPrivateProfileInt( SECT_NAME, MW_CODE_TYPE,
                                        info.code_disp_type, WATCOM_INI );
    SetMemWndConfig( &info );
    InitMonoFont( SECT_NAME, WATCOM_INI, SYSTEM_FIXED_FONT, Instance );
} /* ReadConfig */


/*
 * SaveConfigFile - save configuration information to the .ini file
 */
void SaveConfigFile( BOOL save_all_values ) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -