Skip to content

Commit

Permalink
start working on version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckmann committed Jan 17, 2024
1 parent 6280fd7 commit 3d1c54e
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 110 deletions.
1 change: 1 addition & 0 deletions doc/fdisk/contrib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ Mateusz Viste svarlang lib, FDISK lite, code improvements,
Emir SARI Turkish translation
Berki Yenigün French, Turkish translation
Alejandro de Garate Spanish translation
Robert Riebisch German translation fixes
26 changes: 8 additions & 18 deletions source/fdisk/fdiskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,25 +812,23 @@ void Process_Fdiskini_File( void )
/* Check for the VERSION statement */
if ( 0 == stricmp( command_buffer, "VERSION" ) ) {
if ( 0 == stricmp( setting_buffer, "4" ) ) {
flags.version = FOUR;
flags.version = COMP_FOUR;
}
if ( 0 == stricmp( setting_buffer, "5" ) ) {
flags.version = FIVE;
flags.version = COMP_FIVE;
}
if ( 0 == stricmp( setting_buffer, "6" ) ) {
flags.version = SIX;
flags.version = COMP_SIX;
}
if ( 0 == stricmp( setting_buffer, "W95" ) ) {
flags.version = W95;
flags.version = COMP_W95;
}
if ( 0 == stricmp( setting_buffer, "W95B" ) ) {
flags.version = W95B;
flags.version = COMP_W95B;
}
if ( 0 == stricmp( setting_buffer, "W98" ) ) {
flags.version = W98;
}
if ( 0 == stricmp( setting_buffer, "FD" ) ) {
flags.version = FREEDOS_VERSION;
if ( 0 == stricmp( setting_buffer, "W98" )
|| 0 == stricmp( setting_buffer, "FD" ) ) {
flags.version = COMP_FD;
}
if ( flags.version == UNCHANGED ) {
con_printf( error_str, line_counter );
Expand Down Expand Up @@ -959,14 +957,6 @@ void Process_Fdiskini_File( void )
if ( flags.use_ambr == UNCHANGED ) {
flags.use_ambr = FALSE;
}
if ( flags.version == UNCHANGED ) {
if ( DEFAULT_VERSION != FD ) {
flags.version = DEFAULT_VERSION;
}
else {
flags.version = FREEDOS_VERSION;
}
}

#ifdef DEBUG
/* If debug.all==TRUE then set all debugging options to true */
Expand Down
50 changes: 13 additions & 37 deletions source/fdisk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,25 +254,25 @@ static int Get_Environment_Settings( char *environment[] )
/* Check for the VERSION statement */
if ( 0 == strcmp( command_buffer, "FFD_VERSION" ) ) {
if ( 0 == strcmp( setting_buffer, "4" ) ) {
flags.version = FOUR;
flags.version = COMP_FOUR;
}
if ( 0 == strcmp( setting_buffer, "5" ) ) {
flags.version = FIVE;
flags.version = COMP_FIVE;
}
if ( 0 == strcmp( setting_buffer, "6" ) ) {
flags.version = SIX;
flags.version = COMP_SIX;
}
if ( 0 == strcmp( setting_buffer, "W95" ) ) {
flags.version = W95;
flags.version = COMP_W95;
}
if ( 0 == strcmp( setting_buffer, "W95B" ) ) {
flags.version = W95B;
flags.version = COMP_W95B;
}
if ( 0 == strcmp( setting_buffer, "W98" ) ) {
flags.version = W98;
flags.version = COMP_W98;
}
if ( 0 == strcmp( setting_buffer, "FD" ) ) {
flags.version = FREEDOS_VERSION;
flags.version = COMP_FD;
}
}

Expand Down Expand Up @@ -302,7 +302,8 @@ static void Initialization( char *environment[] )
{
int index;

/* Set some flags */
/* initialize base flags */
flags.version = COMP_W95B;
flags.display_name_description_copyright = TRUE;
flags.do_not_pause_help_information = FALSE;
flags.fprmt = FALSE;
Expand Down Expand Up @@ -340,13 +341,12 @@ static void Initialization( char *environment[] )
con_enable_attr( !flags.monochrome );

/* Check for interrupt 0x13 extensions (If the proper version is set.) */
if ( ( flags.version == W95 ) || ( flags.version == W95B ) ||
( flags.version == W98 ) ) {
if ( flags.version >= COMP_W95 ) {
Check_For_INT13_Extensions();
}

/* If the version is W95B or W98 then default to FAT32 support. */
if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) {
if ( flags.version >= COMP_W95B ) {
flags.fat32 = TRUE;
}

Expand Down Expand Up @@ -375,30 +375,6 @@ void Reboot_PC( void )
(*fp)();
}

/* Re-Initialize LBA related functions. */
/* UNUSED */
#if 0
void Re_Initialization( void )
{
/* Check for interrupt 0x13 extensions (If the proper version is set.) */
if ( ( flags.version == W95 ) || ( flags.version == W95B ) ||
( flags.version == W98 ) ) {
Check_For_INT13_Extensions();
}

/* If the version is W95B or W98 then default to FAT32 support. */
if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) {
flags.fat32 = TRUE;
}

/* Initialize LBA structures, if necessary. */
if ( flags.use_extended_int_13 == TRUE ) {
Initialize_LBA_Structures();
}

Read_Partition_Tables();
}
#endif

/*
if the C: drive has not been formatted, and fdisk
Expand Down Expand Up @@ -676,7 +652,7 @@ int main( int argc, char *argv[] )
}

if ( 0 == strcmp( arg[0].choice, "FPRMT" ) ) {
if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) {
if ( flags.version >= COMP_W95B ) {
flags.fprmt = TRUE;
}
}
Expand Down Expand Up @@ -798,7 +774,7 @@ int main( int argc, char *argv[] )
if ( 0 == strcmp( arg[0].choice, "Q" ) ) {
flags.reboot = FALSE;

if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) {
if ( flags.version >= COMP_W95B ) {
Ask_User_About_FAT32_Support();
}
}
Expand Down
16 changes: 7 additions & 9 deletions source/fdisk/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
#define VERSION "1.3.12"
#define COPYLEFT "1998 - 2024"

#define DEFAULT_VERSION 8
/* ***** 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. */
#define FREEDOS_VERSION 7
/* ***** Set the above definition to the */
/* ***** version to be emulated if the */
/* ***** VERSION statement in the fdisk.ini */
Expand Down Expand Up @@ -76,13 +74,13 @@ typedef unsigned char _u8;
#define UNCHANGED 220
#define UNUSED 99

#define FD 100
#define FOUR 4
#define FIVE 5
#define SIX 6
#define W95 7
#define W95B 72
#define W98 8
#define COMP_FOUR 4
#define COMP_FIVE 5
#define COMP_SIX 6
#define COMP_W95 7
#define COMP_W95B 8
#define COMP_W98 9
#define COMP_FD 10

#define MEG 1048576

Expand Down
36 changes: 6 additions & 30 deletions source/fdisk/pcompute.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,10 @@ unsigned long Max_Log_Part_Size_In_MB( void )
stored_max_size_mb = max_size_mb;

/* Adjust max_size_mb depending upon version */
if ( ( flags.version == FOUR ) && ( max_size_mb > MAXFAT16NORM ) ) {
if ( ( flags.version <= COMP_W95 ) && ( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}
if ( ( flags.version == FIVE ) && ( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}
if ( ( flags.version == SIX ) && ( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}
if ( ( flags.version == W95 ) && ( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}
if ( ( ( flags.version == W95B ) || ( flags.version == W98 ) ) &&
if ( ( flags.version >= COMP_W95B ) &&
( flags.fat32 == FALSE ) && ( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}
Expand Down Expand Up @@ -789,28 +780,13 @@ unsigned long Max_Pri_Part_Size_In_MB( int type )
stored_max_size_mb = max_size_mb;

/* Adjust max_size_mb depending upon version */
if ( ( type != EXTENDED ) && ( flags.version == FOUR ) &&
( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}

if ( ( type != EXTENDED ) && ( flags.version == FIVE ) &&
( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}

if ( ( type != EXTENDED ) && ( flags.version == SIX ) &&
( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}

if ( ( type != EXTENDED ) && ( flags.version == W95 ) &&
if ( ( type != EXTENDED ) && ( flags.version <= COMP_W95 ) &&
( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}

if ( ( type != EXTENDED ) &&
( ( flags.version == W95B ) || ( flags.version == W98 ) ) &&
( flags.version >= COMP_W95B ) &&
( flags.fat32 == FALSE ) && ( max_size_mb > MAXFAT16NORM ) ) {
max_size_mb = MAXFAT16NORM;
}
Expand Down Expand Up @@ -950,13 +926,13 @@ int Partition_Type_To_Create( unsigned long size_in_mb,

/* FAT 32 */
if ( ( size_in_mb > 128 ) &&
( ( flags.version == W95B ) || ( flags.version == W98 ) ) &&
( flags.version >= COMP_W95B ) &&
( flags.fat32 == TRUE ) && ( flags.fprmt == TRUE ) ) {
numeric_type = 0x0b;
}

if ( ( size_in_mb > 512 ) &&
( ( flags.version == W95B ) || ( flags.version == W98 ) ) &&
( flags.version >= COMP_W95B ) &&
( flags.fat32 == TRUE ) ) {
numeric_type = 0x0b;
}
Expand Down
10 changes: 4 additions & 6 deletions source/fdisk/pdiskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ int Is_Supp_Ext_Part( int num_type )
{
return ( num_type == 5 ) ||
( num_type == 0x0f &&
( flags.version == W95 || flags.version == W95B ||
flags.version == W98 ) );
( flags.version >= COMP_W95 ) );
}

int Is_Pri_Tbl_Empty( void )
Expand All @@ -169,18 +168,17 @@ int IsRecognizedFatPartition( unsigned partitiontype )
case 6:
return TRUE;
case 0x0e:
if ( flags.version == W95 || flags.version == W95B ||
flags.version == W98 ) {
if ( flags.version >= COMP_W95 ) {
return TRUE;
}
break;
case 0x0b:
if ( flags.version == W95B || flags.version == W98 ) {
if ( flags.version >= COMP_W95B ) {
return TRUE;
}
break;
case 0x0c:
if ( flags.version == W95B || flags.version == W98 ) {
if ( flags.version >= COMP_W95B ) {
return TRUE;
}
break;
Expand Down
12 changes: 6 additions & 6 deletions source/fdisk/userint0.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ void Display_Information( void )
{
if ( flags.extended_options_flag == TRUE ) {
con_set_cursor_xy( 1, 1 );
if ( flags.version == FOUR ) {
if ( flags.version == COMP_FOUR ) {
con_print( "4" );
}
if ( flags.version == FIVE ) {
if ( flags.version == COMP_FIVE ) {
con_print( "5" );
}
if ( flags.version == SIX ) {
if ( flags.version == COMP_SIX ) {
con_print( "6" );
}
if ( flags.version == W95 ) {
if ( flags.version == COMP_W95 ) {
con_print( "W95" );
}
if ( flags.version == W95B ) {
if ( flags.version == COMP_W95B ) {
con_print( "W95B" );
}
if ( flags.version == W98 ) {
if ( flags.version == COMP_W98 ) {
con_print( "W98" );
}

Expand Down
4 changes: 2 additions & 2 deletions source/fdisk/userint1.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void Interactive_User_Interface( void )
}

/* Ask the user if FAT32 is desired. */
if ( ( flags.version == W95B ) || ( flags.version == W98 ) ) {
if ( flags.version >= COMP_W95B ) {
Ask_User_About_FAT32_Support();
}

Expand Down Expand Up @@ -534,7 +534,7 @@ int Standard_Menu( int menu )
option_2 = svarlang_str(5, 2); /* Delete Extended DOS Partition */
option_3 = svarlang_str(5, 3); /* Del Log DOS Drive in Ext DOS Part */
option_4 = svarlang_str(5, 4); /* Delete Non-DOS Partition */
if ( flags.version == FOUR ) {
if ( flags.version == COMP_FOUR ) {
maximum_number_of_options = 3;
}
}
Expand Down
3 changes: 1 addition & 2 deletions source/fdisk/userint2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,7 @@ void Display_Primary_Partition_Information_SS( void )
type = "EXT DOS";
}
else if ( ( p->num_type == 0x0f ) &&
( flags.version == W95 || flags.version == W95B ||
flags.version == W98 ) ) {
( flags.version >= COMP_W95 ) ) {
type = "EXT DOS";
}
Print_At( 23, ( cursor_offset + 9 ), type );
Expand Down

0 comments on commit 3d1c54e

Please sign in to comment.