Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1999 Intel Corporation
  3. Module Name:
  4. pause.c
  5. Abstract:
  6. Internal Shell batch cmd "pause"
  7. Revision History
  8. --*/
  9. #include "shelle.h"
  10. /*
  11. * Internal prototypes
  12. */
  13. /*///////////////////////////////////////////////////////////////////////
  14. Function Name:
  15. SEnvCmdPause
  16. Description:
  17. Builtin shell command "pause" for interactive continue/abort
  18. functionality from scripts.
  19. */
  20. EFI_STATUS
  21. SEnvCmdPause (
  22. IN EFI_HANDLE ImageHandle,
  23. IN EFI_SYSTEM_TABLE *SystemTable
  24. )
  25. {
  26. CHAR16 **Argv;
  27. UINTN Argc = 0;
  28. UINTN Index = 0;
  29. EFI_STATUS Status = EFI_SUCCESS;
  30. SIMPLE_INPUT_INTERFACE *TextIn = NULL;
  31. SIMPLE_TEXT_OUTPUT_INTERFACE *TextOut = NULL;
  32. EFI_INPUT_KEY Key;
  33. CHAR16 QStr[2];
  34. InitializeShellApplication (ImageHandle, SystemTable);
  35. Argv = SI->Argv;
  36. Argc = SI->Argc;
  37. if ( !SEnvBatchIsActive() ) {
  38. Print( L"Error: PAUSE command only supported in script files\n" );
  39. Status = EFI_UNSUPPORTED;
  40. goto Done;
  41. }
  42. SEnvBatchGetConsole( &TextIn, &TextOut );
  43. Status = TextOut->OutputString( TextOut,
  44. L"Enter 'q' to quit, any other key to continue: " );
  45. if ( EFI_ERROR(Status) ) {
  46. Print( L"PAUSE: error writing prompt\n" );
  47. goto Done;
  48. }
  49. WaitForSingleEvent (TextIn->WaitForKey, 0);
  50. Status = TextIn->ReadKeyStroke( TextIn, &Key );
  51. if ( EFI_ERROR(Status) ) {
  52. Print( L"PAUSE: error reading keystroke\n" );
  53. goto Done;
  54. }
  55. /*
  56. * Check if input character is q or Q, if so set abort flag
  57. */
  58. if ( Key.UnicodeChar == L'q' || Key.UnicodeChar == L'Q' ) {
  59. SEnvSetBatchAbort();
  60. }
  61. if ( Key.UnicodeChar != (CHAR16)0x0000 ) {
  62. QStr[0] = Key.UnicodeChar;
  63. QStr[1] = (CHAR16)0x0000;
  64. TextOut->OutputString( TextOut, QStr );
  65. }
  66. TextOut->OutputString( TextOut, L"\n\r" );
  67. Done:
  68. return Status;
  69. }