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.

146 lines
6.6 KiB

  1. /**INC+**********************************************************************/
  2. /* Header: adcgfsm.h */
  3. /* */
  4. /* Purpose: FSM macros and constants */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1997 */
  7. /* */
  8. /****************************************************************************/
  9. /** Changes:
  10. * $Log: Y:/logs/h/dcl/adcgfsm.h_v $
  11. *
  12. * Rev 1.8 21 Aug 1997 16:40:36 SJ
  13. * SFR1322: Assert FSM macro should use TRC_FILE not __FILE__
  14. *
  15. * Rev 1.7 18 Aug 1997 14:37:58 AK
  16. * SFR1184: Complete tidy-up of ASSERT_FSM
  17. *
  18. * Rev 1.6 13 Aug 1997 15:11:08 ENH
  19. * SFR1182: Changed UT to UI _FATAL_ERR
  20. *
  21. * Rev 1.5 07 Aug 1997 14:56:02 AK
  22. * SFR1184: FSM errors and Fatal Error tidy-up
  23. *
  24. * Rev 1.4 09 Jul 1997 16:56:52 AK
  25. * SFR1016: Initial changes to support Unicode
  26. *
  27. * Rev 1.3 04 Jul 1997 17:11:34 AK
  28. * SFR1007: Improve FSM error handling and trace
  29. *
  30. * Rev 1.2 03 Jul 1997 13:36:58 AK
  31. * SFR0000: Initial development completed
  32. **/
  33. /**INC-**********************************************************************/
  34. #ifndef _H_ADCGFSM
  35. #define _H_ADCGFSM
  36. /**STRUCT+*******************************************************************/
  37. /* Structure: FSM_ENTRY */
  38. /* */
  39. /* Description: Entry in an FSM Table */
  40. /****************************************************************************/
  41. typedef struct tagFSM_ENTRY
  42. {
  43. DCUINT8 next_state;
  44. DCUINT8 action;
  45. /**************************************************************************/
  46. /* If FSM coverage required, add a boolean 'touched' field here. */
  47. /**************************************************************************/
  48. } FSM_ENTRY;
  49. /**STRUCT-*******************************************************************/
  50. /****************************************************************************/
  51. /* EVENT_TYPE and EVENT_DATA definitions */
  52. /****************************************************************************/
  53. typedef DCUINT8 EVENT_TYPE;
  54. typedef PDCUINT8 EVENT_DATA;
  55. /****************************************************************************/
  56. /* null FSM event */
  57. /****************************************************************************/
  58. #define NULL_EVENT ((EVENT_TYPE) 0xFF)
  59. /****************************************************************************/
  60. /* Invalid State for FSM */
  61. /****************************************************************************/
  62. #define STATE_INVALID 0xFF
  63. /****************************************************************************/
  64. /* Actions for FSMs */
  65. /****************************************************************************/
  66. #define ACT_NO 0
  67. #define ACT_A 1
  68. #define ACT_B 2
  69. #define ACT_C 3
  70. #define ACT_D 4
  71. #define ACT_E 5
  72. #define ACT_F 6
  73. #define ACT_G 7
  74. #define ACT_H 8
  75. #define ACT_I 9
  76. #define ACT_J 10
  77. #define ACT_K 11
  78. #define ACT_L 12
  79. #define ACT_M 13
  80. #define ACT_N 14
  81. #define ACT_O 15
  82. #define ACT_P 16
  83. #define ACT_Q 17
  84. #define ACT_R 18
  85. #define ACT_S 19
  86. #define ACT_T 20
  87. #define ACT_U 21
  88. #define ACT_V 22
  89. #define ACT_W 23
  90. #define ACT_X 24
  91. #define ACT_Y 25
  92. #define ACT_Z 26
  93. #define ACT_CONNECTENDPOINT 27
  94. /****************************************************************************/
  95. /* FSM Direct Calls. */
  96. /* Add FSM coverage versions if required for Unit Testing */
  97. /****************************************************************************/
  98. #define CHECK_FSM(FSM,INPUT,STATE) \
  99. (FSM[INPUT][STATE].next_state != STATE_INVALID)
  100. #define UI_FATAL_FSM_ERR_4(msg, p1, p2, p3, p4) \
  101. { \
  102. TRC_ERR((TB, \
  103. _T("FSM error: %S@%d state:%d input:%d"), (p1), (p2), (p3), (p4))); \
  104. _pUi->UI_FatalError(msg); \
  105. }
  106. /****************************************************************************/
  107. /* ASSERT_FSM: validate the FSM transition */
  108. /* If transition is invalid, assert and display a fatal error message. */
  109. /* Note that EVT_STR and ST_STR are invalid in the retail build. */
  110. /****************************************************************************/
  111. #define ASSERT_FSM(FSM, INPUT, STATE, EVT_STR, ST_STR) \
  112. if (!CHECK_FSM(FSM, INPUT, STATE)) \
  113. { \
  114. UI_FATAL_FSM_ERR_4(DC_ERR_FSM_ERROR, TRC_FILE, __LINE__, STATE, INPUT); \
  115. TRC_ABORT((TB, _T("Invalid Transition from state %s- input %s"), \
  116. ST_STR[STATE], EVT_STR[INPUT])); \
  117. }
  118. /****************************************************************************/
  119. /* EXECUTE_FSM: change the STATE and ACTION; trace out the state change */
  120. /****************************************************************************/
  121. #define EXECUTE_FSM(FSM,INPUT,STATE,ACTION, EVT_STR, ST_STR) \
  122. { \
  123. TRC_DBG((TB, _T("Old state %s Input event %s"), \
  124. ST_STR[STATE], EVT_STR[INPUT])); \
  125. TRC_DBG((TB, _T("New state %s Action %d"), \
  126. ST_STR[FSM[INPUT][STATE].next_state], \
  127. FSM[INPUT][STATE].action)); \
  128. ASSERT_FSM(FSM, INPUT, STATE, EVT_STR, ST_STR); \
  129. ACTION = FSM[INPUT][STATE].action; \
  130. STATE = FSM[INPUT][STATE].next_state; \
  131. }
  132. #endif /* _H_ADCGFSM */