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.

97 lines
3.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2000, Microsoft Corporation.
  4. //
  5. // File: name_table.h
  6. //
  7. // Contents: The DFS Name Table
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __NAME_TABLE_H__
  11. #define __NAME_TABLE_H__
  12. #include <dfsheader.h>
  13. #include <dfsnametable.h>
  14. typedef struct _DFS_NAME_TABLE_BUCKET {
  15. ULONG Count;
  16. LIST_ENTRY ListHead;
  17. } DFS_NAME_TABLE_BUCKET, *PDFS_NAME_TABLE_BUCKET;
  18. typedef struct _DFS_NAME_TABLE_ENTRY {
  19. PUNICODE_STRING pName;
  20. LIST_ENTRY NameTableLink;
  21. PVOID pData;
  22. } DFS_NAME_TABLE_ENTRY, *PDFS_NAME_TABLE_ENTRY;
  23. typedef struct _DFS_NAME_TABLE {
  24. DFS_OBJECT_HEADER DfsHeader;
  25. ULONG Flags;
  26. ULONG NumBuckets;
  27. PVOID pLock;
  28. DFS_NAME_TABLE_BUCKET HashBuckets[0];
  29. } DFS_NAME_TABLE, *PDFS_NAME_TABLE;
  30. #define NAME_TABLE_LOCKED 1
  31. #define DFS_NAMETABLE_CRIT_SPIN_COUNT 4000
  32. NTSTATUS
  33. DfsCheckNameTable(
  34. IN PUNICODE_STRING lookupName,
  35. IN PDFS_NAME_TABLE_BUCKET pBucket,
  36. OUT PVOID *ppData );
  37. #define DEFAULT_NAME_TABLE_SIZE 47
  38. #define DFS_LOCK_NAME_TABLE(_pTable, _sts)\
  39. { EnterCriticalSection((_pTable)->pLock); (_pTable)->Flags |= NAME_TABLE_LOCKED; (_sts) = STATUS_SUCCESS; }
  40. #define DFS_UNLOCK_NAME_TABLE(_pTable)\
  41. {(_pTable)->Flags &= ~NAME_TABLE_LOCKED; LeaveCriticalSection((_pTable)->pLock); }
  42. #define GET_NAME_TABLE_BUCKET(_name, _table, BucketNo) \
  43. { \
  44. WCHAR *pPathBuffer = (_name)->Buffer; \
  45. WCHAR pCurrent; \
  46. WCHAR *pPathBufferEnd = &(pPathBuffer[(_name)->Length / sizeof(WCHAR)]); \
  47. BucketNo = 0; \
  48. while ((pPathBufferEnd != pPathBuffer) && \
  49. (*pPathBuffer)) \
  50. { \
  51. pCurrent = *pPathBuffer++; \
  52. pCurrent = (pCurrent < L'a') \
  53. ? pCurrent \
  54. : ((pCurrent < L'z') \
  55. ? (pCurrent - L'a' + L'A') \
  56. : RtlUpcaseUnicodeChar(pCurrent)); \
  57. BucketNo *= 131; \
  58. BucketNo += pCurrent; \
  59. } \
  60. BucketNo = BucketNo % ((_table)->NumBuckets); \
  61. }
  62. #if defined (PREFIX_TABLE_HEAP_MEMORY)
  63. extern HANDLE PrefixTableHeapHandle;
  64. #define ALLOCATE_MEMORY(_sz) \
  65. HeapAlloc(PrefixTableHeapHandle, 0, _sz)
  66. #define FREE_MEMORY(_addr) \
  67. HeapFree(PrefixTableHeapHandle, 0, _addr)
  68. #else
  69. #define ALLOCATE_MEMORY(_sz)\
  70. malloc(_sz)
  71. #define FREE_MEMORY(_addr) \
  72. free(_addr)
  73. #endif
  74. #endif // __NAME_TABLE_H__