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.

256 lines
6.7 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. growlist.h
  5. Abstract:
  6. Implements a dynamic array-indexed list of binary objects. Typically,
  7. the binary objects are strings. The list uses a GROWBUF for the array,
  8. and a pool for the binary data of each list item.
  9. Author:
  10. Jim Schmidt (jimschm) 08-Aug-1997
  11. Revision History:
  12. <alias> <date> <comments>
  13. --*/
  14. #pragma once
  15. //
  16. // Types
  17. //
  18. typedef struct {
  19. GROWBUFFER ListArray;
  20. } GROWLIST, *PGROWLIST;
  21. #ifdef DEBUG
  22. #define INIT_GROWLIST {NULL,0,0,0,0,0, NULL}
  23. #else
  24. #define INIT_GROWLIST {NULL,0,0,0,0, NULL}
  25. #endif
  26. //
  27. // Function Prototypes
  28. //
  29. #define GlGetPtrArray(listptr) ((PVOID *) ((listptr)->ListArray.Buf))
  30. #define GlGetStringPtrArrayA(listptr) ((PCSTR *) ((listptr)->ListArray.Buf))
  31. #define GlGetStringPtrArrayW(listptr) ((PCWSTR *) ((listptr)->ListArray.Buf))
  32. PBYTE
  33. RealGlAppend (
  34. IN OUT PGROWLIST GrowList,
  35. IN PBYTE DataToAppend, OPTIONAL
  36. IN UINT SizeOfData
  37. );
  38. #define GlAppend(list,data,size) DBGTRACK(PBYTE, GlAppend, (list,data,size))
  39. PBYTE
  40. RealGlAppendAddNul (
  41. IN OUT PGROWLIST GrowList,
  42. IN PBYTE DataToAppend, OPTIONAL
  43. IN UINT SizeOfData
  44. );
  45. #define GlAppendAddNul(list,data,size) DBGTRACK(PBYTE, GlAppendAddNul, (list,data,size))
  46. VOID
  47. GlFree (
  48. IN PGROWLIST GrowList
  49. );
  50. VOID
  51. GlReset (
  52. IN OUT PGROWLIST GrowList
  53. );
  54. PBYTE
  55. GlGetItem (
  56. IN PGROWLIST GrowList,
  57. IN UINT Index
  58. );
  59. UINT
  60. GlGetSize (
  61. IN PGROWLIST GrowList
  62. );
  63. PBYTE
  64. RealGlInsert (
  65. IN OUT PGROWLIST GrowList,
  66. IN UINT Index,
  67. IN PBYTE DataToAppend, OPTIONAL
  68. IN UINT SizeOfData
  69. );
  70. #define GlInsert(list,index,data,size) DBGTRACK(PBYTE, GlInsert, (list,index,data,size))
  71. PBYTE
  72. RealGlInsertAddNul (
  73. IN OUT PGROWLIST GrowList,
  74. IN UINT Index,
  75. IN PBYTE DataToAppend, OPTIONAL
  76. IN UINT SizeOfData
  77. );
  78. #define GlInsertAddNul(list,index,data,size) DBGTRACK(PBYTE, GlInsertAddNul, (list,index,data,size))
  79. BOOL
  80. GlDeleteItem (
  81. IN OUT PGROWLIST GrowList,
  82. IN UINT Index
  83. );
  84. BOOL
  85. GlResetItem (
  86. IN OUT PGROWLIST GrowList,
  87. IN UINT Index
  88. );
  89. PBYTE
  90. RealGlSetItem (
  91. IN OUT PGROWLIST GrowList,
  92. IN UINT Index,
  93. IN PCBYTE DataToSet, OPTIONAL
  94. IN UINT SizeOfData
  95. );
  96. #define GlSetItem(list,index,data,size) DBGTRACK(PBYTE, GlSetItem, (list,index,data,size))
  97. __inline
  98. PCSTR
  99. RealGlAppendStringABA (
  100. IN OUT PGROWLIST GrowList,
  101. IN PCSTR String,
  102. IN PCSTR End
  103. )
  104. {
  105. MYASSERT_F(String < End, "Start is greater than End in GrowListAppendStringABA");
  106. return (PCSTR) GlAppendAddNul (
  107. GrowList,
  108. (PBYTE) String,
  109. String < End ? SzByteCountABA (String, End) : 0
  110. );
  111. }
  112. __inline
  113. PCWSTR
  114. RealGlAppendStringABW (
  115. IN OUT PGROWLIST GrowList,
  116. IN PCWSTR String,
  117. IN PCWSTR End
  118. )
  119. {
  120. MYASSERT_F(String < End, "Start is greater than End in GrowListAppendStringABW");
  121. return (PCWSTR) GlAppendAddNul (
  122. GrowList,
  123. (PBYTE) String,
  124. String < End ? SzByteCountABW (String, End) : 0
  125. );
  126. }
  127. __inline
  128. PCSTR
  129. RealGlInsertStringABA (
  130. IN OUT PGROWLIST GrowList,
  131. IN UINT Index,
  132. IN PCSTR String,
  133. IN PCSTR End
  134. )
  135. {
  136. MYASSERT_F(String < End, "Start is greater than End in GrowListInsertStringABA");
  137. return (PCSTR) GlInsertAddNul (
  138. GrowList,
  139. Index,
  140. (PBYTE) String,
  141. String < End ? SzByteCountABA (String, End) : 0
  142. );
  143. }
  144. __inline
  145. PCWSTR
  146. RealGlInsertStringABW (
  147. IN OUT PGROWLIST GrowList,
  148. IN UINT Index,
  149. IN PCWSTR String,
  150. IN PCWSTR End
  151. )
  152. {
  153. MYASSERT_F(String < End, "Start is greater than End in GrowListInsertStringABW");
  154. return (PCWSTR) GlInsertAddNul (
  155. GrowList,
  156. Index,
  157. (PBYTE) String,
  158. String < End ? SzByteCountABW (String, End) : 0
  159. );
  160. }
  161. #define GlAppendStringABA(list,a,b) DBGTRACK(PCSTR, GlAppendStringABA, (list,a,b))
  162. #define GlAppendStringABW(list,a,b) DBGTRACK(PCWSTR, GlAppendStringABW, (list,a,b))
  163. #define GlInsertStringABA(list,index,a,b) DBGTRACK(PCSTR, GlInsertStringABA, (list,index,a,b))
  164. #define GlInsertStringABW(list,index,a,b) DBGTRACK(PCWSTR, GlInsertStringABW, (list,index,a,b))
  165. #define GlAppendStringA(list,str) GlAppendStringABA(list,str,SzGetEndA(str))
  166. #define GlAppendStringW(list,str) GlAppendStringABW(list,str,SzGetEndW(str))
  167. #define GlInsertStringA(list,index,str) GlInsertStringABA(list,index,str,SzGetEndA(str))
  168. #define GlInsertStringW(list,index,str) GlInsertStringABW(list,index,str,SzGetEndW(str))
  169. #define GlAppendStringNA(list,str,len) GlAppendStringABA(list,str,SzTcharsToPointerA(str,len))
  170. #define GlAppendStringNW(list,str,len) GlAppendStringABW(list,str,SzTcharsToPointerW(str,len))
  171. #define GlInsertStringNA(list,index,str,len) GlInsertStringABA(list,index,str,SzTcharsToPointerA(str,len))
  172. #define GlInsertStringNW(list,index,str,len) GlInsertStringABW(list,index,str,SzTcharsToPointerW(str,len))
  173. #define GlGetStringA(list,index) (PCSTR)(GlGetItem(list,index))
  174. #define GlGetStringW(list,index) (PCWSTR)(GlGetItem(list,index))
  175. #define GlAppendEmptyItem(list) GlAppend (list,NULL,0)
  176. #define GlInsertEmptyItem(list,index) GlInsert (list,index,NULL,0)
  177. //
  178. // A & W Macros
  179. //
  180. #ifdef UNICODE
  181. #define GlAppendString GlAppendStringW
  182. #define GlInsertString GlInsertStringW
  183. #define GlAppendStringAB GlAppendStringABW
  184. #define GlInsertStringAB GlInsertStringABW
  185. #define GlAppendStringN GlAppendStringNW
  186. #define GlInsertStringN GlInsertStringNW
  187. #define GlGetString GlGetStringW
  188. #define GlGetStringPtrArray GlGetStringPtrArrayW
  189. #else
  190. #define GlAppendString GlAppendStringA
  191. #define GlInsertString GlInsertStringA
  192. #define GlAppendStringAB GlAppendStringABA
  193. #define GlInsertStringAB GlInsertStringABA
  194. #define GlAppendStringN GlAppendStringNA
  195. #define GlInsertStringN GlInsertStringNA
  196. #define GlGetString GlGetStringA
  197. #define GlGetStringPtrArray GlGetStringPtrArrayA
  198. #endif