⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stage2.c

📁 grub4dos-0.4.4-2008- 08-src.zip
💻 C
📖 第 1 页 / 共 3 页
字号:
	    {	      temp_entryno = 0;	      if (current_term->flags & TERM_DUMB)		{		  if (entryno > 0)		      entryno--;		}	      else		{		  if (entryno > 0)		    {		      print_entry (MENU_BOX_Y + entryno, 0,				   get_entry (menu_entries,					      first_entry + entryno,					      0));		      entryno--;		      print_entry (MENU_BOX_Y + entryno, 1,				   get_entry (menu_entries,					      first_entry + entryno,					      0));		    }		  else if (first_entry > 0)		    {		      first_entry--;		      print_entries (first_entry, entryno, menu_entries);		    }		  else	/* loop forward to END */		    {		      temp_entryno = num_entries - 1;		      goto check_update;		    }		}	    }	  else if ((c == KEY_DOWN/*14*/ || ((char)c) == 'v')		   /* && first_entry + entryno + 1 < num_entries */)	    {	      temp_entryno = 0;	      if (current_term->flags & TERM_DUMB)		{		  if (first_entry + entryno + 1 < num_entries)		      entryno++;		}	      else		{		  if (first_entry + entryno + 1 >= num_entries)		    {		      temp_entryno = 0;	/* loop backward to HOME */		      goto check_update;		    }		  if (entryno < MENU_BOX_H - 1)		    {		      print_entry (MENU_BOX_Y + entryno, 0,				   get_entry (menu_entries,					      first_entry + entryno,					      0));		      entryno++;		      print_entry (MENU_BOX_Y + entryno, 1,				   get_entry (menu_entries,					      first_entry + entryno,					      0));		    }		  else if (num_entries > MENU_BOX_H + first_entry)		    {		      first_entry++;		      print_entries (first_entry, entryno, menu_entries);		    }		}	    }	  else if (c == KEY_PPAGE/*7*/)	    {	      /* Page Up */	      temp_entryno = 0;	      first_entry -= MENU_BOX_H;	      if (first_entry < 0)		{		  entryno += first_entry;		  first_entry = 0;		  if (entryno < 0)		    entryno = 0;		}	      print_entries (first_entry, entryno, menu_entries);	    }	  else if (c == KEY_NPAGE/*3*/)	    {	      /* Page Down */	      temp_entryno = 0;	      first_entry += MENU_BOX_H;	      if (first_entry + entryno + 1 >= num_entries)		{		  first_entry = num_entries - MENU_BOX_H;		  if (first_entry < 0)		    first_entry = 0;		  entryno = num_entries - first_entry - 1;		}	      print_entries (first_entry, entryno, menu_entries);	    }	  else if ( ((char)c) >= '0' && ((char)c) <= '9')	    {	      temp_entryno *= 10;	      temp_entryno += ((char)c) - '0';//	      if (temp_entryno >= num_entries)//		  temp_entryno = num_entries - 1;	      if (temp_entryno >= num_entries)	/* too big an entryno */	      {		if ((char)c - '0' >= num_entries)		  temp_entryno = 0;	        else		  temp_entryno = (char)c - '0';	      }	      if (temp_entryno != 0 || (char)c == '0')	      {check_update:		  if (temp_entryno != first_entry + entryno)		  {		      first_entry = (temp_entryno / MENU_BOX_H) * MENU_BOX_H;		      entryno = temp_entryno % MENU_BOX_H;		      print_entries (first_entry, entryno, menu_entries);		  }	      }	      if (temp_entryno * 10 >= num_entries)		  temp_entryno = 0;	    }	  else if (c == KEY_HOME/*1*/)	    {	      temp_entryno = 0;	      goto check_update;	    }	  else if (c == KEY_END/*5*/)	    {	      temp_entryno = num_entries - 1;	      goto check_update;	    }	  else	      temp_entryno = 0;	  gotoxy (MENU_BOX_E - 8, MENU_BOX_Y - 2);	  grub_printf ("%d  ", first_entry + entryno);	  gotoxy (MENU_BOX_E, MENU_BOX_Y + entryno);	  if (config_entries)	    {	      if ((((char)c) == '\n') || (((char)c) == '\r') || (((char)c) == 'b'/*6*/))		break;	    }	  else	    {	      if ((((char)c) == 'd') || (((char)c) == 'o') || (((char)c) == 'O'))		{		  if (! (current_term->flags & TERM_DUMB))		    print_entry (MENU_BOX_Y + entryno, 0,				 get_entry (menu_entries,					    first_entry + entryno,					    0));		  /* insert after is almost exactly like insert before */		  if (((char)c) == 'o')		    {		      /* But `o' differs from `O', since it may causes			 the menu screen to scroll up.  */		      if (entryno < MENU_BOX_H - 1 || (current_term->flags & TERM_DUMB))			entryno++;		      else			first_entry++;		      		      c = 'O';		    }		  cur_entry = get_entry (menu_entries,					 first_entry + entryno,					 0);		  if (((char)c) == 'O')		    {		      grub_memmove (cur_entry + 2, cur_entry,				    ((int) heap) - ((int) cur_entry));		      cur_entry[0] = ' ';		      cur_entry[1] = 0;		      heap += 2;		      num_entries++;		    }		  else if (num_entries > 0)		    {		      char *ptr = get_entry(menu_entries,					    first_entry + entryno + 1,					    0);		      grub_memmove (cur_entry, ptr,				    ((int) heap) - ((int) ptr));		      heap -= (((int) ptr) - ((int) cur_entry));		      num_entries--;		      if (entryno >= num_entries)			entryno--;		      if (first_entry && num_entries < MENU_BOX_H + first_entry)			first_entry--;		    }		  if (current_term->flags & TERM_DUMB)		    {		      grub_printf ("\n\n");		      print_entries_raw (num_entries, first_entry,					 menu_entries);		      grub_printf ("\n");		    }		  else		    print_entries (first_entry, entryno, menu_entries);		}	      cur_entry = menu_entries;	      if (((char)c) == 27)		return;	      if (((char)c) == 'b')		break;	    }	  if (! auth && password)	    {	      if (((char)c) == 'p')		{		  /* Do password check here! */		  char entered[32];		  char *pptr = password;		  if (current_term->flags & TERM_DUMB)		    grub_printf ("\r                                    ");		  else		    gotoxy (MENU_BOX_X - 2, MENU_BOX_H + 6);		  /* Wipe out the previously entered password */		  grub_memset (entered, 0, sizeof (entered));		  prompt = "Password: ";		  maxlen = sizeof (entered) - 1;		  echo_char = '*';		  readline = 0;		  get_cmdline (entered);		  while (! isspace (*pptr) && *pptr)		    pptr++;		  /* Make sure that PASSWORD is NUL-terminated.  */		  *pptr++ = 0;		  if (! check_password (entered, password, password_type))		    {		      char *new_file = config_file;		      while (isspace (*pptr))			pptr++;		      /* If *PPTR is NUL, then allow the user to use			 privileged instructions, otherwise, load			 another configuration file.  */		      if (*pptr != 0)			{			  while ((*(new_file++) = *(pptr++)) != 0)			    ;			  /* Make sure that the user will not have			     authority in the next configuration.  */			  auth = 0;			  return;			}		      else			{			  /* Now the user is superhuman.  */			  auth = 1;			  goto restart;			}		    }		  else		    {		      grub_printf ("Failed! Press any key to continue...");		      getkey ();		      goto restart;		    }		}	    }	  else	    {	      if (((char)c) == 'e')		{		  int new_num_entries = 0, i = 0;		  char *new_heap;		  if (config_entries)		    {		      new_heap = heap;		      cur_entry = get_entry (config_entries,					     first_entry + entryno,					     1);		    }		  else		    {		      /* safe area! */		      new_heap = heap + NEW_HEAPSIZE + 1;		      cur_entry = get_entry (menu_entries,					     first_entry + entryno,					     0);		    }		  do		    {		      while ((*(new_heap++) = cur_entry[i++]) != 0);		      new_num_entries++;		    }		  while (config_entries && cur_entry[i]);		  /* this only needs to be done if config_entries is non-NULL,		     but it doesn't hurt to do it always */		  *(new_heap++) = 0;		  if (config_entries)		    run_menu (heap, NULL, new_num_entries, new_heap, 0);		  else		    {		      cls ();		      print_cmdline_message (0);		      new_heap = heap + NEW_HEAPSIZE + 1;		      saved_drive = boot_drive;		      saved_partition = install_partition;		      current_drive = GRUB_INVALID_DRIVE;		      prompt = PACKAGE " edit> ";		      maxlen = NEW_HEAPSIZE + 1;		      echo_char = 0;		      readline = 1;		      if (! get_cmdline (new_heap))			{			  int j = 0;			  /* get length of new command */			  while (new_heap[j++])			    ;			  if (j < 2)			    {			      j = 2;			      new_heap[0] = ' ';			      new_heap[1] = 0;			    }			  /* align rest of commands properly */			  grub_memmove (cur_entry + j, cur_entry + i,					(int) heap - ((int) cur_entry + i));			  /* copy command to correct area */			  grub_memmove (cur_entry, new_heap, j);			  heap += (j - i);			}		    }		  goto restart;		}	      if (((char)c) == 'c')		{		  enter_cmdline (heap, 0);		  goto restart;		}#ifdef GRUB_UTIL	      if (((char)c) == 'q')		{		  /* The same as ``quit''.  */		  stop ();		}#endif	    }	}    }    /* Attempt to boot an entry.  */   boot_entry:    cls ();  setcursor (1);//  /* if our terminal needed initialization, we should shut it down//   * before booting the kernel, but we want to save what it was so//   * we can come back if needed *///  prev_term = current_term;////  if (current_term->shutdown)////    {////      (*current_term->shutdown)();////      current_term = term_table; /* assumption: console is first */////    }    while (1)    {      if (debug > 0)      {	if (config_entries)		printf ("  Booting \'%s\'\n\n",			get_entry (menu_entries, first_entry + entryno, 0));	else		printf ("  Booting command-list\n\n");      }      if (! cur_entry)	cur_entry = get_entry (config_entries, first_entry + entryno, 1);      /* Set CURRENT_ENTRYNO for the command "savedefault".  */      current_entryno = first_entry + entryno;            if (run_script (cur_entry, heap))	{	  if (fallback_entryno >= 0)	    {	      cur_entry = NULL;	      first_entry = 0;	      entryno = fallback_entries[fallback_entryno];	      fallback_entryno++;	      if (fallback_entryno >= MAX_FALLBACK_ENTRIES		  || fallback_entries[fallback_entryno] < 0)		fallback_entryno = -1;	    }	  else	    break;	}      else	break;    }//  /* if we get back here, we should go back to what our term was before *///  current_term = prev_term;//  if (current_term->startup)//      /* if our terminal fails to initialize, fall back to console since//       * it should always work *///      if ((*current_term->startup)() == 0)//          current_term = term_table; /* we know that console is first */  show_menu = 1;  goto restart;}static intget_line_from_config (char *cmdline, int max_len, int read_from_file){  int pos = 0, literal = 0, comment = 0;  char c;  /* since we're loading it a byte at a time! */    while (1)    {      if (read_from_file)	{	  if (! grub_read (&c, 1))	    break;	}      else	{	  if (! read_from_preset_menu (&c, 1))	    break;	}      /* Skip all carriage returns.  */      if (c == '\r')	continue;      /* Replace tabs with spaces.  */      if (c == '\t')	c = ' ';      /* The previous is a backslash, then...  */      if (literal)	{	  /* If it is a newline, replace it with a space and continue.  */	  if (c == '\n')	    {	      c = ' ';	      	      /* Go back to overwrite a backslash.  */	      if (pos > 0)		pos--;	    }	    	  literal = 0;	}	        /* translate characters first! */      if (c == '\\' && ! literal)	literal = 1;      if (comment)	{	  if (c == '\n')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -