📄 userint1.c
字号:
{
counter++;
if(IsRecognizedFatPartition(pDrive->pri_part[index].num_type))
{
counter--;
}
index++;
}while(index<4);
if(counter==0)
{
cprintAt(4,22,"No Non-DOS Partition to delete.");
printAt (4,24," ");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
}
else Delete_N_DOS_Partition_Interface();
}
if(menu==DPI) Display_Partition_Information();
if(menu==CD) Change_Current_Fixed_Disk_Drive();
if(menu==BMBR)
{
Create_BootEasy_MBR();
cprintAt(4,22,"BootEasy MBR has been created.");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
}
if(menu==AMBR)
{
char home_path[255];
FILE *file_pointer;
strcpy(home_path,path);
strcat(home_path,"boot.mbr");
/* Search the directory Free FDISK resides in before searching the */
/* PATH in the environment for the boot.mbr file. */
file_pointer=fopen(home_path,"rb");
if(!file_pointer) file_pointer=fopen(searchpath("boot.mbr"),"rb");
if(!file_pointer)
{
cprintAt(4,22,"\Unable to find the \"boot.mbr\" file...MBR has not been created.\n");
}
else
{
Create_Alternate_MBR();
cprintAt(4,22,"MBR has been written using \"boot.mbr\"");
}
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
}
if(menu==SMBR)
{
Save_MBR();
cprintAt(4,22,"MBR has been saved to \"boot.mbr\"");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
}
if(menu==RMBR)
{
Remove_MBR();
cprintAt(4,22,"MBR has been removed from the hard disk.");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
}
if(menu!=EXIT)
{
if( (menu>0x0f) || (menu==MM) )menu=MM;
else menu=menu&0xf0;
}
}while(menu!=EXIT);
if(flags.return_from_iui==FALSE) Exit_Screen();
Clear_Screen(NOEXTRAS);
}
/* Pause Routine */
void Pause()
{
printf("\nPress any key to continue");
asm{
mov ah,7
int 0x21
}
printf("\r \r");
}
/* Position cursor on the screen */
void Position_Cursor(int column,int row)
{
asm{
/* Get video page number */
mov ah,0x0f
int 0x10
/* Position Cursor */
mov ah,0x02
mov dh,BYTE PTR row
mov dl,BYTE PTR column
int 0x10
}
}
/* Print Centered Text */
void Print_Centered(int y,char *text,int style)
{
int x=40-strlen(text)/2;
Position_Cursor(x,y);
if(style==BOLD) cprintf(text);
else printf(text);
}
/* Print 6 Digit Unsigned Long Values */
void Print_UL(unsigned long number)
{
printf("%6lu",number);
}
/* Print 6 Digit Unsigned Long Values in bold print */
void Print_UL_B(unsigned long number)
{
cprintf("%6lu",number);
}
/* Standard Menu Routine */
/* Displays the menus laid out in a standard format and returns the */
/* selection chosen by the user. */
int Standard_Menu(int menu)
{
int counter;
int index;
int input;
int maximum_number_of_options=0;
char copyleft[60]="";
char program_name[60]="";
char program_description[60]="";
char version[30]="";
char title[60]="";
char option_1[60]="";
char option_2[60]="";
char option_3[60]="";
char option_4[60]="";
char option_5[60]="Change current fixed disk drive";
char optional_char_1[1]={NULL};
char optional_char_2[1]={NULL};
for(;;)
{
Partition_Table *pDrive = &part_table[flags.drive_number-0x80];
/* Load Menu Text */
if(flags.use_freedos_label==FALSE)
{
strcpy(program_name,PRINAME);
strcat(program_name," Version ");
strcat(program_name,VERSION);
}
else strcpy(program_name,ALTNAME);
strcpy(program_description,"Fixed Disk Setup Program");
strcpy(copyleft,"GNU GPL Copyright Brian E. Reifsnyder ");
strcat(copyleft,COPYLEFT);
if(menu==MM)
{
maximum_number_of_options=4;
strcpy(title,"FDISK Options");
strcpy(option_1,"Create DOS partition or Logical DOS Drive");
strcpy(option_2,"Set Active partition");
strcpy(option_3,"Delete partition or Logical DOS Drive");
if(flags.extended_options_flag==FALSE) strcpy(option_4,"Display partition information");
else strcpy(option_4,"Display/Modify partition information");
}
if(menu==CP)
{
maximum_number_of_options=3;
strcpy(title,"Create DOS Partition or Logical DOS Drive");
strcpy(option_1,"Create Primary DOS Partition");
strcpy(option_2,"Create Extended DOS Partition");
strcpy(option_3,"Create Logical DOS Drive(s) in the Extended DOS Partition");
strcpy(option_4,"");
}
if(menu==DP)
{
maximum_number_of_options=4;
strcpy(title,"Delete DOS Partition or Logical DOS Drive");
strcpy(option_1,"Delete Primary DOS Partition");
strcpy(option_2,"Delete Extended DOS Partition");
strcpy(option_3,"Delete Logical DOS Drive(s) in the Extended DOS Partition");
strcpy(option_4,"Delete Non-DOS Partition");
if(flags.version==FOUR) maximum_number_of_options=3;
}
if(menu==MBR)
{
maximum_number_of_options=4;
strcpy(title,"MBR Maintenance");
strcpy(option_1,"Create BootEasy MBR");
strcpy(option_2,"Create MBR using the saved file");
strcpy(option_3,"Save the MBR to a file");
strcpy(option_4,"Remove the MBR from the disk");
}
/* Display Program Name and Copyright Information */
Clear_Screen(0);
if( (flags.extended_options_flag==TRUE) && (menu==MM) )
/* */
flags.display_name_description_copyright=TRUE;
if(flags.display_name_description_copyright==TRUE)
{
Print_Centered(0,program_name,STANDARD);
Print_Centered(1,program_description,STANDARD);
Print_Centered(2,copyleft,STANDARD);
if(flags.use_freedos_label==TRUE)
{
strcpy(version,"Version: ");
strcat(version,VERSION);
Position_Cursor( (76-strlen(version)),24 );
printf("%s",version);
}
}
flags.display_name_description_copyright=FALSE;
/* Display Menu Title(s) */
Print_Centered(4,title,BOLD);
/* Display Current Drive Number */
printAt(4,6,"Current fixed disk drive: ");
cprintf("%d",(flags.drive_number-127));
if(menu==DP)
{
/* Ensure that primary partitions are available to delete. */
counter=0;
index=0;
do
{
if(pDrive->pri_part[index].num_type>0)
counter++;
index++;
}while(index<4);
if(counter==0)
{
cprintAt(4,22,"No partitions to delete.");
printAt(4,24," ");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
return(menu);
}
}
/* Display Menu */
printAt(4,8,"Choose one of the following:");
cprintAt(4,10,"1. "); printf("%s",option_1);
if(maximum_number_of_options>1)
{
cprintAt(4,11,"2. ");printf("%s",option_2);
}
if(maximum_number_of_options>2)
{
cprintAt(4,12,"3. ");printf("%s",option_3);
}
if(maximum_number_of_options>3)
{
cprintAt(4,13,"4. ");printf("%s",option_4);
}
if( (menu==MM) && (flags.more_than_one_drive==TRUE) )
{
maximum_number_of_options=5;
cprintAt(4,14,"5. "); printf("%s",option_5);
}
if( (menu==MM) && (flags.extended_options_flag==TRUE) )
{
cprintAt(50,15,"M. ");printf("MBR maintenance");
optional_char_1[0]='M';
}
else optional_char_1[0]=NULL;
if( (menu==MM) && (flags.allow_abort==TRUE) )
{
cprintAt(50,16,"A. "); printf("Abort changes and exit");
optional_char_2[0]='A';
}
else optional_char_2[0]=NULL;
/* Display Special Messages */
/* If there is not an active partition */
if( ( (pDrive->pri_part[0].num_type>0) || (pDrive->pri_part[1].num_type>0) || (pDrive->pri_part[2].num_type>0) || (pDrive->pri_part[3].num_type>0) ) && (flags.drive_number==0x80) && (menu==MM) && (pDrive->pri_part[0].active_status==0) && (pDrive->pri_part[1].active_status==0) && (pDrive->pri_part[2].active_status==0) && (pDrive->pri_part[3].active_status==0) )
{
cprintAt(4,21,"WARNING! ");
printf("No partitions are set active - disk 1 is not startable unless");
printAt(4,22,"a partition is set active");
}
/* Get input from user */
printAt(4,17,"Enter choice: ");
if(menu==MM) input=(int)Input(1,19,17,NUM,1,maximum_number_of_options,ESCE,1,0,optional_char_1,optional_char_2);
else input=(int)Input(1,19,17,NUM,1,maximum_number_of_options,ESCR,-1,0,NULL,NULL);
/* Process the input */
if(input=='A')
{
/* Abort any changes and exit the program immediately. */
flags.screen_color=7; /* Set screen colors back to default. */
Clear_Screen(NOEXTRAS);
exit(0);
}
if(input=='M') input=6;
if(input!=0)
{
if(menu==MM) menu=input<<4;
else menu=menu|input;
}
else
{
if(menu==MM)
{
menu=EXIT;
}
else
{
if(menu>0x0f) menu=MM;
else menu=menu&0xf0;
}
}
if( (menu==MM) || (menu==CP) || (menu==DP) || (menu==MBR) )
;
else
break;
}
return(menu);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -