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.

216 lines
6.9 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998-2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: CommandData.cpp
  6. * Content: Class representing a command
  7. *
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 04/07/1999 jtk Derived from SPData.h
  13. * 04/16/2000 jtk Derived from CommandData.h
  14. ***************************************************************************/
  15. #include "dnmdmi.h"
  16. //**********************************************************************
  17. // Constant definitions
  18. //**********************************************************************
  19. //**********************************************************************
  20. // Macro definitions
  21. //**********************************************************************
  22. //**********************************************************************
  23. // Structure definitions
  24. //**********************************************************************
  25. //**********************************************************************
  26. // Variable definitions
  27. //**********************************************************************
  28. //**********************************************************************
  29. // Function prototypes
  30. //**********************************************************************
  31. //**********************************************************************
  32. // Function definitions
  33. //**********************************************************************
  34. //**********************************************************************
  35. // ------------------------------
  36. // CModemCommandData::Reset - reset this command
  37. //
  38. // Entry: Nothing
  39. //
  40. // Exit: Nothing
  41. // ------------------------------
  42. #undef DPF_MODNAME
  43. #define DPF_MODNAME "CModemCommandData::Reset"
  44. void CModemCommandData::Reset( void )
  45. {
  46. m_State = COMMAND_STATE_UNKNOWN;
  47. m_dwDescriptor = NULL_DESCRIPTOR;
  48. m_Type = COMMAND_TYPE_UNKNOWN;
  49. m_pEndpoint = NULL;
  50. m_pUserContext = NULL;
  51. }
  52. //**********************************************************************
  53. //**********************************************************************
  54. // ------------------------------
  55. // CModemCommandData::PoolAllocFunction - function called when item is created in pool
  56. //
  57. // Entry: Nothing
  58. //
  59. // Exit: Boolean indicating success
  60. // TRUE = success
  61. // FALSE = failure
  62. // ------------------------------
  63. #undef DPF_MODNAME
  64. #define DPF_MODNAME "CModemCommandData::PoolAllocFunction"
  65. BOOL CModemCommandData::PoolAllocFunction( void* pvItem, void* pvContext )
  66. {
  67. CModemCommandData* pCmdData = (CModemCommandData*)pvItem;
  68. BOOL fReturn;
  69. fReturn = TRUE;
  70. pCmdData->m_State = COMMAND_STATE_UNKNOWN;
  71. pCmdData->m_dwDescriptor = NULL_DESCRIPTOR;
  72. pCmdData->m_dwNextDescriptor = NULL_DESCRIPTOR + 1;
  73. pCmdData->m_Type = COMMAND_TYPE_UNKNOWN;
  74. pCmdData->m_pEndpoint = NULL;
  75. pCmdData->m_pUserContext = NULL;
  76. pCmdData->m_iRefCount = 0;
  77. pCmdData->m_CommandListLinkage.Initialize();
  78. if ( DNInitializeCriticalSection( &pCmdData->m_Lock ) == FALSE )
  79. {
  80. fReturn = FALSE;
  81. }
  82. DebugSetCriticalSectionGroup( &pCmdData->m_Lock, &g_blDPNModemCritSecsHeld ); // separate dpnmodem CSes from the rest of DPlay's CSes
  83. return fReturn;
  84. }
  85. //**********************************************************************
  86. //**********************************************************************
  87. // ------------------------------
  88. // CModemCommandData::PoolInitFunction - function called when item is created in pool
  89. //
  90. // Entry: Nothing
  91. //
  92. // Exit: Boolean indicating success
  93. // TRUE = success
  94. // FALSE = failure
  95. // ------------------------------
  96. #undef DPF_MODNAME
  97. #define DPF_MODNAME "CModemCommandData::PoolInitFunction"
  98. void CModemCommandData::PoolInitFunction( void* pvItem, void* pvContext )
  99. {
  100. CModemCommandData* pCmdData = (CModemCommandData*)pvItem;
  101. DNASSERT( pCmdData->GetState() == COMMAND_STATE_UNKNOWN );
  102. DNASSERT( pCmdData->GetType() == COMMAND_TYPE_UNKNOWN );
  103. DNASSERT( pCmdData->GetEndpoint() == NULL );
  104. DNASSERT( pCmdData->GetUserContext() == NULL );
  105. pCmdData->m_dwDescriptor = pCmdData->m_dwNextDescriptor;
  106. pCmdData->m_dwNextDescriptor++;
  107. if ( pCmdData->m_dwNextDescriptor == NULL_DESCRIPTOR )
  108. {
  109. pCmdData->m_dwNextDescriptor++;
  110. }
  111. DNASSERT(pCmdData->m_iRefCount == 0);
  112. pCmdData->m_iRefCount = 1;
  113. DPFX(DPFPREP, 8, "Retrieve new CModemCommandData (%p), refcount = 1", pCmdData);
  114. }
  115. //**********************************************************************
  116. //**********************************************************************
  117. // ------------------------------
  118. // CModemCommandData::PoolReleaseFunction - function called when returned to pool
  119. //
  120. // Entry: Nothing
  121. //
  122. // Exit: Nothing
  123. // ------------------------------
  124. #undef DPF_MODNAME
  125. #define DPF_MODNAME "CModemCommandData::PoolReleaseFunction"
  126. void CModemCommandData::PoolReleaseFunction( void* pvItem )
  127. {
  128. CModemCommandData* pCmdData = (CModemCommandData*)pvItem;
  129. DPFX(DPFPREP, 8, "Return CModemCommandData (%p), refcount = 0", pCmdData);
  130. pCmdData->SetState( COMMAND_STATE_UNKNOWN );
  131. pCmdData->SetType( COMMAND_TYPE_UNKNOWN );
  132. pCmdData->SetEndpoint( NULL );
  133. pCmdData->SetUserContext( NULL );
  134. pCmdData->m_dwDescriptor = NULL_DESCRIPTOR;
  135. DNASSERT( pCmdData->m_iRefCount == 0 );
  136. DNASSERT( pCmdData->m_CommandListLinkage.IsEmpty() != FALSE );
  137. }
  138. //**********************************************************************
  139. //**********************************************************************
  140. // ------------------------------
  141. // CModemCommandData::PoolDeallocFunction - function called when deleted from pool
  142. //
  143. // Entry: Nothing
  144. //
  145. // Exit: Nothing
  146. // ------------------------------
  147. #undef DPF_MODNAME
  148. #define DPF_MODNAME "CModemCommandData::PoolDeallocFunction"
  149. void CModemCommandData::PoolDeallocFunction( void* pvItem )
  150. {
  151. CModemCommandData* pCmdData = (CModemCommandData*)pvItem;
  152. DNASSERT( pCmdData->m_State == COMMAND_STATE_UNKNOWN );
  153. DNASSERT( pCmdData->m_dwDescriptor == NULL_DESCRIPTOR );
  154. DNASSERT( pCmdData->m_Type == COMMAND_TYPE_UNKNOWN );
  155. DNASSERT( pCmdData->m_pEndpoint == NULL );
  156. DNASSERT( pCmdData->m_pUserContext == NULL );
  157. DNASSERT( pCmdData->m_CommandListLinkage.IsEmpty() != FALSE );
  158. DNASSERT( pCmdData->m_iRefCount == 0 );
  159. DNDeleteCriticalSection( &pCmdData->m_Lock );
  160. }
  161. //**********************************************************************
  162. //**********************************************************************
  163. // ------------------------------
  164. // CModemCommandData::ReturnSelfToPool - return this item to the pool
  165. //
  166. // Entry: Nothing
  167. //
  168. // Exit: Nothing
  169. // ------------------------------
  170. #undef DPF_MODNAME
  171. #define DPF_MODNAME "CModemCommandData::ReturnSelfToPool"
  172. void CModemCommandData::ReturnSelfToPool( void )
  173. {
  174. g_ModemCommandDataPool.Release( this );
  175. }
  176. //**********************************************************************