Leaked source code of windows server 2003
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.

75 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. input.cxx
  5. Abstract:
  6. This file contains the routines to get user input.
  7. Author:
  8. Jason Hartman (JasonHa) 2001-05-22
  9. Environment:
  10. User Mode
  11. --*/
  12. #include "precomp.hxx"
  13. HRESULT
  14. GetYNInput(
  15. PDEBUG_CONTROL Control,
  16. PCSTR Prompt
  17. )
  18. {
  19. HRESULT hr;
  20. CHAR Response[4];
  21. ULONG ResponseLen;
  22. Control->Output(DEBUG_OUTPUT_NORMAL, "%s yn\n", Prompt);
  23. do
  24. {
  25. hr = Control->Input(Response, sizeof(Response), &ResponseLen);
  26. if (hr == E_ABORT) break;
  27. if (hr == S_OK)
  28. {
  29. if (ResponseLen != 2)
  30. {
  31. hr = E_INVALIDARG;
  32. }
  33. else
  34. {
  35. Response[0] = (CHAR)tolower(Response[0]);
  36. if (Response[0] != 'y' && Response[0] != 'n')
  37. {
  38. hr = E_INVALIDARG;
  39. }
  40. }
  41. }
  42. if (hr != S_OK)
  43. {
  44. Control->Output(DEBUG_OUTPUT_WARNING, " Please answer y or n.\n");
  45. }
  46. } while (hr != S_OK);
  47. if (hr == S_OK && Response[0] != 'y')
  48. {
  49. hr = S_FALSE;
  50. }
  51. return hr;
  52. }