Source code of Windows XP (NT5)
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.

326 lines
7.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. hash.h
  5. Abstract:
  6. Replacement routines for the string table functions in setupapi.dll.
  7. This routines are much more easy to work with.
  8. Author:
  9. Jim Schmidt (jimschm) 22-Dec-1998
  10. Revision History:
  11. ovidiut 11-Oct-1999 Updated for new coding conventions and Win64 compliance
  12. --*/
  13. //
  14. // Includes
  15. //
  16. // None
  17. //
  18. // Strings
  19. //
  20. // None
  21. //
  22. // Constants
  23. //
  24. // None
  25. //
  26. // Macros
  27. //
  28. #define CASE_SENSITIVE TRUE
  29. #define CASE_INSENSITIVE FALSE
  30. //
  31. // Types
  32. //
  33. typedef const void *HASHTABLE;
  34. typedef const void *HASHITEM;
  35. typedef struct {
  36. PCSTR String;
  37. PCVOID ExtraData;
  38. HASHITEM Index;
  39. HASHTABLE Internal;
  40. } HASHTABLE_ENUMA, *PHASHTABLE_ENUMA;
  41. typedef struct {
  42. PCWSTR String;
  43. PCVOID ExtraData;
  44. HASHITEM Index;
  45. HASHTABLE Internal;
  46. } HASHTABLE_ENUMW, *PHASHTABLE_ENUMW;
  47. typedef
  48. BOOL
  49. (*PHASHTABLE_CALLBACK_ROUTINEA)(
  50. IN HASHTABLE HashTable,
  51. IN HASHITEM Index,
  52. IN PCSTR String,
  53. IN PVOID ExtraData,
  54. IN UINT ExtraDataSize,
  55. IN LPARAM lParam
  56. );
  57. typedef
  58. BOOL
  59. (*PHASHTABLE_CALLBACK_ROUTINEW)(
  60. IN HASHTABLE HashTable,
  61. IN HASHITEM Index,
  62. IN PCWSTR String,
  63. IN PVOID ExtraData,
  64. IN UINT ExtraDataSize,
  65. IN LPARAM lParam
  66. );
  67. //
  68. // Globals
  69. //
  70. // None
  71. //
  72. // Macro expansion list
  73. //
  74. // None
  75. //
  76. // Function prototypes and wrapper macros
  77. //
  78. HASHTABLE
  79. HtAllocExAW (
  80. IN BOOL Unicode,
  81. IN BOOL ExternalStrings,
  82. IN UINT ExtraDataSize,
  83. IN UINT BucketCount OPTIONAL
  84. );
  85. #define HtAllocA() HtAllocExAW(FALSE,FALSE,0,0)
  86. #define HtAllocW() HtAllocExAW(TRUE,FALSE,0,0)
  87. #define HtAllocWithDataA(size) HtAllocExAW(FALSE,FALSE,size,0)
  88. #define HtAllocWithDataW(size) HtAllocExAW(TRUE,FALSE,size,0)
  89. #define HtAllocExA(datasize,bucketcount) HtAllocExAW(FALSE,FALSE,size,bucketcount)
  90. #define HtAllocExW(datasize,bucketcount) HtAllocExAW(TRUE,FALSE,size,bucketcount)
  91. #define HtAllocExternStrA() HtAllocExAW(FALSE,TRUE,0,0)
  92. #define HtAllocExternStrW() HtAllocExAW(TRUE,TRUE,0,0)
  93. #define HtAllocExternStrWithDataA(size) HtAllocExAW(FALSE,TRUE,0,0)
  94. #define HtAllocExternStrWithDataW(size) HtAllocExAW(TRUE,TRUE,0,0)
  95. #define HtAllocExternStrExA(size,bucketcount) HtAllocExAW(FALSE,TRUE,size,bucketcount)
  96. #define HtAllocExternStrExW(size,bucketcount) HtAllocExAW(TRUE,TRUE,size,bucketcount)
  97. VOID
  98. HtFree (
  99. IN HASHTABLE HashTable
  100. );
  101. HASHITEM
  102. HtAddStringExA (
  103. IN HASHTABLE HashTable,
  104. IN PCSTR String,
  105. IN PCVOID ExtraData, OPTIONAL
  106. IN BOOL CaseSensitive
  107. );
  108. #define HtAddStringA(table,string) HtAddStringExA(table,string,NULL,CASE_INSENSITIVE)
  109. HASHITEM
  110. HtAddStringExW (
  111. IN HASHTABLE HashTable,
  112. IN PCWSTR String,
  113. IN PCVOID ExtraData, OPTIONAL
  114. IN BOOL CaseSensitive
  115. );
  116. #define HtAddStringW(table,string) HtAddStringExW(table,string,NULL,CASE_INSENSITIVE)
  117. HASHITEM
  118. HtFindStringExA (
  119. IN HASHTABLE HashTable,
  120. IN PCSTR String,
  121. OUT PVOID ExtraData, OPTIONAL
  122. IN BOOL CaseSensitive
  123. );
  124. #define HtFindStringA(table,string) HtFindStringExA(table,string,NULL,CASE_INSENSITIVE)
  125. HASHITEM
  126. HtFindStringExW (
  127. IN HASHTABLE HashTable,
  128. IN PCWSTR String,
  129. OUT PVOID ExtraData, OPTIONAL
  130. IN BOOL CaseSensitive
  131. );
  132. #define HtFindStringW(table,string) HtFindStringExW(table,string,NULL,CASE_INSENSITIVE)
  133. HASHITEM
  134. HtFindPrefixExA (
  135. IN HASHTABLE HashTable,
  136. IN PCSTR StringStart,
  137. IN PCSTR BufferEnd,
  138. OUT PVOID ExtraData, OPTIONAL
  139. IN BOOL CaseSensitive
  140. );
  141. #define HtFindPrefixA(table,str,end) HtFindPrefixExA(table,str,end,NULL,CASE_INSENSITIVE)
  142. HASHITEM
  143. HtFindPrefixExW (
  144. IN HASHTABLE HashTable,
  145. IN PCWSTR StringStart,
  146. IN PCWSTR BufferEnd,
  147. OUT PVOID ExtraData, OPTIONAL
  148. IN BOOL CaseSensitive
  149. );
  150. #define HtFindPrefixW(table,str,end) HtFindPrefixExW(table,str,end,NULL,CASE_INSENSITIVE)
  151. BOOL
  152. HtGetStringData (
  153. IN HASHTABLE HashTable,
  154. IN HASHITEM Index,
  155. OUT PCVOID *ExtraData
  156. );
  157. BOOL
  158. HtCopyStringData (
  159. IN HASHTABLE HashTable,
  160. IN HASHITEM Index,
  161. OUT PVOID ExtraData
  162. );
  163. BOOL
  164. HtSetStringData (
  165. IN HASHTABLE HashTable,
  166. IN HASHITEM Index,
  167. IN PCVOID ExtraData
  168. );
  169. PCSTR
  170. HtGetStringFromItemA (
  171. IN HASHITEM Item
  172. );
  173. PCWSTR
  174. HtGetStringFromItemW (
  175. IN HASHITEM Item
  176. );
  177. BOOL
  178. EnumFirstHashTableStringA (
  179. OUT PHASHTABLE_ENUMA EnumPtr,
  180. IN HASHTABLE HashTable
  181. );
  182. BOOL
  183. EnumFirstHashTableStringW (
  184. OUT PHASHTABLE_ENUMW EnumPtr,
  185. IN HASHTABLE HashTable
  186. );
  187. BOOL
  188. EnumNextHashTableStringA (
  189. IN OUT PHASHTABLE_ENUMA EnumPtr
  190. );
  191. BOOL
  192. EnumNextHashTableStringW (
  193. IN OUT PHASHTABLE_ENUMW EnumPtr
  194. );
  195. BOOL
  196. EnumHashTableWithCallbackA (
  197. IN HASHTABLE Table,
  198. IN PHASHTABLE_CALLBACK_ROUTINEA Proc,
  199. IN LPARAM lParam
  200. );
  201. BOOL
  202. EnumHashTableWithCallbackW (
  203. IN HASHTABLE Table,
  204. IN PHASHTABLE_CALLBACK_ROUTINEW Proc,
  205. IN LPARAM lParam
  206. );
  207. //
  208. // Macro expansion definition
  209. //
  210. // None
  211. //
  212. // A & W macros
  213. //
  214. #ifdef UNICODE
  215. #define HASHTABLE_ENUM HASHTABLE_ENUMW
  216. #define PHASH_CALLBACK_ROUTINE PHASH_CALLBACK_ROUTINEW
  217. #define HtAlloc HtAllocW
  218. #define HtAllocWithData HtAllocWithDataW
  219. #define HtAllocEx HtAllocExW
  220. #define HtAllocExternStr HtAllocExternStrW
  221. #define HtAllocExternStrWithData HtAllocExternStrWithDataW
  222. #define HtAllocExternStrEx HtAllocExternStrExW
  223. #define HtAddString HtAddStringW
  224. #define HtAddStringEx HtAddStringExW
  225. #define HtFindString HtFindStringW
  226. #define HtFindStringEx HtFindStringExW
  227. #define HtFindPrefix HtFindPrefixW
  228. #define HtFindPrefixEx HtFindPrefixExW
  229. #define HtGetStringFromItem HtGetStringFromItemW
  230. #define EnumFirstHashTableString EnumFirstHashTableStringW
  231. #define EnumNextHashTableString EnumNextHashTableStringW
  232. #define EnumHashTableWithCallback EnumHashTableWithCallbackW
  233. #else
  234. #define HASHTABLE_ENUM HASHTABLE_ENUMA
  235. #define PHASH_CALLBACK_ROUTINE PHASH_CALLBACK_ROUTINEA
  236. #define HtAlloc HtAllocA
  237. #define HtAllocWithData HtAllocWithDataA
  238. #define HtAllocEx HtAllocExA
  239. #define HtAllocExternStr HtAllocExternStrA
  240. #define HtAllocExternStrWithData HtAllocExternStrWithDataA
  241. #define HtAllocExternStrEx HtAllocExternStrExA
  242. #define HtAddString HtAddStringA
  243. #define HtAddStringEx HtAddStringExA
  244. #define HtFindString HtFindStringA
  245. #define HtFindStringEx HtFindStringExA
  246. #define HtFindPrefix HtFindPrefixA
  247. #define HtFindPrefixEx HtFindPrefixExA
  248. #define HtGetStringFromItem HtGetStringFromItemA
  249. #define EnumFirstHashTableString EnumFirstHashTableStringA
  250. #define EnumNextHashTableString EnumNextHashTableStringA
  251. #define EnumHashTableWithCallback EnumHashTableWithCallbackA
  252. #endif