From 39efd5185e6dcd8263e11eeca62d17e4e23215a8 Mon Sep 17 00:00:00 2001 From: Bernd Boeckmann Date: Wed, 17 Jan 2024 18:31:29 +0100 Subject: [PATCH] start to cleanup configuration mess --- bin/fdisk.ini | 69 +------ source/fdisk/fdiskio.c | 445 ++++++----------------------------------- source/fdisk/fdiskio.h | 1 + source/fdisk/main.c | 96 ++------- source/fdisk/main.h | 27 --- 5 files changed, 86 insertions(+), 552 deletions(-) diff --git a/bin/fdisk.ini b/bin/fdisk.ini index 897d7bc..8110946 100644 --- a/bin/fdisk.ini +++ b/bin/fdisk.ini @@ -15,13 +15,6 @@ ; AMBR={ON | OFF} ; CHECKEXTRA={TRUE | FALSE} ; COLORS={0<=N<=127} -; D_ALL={ON | OFF} -; D_CMD_ARG={ON | OFF} -; D_CR_PART={ON | OFF} -; D_DET_FR_SPC={ON | OFF} -; D_INPUT={ON | OFF} -; D_PATH={ON | OFF} -; D_READ_S={ON | OFF} ; DEL_ND_LOG={ON | OFF} ; DRIVE=#-####-###-## ; FLAG_SECTOR={0 | 2<=N<=64 | 256} @@ -43,8 +36,10 @@ ; * OFF Aligns partitions to cylindes. ; ; ALLOW_4GB_FAT16 -; TRUE Permits the creation of 4GB, FAT16, partitions. -; * FALSE Limits the maximum FAT16 partition size to 2GB. +; Permits the creation of 4GB FAT16 partitions. +; Supported by FreeDOS kernel. +; TRUE +; * FALSE ; ; ALLOW_ABORT ; TRUE Allows the user to abort Free FDISK without making @@ -65,38 +60,6 @@ ; * 7 Light grey on black ; 0 TO 127 ; -; D_ALL ON Show all debugging information for functions that have -; built-in debugging capability. -; * OFF All debugging information, for functions with built-in -; debugging capabilities, is not displayed. Individual -; functions may display debugging information as -; described elsewhere in this file. -; D_CMD_ARG -; ON Displays the remaining command line arguments as they -; are processed. -; * OFF -; -; D_CR_PART Shows debugging information for the function that -; creates partitions. -; ON -; * OFF -; -; D_DET_FR_SPC Shows debugging information for the function that -; determines the amount of free space available. -; ON -; * OFF -; -; D_INPUT Shows debugging information for the function that -; obtains user input. -; ON -; * OFF -; -; D_PATH ON Displays the path to Free FDISK. -; * OFF Opposite of the above. -; -; D_READ_S ON Displays the result of a call to void Read_Physical_Sector() -; * OFF -; ; DEL_ND_LOG Allows non-dos logical drives to be deleted. ; TRUE ; * FALSE @@ -138,10 +101,9 @@ ; 5 Emulates the MS-FDISK that came with MS-DOS 5.xx. ; 6 Emulates the MS-FDISK that came with MS-DOS 6.xx. ; W95 Adds support for LBA hard disks. -; W95B Same as W95, with the addition of FAT32 support. -; * W98 Same as W95B -; FD Setting for FreeDOS. Currently is the same as W95 -; with ALLOW_4GB_FAT16 set to TRUE. +; * W95B Same as W95, with the addition of FAT32 support. +; W98 Same as W95B. +; FD Setting for FreeDOS, same as W95B. ; ; WRITE * ON Changes will be written the the hard disk(s). ; OFF Changes will not be written to the hard disk(s) and @@ -181,11 +143,8 @@ ; ; Current settings: ; - CHECKEXTRA FALSE + DEL_ND_LOG TRUE - FLAG_SECTOR 2 - SET_ANY_ACT FALSE - VERSION W98 ; ; Hard Disk Detection Overrides: @@ -204,18 +163,6 @@ ; ; Uncomment the debugging settings, below, if debugging is compiled in. ; -; Debugging settings: -; -; D_ALL OFF -; D_CMD_ARG OFF -; D_CR_PART OFF -; D_DET_FR_SPC OFF -; D_INPUT OFF -; D_LBA OFF -; D_PATH OFF -; D_READ_S OFF -; -; WRITE ON ; ; ; End of file marker follows, do not remove it. diff --git a/source/fdisk/fdiskio.c b/source/fdisk/fdiskio.c index cc9e646..0202564 100644 --- a/source/fdisk/fdiskio.c +++ b/source/fdisk/fdiskio.c @@ -300,6 +300,22 @@ int Create_MBR_If_Not_Present( void ) */ +/* parse bool_text for "ON" or "OFF" and set integer var accordingly */ +int bool_string_to_int( int *var, const char *bool_text ) +{ + if ( 0 == stricmp( bool_text, "ON" ) ) { + *var = TRUE; + return 1; + } + if ( 0 == stricmp( bool_text, "OFF" ) ) { + *var = FALSE; + return 1; + } + + return 0; +} + + /* Read and process the fdisk.ini file */ void Process_Fdiskini_File( void ) { @@ -324,34 +340,6 @@ void Process_Fdiskini_File( void ) FILE *file; - /* Set values to UNCHANGED */ -#ifdef DEBUG - debug.all = UNCHANGED; - debug.command_line_arguments = UNCHANGED; - debug.create_partition = UNCHANGED; - debug.determine_free_space = UNCHANGED; - debug.input_routine = UNCHANGED; - debug.lba = UNCHANGED; - debug.path = UNCHANGED; - debug.read_sector = UNCHANGED; - debug.write = UNCHANGED; -#endif - - flags.align_4k = UNCHANGED; - flags.allow_4gb_fat16 = UNCHANGED; - flags.allow_abort = UNCHANGED; - flags.check_for_extra_cylinder = UNCHANGED; - flags.del_non_dos_log_drives = UNCHANGED; - flags.extended_options_flag = UNCHANGED; - flags.flag_sector = UNCHANGED; - flags.monochrome = UNCHANGED; - flags.lba_marker = UNCHANGED; - flags.reboot = UNCHANGED; - flags.screen_color = UNCHANGED; - flags.set_any_pri_part_active = UNCHANGED; - flags.use_ambr = UNCHANGED; - flags.version = UNCHANGED; - strcpy( home_path, path ); strcat( home_path, "fdisk.ini" ); @@ -454,76 +442,36 @@ void Process_Fdiskini_File( void ) /* Align partitions to 4k */ if ( 0 == stricmp( command_buffer, "ALIGN_4K" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.align_4k = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.align_4k = FALSE; - } - if ( flags.align_4k == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.align_4k, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the ALLOW_4GB_FAT16 statement */ if ( 0 == stricmp( command_buffer, "ALLOW_4GB_FAT16" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.allow_4gb_fat16 = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.allow_4gb_fat16 = FALSE; - } - if ( flags.allow_4gb_fat16 == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.allow_4gb_fat16, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the ALLOW_ABORT statement */ if ( 0 == stricmp( command_buffer, "ALLOW_ABORT" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.allow_abort = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.allow_abort = FALSE; - } - if ( flags.allow_abort == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.allow_abort, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the AMBR statement */ if ( 0 == stricmp( command_buffer, "AMBR" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.use_ambr = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.use_ambr = FALSE; - } - if ( flags.use_ambr == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.use_ambr, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the CHECKEXTRA statement */ if ( 0 == stricmp( command_buffer, "CHECKEXTRA" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.check_for_extra_cylinder = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.check_for_extra_cylinder = FALSE; - } - if ( flags.check_for_extra_cylinder == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.check_for_extra_cylinder, setting_buffer) ) + goto parse_error; command_ok = TRUE; } @@ -534,148 +482,14 @@ void Process_Fdiskini_File( void ) if ( ( number >= 0 ) && ( number <= 127 ) ) { flags.screen_color = number; } - - if ( flags.screen_color == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + else goto parse_error; command_ok = TRUE; } -#ifdef DEBUG - /* Check for the D_ALL statement */ - if ( 0 == stricmp( command_buffer, "D_ALL" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.all = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.all = FALSE; - } - if ( debug.all == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_CMD_ARG statement */ - if ( 0 == stricmp( command_buffer, "D_CMD_ARG" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.command_line_arguments = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.command_line_arguments = FALSE; - } - if ( debug.command_line_arguments == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_CR_PART statement */ - if ( 0 == stricmp( command_buffer, "D_CR_PART" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.create_partition = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.create_partition = FALSE; - } - if ( debug.create_partition == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_DET_FR_SPC statement */ - if ( 0 == stricmp( command_buffer, "D_DET_FR_SPC" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.determine_free_space = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.determine_free_space = FALSE; - } - if ( debug.determine_free_space == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_INPUT statement */ - if ( 0 == stricmp( command_buffer, "D_INPUT" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.input_routine = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.input_routine = FALSE; - } - if ( debug.input_routine == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_LBA statement */ - if ( 0 == stricmp( command_buffer, "D_LBA" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.lba = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.lba = FALSE; - } - if ( debug.lba == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_PATH statement */ - if ( 0 == stricmp( command_buffer, "D_PATH" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.path = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.path = FALSE; - } - if ( debug.path == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } - - /* Check for the D_READ_S statement */ - if ( 0 == stricmp( command_buffer, "D_READ_S" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.read_sector = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.read_sector = FALSE; - } - if ( debug.read_sector == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } -#endif - /* Check for the DEL_ND_LOG statement */ if ( 0 == stricmp( command_buffer, "DEL_ND_LOG" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.del_non_dos_log_drives = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.del_non_dos_log_drives = FALSE; - } - if ( flags.del_non_dos_log_drives == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.del_non_dos_log_drives, setting_buffer) ) + goto parse_error; command_ok = TRUE; } @@ -728,16 +542,13 @@ void Process_Fdiskini_File( void ) if ( number == 0 ) { flags.flag_sector = 0; } - if ( ( number >= 2 ) && ( number <= 64 ) ) { + else if ( ( number >= 2 ) && ( number <= 64 ) ) { flags.flag_sector = number; } - if ( number == 256 ) { + else if ( number == 256 ) { flags.flag_sector = part_table[0].total_sect; } - if ( flags.flag_sector == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + else goto parse_error; command_ok = TRUE; } @@ -748,64 +559,29 @@ void Process_Fdiskini_File( void ) /* Check for the LBA_MARKER statement */ if ( 0 == stricmp( command_buffer, "LBA_MARKER" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.lba_marker = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.lba_marker = FALSE; - } - if ( flags.lba_marker == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.lba_marker, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the MONO statement */ if ( 0 == stricmp( command_buffer, "MONO" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.monochrome = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.monochrome = FALSE; - } - - if ( flags.monochrome == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.monochrome, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the REBOOT statement */ if ( 0 == stricmp( command_buffer, "REBOOT" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.reboot = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.reboot = FALSE; - } - - if ( flags.reboot == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.reboot, setting_buffer) ) + goto parse_error; command_ok = TRUE; } /* Check for the SET_ANY_ACT statement */ if ( 0 == stricmp( command_buffer, "SET_ANY_ACT" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.set_any_pri_part_active = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.set_any_pri_part_active = FALSE; - } - - if ( flags.set_any_pri_part_active == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.set_any_pri_part_active, setting_buffer) ) + goto parse_error; command_ok = TRUE; } @@ -814,65 +590,36 @@ void Process_Fdiskini_File( void ) if ( 0 == stricmp( setting_buffer, "4" ) ) { flags.version = COMP_FOUR; } - if ( 0 == stricmp( setting_buffer, "5" ) ) { + else if ( 0 == stricmp( setting_buffer, "5" ) ) { flags.version = COMP_FIVE; } - if ( 0 == stricmp( setting_buffer, "6" ) ) { + else if ( 0 == stricmp( setting_buffer, "6" ) ) { flags.version = COMP_SIX; } - if ( 0 == stricmp( setting_buffer, "W95" ) ) { + else if ( 0 == stricmp( setting_buffer, "W95" ) ) { flags.version = COMP_W95; } - if ( 0 == stricmp( setting_buffer, "W95B" ) ) { + else if ( 0 == stricmp( setting_buffer, "W95B" ) ) { flags.version = COMP_W95B; } - if ( 0 == stricmp( setting_buffer, "W98" ) - || 0 == stricmp( setting_buffer, "FD" ) ) { - flags.version = COMP_FD; + else if ( 0 == stricmp( setting_buffer, "W98" ) ) { + flags.version = COMP_W98; } - if ( flags.version == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); + else if ( 0 == stricmp( setting_buffer, "FD" ) ) { + flags.version = COMP_FD; } + else goto parse_error; command_ok = TRUE; } /* Check for the XO statement */ if ( 0 == stricmp( command_buffer, "XO" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - flags.extended_options_flag = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - flags.extended_options_flag = FALSE; - } - if ( flags.extended_options_flag == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( !bool_string_to_int( &flags.extended_options_flag, setting_buffer) ) + goto parse_error; command_ok = TRUE; } -#ifdef DEBUG - /* Check for the WRITE statement */ - if ( 0 == stricmp( command_buffer, "WRITE" ) ) { - if ( 0 == stricmp( setting_buffer, "ON" ) ) { - debug.write = TRUE; - } - if ( 0 == stricmp( setting_buffer, "OFF" ) ) { - debug.write = FALSE; - } - if ( debug.write == UNCHANGED ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } - command_ok = TRUE; - } -#endif - - if ( command_ok == FALSE ) { - con_printf( error_str, line_counter ); - exit( 3 ); - } + if ( command_ok == FALSE ) goto parse_error; } if ( ( 0 == strncmp( line_buffer, "999", 3 ) ) && @@ -887,90 +634,12 @@ void Process_Fdiskini_File( void ) fclose( file ); } - /* Set options to defaults, if not already set */ -#ifdef DEBUG - if ( debug.all == UNCHANGED ) { - debug.all = FALSE; - } - if ( debug.command_line_arguments == UNCHANGED ) { - debug.command_line_arguments = FALSE; - } - if ( debug.create_partition == UNCHANGED ) { - debug.create_partition = FALSE; - } - if ( debug.determine_free_space == UNCHANGED ) { - debug.determine_free_space = FALSE; - } - if ( debug.lba == UNCHANGED ) { - debug.lba = FALSE; - } - if ( debug.input_routine == UNCHANGED ) { - debug.input_routine = FALSE; - } - if ( debug.path == UNCHANGED ) { - debug.path = FALSE; - } - if ( debug.read_sector == UNCHANGED ) { - debug.read_sector = FALSE; - } - if ( debug.write == UNCHANGED ) { - debug.write = TRUE; - } -#endif - - if ( flags.align_4k == UNCHANGED ) { - flags.align_4k = FALSE; - } - if ( flags.allow_4gb_fat16 == UNCHANGED ) { - flags.allow_4gb_fat16 = FALSE; - } - if ( flags.allow_abort == UNCHANGED ) { - flags.allow_abort = FALSE; - } - if ( flags.check_for_extra_cylinder == UNCHANGED ) { - flags.check_for_extra_cylinder = FALSE; - } - if ( flags.del_non_dos_log_drives == UNCHANGED ) { - flags.del_non_dos_log_drives = FALSE; - } - if ( flags.extended_options_flag == UNCHANGED ) { - flags.extended_options_flag = FALSE; - } - if ( flags.flag_sector == UNCHANGED ) { - flags.flag_sector = 2; - } - if ( flags.lba_marker == UNCHANGED ) { - flags.lba_marker = TRUE; - } - if ( flags.monochrome == UNCHANGED ) { - flags.monochrome = FALSE; - } - if ( flags.reboot == UNCHANGED ) { - flags.reboot = FALSE; - } - if ( flags.screen_color == UNCHANGED ) { - flags.screen_color = 0x07; /* light grey on black */ - } - if ( flags.set_any_pri_part_active == UNCHANGED ) { - flags.set_any_pri_part_active = TRUE; - } - if ( flags.use_ambr == UNCHANGED ) { - flags.use_ambr = FALSE; - } + return; -#ifdef DEBUG - /* If debug.all==TRUE then set all debugging options to true */ - if ( debug.all == TRUE ) { - debug.command_line_arguments = TRUE; - debug.create_partition = TRUE; - debug.determine_free_space = TRUE; - debug.input_routine = TRUE; - debug.lba = TRUE; - debug.path = TRUE; - debug.read_sector = TRUE; - debug.write = FALSE; - } -#endif +parse_error: + con_printf( error_str, line_counter ); + exit( 3 ); + return; } /* Remove MBR */ diff --git a/source/fdisk/fdiskio.h b/source/fdisk/fdiskio.h index ad1556f..4face52 100644 --- a/source/fdisk/fdiskio.h +++ b/source/fdisk/fdiskio.h @@ -18,6 +18,7 @@ void Load_External_Lookup_Table( void ); void Process_Fdiskini_File( void ); int Remove_IPL( void ); int Save_MBR( void ); +int bool_string_to_int( int *var, const char *bool_text ); int Set_Flag( int flag_number, int flag_value ); #ifdef SMART_MBR diff --git a/source/fdisk/main.c b/source/fdisk/main.c index 4d816a3..d3f7b9c 100644 --- a/source/fdisk/main.c +++ b/source/fdisk/main.c @@ -1,7 +1,7 @@ /* // Program: Free FDISK // Written by: Brian E. Reifsnyder and The FreeDOS Project -// Copyright: 1998-2023 under the terms of the GNU GPL, Version 2 +// Copyright: 1998-2024 under the terms of the GNU GPL, Version 2 */ #define MAIN @@ -130,52 +130,27 @@ static int Get_Environment_Settings( char *environment[] ) /* Align partitions to 4K */ if ( 0 == strcmp( command_buffer, "FFD_ALIGN_4K" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.align_4k = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.align_4k = FALSE; - } + bool_string_to_int( &flags.align_4k, setting_buffer ); } /* Check for the ALLOW_4GB_FAT16 statement */ if ( 0 == strcmp( command_buffer, "FFD_ALLOW_4GB_FAT16" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.allow_4gb_fat16 = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.allow_4gb_fat16 = FALSE; - } + bool_string_to_int( &flags.allow_4gb_fat16, setting_buffer ); } /* Check for the ALLOW_ABORT statement */ if ( 0 == strcmp( command_buffer, "FFD_ALLOW_ABORT" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.allow_abort = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.allow_abort = FALSE; - } + bool_string_to_int( &flags.allow_abort, setting_buffer ); } /* Check for the AMBR statement */ if ( 0 == strcmp( command_buffer, "FFD_AMBR" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.use_ambr = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.use_ambr = FALSE; - } + bool_string_to_int( &flags.use_ambr, setting_buffer ); } /* Check for the CHECKEXTRA statement */ if ( 0 == strcmp( command_buffer, "FFD_CHECKEXTRA" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.check_for_extra_cylinder = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.check_for_extra_cylinder = FALSE; - } + bool_string_to_int( &flags.check_for_extra_cylinder, setting_buffer ); } /* Check for the COLORS statement */ @@ -189,12 +164,7 @@ static int Get_Environment_Settings( char *environment[] ) /* Check for the DEL_ND_LOG statement */ if ( 0 == strcmp( command_buffer, "FFD_DEL_ND_LOG" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.del_non_dos_log_drives = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.del_non_dos_log_drives = FALSE; - } + bool_string_to_int( &flags.del_non_dos_log_drives, setting_buffer ); } /* Check for the FLAG_SECTOR statement */ @@ -213,42 +183,22 @@ static int Get_Environment_Settings( char *environment[] ) /* Check for the LBA_MARKER statement */ if ( 0 == strcmp( command_buffer, "FFD_LBA_MARKER" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.lba_marker = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.lba_marker = FALSE; - } + bool_string_to_int( &flags.lba_marker, setting_buffer ); } /* Check for the MONO statement */ if ( 0 == strcmp( command_buffer, "FFD_MONO" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.monochrome = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.monochrome = FALSE; - } + bool_string_to_int( &flags.monochrome, setting_buffer ); } /* Check for the REBOOT statement */ if ( 0 == strcmp( command_buffer, "FFD_REBOOT" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.reboot = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.reboot = FALSE; - } + bool_string_to_int( &flags.reboot, setting_buffer ); } /* Check for the SET_ANY_ACT statement */ if ( 0 == strcmp( command_buffer, "FFD_SET_ANY_ACT" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.set_any_pri_part_active = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.set_any_pri_part_active = FALSE; - } + bool_string_to_int( &flags.set_any_pri_part_active, setting_buffer ); } /* Check for the VERSION statement */ @@ -278,12 +228,7 @@ static int Get_Environment_Settings( char *environment[] ) /* Check for the XO statement */ if ( 0 == strcmp( command_buffer, "FFD_XO" ) ) { - if ( 0 == strcmp( setting_buffer, "ON" ) ) { - flags.extended_options_flag = TRUE; - } - if ( 0 == strcmp( setting_buffer, "OFF" ) ) { - flags.extended_options_flag = FALSE; - } + bool_string_to_int( &flags.extended_options_flag, setting_buffer ); } /* Check for the LANG statement */ @@ -302,18 +247,17 @@ static void Initialization( char *environment[] ) { int index; - /* initialize base flags */ - flags.version = COMP_W95B; + /* initialize flags, the ones not set here default to FALSE */ flags.display_name_description_copyright = TRUE; - flags.do_not_pause_help_information = FALSE; - flags.fprmt = FALSE; - flags.return_from_iui = FALSE; - flags.partitions_have_changed = FALSE; + flags.drive_number = 128; + flags.flag_sector = 2; + flags.lba_marker = TRUE; + flags.screen_color = 0x07; /* light grey on black */ + flags.set_any_pri_part_active = TRUE; flags.total_number_hard_disks = 255; flags.use_iui = TRUE; flags.using_default_drive_number = TRUE; - - flags.drive_number = 128; + flags.version = COMP_W95B; /* Clear the user_defined_chs_settings structure */ index = 0; @@ -345,7 +289,7 @@ static void Initialization( char *environment[] ) Check_For_INT13_Extensions(); } - /* If the version is W95B or W98 then default to FAT32 support. */ + /* If the version is W95B or later then default to FAT32 support. */ if ( flags.version >= COMP_W95B ) { flags.fat32 = TRUE; } diff --git a/source/fdisk/main.h b/source/fdisk/main.h index 659e97e..7e7d8b7 100644 --- a/source/fdisk/main.h +++ b/source/fdisk/main.h @@ -7,33 +7,6 @@ #define VERSION "1.3.12" #define COPYLEFT "1998 - 2024" -/* ***** Set the above definition to the */ -/* ***** version to be emulated if the */ -/* ***** fdisk.ini file does not exist or if */ -/* ***** the fdisk.ini file does not have a */ -/* ***** VERSION statement. */ -/* ***** Set the above definition to the */ -/* ***** version to be emulated if the */ -/* ***** VERSION statement in the fdisk.ini */ -/* ***** file is set to "FD." Note: Do not */ -/* ***** enter "100" in the above line. */ - -/* ***** Version Codes: */ -/* ***** Version 4: 4 */ -/* ***** Version 5: 5 */ -/* ***** Version 6: 6 */ -/* ***** Win 95/Win 95A: 7 */ -/* ***** Win 95B: 72 */ -/* ***** Win 98 8 */ -/* ***** FreeDOS: 100 */ - -//#define SIZE_OF_IPL 445 -/* ***** This is the number of bytes for the */ -/* ***** boot code in the partition table. */ -/* ***** If the boot code in the partition */ -/* ***** table changes, this WILL need */ -/* ***** changed. (Start the count at 0.) */ -// sectorsize - 4 tables - '55aa' - signature #define SIZE_OF_IPL ( 512 - 4 * 16 - 2 - 6 ) #define EMULATED_CYLINDERS 15000