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.

167 lines
3.7 KiB

  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. /*++
  6. This structure contains an extent and a depth, which the namespace
  7. manager knows how to interpret in the right context. The NS_NAMESPACE
  8. structure contains a list of these which represent aliases at various
  9. depths along the document structure. The NS_DEFAULT_NAMESPACES contains
  10. a pseudo-stack which has the current 'default' namespace at the top.
  11. --*/
  12. typedef struct NS_NAME_DEPTH {
  13. XML_EXTENT Name;
  14. ULONG Depth;
  15. }
  16. NS_NAME_DEPTH, *PNS_NAME_DEPTH;
  17. #define NS_ALIAS_MAP_INLINE_COUNT (5)
  18. #define NS_ALIAS_MAP_GROWING_COUNT (20)
  19. typedef struct _NS_ALIAS {
  20. //
  21. // Is this in use?
  22. //
  23. BOOLEAN fInUse;
  24. //
  25. // The name of the alias - "x" or "asm" or the short tag before the : in
  26. // an element name, like <x:foo>
  27. //
  28. XML_EXTENT AliasName;
  29. //
  30. // How many aliased namespaces are there?
  31. //
  32. ULONG ulNamespaceCount;
  33. //
  34. // The namespaces that it can map to, with their depths
  35. //
  36. RTL_GROWING_LIST NamespaceMaps;
  37. //
  38. // A list of some inline elements, for fun. This is shallow, as it's
  39. // the typical case that someone will create a large set of aliases
  40. // to a small set of namespaces, rather than the other way around.
  41. //
  42. NS_NAME_DEPTH InlineNamespaceMaps[NS_ALIAS_MAP_INLINE_COUNT];
  43. }
  44. NS_ALIAS, *PNS_ALIAS;
  45. #define NS_MANAGER_INLINE_ALIAS_COUNT (10)
  46. #define NS_MANAGER_ALIAS_GROWTH_SIZE (40)
  47. #define NS_MANAGER_DEFAULT_COUNT (20)
  48. #define NS_MANAGER_DEFAULT_GROWTH_SIZE (40)
  49. typedef NTSTATUS (*PFNCOMPAREEXTENTS)(
  50. PVOID pvContext,
  51. PCXML_EXTENT pLeft,
  52. PCXML_EXTENT pRight,
  53. XML_STRING_COMPARE *pfMatching);
  54. typedef struct _NS_MANAGER {
  55. //
  56. // How deep is the default namespace stack?
  57. //
  58. ULONG ulDefaultNamespaceDepth;
  59. //
  60. // The default namespaces go into this list
  61. //
  62. RTL_GROWING_LIST DefaultNamespaces;
  63. //
  64. // How many aliases are there?
  65. //
  66. ULONG ulAliasCount;
  67. //
  68. // The array of aliases. N.B. that this list can have holes in it, and
  69. // the user will have to do some special magic to find empty slots in
  70. // it to make efficient use of this. Alternatively, you could have another
  71. // growing list representing a 'freed slot' stack, but I'm not sure that
  72. // would really be an optimization.
  73. //
  74. RTL_GROWING_LIST Aliases;
  75. //
  76. // Comparison
  77. //
  78. PFNCOMPAREEXTENTS pfnCompare;
  79. //
  80. // Context
  81. //
  82. PVOID pvCompareContext;
  83. //
  84. // Inline list of aliases to start with
  85. //
  86. NS_ALIAS InlineAliases[NS_MANAGER_INLINE_ALIAS_COUNT];
  87. NS_NAME_DEPTH InlineDefaultNamespaces[NS_MANAGER_DEFAULT_COUNT];
  88. }
  89. NS_MANAGER, *PNS_MANAGER;
  90. NTSTATUS
  91. RtlNsInitialize(
  92. PNS_MANAGER pManager,
  93. PFNCOMPAREEXTENTS pCompare,
  94. PVOID pCompareContext,
  95. PRTL_ALLOCATOR Allocation
  96. );
  97. NTSTATUS
  98. RtlNsDestroy(
  99. PNS_MANAGER pManager
  100. );
  101. NTSTATUS
  102. RtlNsInsertDefaultNamespace(
  103. PNS_MANAGER pManager,
  104. ULONG ulDepth,
  105. PXML_EXTENT pNamespace
  106. );
  107. NTSTATUS
  108. RtlNsInsertNamespaceAlias(
  109. PNS_MANAGER pManager,
  110. ULONG ulDepth,
  111. PXML_EXTENT pNamespace,
  112. PXML_EXTENT pAlias
  113. );
  114. NTSTATUS
  115. RtlNsLeaveDepth(
  116. PNS_MANAGER pManager,
  117. ULONG ulDepth
  118. );
  119. NTSTATUS
  120. RtlNsGetNamespaceForAlias(
  121. PNS_MANAGER pManager,
  122. ULONG ulDepth,
  123. PXML_EXTENT Alias,
  124. PXML_EXTENT pNamespace
  125. );
  126. #ifdef __cplusplus
  127. };
  128. #endif