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.

138 lines
1.8 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1997 - 1999
  3. Module Name:
  4. linklist.hxx
  5. Abstract:
  6. Header file for the linked list class
  7. Author:
  8. Gopal Parupudi <GopalP>
  9. [Notes:]
  10. optional-notes
  11. Revision History:
  12. GopalP 10/30/1997 Start.
  13. --*/
  14. #define REACHABLE 0x1
  15. #define UNREACHABLE 0x0
  16. #define UNTRIED ~0
  17. class NODE;
  18. class LIST;
  19. typedef NODE *PNODE;
  20. class NODE
  21. {
  22. friend class LIST;
  23. friend SENS_TIMER_CALLBACK_RETURN ReachabilityPollingRoutine(PVOID, BOOLEAN);
  24. public:
  25. NODE();
  26. NODE(DWORD, PWCHAR, PDWORD);
  27. ~NODE();
  28. LONG AddRef() { return InterlockedIncrement(&cRef); }
  29. LONG Release() { return InterlockedDecrement(&cRef); }
  30. private:
  31. PNODE Next;
  32. PNODE Prev;
  33. PWCHAR Destination;
  34. DWORD SubId;
  35. LONG cRef;
  36. DWORD State;
  37. };
  38. class LIST
  39. {
  40. friend SENS_TIMER_CALLBACK_RETURN ReachabilityPollingRoutine(PVOID, BOOLEAN);
  41. public:
  42. LIST();
  43. ~LIST();
  44. DWORD
  45. Insert(
  46. PNODE
  47. );
  48. DWORD
  49. InsertByDest(
  50. PWCHAR
  51. );
  52. void
  53. Delete(
  54. PNODE
  55. );
  56. BOOL
  57. DeleteByDest(
  58. PWCHAR
  59. );
  60. BOOL
  61. DeleteById(
  62. DWORD
  63. );
  64. void
  65. DeleteAll(
  66. void
  67. );
  68. PNODE
  69. Find(
  70. PWCHAR,
  71. BOOL
  72. );
  73. BOOL
  74. IsEmpty(
  75. void
  76. );
  77. void
  78. RequestLock(
  79. void
  80. )
  81. {
  82. EnterCriticalSection(&ListLock);
  83. }
  84. void
  85. ReleaseLock(
  86. void
  87. )
  88. {
  89. LeaveCriticalSection(&ListLock);
  90. }
  91. void
  92. Print(
  93. void
  94. );
  95. private:
  96. PNODE pHead;
  97. ULONG cElements;
  98. CRITICAL_SECTION ListLock;
  99. };