Esempio n. 1
0
/* Get input from keyboard */
unsigned long Input(int size_of_field,int x_position,int y_position,int type
 ,int min_range,long max_range,int return_message,long default_value
 ,long maximum_possible_percentage,char optional_char_1[1],char optional_char_2[1])
{
  /*
  size_of_field:                 number of characters for the user to enter,
                                 if size of field is 0 then no input box
				 is drawn on the screen.
  x_position, y_position:        screen coordinates to place the input box
  type                           type of input--CHAR  A single character as
                                                      specified by min_range
                                                      and max_range.  min_range
                                                      and max_range are the
                                                      min. and max. ASCII
                                                      values possible for this
                                                      input field. The ASCII
                                                      values in these 2 fields
                                                      should be of capital
                                                      characters only.  If the
                                                      user enters a lower case
                                                      character it will be
						      converted to uppercase.
						YN    Either a yes or no.
						NUM   A number as specified
                                                      by min_range and
                                                      max_range.
                                                NUMP  A number or percentage
                                                      within the limits of
                                                      the size_of_field.
                                                ESC   Waits for the ESC key
                                                      only
  return_message                                ESCR  Displays "Press
                                                      Esc to return to FDISK
						      Options"
                                                ESCE  Displays "Press
						      Esc to exit FDISK"
                                                ESCC  Displays "Press Esc to
                                                      continue"
						NONE  Does not display a
                                                      return message.
  default_value                  The default value that is displayed for
                                 input.  This option only works with the NUM
				 type or the YN type.
                                 Set this to -1 if it is not used.
  maximum_possible_percentage                   If type is NUMP, this is the
                                                maximum percentage possible.
  optional_char_1[1] and
  optional_char_2[1]             2 optional character fields for use with
                                 the NUM type when size_of_field==1
                                 Also is used as two option number fields
                                 (converted to char value) when type==CHAR
                                 and a single digit numeric input is possible.
                                 In this case these two variables define a
                                 range.  When type==YN this functions the same
                                 as with NUM type above.
  */

  char input;
  char line_buffer[18];

  unsigned long multiplier;

  int char_max_range;
  int default_value_preentered=FALSE;
  int index;
  int invalid_input=FALSE;
  int line_buffer_index=0;
  int proper_input_given=FALSE;
  int percent_entered=FALSE;
  int percent_just_entered=FALSE;

  unsigned long data_max_range=max_range;
  unsigned long data;

  /* Clear line buffer */
  index=0;
  do
    {
    line_buffer[index]=0;
    index++;
    }while(index<10);

  /* Place appropriate text on the screen prior to obtaining input */
  if(type!=ESC)
    {
    Position_Cursor(x_position,y_position);

    cprintf("[");

    index=0;
    do
      {
      cprintf(" ");
      index++;
      }while(index<size_of_field);

    cprintf("]");
    }

  /* Display the return message */
  if( (return_message==ESCR) || (return_message==ESCE) || (return_message==ESCC) )
    {
    printAt(4,24,"                                                 ");
    printAt(4,24,catgets(cat,4,1,"Press"));
    cprintf(" Esc ");
    printf(catgets(cat,4,2,"to"));
    printf(" ");
    }

  if(return_message==ESCR) printf(catgets(cat,4,3,"return to FDISK options"));

  if(return_message==ESCE) printf(catgets(cat,4,4,"exit FDISK"));

  if(return_message==ESCC) printf(catgets(cat,4,5,"continue"));

  /* Set the default value for NUM type, if applicable */
  if( (default_value>=0) && (type==NUM) && (size_of_field==1) )
    {
    Position_Cursor(x_position+1,y_position);
    printf("%d",default_value);
    line_buffer_index=0;
    line_buffer[0]=default_value+48;
    }

  /* Set the default value for NUMP type, if applicable */
  if( (default_value>=0) && (type==NUMP) && (size_of_field>1) )
    {
    ltoa(default_value,line_buffer,10);
    line_buffer_index=strlen(line_buffer);

    /* Display line_buffer */
    index=line_buffer_index;
    do
      {
      Position_Cursor((x_position+size_of_field-line_buffer_index+index)
       ,y_position);
      index--;
      cprintf("%c",line_buffer[index]);
      }while(index>0);

    default_value_preentered=TRUE;
    }

  /* Set the default value for YN type, if applicable */
  if( (default_value>=0) && (type==YN) && (size_of_field==1) )
    {
    Position_Cursor(x_position+1,y_position);

    if(default_value==1)
      {
      printf("Y");
      line_buffer_index=0;
      line_buffer[0]='Y';
      data=TRUE;
      }

    if(default_value==0)
      {
      printf("N");
      line_buffer_index=0;
      line_buffer[0]='N';
      data=FALSE;
      }
    }

  do
    {
    if(type!=ESC) Position_Cursor((size_of_field+x_position),y_position);

    /* Obtain keypress from keyboard */
    asm{
      mov ah,7
      int 0x21
      mov BYTE PTR input,al
      }

    /* Zero the default value if type==NUMP, the enter, esc, or backspace key */
    /* has not been pressed, and the default value is pre-entered. */
    if( (default_value>=0) && (type==NUMP) && (size_of_field>1)
     && (input!=8) && (input!=13) && (input!=27)
     && (default_value_preentered==TRUE) )
      {
      line_buffer_index=0;

      index=0;
      do
        {
        line_buffer[index]=0;
        index++;
        }while(index<10);

      default_value_preentered=FALSE;
      }

    /* Clear error messages from screen */
    if(type!=YN)
      {
      printAt(4,22,"                                                              ");
      }

    printAt(4,23,"                                                    ");
    Position_Cursor(4,24);

    /* Esc key has been hit */
    if(input==27)
      {
      flags.esc=TRUE;
      proper_input_given=TRUE;
      data=0;
      type=99;
      }

    /* Enter key has been hit */
    if(input==13)
      {
      if( ( (type==CHAR) || (type==YN) ) && (line_buffer[0]!=0) && ( (data==TRUE) || (data==FALSE) || (data!=99) ) )
        {
        proper_input_given=TRUE;

        type=99;
        }

      if( (type==NUMYN) && (line_buffer[0]!=0) )
        {
        data=line_buffer[0];
        proper_input_given=TRUE;
        type=99;
        }

      if( (type==CHARNUM) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;
	data=line_buffer[0];

        type=99;
        }

      if( (type==NUMCHAR) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;
        data=line_buffer[0];

        type=99;
        }

      if( (type==NUM) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;

        /* Convert line_buffer to an unsigned integer in data */
        data=0;
        index=strlen(line_buffer)-1;
        multiplier=1;
        do
          {
          data=data+((line_buffer[index]-48)*multiplier);
          index--;
          multiplier=multiplier*10;
          }while(index>=0);

        /* Make sure that data is <= max_range */
        if(data>data_max_range)
          {
          data=0;
          proper_input_given=FALSE;

	  cprintAt(4,22,catgets(cat,4,6,"Requested partition size exceeds the maximum available space"));

	  /* Set input=0xff to avoid processing this time around */
          input='\xff';
          }
        else type=99;
        }

      if( (type==NUMP) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;

        /* Convert line_buffer to an unsigned integer in data */
        data=0;
        index=strlen(line_buffer)-1;

        if(percent_entered==TRUE) index--;

        multiplier=1;
        do
          {
          data=data+((line_buffer[index]-48)*multiplier);
          index--;
          multiplier=multiplier*10;
          }while(index>=0);


        if(percent_entered==TRUE) data=(data*data_max_range)/maximum_possible_percentage;

        /* Make sure that data is <= max_range */
        if(data>data_max_range)
          {
	  data=0;
          proper_input_given=FALSE;

	  cprintAt(4,22,catgets(cat,4,6,"Requested partition size exceeds the maximum available space"));

	  /* Set input=0xff to avoid processing this time around */
          input='\xff';
          }
        else type=99;
        }

#ifdef DEBUG
      if( (debug.input_routine==TRUE) && (type==99) )
        {
        Clear_Screen(NULL);

        printf("Input entered by user:  %d",data);
        Pause();
        }
#endif
      }

#ifdef DEBUG
    if(debug.input_routine==TRUE)
      {
      printAt(50,22,"                  ");

      printAt(50,22,"Input:  %d",input);
      }
#endif

    /* Process the backspace key if type==CHARNUM. */
    if( (type==CHARNUM) && (input==8) )
      {
      type=NUM;

      input='\xff';
      line_buffer[0]='0';
      line_buffer_index=1;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process a legitimate entry if type==CHARNUM. */
    if( (type==CHARNUM) && ( ((input-48)>=1) && ((input-48)<=max_range) ) )
      {
      type=NUM;

      line_buffer[0]='0';
      line_buffer_index=1;
      }

    if( (type==CHARNUM)
     && ( (input==optional_char_1[0])
     || ( (input-32)==optional_char_1[0])
     || (input==optional_char_2[0])
     || ( (input-32)==optional_char_2[0]) ) )
      {
      if(input>=97) input=input-32;

      line_buffer_index=1;
      line_buffer[0]=input;
      input='\xff';
      type=CHARNUM;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process a legitimate entry if type==NUMYN. */
    if( (type==NUMYN) && ( (input=='Y') || (input=='N') || (input=='y')
     || (input=='n') ) )
      {
      type=YN;

      line_buffer[0]=' ';
      line_buffer_index=1;
      }

    /* Process a legitimate entry if type==NUMCHAR. */
    if( (type==NUMCHAR) && (optional_char_1[0]!=NULL)
     && (optional_char_2[0]!=NULL) )
      {
      char_max_range=atoi(optional_char_2);

      if( (input>='1') && (input<=(char_max_range+48)) )
        {
        line_buffer_index=1;
        line_buffer[0]=input;
        type=NUMCHAR;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }

      if( (input<'1') || (input>(char_max_range+48)) )
        {
        line_buffer_index=0;
        line_buffer[0]=0;
        type=CHAR;
        }
      }

    /* Process optional character fields. */
    if( (type==NUM) && ( (optional_char_1[0]!=NULL)
     || (optional_char_2[0]!=NULL) ) )
      {
      if( (input==optional_char_1[0]) || ( (input-32)==optional_char_1[0]) )
        {
	if(input>=97) input=input-32;

        line_buffer_index=1;
        line_buffer[0]=input;
        input='\xff';
        type=CHARNUM;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }

      if( (input==optional_char_2[0]) || ( (input-32)==optional_char_2[0]) )
        {
        if(input>=97) input=input-32;

        line_buffer_index=1;
        line_buffer[0]=input;
        input='\xff';
        type=CHARNUM;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }
      }

    if( (type==CHAR) && (optional_char_1[0]!=NULL)
     && (optional_char_2[0]!=NULL) )
      {
      char_max_range=atoi(optional_char_2);

      if( (input>='1') && (input<=(char_max_range+48)) )
        {
        line_buffer_index=1;
        line_buffer[0]=input;
        type=NUMCHAR;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }
      }

    if( ( (type==YN) || (type==NUMYN) ) && (optional_char_1[0]!=NULL)
     && (optional_char_2[0]!=NULL) )
      {
      char_max_range=atoi(optional_char_2);

      if( (input>='1') && (input<=(char_max_range+48)) )
        {
        line_buffer_index=1;
        line_buffer[0]=input;
        type=NUMYN;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }
      }

    if(type==CHAR)
      {
      /* Convert to upper case, if necessary. */
      if(input>=97) input=input-32;

      if( (input>=min_range) && (input<=max_range) )
        {
        line_buffer[0]=input;
        data=input;
        }
      else
        {
        proper_input_given=FALSE;
	line_buffer[0]=' ';
        data=99;

        Position_Cursor(4,23);
        cprintf("Invalid entry, please enter %c-",min_range);
        cprintf("%c.",max_range);
        }

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process the backspace key if type==NUMCHAR. */
    if( (type==NUMCHAR) && (input==8) )
      {
      type=CHAR;

      line_buffer[0]=' ';
      line_buffer_index=1;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    if(type==YN)
      {
      switch (input) {
	case 'Y':
	  line_buffer[0]='Y';
	  data=TRUE;
	  break;
	case 'y':
	  line_buffer[0]='Y';
	  data=TRUE;
	  break;
	case 'N':
	  line_buffer[0]='N';
	  data=FALSE;
	  break;
	case 'n':
	  line_buffer[0]='N';
	  data=FALSE;
	  break;
	default:
	  proper_input_given=FALSE;
	  line_buffer[0]=' ';
	  data=99;

	  cprintAt(4,23,catgets(cat,4,7,"Invalid entry, please enter Y-N."));

	}

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process the backspace key if type==NUMYN. */
    if( (type==NUMYN) && (input==8) )
      {
      type=YN;
      line_buffer[0]=' ';
      line_buffer_index=1;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    if( (type==NUM) && (input!='\xff') )
      {
      /* If the backspace key has not been hit. */
      if(input!=8)
        {
	invalid_input=FALSE;

        if(size_of_field>1)
	  {
	  min_range=0;
	  max_range=9;
	  }

	if( (input>='0') && (input<='9') )input=input-48;
	else
	  {
	  if(input<10) input=11;
	  }

	if( ( (size_of_field>1) && (input>max_range) ) || (input>9) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"Invalid entry, please enter %d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( (size_of_field==1) && ( (input<min_range) || ( (input>max_range) && (input<10) ) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"%d is not a choice, please enter ",input);
	  cprintf("%d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field>1) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,catgets(cat,4,8,"Invalid entry."));
	  invalid_input=TRUE;
          }

	if( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field==1) )
	  {
	  line_buffer_index=0;
	  }

	if(invalid_input==FALSE)
	  {
	  if( (line_buffer_index==1) && (line_buffer[0]=='0') )
	    {
	    line_buffer[0]=0;
	    line_buffer_index=0;
	    }

	  line_buffer[line_buffer_index]=(input+48);
	  line_buffer_index++;
	  }
	}
      else
	{
	/* If the backspace key has been hit */
	line_buffer_index--;
	if(line_buffer_index<0) line_buffer_index=0;
	line_buffer[line_buffer_index]=0;

	if(line_buffer_index==0)
	  {
	  line_buffer[0]='0';
	  line_buffer_index=1;
	  }
	}

      /* Clear text box before displaying line_buffer */
      index=0;
      do
	{
	Position_Cursor((x_position+1+index),y_position);
	printf(" ");

	index++;
	}while(index<size_of_field);

      /* Display line_buffer */
      index=line_buffer_index;
      do
	{
	Position_Cursor((x_position+size_of_field-line_buffer_index+index),y_position);
	index--;
	cprintf("%c",line_buffer[index]);
	}while(index>0);
      }

    if( (type==NUMP) && (input!='\xff') )
      {
      /* If the backspace key has not been hit. */
      if(input!=8)
	{
	invalid_input=FALSE;

	if(size_of_field>1)
	  {
	  min_range=0;
	  max_range=9;
	  }

	if( (input=='%') && (percent_entered==FALSE) )
	  {
	  percent_entered=TRUE;
	  percent_just_entered=TRUE;
	  }

	if( (input>='0') && (input<='9') )input=input-48;
	else
	  {
	  if(input<10) input=11;
	  }

	if( (percent_entered==FALSE) && (percent_just_entered==FALSE) && ( ( (size_of_field>1) && (input>max_range) ) || (input>9) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"Invalid entry, please enter %d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( (percent_entered==FALSE) && (size_of_field==1) && ( (input<min_range) || ( (input>max_range) && (input<10) ) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"%d is not a choice, please enter ",input);
	  cprintf("%d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( ( (percent_entered==TRUE) && (percent_just_entered==FALSE) ) || ( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field>1) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,catgets(cat,4,8,"Invalid entry."));
          invalid_input=TRUE;
	  }

        if( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field==1) )
          {
          line_buffer_index=0;
          }

        if(invalid_input==FALSE)
          {
          if( (line_buffer_index==1) && (line_buffer[0]=='0') )
            {
            line_buffer[0]=0;
            line_buffer_index=0;
            }

          if(percent_just_entered==TRUE)
            {
            percent_just_entered=FALSE;
            line_buffer[line_buffer_index]='%';
            line_buffer_index++;
            }
          else
            {
            line_buffer[line_buffer_index]=(input+48);
            line_buffer_index++;
            }
          }
        }
      else
        {
	/* If the backspace key has been hit */
        line_buffer_index--;
        if(line_buffer_index<0) line_buffer_index=0;
        line_buffer[line_buffer_index]=0;

	if(line_buffer_index==0)
          {
          line_buffer[0]='0';
          line_buffer_index=1;
          }

        if(percent_entered==TRUE) percent_entered=FALSE;
        }

      /* Clear text box before displaying line_buffer */
      index=0;
      do
        {
        Position_Cursor((x_position+1+index),y_position);
        printf(" ");

        index++;
        }while(index<size_of_field);

      /* Display line_buffer */
      index=line_buffer_index;
      do
        {
        Position_Cursor((x_position+size_of_field-line_buffer_index+index),y_position);
        index--;
        cprintf("%c",line_buffer[index]);
        }while(index>0);
      }

#ifdef DEBUG
    if(debug.input_routine==TRUE)
      {
      printAt(60,23,"                ");

      printAt(60,24,"                ");

      printAt(50,23,"Line Buffer:  %10s",line_buffer);

      printAt(50,24,"Line Buffer Index:  %d",line_buffer_index);

      if(percent_entered==TRUE)
        {
        printAt(75,24,"P");
        }
      else
        {
        printAt(75,24,"  ");
        }
      }
#endif

    /* Place brackets back on screen as a precautionary measure. */
    if(type!=ESC)
      {
      Position_Cursor(x_position,y_position);
      cprintf("[");

      Position_Cursor((x_position+size_of_field+1),y_position);
      cprintf("]");
      }

    }while(proper_input_given==FALSE);

  return(data);
}
Esempio n. 2
0
/* Display Extended Partition Information Sub Screen */
void Display_Extended_Partition_Information_SS()
{
  int column_index=0;
  int index;
  int print_index=4;

  unsigned long usage;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  Determine_Drive_Letters();

  /* Check to see if there are any drives to display */
  if( (brief_partition_table[(flags.drive_number-128)] [4]>0) || (brief_partition_table[(flags.drive_number-128)] [5]>0) )
    {
    printAt(0,3,"Drv Volume Label  Mbytes  System  Usage");

    /* Display information for each Logical DOS Drive */
    index=4;
    print_index=4;
    do
      {
      if(print_index>15)
	{
	column_index=41;
	print_index=4;

	printAt(41,3,"Drv Volume Label  Mbytes  System  Usage");
	}

      if(brief_partition_table[(flags.drive_number-128)] [index]>0)
	{
	if( IsRecognizedFatPartition(brief_partition_table[(flags.drive_number-128)] [index]))
	  {
	  /* Display drive letter */
	  cprintAt(column_index+0,print_index,"%c",drive_lettering_buffer[(flags.drive_number-128)] [index]);
	  cprintAt(column_index+1,print_index,":");

	  /* Display volume label */
	  printAt(column_index+4,print_index,"%11s",pDrive->log_drive[index-4].vol_label);
	  }
	else
	  {
	  if(flags.del_non_dos_log_drives==TRUE)
	    {
	    /* Display drive number */
	    cprintAt(column_index+0,print_index,"%c",drive_lettering_buffer[(flags.drive_number-128)] [index]);
	    }
	  }

	/* Display size in MB */
	Position_Cursor((column_index+17),print_index);
	Print_UL(pDrive->log_drive[(index-4)].size_in_MB);

	/* Display file system type */
	printAt(column_index+25,print_index,"%s",
	 partition_lookup_table_buffer_short[pDrive->log_drive[(index-4)].num_type]);

	/* Display usage in % */
	usage
	 = Convert_To_Percentage(pDrive->log_drive[index-4].num_sect,
	 pDrive->ext_part_num_sect);

	printAt(column_index+35,print_index,"%3d%%",usage);
	print_index++;
	}
      index++;
      }while(index<27);
    }
  else
    {
    cprintAt(4,10,"No logical drives defined");
    }

  printAt(4,17,"Total Extended DOS Partition size is ");

  if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) )
   Print_UL_B(part_table[flags.drive_number-128].ext_part_size_in_MB);
  else cprintf("%4d",(part_table[flags.drive_number-128].ext_part_size_in_MB) );
  printf(" Mbytes (1 Mbyte = 1048576 bytes)");
}
Esempio n. 3
0
/* Create DOS Partition Interface */
int Create_DOS_Partition_Interface(int type)
{
  int numeric_type;
  int partition_created=FALSE;
  int partition_slot_just_used;

  long maximum_partition_size_in_MB;
  long maximum_possible_percentage;

  unsigned long input=0;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  maximum_partition_size_in_MB
   = Max_Pri_Part_Size_In_MB(type);

  if(type==PRIMARY)
    {
    Clear_Screen(0);

    Print_Centered(4,"Create Primary DOS Partition",BOLD);

    printAt(4,6,"Current fixed disk drive: ");
    cprintf("%d",(flags.drive_number-127));

    printAt(4,8,"Do you wish to use the maximum available size for a Primary DOS Partition");

    if((flags.drive_number-128)==0)
      {
      printAt(4,9,"and make the partition active (Y/N).....................? ");
      }
    else
      {
      printAt(4,9,"(Y/N)...................................................? ");
      }

    flags.esc=FALSE;
    input=Input(1,62,9,YN,0,0,ESCR,1,0,NULL,NULL);
    if(flags.esc==TRUE) return(1);

    if(input==1)
      {
      input=maximum_partition_size_in_MB;
      numeric_type=6;  /* Set the numeric type to 6 so that it will be    */
                       /* decided by Partition_Type_To_Create().          */

      if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) )
        {
        printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)?    ");
	flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL);
        }

      /* Use the maximum available free space to create a DOS Partition */

      /* Adjust numeric type depending upon partition size and the FDISK */
      /* version emulated.                                               */
      numeric_type=Partition_Type_To_Create(input,numeric_type);

      partition_slot_just_used=Create_Primary_Partition(numeric_type,input);
      if((flags.drive_number-128)==0) Set_Active_Partition(partition_slot_just_used);
      partition_created=TRUE;
      }
    }

  if(partition_created==FALSE)
    {
    Clear_Screen(0);

    if(type==PRIMARY) 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();

    printAt(4,15,"Maximum space available for partition is ");

    if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) )
      Print_UL_B(maximum_partition_size_in_MB);
    else cprintf("%4d",maximum_partition_size_in_MB);

    printf(" Mbytes ");

    maximum_possible_percentage
     = Convert_To_Percentage(maximum_partition_size_in_MB
      ,pDrive->total_hard_disk_size_in_MB);

    cprintf("(%3d%%)",maximum_possible_percentage);

    printAt(4,18,"Enter partition size in Mbytes or percent of disk space (%) to");

    if(type==PRIMARY) printAt(4,19,"create a Primary DOS Partition.................................: ");
    else              printAt(4,19,"create an Extended DOS Partition...............................: ");

    flags.esc=FALSE;

    if( (flags.version==4) || (flags.version==5) || (flags.version==6) )
     input=Input(4,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR
     ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL);
    else input=Input(6,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR
     ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL);

    if(flags.esc==TRUE) return(1);

    if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) )
      {
      printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)?    ");
      flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL);
      }

    if(type==PRIMARY) numeric_type=Partition_Type_To_Create(input,0);
    else numeric_type=5;

    Create_Primary_Partition(numeric_type,input);
    }

  if(flags.fprmt==TRUE) flags.fat32=FALSE;

  Clear_Screen(0);

  if(type==PRIMARY) 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();

  Position_Cursor(4,21);
  if(type==PRIMARY) cprintf("Primary DOS Partition created");
  else              cprintf("Extended DOS Partition created");

  Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);

  if(type==EXTENDED) Create_Logical_Drive_Interface();

  return(0);
}
Esempio n. 4
0
/* Display information for all hard drives */
void Display_All_Drives()
{
  int current_column_offset_of_general_drive_information;
  int current_column_offset=4;
  int current_line=3;
  int current_line_of_general_drive_information;
  int drive=1;
  int drive_letter_index=0;
  int index;

  long space_used_on_drive_in_MB;

  unsigned long usage;

  Determine_Drive_Letters();

  printAt(2,2,"Disk   Drv   Mbytes   Free   Usage");

  do
    {
    if(current_line>18)
      {
      current_line=3;
      current_column_offset=45;

      printAt(43,2,"Disk   Drv   Mbytes   Free   Usage");
      }

    /* Print physical drive information */
    current_column_offset_of_general_drive_information=current_column_offset;
    current_line_of_general_drive_information=current_line;
    space_used_on_drive_in_MB=0;

    /* Print drive number */
    Position_Cursor(current_column_offset_of_general_drive_information,current_line);
    cprintf("%d",drive);

    /* Print size of drive */
    Position_Cursor((current_column_offset_of_general_drive_information+10),current_line);
    Print_UL(part_table[drive-1].total_hard_disk_size_in_MB);

    /* Get space_used_on_drive_in_MB */
    index=0;
    do
      {
      if( (part_table[drive-1].pri_part[index].num_type!=5)
       && (part_table[drive-1].pri_part[index].num_type!=15)
       && (part_table[drive-1].pri_part[index].num_type!=0) )
       space_used_on_drive_in_MB
	+= part_table[drive-1].pri_part[index].size_in_MB;

      index++;
      }while(index<=3);

    index=0;
    do
      {
      if(part_table[drive-1].log_drive[index].num_type>0)
       space_used_on_drive_in_MB
	+= part_table[drive-1].log_drive[index].size_in_MB;

      index++;
      }while(index<=22);

    /* Print logical drives on disk, if applicable */

    drive_letter_index=0;
    do
      {
      if(drive_lettering_buffer[drive-1] [drive_letter_index]>0)
        {
        current_line++;

        if(current_line>18)
          {
          current_line=3;
          current_column_offset=45;

          printAt(43,2,"Disk   Drv   Mbytes   Free   Usage");
          }

        /* Print drive letter of logical drive */
        if( ( (drive_lettering_buffer[drive-1] [drive_letter_index]>='C')
         && (drive_lettering_buffer[drive-1] [drive_letter_index]<='Z') )
         || (flags.del_non_dos_log_drives==TRUE) )
          {
	  Position_Cursor((current_column_offset+6),current_line);
          printf("%c:",drive_lettering_buffer[drive-1] [drive_letter_index]);
          }
        else
          {
          Position_Cursor((current_column_offset+8),current_line);
          }

        /* Print size of logical drive */
        Position_Cursor((current_column_offset+10),current_line);

	if(drive_letter_index<4)
	  {
	  Print_UL(part_table[drive-1].pri_part[drive_letter_index].size_in_MB);
	  }
	else
	  {

	  Print_UL(part_table[drive-1].log_drive[(drive_letter_index-4)].size_in_MB);
	  }
	}

      drive_letter_index++;
      }while(drive_letter_index<27);

    /* Print amount of free space on drive */
    if(part_table[drive-1].total_hard_disk_size_in_MB>space_used_on_drive_in_MB)
      {
      Position_Cursor((current_column_offset_of_general_drive_information+18),current_line_of_general_drive_information);
      Print_UL(part_table[drive-1].total_hard_disk_size_in_MB-space_used_on_drive_in_MB);
      }

    /* Print drive usage percentage */
    if(space_used_on_drive_in_MB==0) usage=0;
    else
      {
      usage
       = Convert_To_Percentage(space_used_on_drive_in_MB,
       part_table[drive-1].total_hard_disk_size_in_MB);
      }

    Position_Cursor((current_column_offset_of_general_drive_information+28),current_line_of_general_drive_information);
    printf("%3d%%",usage);

    current_line++;
    drive++;
    }while(drive<=(flags.maximum_drive_number-127));

  printAt(4,20,"(1 Mbyte = 1048576 bytes)");
}
Esempio n. 5
0
/* Display Primary Partition information Sub-screen */
void Display_Primary_Partition_Information_SS()
{
  int cursor_offset=0;
  int index=0;
  char *type;

  unsigned long usage=0;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  Determine_Drive_Letters();

  printAt(4,6,"Current fixed disk drive: ");
  cprintf("%d",(flags.drive_number-127));

  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) )
    {
    if(flags.extended_options_flag==FALSE)
      {
      printAt(4,8,"Partition  Status   Type    Volume Label  Mbytes   System   Usage");

      for (index=0; index < 4; index++)
        {
        if(pDrive->pri_part[index].num_type>0)
          {
          /* Drive Letter of Partition */

          if( IsRecognizedFatPartition(pDrive->pri_part[index].num_type) )
            {
            printAt(5,(cursor_offset+9),"%c:",drive_lettering_buffer[(flags.drive_number-128)] [index]);
            }

          /* Partition Number */
          cprintAt(8,(cursor_offset+9),"%d",(index+1));

          /* Status */
          if(pDrive->pri_part[index].active_status>0)
            {
            printAt(18,(cursor_offset+9),"A");
            }

          /* Type */
          type  = "Non-DOS";
          if( IsRecognizedFatPartition(pDrive->pri_part[index].num_type) )
            {
            type = "PRI DOS";
            }
          else if(pDrive->pri_part[index].num_type==5)
            {
            type = "EXT DOS";
            }
          else if( (pDrive->pri_part[index].num_type==0x0f) && 
          			( flags.version==W95 || flags.version==W95B || flags.version==W98 ) )
            {
            type = "EXT DOS";
            }
          printAt(23,(cursor_offset+9),type);


          /* Volume Label */
          printAt(33,(cursor_offset+9),"%11s",pDrive->pri_part[index].vol_label);

          /* Mbytes */
          Position_Cursor(45,(cursor_offset+9));
          Print_UL(pDrive->pri_part[index].size_in_MB);

          /* System */
          printAt(54,(cursor_offset+9),"%s",partition_lookup_table_buffer_short[pDrive->pri_part[index].num_type]);

          /* Usage */
	  usage
	   = Convert_To_Percentage(pDrive->pri_part[index].size_in_MB,
	   pDrive->total_hard_disk_size_in_MB);

          printAt(65,(cursor_offset+9),"%3d%%",usage);

          cursor_offset++;
          }
        } /* while(index<4);*/
      }
    else
      {
      printAt(4,8,"Partition   Status   Mbytes    Description    Usage  Start Cyl  End Cyl");

	  for (index=0; index < 4; index++)
        {
        if(pDrive->pri_part[index].num_type>0)
          {
          /* Drive Letter of Partition */
          if (IsRecognizedFatPartition (pDrive->pri_part[index].num_type))
            {
            printAt(5,(cursor_offset+9),"%c:",drive_lettering_buffer[flags.drive_number-128] [index]);
            }
          
          /* Partition Number */
          cprintAt(8,(cursor_offset+9),"%d",index+1);

          /* Partition Type */
          printAt(10,(cursor_offset+9),"%3d",pDrive->pri_part[index].num_type);

          /* Status */
          if(pDrive->pri_part[index].active_status>0)
            {
            printAt(19,(cursor_offset+9),"A");
            }

          /* Mbytes */
          Position_Cursor(24,(cursor_offset+9));
          Print_UL(pDrive->pri_part[index].size_in_MB);

          /* Description */
          printAt(33,(cursor_offset+9),"%15s",partition_lookup_table_buffer_long[pDrive->pri_part[index].num_type]);

          /* Usage */
	  usage
	   = Convert_To_Percentage(pDrive->pri_part[index].size_in_MB,
	   pDrive->total_hard_disk_size_in_MB);

          printAt(51,(cursor_offset+9),"%3d%%",usage);

          /* Starting Cylinder */
          printAt(59,(cursor_offset+9),"%4d",pDrive->pri_part[index].start_cyl);

          /* Ending Cylinder */
          printAt(69,(cursor_offset+9),"%4d",pDrive->pri_part[index].end_cyl);

          cursor_offset++;
          }

        } /*while(index<4);*/
      }
    }
  else
    {
    cprintAt(4,21,"No partitions defined");
    }

  printAt(4,14,"Total disk space is ");

  if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) )
    Print_UL_B(pDrive->total_hard_disk_size_in_MB);
  else cprintf("%4d",pDrive->total_hard_disk_size_in_MB);

  printf(" Mbytes (1 Mbyte = 1048576 bytes)");
}