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.

83 lines
1.6 KiB

  1. /*
  2. *
  3. * REVISIONS:
  4. * ker23NOV92 Initial OS/2 Revision
  5. * pcy17Dec92 Added Validate()
  6. * cad10Jun93: fixed GetState()
  7. *
  8. */
  9. #include "cdefine.h"
  10. #define INCL_BASE
  11. #define INCL_DOS
  12. #define INCL_NOPM
  13. extern "C" {
  14. #if (C_OS & C_OS2)
  15. #include <os2.h>
  16. #endif
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include <malloc.h>
  20. #include <string.h>
  21. }
  22. #include "apc.h"
  23. #include "stsensor.h"
  24. #include "utils.h"
  25. //Constructor
  26. StateSensor :: StateSensor(PDevice aParent,
  27. PCommController aCommController,
  28. INT aSensorCode,
  29. ACCESSTYPE anACCESSTYPE)
  30. :Sensor(aParent,aCommController, aSensorCode, anACCESSTYPE)
  31. {
  32. storeState(STATE_UNKNOWN);
  33. }
  34. INT StateSensor::GetState(INT aCode, INT *aState)
  35. {
  36. *aState = atoi(theValue);
  37. return ErrNO_ERROR;
  38. }
  39. INT StateSensor::SetState(INT aCode, INT aState)
  40. {
  41. CHAR the_temp_string[32];
  42. _itoa(aState, the_temp_string, 10);
  43. if(Validate(aCode, the_temp_string) == ErrNO_ERROR)
  44. {
  45. INT the_return=Set(aCode, the_temp_string);
  46. return the_return;
  47. }
  48. else
  49. {
  50. return ErrINVALID_VALUE;
  51. }
  52. }
  53. INT StateSensor::Validate(INT aCode, const PCHAR aValue)
  54. {
  55. INT err = ErrNO_ERROR;
  56. if(theValue) {
  57. if(strcmp(aValue, theValue) == 0) {
  58. err = ErrNO_STATE_CHANGE;
  59. }
  60. }
  61. return err;
  62. }
  63. INT StateSensor::storeState(const INT aState)
  64. {
  65. CHAR the_temp_state[32];
  66. _itoa(aState, the_temp_state, 10);
  67. INT err = Sensor::storeValue(the_temp_state);
  68. return ErrNO_ERROR;
  69. }