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.

91 lines
1.4 KiB

  1. /* Copyright 1999 American Power Conversion, All Rights Reserved
  2. *
  3. * Description:
  4. * This is the implementation of the policy manager for the native UPS service of Windows 2000.
  5. *
  6. * Revision History:
  7. * dsmith 31Mar1999 Created
  8. *
  9. */
  10. #include <windows.h>
  11. #include <lmerr.h>
  12. #include "polmgr.h"
  13. #include "statmach.h"
  14. #include "driver.h"
  15. #include "states.h"
  16. #include "events.h"
  17. #include "upsreg.h"
  18. #include "eventlog.h"
  19. // Internal Variables
  20. BOOL theIsInitialized = FALSE;
  21. BOOL theShutdownPending = FALSE;
  22. /**
  23. * PolicyManagerInit
  24. *
  25. * Description:
  26. * Initializes the UPS service state machine.
  27. * exiting.
  28. *
  29. * Parameters:
  30. * None
  31. *
  32. * Returns:
  33. * An error code defined in lmerr.h
  34. */
  35. DWORD PolicyManagerInit(){
  36. DWORD err;
  37. Initializing_Enter(NO_EVENT);
  38. err = Initializing_DoWork();
  39. Initializing_Exit(NO_EVENT);
  40. if (err == NERR_Success){
  41. theIsInitialized = TRUE;
  42. }
  43. // Log the failure event
  44. else {
  45. LogEvent(err, NULL, ERROR_SUCCESS);
  46. }
  47. return err;
  48. }
  49. /**
  50. * PolicyManagerRun
  51. *
  52. * Description:
  53. * Starts the UPS service state machine and does not return until the service is
  54. * exiting.
  55. *
  56. * Parameters:
  57. * None
  58. *
  59. * Returns:
  60. * None
  61. */
  62. void PolicyManagerRun(){
  63. if (theIsInitialized){
  64. RunStateMachine();
  65. }
  66. }
  67. /**
  68. * PolicyManagerStop
  69. *
  70. * Description:
  71. * Stops the UPS service state machine if the service is not in the middle of a
  72. * shutdown sequence.
  73. *
  74. * Parameters:
  75. * None
  76. *
  77. * Returns:
  78. * None
  79. */
  80. void PolicyManagerStop(){
  81. StopStateMachine();
  82. }