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.

275 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. upcase.hxx
  5. Abstract:
  6. This module contains the declarations for the NTFS_UPCASE_TABLE
  7. class. This class models the upcase table stored on an NTFS volume,
  8. which is used to upcase attribute names and file names resident
  9. on that volume.
  10. Author:
  11. Bill McJohn (billmc) 04-March-92
  12. Environment:
  13. ULIB, User Mode
  14. --*/
  15. #if !defined( _NTFS_UPCASE_TABLE_DEFN_ )
  16. #define _NTFS_UPCASE_TABLE_DEFN_
  17. DECLARE_CLASS( NTFS_ATTRIBUTE );
  18. DECLARE_CLASS( NTFS_BITMAP );
  19. DECLARE_CLASS( NTFS_UPCASE_TABLE );
  20. #include "attrib.hxx"
  21. // This function is used to compare two NTFS names. Its definition
  22. // appears in upcase.cxx.
  23. //
  24. LONG
  25. UNTFS_EXPORT
  26. NtfsUpcaseCompare(
  27. IN PCWSTR LeftName,
  28. IN ULONG LeftNameLength,
  29. IN PCWSTR RightName,
  30. IN ULONG RightNameLength,
  31. IN PCNTFS_UPCASE_TABLE UpcaseTable,
  32. IN BOOLEAN CaseSensitive
  33. );
  34. class NTFS_UPCASE_TABLE : public OBJECT {
  35. public:
  36. UNTFS_EXPORT
  37. DECLARE_CONSTRUCTOR( NTFS_UPCASE_TABLE );
  38. VIRTUAL
  39. UNTFS_EXPORT
  40. ~NTFS_UPCASE_TABLE(
  41. );
  42. NONVIRTUAL
  43. UNTFS_EXPORT
  44. BOOLEAN
  45. Initialize(
  46. IN PNTFS_ATTRIBUTE Attribute
  47. );
  48. NONVIRTUAL
  49. BOOLEAN
  50. Initialize(
  51. IN PWCHAR Data,
  52. IN ULONG Length
  53. );
  54. NONVIRTUAL
  55. BOOLEAN
  56. Initialize(
  57. );
  58. NONVIRTUAL
  59. BOOLEAN
  60. Verify(
  61. ) CONST;
  62. NONVIRTUAL
  63. WCHAR
  64. UpperCase(
  65. IN WCHAR Character
  66. ) CONST;
  67. NONVIRTUAL
  68. BOOLEAN
  69. Write(
  70. IN OUT PNTFS_ATTRIBUTE Attribute,
  71. IN OUT PNTFS_BITMAP VolumeBitmap OPTIONAL
  72. );
  73. NONVIRTUAL
  74. PCWCHAR
  75. GetUpcaseArray(
  76. OUT PULONG Length
  77. ) CONST;
  78. STATIC
  79. ULONG
  80. QueryDefaultLength(
  81. );
  82. STATIC
  83. ULONG
  84. QueryDefaultSize(
  85. );
  86. private:
  87. NONVIRTUAL
  88. VOID
  89. Construct(
  90. );
  91. NONVIRTUAL
  92. VOID
  93. Destroy(
  94. );
  95. PWCHAR _Data;
  96. ULONG _Length;
  97. };
  98. INLINE
  99. WCHAR
  100. NTFS_UPCASE_TABLE::UpperCase(
  101. IN WCHAR Character
  102. ) CONST
  103. /*++
  104. Routine Description:
  105. This method returns the upper-case value of the supplied
  106. character.
  107. Arguments:
  108. Character -- Supplies the character to upcase.
  109. Notes:
  110. If Character is not in the table (ie. is greater or equal
  111. to _Length), it upcases to itself.
  112. --*/
  113. {
  114. return( (Character < _Length) ? _Data[Character] : Character );
  115. }
  116. INLINE
  117. BOOLEAN
  118. NTFS_UPCASE_TABLE::Write(
  119. IN OUT PNTFS_ATTRIBUTE Attribute,
  120. IN OUT PNTFS_BITMAP VolumeBitmap
  121. )
  122. /*++
  123. Routine Description:
  124. This method writes the upcase table through the supplied
  125. attribute.
  126. Arguments:
  127. Attribute -- Supplies the attribute which has the upcase
  128. table as its value.
  129. VolumeBitmap -- Supplies the volume bitmap. This parameter
  130. may be omitted if the attribute is already
  131. the correct size.
  132. Return Value:
  133. TRUE upon successful completion.
  134. --*/
  135. {
  136. ULONG BytesInTable, BytesWritten;
  137. BytesInTable = _Length * sizeof( WCHAR );
  138. return( Attribute->Resize( _Length, VolumeBitmap ) &&
  139. Attribute->Write( _Data,
  140. 0,
  141. BytesInTable,
  142. &BytesWritten,
  143. VolumeBitmap ) &&
  144. BytesWritten == BytesInTable );
  145. }
  146. INLINE
  147. PCWCHAR
  148. NTFS_UPCASE_TABLE::GetUpcaseArray(
  149. OUT PULONG Length
  150. ) CONST
  151. /*++
  152. Routine Description:
  153. This method returns the in-memory upcase array.
  154. Arguments:
  155. Length - Returns the number of characters in the array.
  156. Return Value:
  157. The in-memory upcase array.
  158. --*/
  159. {
  160. *Length = _Length;
  161. return _Data;
  162. }
  163. INLINE
  164. ULONG
  165. NTFS_UPCASE_TABLE::QueryDefaultLength(
  166. )
  167. /*++
  168. Routine Description:
  169. This method returns the length (in characters) of the
  170. default upcase table.
  171. Arguments:
  172. None.
  173. Return Value:
  174. The length (in characters) of the default upcase table.
  175. --*/
  176. {
  177. return 0x10000;
  178. }
  179. INLINE
  180. ULONG
  181. NTFS_UPCASE_TABLE::QueryDefaultSize(
  182. )
  183. /*++
  184. Routine Description:
  185. This method returns the size of the default upcase table.
  186. Arguments:
  187. None.
  188. Return Value:
  189. The size of the default upcase table.
  190. --*/
  191. {
  192. return( QueryDefaultLength() * sizeof( WCHAR ) );
  193. }
  194. #endif