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.

52 lines
1.4 KiB

  1. /*
  2. * poc25Jun96: Needed stdlib.h for AIX 4.x
  3. * djs05Nov96: Added check for 2G units to stop excessive waiting
  4. * mholly24Sep98 : increased the buffer size for UPS_NAME to 64 from 32
  5. * the ^A command can return values up to 32 characters long
  6. * +1 for the NULL character - set it to 64 to allow room
  7. */
  8. #include "cdefine.h"
  9. extern "C" {
  10. #if ((C_OS & C_AIX) && (C_AIX_VERSION & C_AIX4))
  11. #include <stdlib.h>
  12. #endif
  13. }
  14. #include <malloc.h>
  15. #include "cfgmgr.h"
  16. #include "upsmodl.h"
  17. #include "firmrevs.h"
  18. UpsModelSensor :: UpsModelSensor(PDevice aParent, PCommController
  19. aCommController, PFirmwareRevSensor aFirmwareRev)
  20. : Sensor(aParent, aCommController, UPS_MODEL_NAME)
  21. {
  22. // Try to get UPS name from the UPS itself. If not supported, get UPS
  23. // name from firmware revision
  24. // This is not the cleanest solution around but.....
  25. // If a 2G unit is asked to supply the ups model name, the delay
  26. // can be as long as 10 seconds.
  27. CHAR firmware_rev[32];
  28. aFirmwareRev->Get(IS_THIRD_GEN, firmware_rev);
  29. if (_strcmpi(firmware_rev, "yes")==0){
  30. DeepGet();
  31. }
  32. if (!theValue || strlen(theValue) == 0) {
  33. // Allocate enough memory for the UPS name
  34. // This memory is released by the sensor destructor
  35. theValue = (char*) malloc(64);
  36. aFirmwareRev->Get(UPS_NAME,theValue);
  37. }
  38. }