📄 userint1.c
字号:
/*
// Program: Free FDISK
// Written By: Brian E. Reifsnyder
// Module: USERINT1.C
// Module Description: First User Interface Code Module
// Version: 1.2.1
// Copyright: 1998-2002 under the terms of the GNU GPL, Version 2
*/
/*
/////////////////////////////////////////////////////////////////////////////
// DEFINES
/////////////////////////////////////////////////////////////////////////////
*/
#define USERINTM
/*
/////////////////////////////////////////////////////////////////////////////
// INCLUDES
/////////////////////////////////////////////////////////////////////////////
*/
#include <conio.h>
#include <ctype.h>
#include <dir.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fdiskio.h"
#include "kbdinput.h"
#include "main.h"
#include "pcompute.h"
#include "pdiskio.h"
#include "userint2.h"
#include "userint1.h"
/*
/////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
/////////////////////////////////////////////////////////////////////////////
*/
extern char **environ;
/*
/////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////
*/
/* Clear Screen */
void Clear_Screen(int type) /* Clear screen code as suggested by */
{ /* Ralf Quint */
asm{
mov ah,0x0f /* get max column to clear */
int 0x10
mov dh,ah
mov ah,0x06 /* scroll up */
mov al,0x00 /* 0 rows, clear whole window */
mov bh,BYTE PTR flags.screen_color /* set color */
mov cx,0x0000 /* coordinates of upper left corner of screen */
/* mov dh,25 */ /* maximum row */
mov dl,79 /* maximum column */
int 0x10
}
if(type!=NOEXTRAS)
{
Display_Information();
Display_Label();
}
}
/* Display Information */
void Display_Information()
{
if(flags.extended_options_flag==TRUE)
{
Position_Cursor(0,0);
if(flags.version==FOUR) cprintf("4");
if(flags.version==FIVE) cprintf("5");
if(flags.version==SIX) cprintf("6");
if(flags.version==W95) cprintf("W95");
if(flags.version==W95B) cprintf("W95B");
if(flags.version==W98) cprintf("W98");
if(flags.partition_type_lookup_table==INTERNAL)
cprintAt(5,0,"INT");
else
cprintAt(5,0,"EXT");
if(flags.use_extended_int_13==TRUE) cprintAt(9,0,"LBA");
if(flags.fat32==TRUE) cprintAt(13,0,"FAT32");
if(flags.use_ambr==TRUE) cprintAt(72,0,"AMBR");
if(flags.partitions_have_changed==TRUE) cprintAt(77,0,"C");
if(flags.extended_options_flag==TRUE) cprintAt(79,0,"X");
}
#ifdef BETA_RELEASE
Position_Cursor(2,1);
cprintf("BETA RELEASE");
Position_Cursor(66,1);
cprintf("BETA RELEASE");
#endif
#ifdef DEBUG
cprintAt(60,0,"DEBUG");
if(debug.emulate_disk>0)
{
cprintAt(66,0,"E%1d",debug.emulate_disk);
}
if(debug.write==FALSE)
{
cprintAt(69,0,"RO");
}
#endif
}
/* Display Label */
void Display_Label()
{
if(flags.label==TRUE)
{
int index=0;
char label[20];
strcpy(label,PRINAME);
do
{
printAt(79,((index*2)+3),"%c",label[index]);
index++;
}while(index<10);
}
}
/* Exit Screen */
void Exit_Screen(void)
{
if(flags.partitions_have_changed==TRUE)
{
Write_Partition_Tables();
flags.partitions_have_changed=FALSE;
Clear_Screen(NOEXTRAS);
if(flags.reboot==FALSE)
{
printAt(4,11,"You ");
cprintf("MUST");
printf(" restart your system for your changes to take effect.");
printAt(4,12,"Any drives you have created or changed must be formatted");
cprintAt(4,13,"AFTER");
printf(" you restart.");
Input(0,0,0,ESC,0,0,ESCE,0,0,NULL,NULL);
Clear_Screen(NOEXTRAS);
}
else
{
cprintAt(4,13,"System will now restart");
printAt(4,15,"Press any key when ready . . .");
/* Wait for a keypress. */
asm{
mov ah,7
int 0x21
}
Reboot_PC();
}
}
else Clear_Screen(NOEXTRAS);
}
/* Interactive User Interface Control Routine */
void Interactive_User_Interface()
{
int counter=0;
int index=0;
int menu=MM;
Partition_Table *pDrive = &part_table[flags.drive_number-0x80];
flags.verbose = flags.quiet = 0;
/* Ask the user if FAT32 is desired. */
if( (flags.version==W95B) || (flags.version==W98) )
Ask_User_About_FAT32_Support();
Create_MBR_If_Not_Present();
do
{
menu=Standard_Menu(menu);
pDrive = &part_table[flags.drive_number-0x80];
/* Definitions for the menus */
/* MM 0x00 Main Menu */
/* CP 0x10 Create PDP or LDD */
/* CPDP 0x11 Create Primary DOS Partition */
/* CEDP 0x12 Create Extended DOS Partition */
/* CLDD 0x13 Create Logical DOS Drive */
/* SAP 0x20 Set Active Partition */
/* DP 0x30 Delete partition or LDD */
/* DPDP 0x31 Delete Primary DOS Partition */
/* DEDP 0x32 Delete Extended DOS Partition */
/* DLDD 0x33 Delete Logical DOS Drive */
/* DNDP 0x34 Delete Non-DOS Partition */
/* DPI 0x40 Display Partition Information */
/* CD 0x50 Change Drive */
/* MBR 0x60 MBR Functions */
/* BMBR 0x61 Write booteasy MBR to drive */
/* AMBR 0x62 Write alternate MBR to drive */
/* SMBR 0x63 Save MBR to file */
/* RMBR 0x64 Remove MBR from disk */
/* EXIT 0x0f Code to Exit from Program */
if( (menu==CPDP) || (menu==CEDP) )
{
/* Ensure that space is available in the primary partition table */
/* to create a partition. */
/* First make sure that an empty slot is available. */
index=0;
counter=0;
do
{
if(pDrive->pri_part[index].num_type>0) counter++;
index++;
}while(index<4);
/* Next, make sure that there is a space available of at least */
/* two cylinders. */
Determine_Free_Space();
if(pDrive->pri_part_largest_free_space<2) counter=4;
if(counter>3)
{
Clear_Screen(0);
if(menu==CPDP)
Print_Centered(4,"Create Primary DOS Partition",BOLD);
else Print_Centered(4,"Create Extended DOS Partition",BOLD);
printAt(4,6,"Current fixed disk drive: ");
cprintf("%d",(flags.drive_number-127));
Display_Primary_Partition_Information_SS();
cprintAt(4,22,"No space to create a DOS partition.");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
}
}
if(menu==CPDP) Create_DOS_Partition_Interface(PRIMARY);
if(menu==CEDP)
{
if(pDrive->ptr_ext_part)
{
Clear_Screen(0);
Print_Centered(4,"Create Extended DOS Partition",BOLD);
printAt(4,6,"Current fixed disk drive: ");
cprintf("%d",(flags.drive_number-127));
Display_Primary_Partition_Information_SS();
cprintAt(4,22,"Extended DOS Partition already exists.");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
}
else Create_DOS_Partition_Interface(EXTENDED);
}
if(menu==CLDD)
{
if(pDrive->ptr_ext_part==NULL)
{
cprintAt(4,22,"Cannot create Logical DOS Drive without");
cprintAt(4,23,"an Extended DOS Partition on the current drive.");
printAt(4,24," ");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
}
else Create_Logical_Drive_Interface();
}
if(menu==SAP) Set_Active_Partition_Interface();
if(menu==DPDP)
{
/* Ensure that primary partitions are available to delete. */
counter=0;
index=0;
do
{
if(IsRecognizedFatPartition(pDrive->pri_part[index].num_type))
{
counter++;
}
index++;
}while(index<4);
if(counter==0)
{
cprintAt(4,22,"No Primary DOS Partition to delete.");
printAt(4,24," ");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
}
/* */
else Delete_Primary_DOS_Partition_Interface();
}
if(menu==DEDP)
{
if(pDrive->ptr_ext_part==NULL)
{
cprintAt(4,22,"No Extended DOS Partition to delete.");
printAt(4,24," ");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
}
else Delete_Extended_DOS_Partition_Interface();
}
if(menu==DLDD)
{
if( (pDrive->num_of_log_drives==0) || (pDrive->ptr_ext_part==NULL) )
{
cprintAt(4,22,"No Logical DOS Drive(s) to delete.");
printAt(4,24," ");
Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
menu=MM;
}
else Delete_Logical_Drive_Interface();
}
if(menu==DNDP)
{
/* First Ensure that Non-DOS partitions are available to delete. */
index=0;
counter=0;
do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -