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.

451 lines
13 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. objstr.h
  5. Abstract:
  6. Implements a set of APIs to handle the string representation of nodes/leafs of a tree
  7. Author:
  8. 03-Jan-2000 Ovidiu Temereanca (ovidiut) - File creation.
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. /*
  13. +-------+
  14. | root1 | Level 1
  15. +-------+
  16. / \
  17. / \
  18. +---------+ (-------)
  19. | node1 | ( leaf1 ) Level 2
  20. +---------+ (-------)
  21. / | \ \__________
  22. / | \ \
  23. +-------+ +-------+ (-------) (-------)
  24. | node2 | | node3 | ( leaf2 ) ( leaf3 ) Level 3
  25. +-------+ +-------+ (-------) (-------)
  26. / \
  27. / \
  28. +-------+ (-------)
  29. | node4 | ( leaf4 ) Level 4
  30. +-------+ (-------)
  31. / \
  32. / \
  33. (-------) (-------)
  34. ( leaf5 ) ( leaf6 ) Level 5
  35. (-------) (-------)
  36. The string representation of some tree elements above:
  37. root1
  38. root1 <leaf1>
  39. root1\node1
  40. root1\node1 <leaf2>
  41. root1\node1 <leaf3>
  42. */
  43. //
  44. // Types
  45. //
  46. typedef PCTSTR ENCODEDSTRHANDLE;
  47. typedef enum {
  48. OBSPF_EXACTNODE = 0x0001,
  49. OBSPF_NODEISROOTPLUSSTAR = 0x0002,
  50. OBSPF_OPTIONALNODE = 0x0004,
  51. OBSPF_NOLEAF = 0x0008,
  52. OBSPF_EXACTLEAF = 0x0010,
  53. OBSPF_OPTIONALLEAF = 0x0020,
  54. } OBSP_FLAGS;
  55. typedef struct TAG_OBSPARSEDPATTERNA {
  56. PPARSEDPATTERNA NodePattern;
  57. PPARSEDPATTERNA LeafPattern;
  58. PSTR ExactRoot;
  59. DWORD ExactRootBytes;
  60. PCSTR Leaf;
  61. DWORD MinNodeLevel;
  62. DWORD MaxNodeLevel;
  63. DWORD MaxSubLevel;
  64. DWORD Flags;
  65. PMHANDLE Pool;
  66. } OBSPARSEDPATTERNA, *POBSPARSEDPATTERNA;
  67. typedef struct TAG_OBSPARSEDPATTERNW {
  68. PPARSEDPATTERNW NodePattern;
  69. PPARSEDPATTERNW LeafPattern;
  70. PWSTR ExactRoot;
  71. DWORD ExactRootBytes;
  72. PCWSTR Leaf;
  73. DWORD MinNodeLevel;
  74. DWORD MaxNodeLevel;
  75. DWORD MaxSubLevel;
  76. DWORD Flags;
  77. PMHANDLE Pool;
  78. } OBSPARSEDPATTERNW, *POBSPARSEDPATTERNW;
  79. //
  80. // APIs
  81. //
  82. BOOL
  83. ObsInitialize (
  84. VOID
  85. );
  86. VOID
  87. ObsTerminate (
  88. VOID
  89. );
  90. VOID
  91. ObsFreeA (
  92. IN PCSTR EncodedObject
  93. );
  94. VOID
  95. ObsFreeW (
  96. IN PCWSTR EncodedObject
  97. );
  98. BOOL
  99. ObsEncodeStringExA (
  100. PSTR Destination,
  101. PCSTR Source,
  102. PCSTR CharsToEncode
  103. );
  104. #define ObsEncodeStringA(d,s) ObsEncodeStringExA(d,s,NULL)
  105. BOOL
  106. ObsEncodeStringExW (
  107. PWSTR Destination,
  108. PCWSTR Source,
  109. PCWSTR CharsToEncode
  110. );
  111. #define ObsEncodeStringW(d,s) ObsEncodeStringExW(d,s,NULL)
  112. BOOL
  113. ObsDecodeStringA (
  114. PSTR Destination,
  115. PCSTR Source
  116. );
  117. BOOL
  118. ObsDecodeStringW (
  119. PWSTR Destination,
  120. PCWSTR Source
  121. );
  122. BOOL
  123. RealObsSplitObjectStringExA (
  124. IN PCSTR EncodedObject,
  125. OUT PCSTR* DecodedNode, OPTIONAL
  126. OUT PCSTR* DecodedLeaf, OPTIONAL
  127. IN PMHANDLE Pool, OPTIONAL
  128. IN BOOL DecodeStrings
  129. );
  130. #define ObsSplitObjectStringExA(o,n,l,p,s) TRACK_BEGIN(BOOL, ObsSplitObjectStringExA)\
  131. RealObsSplitObjectStringExA(o,n,l,p,s)\
  132. TRACK_END()
  133. #define ObsSplitObjectStringA(o,n,l) ObsSplitObjectStringExA(o,n,l,NULL,TRUE)
  134. BOOL
  135. RealObsSplitObjectStringExW (
  136. IN PCWSTR EncodedObject,
  137. OUT PCWSTR* DecodedNode, OPTIONAL
  138. OUT PCWSTR* DecodedLeaf, OPTIONAL
  139. IN PMHANDLE Pool, OPTIONAL
  140. IN BOOL DecodeStrings
  141. );
  142. #define ObsSplitObjectStringExW(o,n,l,p,s) TRACK_BEGIN(BOOL, ObsSplitObjectStringExW)\
  143. RealObsSplitObjectStringExW(o,n,l,p,s)\
  144. TRACK_END()
  145. #define ObsSplitObjectStringW(o,n,l) ObsSplitObjectStringExW(o,n,l,NULL,TRUE)
  146. BOOL
  147. ObsHasNodeA (
  148. IN PCSTR EncodedObject
  149. );
  150. BOOL
  151. ObsHasNodeW (
  152. IN PCWSTR EncodedObject
  153. );
  154. PCSTR
  155. ObsGetLeafPortionOfEncodedStringA (
  156. IN PCSTR EncodedObject
  157. );
  158. PCWSTR
  159. ObsGetLeafPortionOfEncodedStringW (
  160. IN PCWSTR EncodedObject
  161. );
  162. PCSTR
  163. ObsGetNodeLeafDividerA (
  164. IN PCSTR EncodedObject
  165. );
  166. PCWSTR
  167. ObsGetNodeLeafDividerW (
  168. IN PCWSTR EncodedObject
  169. );
  170. PCSTR
  171. ObsFindNonEncodedCharInEncodedStringA (
  172. IN PCSTR String,
  173. IN MBCHAR Char
  174. );
  175. PCWSTR
  176. ObsFindNonEncodedCharInEncodedStringW (
  177. IN PCWSTR String,
  178. IN WCHAR Char
  179. );
  180. PSTR
  181. ObsBuildEncodedObjectStringFromPatternA (
  182. IN POBSPARSEDPATTERNA Pattern
  183. );
  184. PWSTR
  185. ObsBuildEncodedObjectStringFromPatternW (
  186. IN POBSPARSEDPATTERNW Pattern
  187. );
  188. PSTR
  189. RealObsBuildEncodedObjectStringExA (
  190. IN PCSTR DecodedNode,
  191. IN PCSTR DecodedLeaf, OPTIONAL
  192. IN BOOL EncodeString
  193. );
  194. #define ObsBuildEncodedObjectStringExA(n,l,e) TRACK_BEGIN(PSTR, ObsBuildEncodedObjectStringExA)\
  195. RealObsBuildEncodedObjectStringExA(n,l,e)\
  196. TRACK_END()
  197. #define ObsBuildEncodedObjectStringA(node,leaf) ObsBuildEncodedObjectStringExA(node,leaf,FALSE)
  198. PSTR
  199. ObsBuildPartialEncodedObjectStringExA (
  200. IN PCSTR DecodedNode,
  201. IN PCSTR DecodedLeaf, OPTIONAL
  202. IN BOOL EncodeString
  203. );
  204. PWSTR
  205. RealObsBuildEncodedObjectStringExW (
  206. IN PCWSTR DecodedNode,
  207. IN PCWSTR DecodedLeaf, OPTIONAL
  208. IN BOOL EncodeString
  209. );
  210. #define ObsBuildEncodedObjectStringExW(n,l,e) TRACK_BEGIN(PWSTR, ObsBuildEncodedObjectStringExW)\
  211. RealObsBuildEncodedObjectStringExW(n,l,e)\
  212. TRACK_END()
  213. #define ObsBuildEncodedObjectStringW(node,leaf) ObsBuildEncodedObjectStringExW(node,leaf,FALSE)
  214. PWSTR
  215. ObsBuildPartialEncodedObjectStringExW (
  216. IN PCWSTR DecodedNode,
  217. IN PCWSTR DecodedLeaf, OPTIONAL
  218. IN BOOL EncodeString
  219. );
  220. POBSPARSEDPATTERNA
  221. RealObsCreateParsedPatternExA (
  222. IN PMHANDLE Pool, OPTIONAL
  223. IN PCSTR EncodedObject,
  224. IN BOOL MakePrimaryRootEndWithWack
  225. );
  226. #define ObsCreateParsedPatternExA(p,o,m) TRACK_BEGIN(POBSPARSEDPATTERNA, ObsCreateParsedPatternExA)\
  227. RealObsCreateParsedPatternExA(p,o,m)\
  228. TRACK_END()
  229. #define ObsCreateParsedPatternA(obj) ObsCreateParsedPatternExA (NULL,obj,FALSE)
  230. POBSPARSEDPATTERNW
  231. RealObsCreateParsedPatternExW (
  232. IN PMHANDLE Pool, OPTIONAL
  233. IN PCWSTR EncodedObject,
  234. IN BOOL MakePrimaryRootEndWithWack
  235. );
  236. #define ObsCreateParsedPatternExW(p,o,m) TRACK_BEGIN(POBSPARSEDPATTERNW, ObsCreateParsedPatternExW)\
  237. RealObsCreateParsedPatternExW(p,o,m)\
  238. TRACK_END()
  239. #define ObsCreateParsedPatternW(obj) ObsCreateParsedPatternExW (NULL,obj,FALSE)
  240. VOID
  241. ObsDestroyParsedPatternA (
  242. IN POBSPARSEDPATTERNA ParsedPattern
  243. );
  244. VOID
  245. ObsDestroyParsedPatternW (
  246. IN POBSPARSEDPATTERNW ParsedPattern
  247. );
  248. BOOL
  249. ObsParsedPatternMatchA (
  250. IN POBSPARSEDPATTERNA ParsedPattern,
  251. IN PCSTR EncodedObject
  252. );
  253. BOOL
  254. ObsParsedPatternMatchW (
  255. IN POBSPARSEDPATTERNW ParsedPattern,
  256. IN PCWSTR EncodedObject
  257. );
  258. BOOL
  259. ObsParsedPatternMatchExA (
  260. IN POBSPARSEDPATTERNA ParsedPattern,
  261. IN PCSTR Node,
  262. IN PCSTR Leaf OPTIONAL
  263. );
  264. BOOL
  265. ObsParsedPatternMatchExW (
  266. IN POBSPARSEDPATTERNW ParsedPattern,
  267. IN PCWSTR Node,
  268. IN PCWSTR Leaf OPTIONAL
  269. );
  270. BOOL
  271. ObsPatternMatchA (
  272. IN PCSTR ObjectPattern,
  273. IN PCSTR ObjectStr
  274. );
  275. BOOL
  276. ObsPatternMatchW (
  277. IN PCWSTR ObjectPattern,
  278. IN PCWSTR ObjectStr
  279. );
  280. BOOL
  281. ObsIsPatternContainedA (
  282. IN PCSTR Container,
  283. IN PCSTR Contained
  284. );
  285. BOOL
  286. ObsIsPatternContainedW (
  287. IN PCWSTR Container,
  288. IN PCWSTR Contained
  289. );
  290. BOOL
  291. ObsGetPatternLevelsA (
  292. IN PCSTR ObjectPattern,
  293. OUT PDWORD MinLevel, OPTIONAL
  294. OUT PDWORD MaxLevel OPTIONAL
  295. );
  296. BOOL
  297. ObsGetPatternLevelsW (
  298. IN PCWSTR ObjectPattern,
  299. OUT PDWORD MinLevel, OPTIONAL
  300. OUT PDWORD MaxLevel OPTIONAL
  301. );
  302. BOOL
  303. ObsPatternIncludesPatternA (
  304. IN POBSPARSEDPATTERNA IncludingPattern,
  305. IN POBSPARSEDPATTERNA IncludedPattern
  306. );
  307. BOOL
  308. ObsPatternIncludesPatternW (
  309. IN POBSPARSEDPATTERNW IncludingPattern,
  310. IN POBSPARSEDPATTERNW IncludedPattern
  311. );
  312. //
  313. // Macros
  314. //
  315. #ifdef UNICODE
  316. #define OBSPARSEDPATTERN OBSPARSEDPATTERNW
  317. #define POBSPARSEDPATTERN POBSPARSEDPATTERNW
  318. #define ObsFree ObsFreeW
  319. #define ObsEncodeStringEx ObsEncodeStringExW
  320. #define ObsEncodeString ObsEncodeStringW
  321. #define ObsDecodeString ObsDecodeStringW
  322. #define ObsSplitObjectString ObsSplitObjectStringW
  323. #define ObsSplitObjectStringEx ObsSplitObjectStringExW
  324. #define ObsHasNode ObsHasNodeW
  325. #define ObsGetLeafPortionOfEncodedString ObsGetLeafPortionOfEncodedStringW
  326. #define ObsGetNodeLeafDivider ObsGetNodeLeafDividerW
  327. #define ObsFindNonEncodedCharInEncodedString ObsFindNonEncodedCharInEncodedStringW
  328. #define ObsBuildEncodedObjectStringFromPattern ObsBuildEncodedObjectStringFromPatternW
  329. #define ObsBuildEncodedObjectStringEx ObsBuildEncodedObjectStringExW
  330. #define ObsBuildPartialEncodedObjectStringEx ObsBuildPartialEncodedObjectStringExW
  331. #define ObsBuildEncodedObjectString ObsBuildEncodedObjectStringW
  332. #define ObsCreateParsedPattern ObsCreateParsedPatternW
  333. #define ObsCreateParsedPatternEx ObsCreateParsedPatternExW
  334. #define ObsDestroyParsedPattern ObsDestroyParsedPatternW
  335. #define ObsParsedPatternMatch ObsParsedPatternMatchW
  336. #define ObsParsedPatternMatchEx ObsParsedPatternMatchExW
  337. #define ObsPatternMatch ObsPatternMatchW
  338. #define ObsIsPatternContained ObsIsPatternContainedW
  339. #define ObsGetPatternLevels ObsGetPatternLevelsW
  340. #define ObsPatternIncludesPattern ObsPatternIncludesPatternW
  341. #else
  342. #define OBSPARSEDPATTERN OBSPARSEDPATTERNA
  343. #define POBSPARSEDPATTERN POBSPARSEDPATTERNA
  344. #define ObsFree ObsFreeA
  345. #define ObsEncodeStringEx ObsEncodeStringExA
  346. #define ObsEncodeString ObsEncodeStringA
  347. #define ObsDecodeString ObsDecodeStringA
  348. #define ObsSplitObjectString ObsSplitObjectStringA
  349. #define ObsSplitObjectStringEx ObsSplitObjectStringExA
  350. #define ObsHasNode ObsHasNodeA
  351. #define ObsGetLeafPortionOfEncodedString ObsGetLeafPortionOfEncodedStringA
  352. #define ObsGetNodeLeafDivider ObsGetNodeLeafDividerA
  353. #define ObsFindNonEncodedCharInEncodedString ObsFindNonEncodedCharInEncodedStringA
  354. #define ObsBuildEncodedObjectStringFromPattern ObsBuildEncodedObjectStringFromPatternA
  355. #define ObsBuildEncodedObjectStringEx ObsBuildEncodedObjectStringExA
  356. #define ObsBuildPartialEncodedObjectStringEx ObsBuildPartialEncodedObjectStringExA
  357. #define ObsBuildEncodedObjectString ObsBuildEncodedObjectStringA
  358. #define ObsCreateParsedPattern ObsCreateParsedPatternA
  359. #define ObsCreateParsedPatternEx ObsCreateParsedPatternExA
  360. #define ObsDestroyParsedPattern ObsDestroyParsedPatternA
  361. #define ObsParsedPatternMatch ObsParsedPatternMatchA
  362. #define ObsParsedPatternMatchEx ObsParsedPatternMatchExA
  363. #define ObsPatternMatch ObsPatternMatchA
  364. #define ObsIsPatternContained ObsIsPatternContainedA
  365. #define ObsGetPatternLevels ObsGetPatternLevelsA
  366. #define ObsPatternIncludesPattern ObsPatternIncludesPatternA
  367. #endif