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.

288 lines
5.6 KiB

  1. //
  2. // Collections(list) class
  3. //
  4. #pragma once
  5. #include "regevent.h"
  6. //
  7. //
  8. //
  9. class CNode
  10. {
  11. public:
  12. CNode(
  13. VOID* pKey,
  14. VOID* pKey2,
  15. VOID* pContext,
  16. VOID* pContext2,
  17. VOID* pContext3
  18. )
  19. {
  20. m_pKey = pKey;
  21. m_pKey2 = pKey2;
  22. m_pContext = pContext;
  23. m_pContext2 = pContext2;
  24. m_pContext3 = pContext3;
  25. };
  26. VOID* m_pKey;
  27. VOID* m_pKey2;
  28. VOID* m_pContext;
  29. VOID* m_pContext2;
  30. VOID* m_pContext3;
  31. CNode* m_pNext;
  32. };
  33. //
  34. //
  35. //
  36. class CGenericList
  37. {
  38. public:
  39. CRITICAL_SECTION m_ObjectListCritical;
  40. CNode* m_Head;
  41. CGenericList()
  42. {
  43. m_Head = NULL;
  44. InitializeCriticalSection(&m_ObjectListCritical);
  45. };
  46. ~CGenericList()
  47. {
  48. DeleteCriticalSection(&m_ObjectListCritical);
  49. };
  50. BOOL Insert(VOID *key, VOID *key2, VOID *context, VOID *context2, VOID *context3);
  51. // removal based on first key
  52. BOOL RemoveKey(VOID *key, VOID **pkey2, VOID **pcontext, VOID **pcontext2, VOID **pcontext3);
  53. // removal based on second key
  54. BOOL RemoveKey2(VOID **pkey, VOID *key2, VOID **pcontext, VOID **pcontext2, VOID **pcontext3);
  55. // removal from list.
  56. BOOL Remove(VOID **pkey, VOID **pkey2, VOID **pcontext, VOID **pcontext2, VOID **pcontext3);
  57. };
  58. //
  59. //
  60. //
  61. class CControlObjectList
  62. {
  63. private:
  64. CGenericList m_ControlObjectList;
  65. public:
  66. ULONG m_NumElements;
  67. CControlObjectList()
  68. {
  69. m_NumElements = 0;
  70. };
  71. BOOL Insert(CFtpControlConnection *pControlConnection);
  72. BOOL Remove(CFtpControlConnection *pControlConnection);
  73. bool
  74. IsSourcePortAvailable(
  75. ULONG nPublicSourceAddress,
  76. USHORT nPublicSourcePortToVerify
  77. );
  78. void ShutdownAll();
  79. };
  80. //
  81. //
  82. //
  83. class CDataChannelList
  84. {
  85. private:
  86. CGenericList m_DataChannelObjectList;
  87. ULONG m_NumElements;
  88. public:
  89. CDataChannelList()
  90. {
  91. m_NumElements = 0;
  92. };
  93. BOOL Insert(IDataChannel *pDataChannel,USHORT icsPort,HANDLE CreationHandle,HANDLE DeletionHandle);
  94. BOOL Remove(IDataChannel **pDataChannel,USHORT *icsPort,HANDLE *CreationHandle,HANDLE *DeletionHandle);
  95. BOOL Remove(IDataChannel *pDataChannel,USHORT *icsPort);
  96. BOOL Remove(IDataChannel *pDataChannel,USHORT *icsPort,HANDLE *DeletionHandle);
  97. };
  98. //
  99. //
  100. //
  101. class CRegisteredEventList
  102. {
  103. private:
  104. CGenericList m_RegEventObjectList;
  105. ULONG m_NumElements;
  106. public:
  107. CRegisteredEventList() { m_NumElements = 0; };
  108. BOOL Insert(HANDLE WaitHandle, HANDLE hEvent,EVENT_CALLBACK CallBack, void *Context, void *Context2);
  109. BOOL Remove(HANDLE WaitHandle, HANDLE *hEvent);
  110. BOOL Remove(HANDLE *WaitHandle, HANDLE hEvent,EVENT_CALLBACK *CallBack,void **context,void **context2);
  111. };
  112. //
  113. // Doubly-linked list manipulation routines. Implemented as macros
  114. // but logically these are procedures.
  115. //
  116. //
  117. // VOID
  118. // InitializeListHead(
  119. // PLIST_ENTRY ListHead
  120. // );
  121. //
  122. #define InitializeListHead(ListHead) (\
  123. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  124. //
  125. // BOOLEAN
  126. // IsListEmpty(
  127. // PLIST_ENTRY ListHead
  128. // );
  129. //
  130. #define IsListEmpty(ListHead) \
  131. ((ListHead)->Flink == (ListHead))
  132. //
  133. // PLIST_ENTRY
  134. // RemoveHeadList(
  135. // PLIST_ENTRY ListHead
  136. // );
  137. //
  138. #define RemoveHeadList(ListHead) \
  139. (ListHead)->Flink;\
  140. {RemoveEntryList((ListHead)->Flink)}
  141. //
  142. // PLIST_ENTRY
  143. // RemoveTailList(
  144. // PLIST_ENTRY ListHead
  145. // );
  146. //
  147. #define RemoveTailList(ListHead) \
  148. (ListHead)->Blink;\
  149. {RemoveEntryList((ListHead)->Blink)}
  150. //
  151. // VOID
  152. // RemoveEntryList(
  153. // PLIST_ENTRY Entry
  154. // );
  155. //
  156. #define RemoveEntryList(Entry) {\
  157. PLIST_ENTRY _EX_Blink;\
  158. PLIST_ENTRY _EX_Flink;\
  159. _EX_Flink = (Entry)->Flink;\
  160. _EX_Blink = (Entry)->Blink;\
  161. _EX_Blink->Flink = _EX_Flink;\
  162. _EX_Flink->Blink = _EX_Blink;\
  163. }
  164. //
  165. // VOID
  166. // InsertTailList(
  167. // PLIST_ENTRY ListHead,
  168. // PLIST_ENTRY Entry
  169. // );
  170. //
  171. #define InsertTailList(ListHead,Entry) {\
  172. PLIST_ENTRY _EX_Blink;\
  173. PLIST_ENTRY _EX_ListHead;\
  174. _EX_ListHead = (ListHead);\
  175. _EX_Blink = _EX_ListHead->Blink;\
  176. (Entry)->Flink = _EX_ListHead;\
  177. (Entry)->Blink = _EX_Blink;\
  178. _EX_Blink->Flink = (Entry);\
  179. _EX_ListHead->Blink = (Entry);\
  180. }
  181. //
  182. // VOID
  183. // InsertHeadList(
  184. // PLIST_ENTRY ListHead,
  185. // PLIST_ENTRY Entry
  186. // );
  187. //
  188. #define InsertHeadList(ListHead,Entry) {\
  189. PLIST_ENTRY _EX_Flink;\
  190. PLIST_ENTRY _EX_ListHead;\
  191. _EX_ListHead = (ListHead);\
  192. _EX_Flink = _EX_ListHead->Flink;\
  193. (Entry)->Flink = _EX_Flink;\
  194. (Entry)->Blink = _EX_ListHead;\
  195. _EX_Flink->Blink = (Entry);\
  196. _EX_ListHead->Flink = (Entry);\
  197. }
  198. //
  199. //
  200. // PSINGLE_LIST_ENTRY
  201. // PopEntryList(
  202. // PSINGLE_LIST_ENTRY ListHead
  203. // );
  204. //
  205. #define PopEntryList(ListHead) \
  206. (ListHead)->Next;\
  207. {\
  208. PSINGLE_LIST_ENTRY FirstEntry;\
  209. FirstEntry = (ListHead)->Next;\
  210. if (FirstEntry != NULL) { \
  211. (ListHead)->Next = FirstEntry->Next;\
  212. } \
  213. }
  214. //
  215. // VOID
  216. // PushEntryList(
  217. // PSINGLE_LIST_ENTRY ListHead,
  218. // PSINGLE_LIST_ENTRY Entry
  219. // );
  220. //
  221. #define PushEntryList(ListHead,Entry) \
  222. (Entry)->Next = (ListHead)->Next; \
  223. (ListHead)->Next = (Entry)