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.

2298 lines
63 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. strings.h
  5. Abstract:
  6. Declares the string utilities implemented in common\migutil.
  7. Author:
  8. Several
  9. Revision History:
  10. See SLM log
  11. --*/
  12. #include <mbstring.h>
  13. #include <wchar.h>
  14. typedef PVOID PMHANDLE;
  15. #pragma once
  16. #define MAX_ENCODED_RULE (256*6)
  17. #define NODE_LEVEL_MAX ((DWORD)-1)
  18. #define SHIFTRIGHT8(l) (/*lint --e(506)*/sizeof(l)<=1?0:l>>8)
  19. #define SHIFTRIGHT16(l) (/*lint --e(506)*/sizeof(l)<=2?0:l>>16)
  20. #define SHIFTRIGHT32(l) (/*lint --e(506)*/sizeof(l)<=4?0:l>>32)
  21. extern CHAR EscapedCharsA[];
  22. extern WCHAR EscapedCharsW[];
  23. //
  24. // String sizing routines and unit conversion
  25. //
  26. #define CharCountA(x) ((DWORD)_mbslen(x))
  27. #define CharCountW(x) ((DWORD)wcslen(x))
  28. #define SIZEOF(x) ((DWORD)sizeof(x))
  29. __inline
  30. PSTR
  31. CharCountToPointerA (
  32. PCSTR String,
  33. UINT Char
  34. )
  35. {
  36. while (Char > 0) {
  37. MYASSERT (*String != 0);
  38. Char--;
  39. String = _mbsinc (String);
  40. }
  41. return (PSTR) String;
  42. }
  43. __inline
  44. PWSTR
  45. CharCountToPointerW (
  46. PCWSTR String,
  47. UINT Char
  48. )
  49. {
  50. #ifdef DEBUG
  51. UINT u;
  52. for (u = 0 ; u < Char ; u++) {
  53. MYASSERT (String[u] != 0);
  54. }
  55. #endif
  56. return (PWSTR) (&String[Char]);
  57. }
  58. __inline
  59. UINT
  60. CharCountABA (
  61. IN PCSTR Start,
  62. IN PCSTR EndPlusOne
  63. )
  64. {
  65. register UINT Count;
  66. Count = 0;
  67. while (Start < EndPlusOne) {
  68. MYASSERT (*Start != 0);
  69. Count++;
  70. Start = _mbsinc (Start);
  71. }
  72. return Count;
  73. }
  74. __inline
  75. UINT
  76. CharCountABW (
  77. IN PCWSTR Start,
  78. IN PCWSTR EndPlusOne
  79. )
  80. {
  81. #ifdef DEBUG
  82. PCWSTR p;
  83. for (p = Start ; p < EndPlusOne ; p++) {
  84. MYASSERT (*p != 0);
  85. }
  86. #endif
  87. return EndPlusOne > Start ? (UINT)(EndPlusOne - Start) : 0;
  88. }
  89. __inline
  90. UINT
  91. CharCountInByteRangeA (
  92. IN PCSTR Start,
  93. IN UINT Bytes
  94. )
  95. {
  96. register UINT Count;
  97. PCSTR EndPlusOne = (PCSTR) ((UBINT) Start + Bytes);
  98. Count = 0;
  99. while (Start < EndPlusOne) {
  100. Count++;
  101. Start = _mbsinc (Start);
  102. }
  103. return Count;
  104. }
  105. __inline
  106. UINT
  107. CharCountInByteRangeW (
  108. IN PCWSTR Start,
  109. IN UINT Bytes
  110. )
  111. {
  112. PCWSTR EndPlusOne = (PCWSTR) ((UBINT) Start + Bytes);
  113. if (Start < EndPlusOne) {
  114. //cast is OK, we don't expect pointers to be that far
  115. return (UINT)(EndPlusOne - Start);
  116. }
  117. MYASSERT (FALSE);
  118. return 0;
  119. }
  120. __inline
  121. UINT
  122. CharCountToBytesA (
  123. IN PCSTR Start,
  124. IN UINT CharCount
  125. )
  126. {
  127. PCSTR EndPlusOne;
  128. EndPlusOne = CharCountToPointerA (Start, CharCount);
  129. //cast is OK, we don't expect pointers to be that far
  130. return (UINT)(EndPlusOne - Start);
  131. }
  132. __inline
  133. UINT
  134. CharCountToBytesW (
  135. IN PCWSTR Start,
  136. IN UINT CharCount
  137. )
  138. {
  139. return CharCount * SIZEOF (WCHAR);
  140. }
  141. #define CharCountToTcharsA CharCountToBytesA
  142. __inline
  143. UINT
  144. CharCountToTcharsW (
  145. IN PCWSTR Start,
  146. IN UINT CharCount
  147. )
  148. {
  149. return CharCount;
  150. }
  151. #define ByteCountA(x) ((DWORD)strlen(x))
  152. #define ByteCountW(x) ((DWORD)wcslen(x)*SIZEOF(WCHAR))
  153. #define SizeOfStringA(str) ((DWORD)ByteCountA(str) + SIZEOF (CHAR))
  154. #define SizeOfStringW(str) ((DWORD)ByteCountW(str) + SIZEOF (WCHAR))
  155. __inline
  156. PSTR
  157. ByteCountToPointerA (
  158. PCSTR String,
  159. UINT BytePos
  160. )
  161. {
  162. return (PSTR)((UBINT) String + BytePos);
  163. }
  164. __inline
  165. PWSTR
  166. ByteCountToPointerW (
  167. PCWSTR String,
  168. UINT BytePos
  169. )
  170. {
  171. return (PWSTR)((UBINT) String + BytePos);
  172. }
  173. __inline
  174. UINT
  175. ByteCountABA (
  176. IN PCSTR Start,
  177. IN PCSTR EndPlusOne
  178. )
  179. {
  180. #ifdef DEBUG
  181. PCSTR p;
  182. for (p = Start ; p < EndPlusOne ; p = _mbsinc (p)) {
  183. MYASSERT (*p != 0);
  184. }
  185. #endif
  186. return EndPlusOne > Start ? (UINT)(EndPlusOne - Start) : 0;
  187. }
  188. __inline
  189. UINT
  190. ByteCountABW (
  191. IN PCWSTR Start,
  192. IN PCWSTR EndPlusOne
  193. )
  194. {
  195. #ifdef DEBUG
  196. PCWSTR p;
  197. for (p = Start ; p < EndPlusOne ; p++) {
  198. MYASSERT (*p != 0);
  199. }
  200. #endif
  201. return EndPlusOne > Start ? (UINT)(EndPlusOne - Start) * SIZEOF (WCHAR) : 0;
  202. }
  203. __inline
  204. UINT
  205. ByteCountToCharsA (
  206. IN PCSTR Start,
  207. IN UINT ByteCount
  208. )
  209. {
  210. PCSTR EndPlusOne;
  211. EndPlusOne = Start + ByteCount;
  212. return CharCountABA (Start, EndPlusOne);
  213. }
  214. __inline
  215. UINT
  216. ByteCountToCharsW (
  217. IN PCWSTR Start,
  218. IN UINT ByteCount
  219. )
  220. {
  221. #ifdef DEBUG
  222. PCWSTR p;
  223. PCWSTR EndPlusOne;
  224. EndPlusOne = (PCWSTR) ((UBINT) Start + ByteCount);
  225. for (p = Start ; p < EndPlusOne ; p++) {
  226. MYASSERT (*p != 0);
  227. }
  228. #endif
  229. return ByteCount / SIZEOF (WCHAR);
  230. }
  231. __inline
  232. UINT
  233. ByteCountToTcharsA (
  234. IN PCSTR Start,
  235. IN UINT ByteCount
  236. )
  237. {
  238. #ifdef DEBUG
  239. PCSTR p;
  240. PCSTR EndPlusOne;
  241. EndPlusOne = Start + ByteCount;
  242. for (p = Start ; p < EndPlusOne ; p = _mbsinc (p)) {
  243. MYASSERT (*p != 0);
  244. }
  245. #endif
  246. return ByteCount;
  247. }
  248. #define ByteCountToTcharsW ByteCountToCharsW
  249. #define TcharCountA strlen
  250. #define TcharCountW wcslen
  251. __inline
  252. PSTR
  253. TcharCountToPointerA (
  254. PCSTR String,
  255. UINT Tchars
  256. )
  257. {
  258. #ifdef DEBUG
  259. PCSTR p;
  260. PCSTR EndPlusOne;
  261. EndPlusOne = String + Tchars;
  262. for (p = String ; p < EndPlusOne ; p = _mbsinc (p)) {
  263. MYASSERT (*p != 0);
  264. }
  265. #endif
  266. return (PSTR) (String + Tchars);
  267. }
  268. __inline
  269. PWSTR
  270. TcharCountToPointerW (
  271. PCWSTR String,
  272. UINT Tchars
  273. )
  274. {
  275. #ifdef DEBUG
  276. PCWSTR p;
  277. PCWSTR EndPlusOne;
  278. EndPlusOne = String + Tchars;
  279. for (p = String ; p < EndPlusOne ; p++) {
  280. MYASSERT (*p != 0);
  281. }
  282. #endif
  283. return (PWSTR) (String + Tchars);
  284. }
  285. #define TcharCountABA ByteCountABA
  286. __inline
  287. UINT
  288. TcharCountABW (
  289. IN PCWSTR Start,
  290. IN PCWSTR EndPlusOne
  291. )
  292. {
  293. #ifdef DEBUG
  294. PCWSTR p;
  295. for (p = Start ; p < EndPlusOne ; p++) {
  296. MYASSERT (*p != 0);
  297. }
  298. #endif
  299. return EndPlusOne > Start ? (UINT)(EndPlusOne - Start) : 0;
  300. }
  301. #define TcharCountToCharsA ByteCountToCharsA
  302. __inline
  303. UINT
  304. TcharCountToCharsW (
  305. IN PCWSTR Start,
  306. IN UINT Tchars
  307. )
  308. {
  309. #ifdef DEBUG
  310. PCWSTR p;
  311. PCWSTR EndPlusOne;
  312. EndPlusOne = Start + Tchars;
  313. for (p = Start ; p < EndPlusOne ; p++) {
  314. MYASSERT (*p != 0);
  315. }
  316. #endif
  317. return Tchars;
  318. }
  319. __inline
  320. UINT
  321. TcharCountToBytesA (
  322. IN PCSTR Start,
  323. IN UINT Tchars
  324. )
  325. {
  326. #ifdef DEBUG
  327. PCSTR p;
  328. PCSTR EndPlusOne;
  329. EndPlusOne = Start + Tchars;
  330. for (p = Start ; p < EndPlusOne ; p = _mbsinc (p)) {
  331. MYASSERT (*p != 0);
  332. }
  333. #endif
  334. return Tchars;
  335. }
  336. __inline
  337. UINT
  338. TcharCountToBytesW (
  339. IN PCWSTR Start,
  340. IN UINT Tchars
  341. )
  342. {
  343. #ifdef DEBUG
  344. PCWSTR p;
  345. PCWSTR EndPlusOne;
  346. EndPlusOne = Start + Tchars;
  347. for (p = Start ; p < EndPlusOne ; p++) {
  348. MYASSERT (*p != 0);
  349. }
  350. #endif
  351. return Tchars * SIZEOF (WCHAR);
  352. }
  353. VOID
  354. UBINTtoHexA (
  355. IN UBINT Number,
  356. OUT PSTR String
  357. );
  358. VOID
  359. UBINTtoHexW (
  360. IN UBINT Number,
  361. OUT PWSTR String
  362. );
  363. VOID
  364. UBINTtoDecA (
  365. IN UBINT Number,
  366. OUT PSTR String
  367. );
  368. VOID
  369. UBINTtoDecW (
  370. IN UBINT Number,
  371. OUT PWSTR String
  372. );
  373. VOID
  374. BINTtoDecA (
  375. IN BINT Number,
  376. OUT PSTR String
  377. );
  378. VOID
  379. BINTtoDecW (
  380. IN BINT Number,
  381. OUT PWSTR String
  382. );
  383. #define StackStringCopyA(stackbuf,src) StringCopyByteCountA(stackbuf,src,SIZEOF(stackbuf))
  384. #define StackStringCopyW(stackbuf,src) StringCopyByteCountW(stackbuf,src,SIZEOF(stackbuf))
  385. //
  386. // String comparison routines
  387. //
  388. #define StringCompareA _mbscmp
  389. #define StringCompareW wcscmp
  390. BOOL
  391. StringMatchA (
  392. IN PCSTR String1,
  393. IN PCSTR String2
  394. );
  395. #define StringMatchW(str1,str2) (wcscmp(str1,str2)==0)
  396. #define StringICompareA _mbsicmp
  397. #define StringICompareW _wcsicmp
  398. #define StringIMatchA(str1,str2) (_mbsicmp(str1,str2)==0)
  399. #define StringIMatchW(str1,str2) (_wcsicmp(str1,str2)==0)
  400. #define StringCompareByteCountA(str1,str2,bytes) _mbsncmp(str1,str2,ByteCountToCharsA(str1,bytes))
  401. #define StringCompareByteCountW(str1,str2,bytes) wcsncmp(str1,str2,ByteCountToCharsW(str1,bytes))
  402. #define StringMatchByteCountA(str1,str2,bytes) StringMatchABA(str1,str2,(PCSTR)((PBYTE)(str2) + bytes))
  403. #define StringMatchByteCountW(str1,str2,bytes) (wcsncmp(str1,str2,ByteCountToCharsW(str1,bytes))==0)
  404. #define StringICompareByteCountA(str1,str2,bytes) _mbsnicmp(str1,str2,ByteCountToCharsA(str1,bytes))
  405. #define StringICompareByteCountW(str1,str2,bytes) _wcsnicmp(str1,str2,ByteCountToCharsW(str1,bytes))
  406. #define StringIMatchByteCountA(str1,str2,bytes) (_mbsnicmp(str1,str2,ByteCountToCharsA(str1,bytes))==0)
  407. #define StringIMatchByteCountW(str1,str2,bytes) (_wcsnicmp(str1,str2,ByteCountToCharsW(str1,bytes))==0)
  408. #define StringCompareCharCountA(str1,str2,chars) _mbsncmp(str1,str2,chars)
  409. #define StringCompareCharCountW(str1,str2,chars) wcsncmp(str1,str2,chars)
  410. #define StringMatchCharCountA(str1,str2,chars) (_mbsncmp(str1,str2,chars)==0)
  411. #define StringMatchCharCountW(str1,str2,chars) (wcsncmp(str1,str2,chars)==0)
  412. #define StringICompareCharCountA(str1,str2,chars) _mbsnicmp(str1,str2,chars)
  413. #define StringICompareCharCountW(str1,str2,chars) _wcsnicmp(str1,str2,chars)
  414. #define StringIMatchCharCountA(str1,str2,chars) (_mbsnicmp(str1,str2,chars)==0)
  415. #define StringIMatchCharCountW(str1,str2,chars) (_wcsnicmp(str1,str2,chars)==0)
  416. #define StringCompareTcharCountA(str1,str2,tchars) StringMatchByteCountA(str1,str2,TcharCountToCharsA(str1,tchars))
  417. #define StringCompareTcharCountW(str1,str2,tchars) wcsncmp(str1,str2,TcharCountToCharsW(str1,tchars))
  418. #define StringMatchTcharCountA(str1,str2,tchars) (_mbsncmp(str1,str2,TcharCountToCharsA(str1,tchars))==0)
  419. #define StringMatchTcharCountW(str1,str2,tchars) (wcsncmp(str1,str2,TcharCountToCharsW(str1,tchars))==0)
  420. #define StringICompareTcharCountA(str1,str2,tchars) _mbsnicmp(str1,str2,TcharCountToCharsA(str1,tchars))
  421. #define StringICompareTcharCountW(str1,str2,tchars) _wcsnicmp(str1,str2,TcharCountToCharsW(str1,tchars))
  422. #define StringIMatchTcharCountA(str1,str2,tchars) (_mbsnicmp(str1,str2,TcharCountToCharsA(str1,tchars))==0)
  423. #define StringIMatchTcharCountW(str1,str2,tchars) (_wcsnicmp(str1,str2,TcharCountToCharsW(str1,tchars))==0)
  424. INT
  425. StringCompareABA (
  426. IN PCSTR String,
  427. IN PCSTR Start,
  428. IN PCSTR End
  429. );
  430. INT
  431. StringCompareABW (
  432. IN PCWSTR String,
  433. IN PCWSTR Start,
  434. IN PCWSTR End
  435. );
  436. BOOL
  437. StringMatchABA (
  438. IN PCSTR String1,
  439. IN PCSTR Start,
  440. IN PCSTR End
  441. );
  442. #define StringMatchABW(String,Start,End) (StringCompareABW(String,Start,End)==0)
  443. // stricmp that takes an end pointer instead of a length
  444. INT
  445. StringICompareABA (
  446. IN PCSTR String,
  447. IN PCSTR Start,
  448. IN PCSTR End
  449. );
  450. INT
  451. StringICompareABW (
  452. IN PCWSTR String,
  453. IN PCWSTR Start,
  454. IN PCWSTR End
  455. );
  456. #define StringIMatchABA(String,Start,End) (StringICompareABA(String,Start,End)==0)
  457. #define StringIMatchABW(String,Start,End) (StringICompareABW(String,Start,End)==0)
  458. //
  459. // String copy routines
  460. //
  461. VOID
  462. StringCopyA (
  463. OUT PSTR Destination,
  464. IN PCSTR Source
  465. );
  466. VOID
  467. StringCopyW (
  468. OUT PWSTR Destination,
  469. IN PCWSTR Source
  470. );
  471. VOID
  472. StringCopyByteCountA (
  473. OUT PSTR Destination,
  474. IN PCSTR Source,
  475. IN UINT MaxBytesToCopyIncNul
  476. );
  477. VOID
  478. StringCopyByteCountW (
  479. OUT PWSTR Destination,
  480. IN PCWSTR Source,
  481. IN UINT MaxBytesToCopyIncNul
  482. );
  483. VOID
  484. StringCopyByteCountABA (
  485. OUT PSTR Destination,
  486. IN PCSTR Start,
  487. IN PCSTR End,
  488. IN UINT MaxBytesToCopyIncNul
  489. );
  490. VOID
  491. StringCopyByteCountABW (
  492. OUT PWSTR Destination,
  493. IN PCWSTR Start,
  494. IN PCWSTR End,
  495. IN UINT MaxBytesToCopyIncNul
  496. );
  497. #define StringCopyCharCountA(str1,str2,chars) StringCopyByteCountA(str1,str2,CharCountToBytesA(str2,chars))
  498. #define StringCopyCharCountW(str1,str2,chars) StringCopyByteCountW(str1,str2,CharCountToBytesW(str2,chars))
  499. #define StringCopyTcharCountA(str1,str2,tchars) StringCopyByteCountA(str1,str2,TcharCountToBytesA(str2,tchars))
  500. #define StringCopyTcharCountW(str1,str2,tchars) StringCopyByteCountW(str1,str2,TcharCountToBytesW(str2,tchars))
  501. #define StringCopyABA(dest,stra,strb) StringCopyByteCountA((dest),(stra),((UINT)((UBINT)(strb)-(UBINT)(stra))+(UINT)SIZEOF(CHAR)))
  502. #define StringCopyABW(dest,stra,strb) StringCopyByteCountW((dest),(stra),((UINT)((UBINT)(strb)-(UBINT)(stra))+(UINT)SIZEOF(WCHAR)))
  503. //
  504. // String cat routines
  505. //
  506. PSTR
  507. StringCatA (
  508. OUT PSTR Destination,
  509. IN PCSTR Source
  510. );
  511. PWSTR
  512. StringCatW (
  513. OUT PWSTR Destination,
  514. IN PCWSTR Source
  515. );
  516. //
  517. // Character search routines
  518. //
  519. #define GetEndOfStringA(s) strchr(s,0)
  520. #define GetEndOfStringW(s) wcschr(s,0)
  521. __inline
  522. UINT
  523. SizeOfMultiSzA (
  524. PCSTR MultiSz
  525. )
  526. {
  527. PCSTR Base;
  528. Base = MultiSz;
  529. while (*MultiSz) {
  530. MultiSz = GetEndOfStringA (MultiSz) + 1;
  531. }
  532. MultiSz++;
  533. return (UINT)((UBINT) MultiSz - (UBINT) Base);
  534. }
  535. __inline
  536. UINT
  537. SizeOfMultiSzW (
  538. PCWSTR MultiSz
  539. )
  540. {
  541. PCWSTR Base;
  542. Base = MultiSz;
  543. while (*MultiSz) {
  544. MultiSz = GetEndOfStringW (MultiSz) + 1;
  545. }
  546. MultiSz++;
  547. return (UINT)((UBINT) MultiSz - (UBINT) Base);
  548. }
  549. __inline
  550. UINT
  551. MultiSzSizeInCharsA (
  552. PCSTR MultiSz
  553. )
  554. {
  555. UINT Chars = 0;
  556. while (*MultiSz) {
  557. do {
  558. Chars++;
  559. MultiSz = _mbsinc (MultiSz);
  560. } while (*MultiSz);
  561. Chars++;
  562. MultiSz++;
  563. }
  564. Chars++;
  565. return Chars;
  566. }
  567. #define MultiSzSizeInCharsW(msz) (SizeOfMultiSzW(msz)/SIZEOF(WCHAR))
  568. PSTR
  569. GetPrevCharA (
  570. IN PCSTR StartStr,
  571. IN PCSTR CurrPtr,
  572. IN MBCHAR SearchChar
  573. );
  574. PWSTR
  575. GetPrevCharW (
  576. IN PCWSTR StartStr,
  577. IN PCWSTR CurrPtr,
  578. IN WCHAR SearchChar
  579. );
  580. //
  581. // Pool allocation routines
  582. //
  583. PSTR
  584. RealAllocTextExA (
  585. IN PMHANDLE Pool, OPTIONAL
  586. IN UINT ByteSize
  587. );
  588. PWSTR
  589. RealAllocTextExW (
  590. IN PMHANDLE Pool, OPTIONAL
  591. IN UINT WcharSize
  592. );
  593. #define AllocTextExA(p,s) TRACK_BEGIN(PSTR, AllocTextExA)\
  594. RealAllocTextExA(p,(UINT)(s))\
  595. TRACK_END()
  596. #define AllocTextExW(p,s) TRACK_BEGIN(PWSTR, AllocTextExW)\
  597. RealAllocTextExW(p,(UINT)(s))\
  598. TRACK_END()
  599. #define AllocTextA(s) AllocTextExA(NULL,(UINT)(s))
  600. #define AllocTextW(s) AllocTextExW(NULL,(UINT)(s))
  601. VOID
  602. FreeTextExA (
  603. IN PMHANDLE Pool, OPTIONAL
  604. IN PCSTR Text OPTIONAL
  605. );
  606. VOID
  607. FreeTextExW (
  608. IN PMHANDLE Pool, OPTIONAL
  609. IN PCWSTR Text OPTIONAL
  610. );
  611. #define FreeTextA(t) FreeTextExA(NULL,t)
  612. #define FreeTextW(t) FreeTextExW(NULL,t)
  613. PSTR
  614. RealDuplicateTextExA (
  615. IN PMHANDLE Pool, OPTIONAL
  616. IN PCSTR Text,
  617. IN UINT ExtraChars,
  618. OUT PSTR *NulChar OPTIONAL
  619. );
  620. PWSTR
  621. RealDuplicateTextExW (
  622. IN PMHANDLE Pool, OPTIONAL
  623. IN PCWSTR Text,
  624. IN UINT ExtraChars,
  625. OUT PWSTR *NulChar OPTIONAL
  626. );
  627. #define DuplicateTextExA(p,t,c,n) TRACK_BEGIN(PSTR, DuplicateTextExA)\
  628. RealDuplicateTextExA(p,t,c,n)\
  629. TRACK_END()
  630. #define DuplicateTextExW(p,t,c,n) TRACK_BEGIN(PWSTR, DuplicateTextExW)\
  631. RealDuplicateTextExW(p,t,c,n)\
  632. TRACK_END()
  633. #define DuplicateTextA(text) DuplicateTextExA(NULL,text,0,NULL)
  634. #define DuplicateTextW(text) DuplicateTextExW(NULL,text,0,NULL)
  635. PSTR
  636. RealJoinTextExA (
  637. IN PMHANDLE Pool, OPTIONAL
  638. IN PCSTR String1,
  639. IN PCSTR String2,
  640. IN PCSTR DelimeterString, OPTIONAL
  641. IN UINT ExtraChars,
  642. OUT PSTR *NulChar OPTIONAL
  643. );
  644. PWSTR
  645. RealJoinTextExW (
  646. IN PMHANDLE Pool, OPTIONAL
  647. IN PCWSTR String1,
  648. IN PCWSTR String2,
  649. IN PCWSTR CenterString, OPTIONAL
  650. IN UINT ExtraChars,
  651. OUT PWSTR *NulChar OPTIONAL
  652. );
  653. #define JoinTextExA(p,s1,s2,cs,ec,nc) TRACK_BEGIN(PSTR, JoinTextExA)\
  654. RealJoinTextExA(p,s1,s2,cs,ec,nc)\
  655. TRACK_END()
  656. #define JoinTextExW(p,s1,s2,cs,ec,nc) TRACK_BEGIN(PWSTR, JoinTextExW)\
  657. RealJoinTextExW(p,s1,s2,cs,ec,nc)\
  658. TRACK_END()
  659. #define JoinTextA(str1,str2) JoinTextExA(NULL,str1,str2,NULL,0,NULL)
  660. #define JoinTextW(str1,str2) JoinTextExW(NULL,str1,str2,NULL,0,NULL)
  661. PSTR
  662. RealExpandEnvironmentTextExA (
  663. IN PCSTR InString,
  664. IN PCSTR * ExtraEnvironmentVariables OPTIONAL
  665. );
  666. PWSTR
  667. RealExpandEnvironmentTextExW (
  668. IN PCWSTR InString,
  669. IN PCWSTR * ExtraEnvironmentVariables OPTIONAL
  670. );
  671. #define ExpandEnvironmentTextExA(str,ev) TRACK_BEGIN(PSTR, ExpandEnvironmentTextExA)\
  672. RealExpandEnvironmentTextExA(str,ev)\
  673. TRACK_END()
  674. #define ExpandEnvironmentTextExW(str,ev) TRACK_BEGIN(PWSTR, ExpandEnvironmentTextExW)\
  675. RealExpandEnvironmentTextExW(str,ev)\
  676. TRACK_END()
  677. #define ExpandEnvironmentTextA(string) ExpandEnvironmentTextExA(string,NULL)
  678. #define ExpandEnvironmentTextW(string) ExpandEnvironmentTextExW(string,NULL)
  679. //
  680. // Function wraps IsDBCSLeadByte(), which tests ACP. Do not use
  681. // isleadbyte().
  682. //
  683. #define IsLeadByte(b) IsDBCSLeadByte(b)
  684. //
  685. // Command line routines
  686. //
  687. // Converts ANSI command line to array of args
  688. PSTR *
  689. CommandLineToArgvA (
  690. IN PCSTR CmdLine,
  691. OUT PUINT NumArgs
  692. );
  693. //
  694. // Need both MBCS and UNICODE versions
  695. //
  696. // an atoi that supports decimal or hex
  697. DWORD _mbsnum (IN PCSTR szNum);
  698. DWORD _wcsnum (IN PCWSTR szNum);
  699. // determines if an entire string is printable chars
  700. int _mbsisprint (PCSTR szStr);
  701. int _wcsisprint (PCWSTR szStr);
  702. // case-insensitive strstr
  703. PCSTR _mbsistr (PCSTR szStr, PCSTR szSubStr);
  704. PCWSTR _wcsistr (PCWSTR szStr, PCWSTR szSubStr);
  705. // copies the first character of str2 to str
  706. void _copymbchar (PSTR str1, PCSTR str2);
  707. #define _copywchar(dest,src) (*(dest)=*(src))
  708. // replaces a character in a multi-byte char string and maintains
  709. // the string integrity (may grow string by one byte)
  710. void _setmbchar (PSTR str, MBCHAR c);
  711. #define _setwchar(str,c) (*(str)=(c))
  712. // removes specified character from the end of a string, if it exists
  713. BOOL _mbsctrim (PSTR str, MBCHAR c);
  714. BOOL _wcsctrim (PWSTR str, WCHAR c);
  715. // Always adds a backslash, returns ptr to nul terminator
  716. PSTR AppendWackA (IN PSTR str);
  717. PWSTR AppendWackW (IN PWSTR str);
  718. // Adds a backslash to the end of a DOS path (unless str is empty
  719. // or is only a drive letter)
  720. PSTR AppendDosWackA (IN PSTR str);
  721. PWSTR AppendDosWackW (IN PWSTR str);
  722. // Adds a backslash unless str is empty
  723. PSTR AppendUncWackA (IN PSTR str);
  724. PWSTR AppendUncWackW (IN PWSTR str);
  725. // Adds a backslash and identifies the correct naming convention (DOS,
  726. // or UNC)
  727. PSTR AppendPathWackA (IN PSTR str);
  728. PWSTR AppendPathWackW (IN PWSTR str);
  729. //
  730. // Joins any number of paths together, allocates string in g_PathsPool if not otherwise specified
  731. // this version checks for wacks at the begin/end of each segment so they are properly joined
  732. //
  733. PSTR
  734. _cdecl
  735. RealJoinPathsInPoolExA (
  736. IN PMHANDLE Pool, OPTIONAL
  737. ...
  738. );
  739. PWSTR
  740. _cdecl
  741. RealJoinPathsInPoolExW (
  742. IN PMHANDLE Pool, OPTIONAL
  743. ...
  744. );
  745. #define JoinPathsInPoolExA(x) TRACK_BEGIN(PSTR, JoinPathsInPoolExA)\
  746. RealJoinPathsInPoolExA x\
  747. TRACK_END()
  748. #define JoinPathsInPoolExW(x) TRACK_BEGIN(PWSTR, JoinPathsInPoolExW)\
  749. RealJoinPathsInPoolExW x\
  750. TRACK_END()
  751. //
  752. // for backwards compatibility, JoinPaths expands to JoinPathsInPoolEx
  753. // and NOT to JoinPathsEx which uses a growbuffer instead
  754. //
  755. #define JoinPathsA(p1,p2) JoinPathsInPoolExA((NULL,p1,p2,NULL))
  756. #define JoinPathsW(p1,p2) JoinPathsInPoolExW((NULL,p1,p2,NULL))
  757. BOOL
  758. _cdecl
  759. JoinPathsExA (
  760. IN OUT PGROWBUFFER Gb,
  761. ...
  762. );
  763. BOOL
  764. _cdecl
  765. JoinPathsExW (
  766. IN OUT PGROWBUFFER Gb,
  767. ...
  768. );
  769. //
  770. // Joins any number of paths together, allocates string in g_PathsPool if not otherwise specified
  771. // this version does NOT check for wacks at the begin/end of each segment
  772. //
  773. PSTR
  774. _cdecl
  775. RealBuildPathInPoolA (
  776. IN PMHANDLE Pool, OPTIONAL
  777. ...
  778. );
  779. PWSTR
  780. _cdecl
  781. RealBuildPathInPoolW (
  782. IN PMHANDLE Pool, OPTIONAL
  783. ...
  784. );
  785. #define BuildPathInPoolA(x) TRACK_BEGIN(PSTR, BuildPathInPoolA)\
  786. RealBuildPathInPoolA x\
  787. TRACK_END()
  788. #define BuildPathInPoolW(x) TRACK_BEGIN(PWSTR, BuildPathInPoolW)\
  789. RealBuildPathInPoolW x\
  790. TRACK_END()
  791. DWORD
  792. _cdecl
  793. BuildPathA (
  794. OUT PSTR Buffer, OPTIONAL
  795. IN DWORD SizeInBytes, OPTIONAL
  796. ...
  797. );
  798. DWORD
  799. _cdecl
  800. BuildPathW (
  801. OUT PWSTR Buffer, OPTIONAL
  802. IN DWORD SizeInBytes, OPTIONAL
  803. ...
  804. );
  805. BOOL
  806. _cdecl
  807. BuildPathExA (
  808. IN OUT PGROWBUFFER Gb,
  809. ...
  810. );
  811. BOOL
  812. _cdecl
  813. BuildPathExW (
  814. IN OUT PGROWBUFFER Gb,
  815. ...
  816. );
  817. // Routine to allocate a 1K buffer for path manipulation, allocated in g_PathsPool
  818. PSTR RealAllocPathStringA (IN DWORD Tchars);
  819. PWSTR RealAllocPathStringW (IN DWORD Tchars);
  820. #define DEFSIZE 0
  821. #define AllocPathStringA(chars) TRACK_BEGIN(PSTR, AllocPathStringA)\
  822. RealAllocPathStringA(chars)\
  823. TRACK_END()
  824. #define AllocPathStringW(chars) TRACK_BEGIN(PWSTR, AllocPathStringW)\
  825. RealAllocPathStringW(chars)\
  826. TRACK_END()
  827. // Routine to divide path into separate strings, each allocated in g_PathsPool
  828. VOID RealSplitPathA (IN PCSTR Path, OUT PSTR *Drive, OUT PSTR *Dir, OUT PSTR *File, OUT PSTR *Ext);
  829. VOID RealSplitPathW (IN PCWSTR Path, OUT PWSTR *Drive, OUT PWSTR *Dir, OUT PWSTR *File, OUT PWSTR *Ext);
  830. #define SplitPathA(path,dv,dir,f,e) TRACK_BEGIN_VOID (VOID, SplitPathA)\
  831. RealSplitPathA(path,dv,dir,f,e)\
  832. TRACK_END()
  833. #define SplitPathW(path,dv,dir,f,e) TRACK_BEGIN_VOID (VOID, SplitPathW)\
  834. RealSplitPathW(path,dv,dir,f,e)\
  835. TRACK_END()
  836. // Routine to extract the file from a path
  837. PCSTR GetFileNameFromPathA (IN PCSTR Path);
  838. PCWSTR GetFileNameFromPathW (IN PCWSTR Path);
  839. // Routine to extract the file extension from a path
  840. PCSTR GetFileExtensionFromPathA (IN PCSTR Path);
  841. PCWSTR GetFileExtensionFromPathW (IN PCWSTR Path);
  842. // Routine to extract the file extension from a path, including the dot, or the
  843. // end of the string if no extension exists
  844. PCSTR GetDotExtensionFromPathA (IN PCSTR Path);
  845. PCWSTR GetDotExtensionFromPathW (IN PCWSTR Path);
  846. // Routine to duplicate a path and allocate space for cat processing
  847. PSTR RealDuplicatePathStringA (IN PCSTR Path, IN DWORD ExtraBytes);
  848. PWSTR RealDuplicatePathStringW (IN PCWSTR Path, IN DWORD ExtraBytes);
  849. #define DuplicatePathStringA(path,eb) TRACK_BEGIN(PSTR, DuplicatePathStringA)\
  850. RealDuplicatePathStringA(path,eb)\
  851. TRACK_END()
  852. #define DuplicatePathStringW(path,eb) TRACK_BEGIN(PWSTR, DuplicatePathStringW)\
  853. RealDuplicatePathStringW(path,eb)\
  854. TRACK_END()
  855. // Routines to enumerate the PATH variable
  856. typedef struct _PATH_ENUMA {
  857. PSTR BufferPtr;
  858. PSTR PtrNextPath;
  859. PSTR PtrCurrPath;
  860. } PATH_ENUMA, *PPATH_ENUMA;
  861. BOOL
  862. EnumFirstPathExA (
  863. OUT PPATH_ENUMA PathEnum,
  864. IN PCSTR AdditionalPath,
  865. IN PCSTR WinDir,
  866. IN PCSTR SysDir,
  867. IN BOOL IncludeEnvPath
  868. );
  869. #define EnumFirstPathA(e,a,w,s) EnumFirstPathExA(e,a,w,s,TRUE)
  870. BOOL
  871. EnumNextPathA (
  872. IN OUT PPATH_ENUMA PathEnum
  873. );
  874. BOOL
  875. AbortPathEnumA (
  876. IN OUT PPATH_ENUMA PathEnum
  877. );
  878. // Frees a string allocated in g_PathsPool
  879. VOID
  880. FreePathStringExA (
  881. IN PMHANDLE Pool, OPTIONAL
  882. IN PCSTR Path OPTIONAL
  883. );
  884. VOID
  885. FreePathStringExW (
  886. IN PMHANDLE Pool, OPTIONAL
  887. IN PCWSTR Path OPTIONAL
  888. );
  889. #define FreePathStringA(p) FreePathStringExA(NULL,p)
  890. #define FreePathStringW(p) FreePathStringExW(NULL,p)
  891. // Removes a trailing backslash, if it exists
  892. #define RemoveWackAtEndA(str) _mbsctrim(str,'\\')
  893. #define RemoveWackAtEndW(str) _wcsctrim(str,L'\\')
  894. PCSTR
  895. FindLastWackA (
  896. IN PCSTR Str
  897. );
  898. PCWSTR
  899. FindLastWackW (
  900. IN PCWSTR Str
  901. );
  902. BOOL
  903. GetNodePatternMinMaxLevelsA (
  904. IN PCSTR NodePattern,
  905. OUT PSTR FormattedNode, OPTIONAL
  906. OUT PDWORD MinLevel, OPTIONAL
  907. OUT PDWORD MaxLevel OPTIONAL
  908. );
  909. BOOL
  910. GetNodePatternMinMaxLevelsW (
  911. IN PCWSTR NodePattern,
  912. OUT PWSTR FormattedNode, OPTIONAL
  913. OUT PDWORD MinLevel, OPTIONAL
  914. OUT PDWORD MaxLevel OPTIONAL
  915. );
  916. // Rule encoding functions used to encode a number of syntax-related
  917. // characters (backslash, brackets, asterisk, etc)
  918. PSTR EncodeRuleCharsA (PSTR szEncRule, PCSTR szRule);
  919. PWSTR EncodeRuleCharsW (PWSTR szEncRule, PCWSTR szRule);
  920. // Rule decoding functions used to restore an encoded string
  921. MBCHAR GetNextRuleCharA (PCSTR *p_szRule, BOOL *p_bFromHex);
  922. WCHAR GetNextRuleCharW (PCWSTR *p_szRule, BOOL *p_bFromHex);
  923. PSTR DecodeRuleCharsA (PSTR szRule, PCSTR szEncRule);
  924. PWSTR DecodeRuleCharsW (PWSTR szRule, PCWSTR szEncRule);
  925. PSTR DecodeRuleCharsABA (PSTR szRule, PCSTR szEncRuleStart, PCSTR End);
  926. PWSTR DecodeRuleCharsABW (PWSTR szRule, PCWSTR szEncRuleStart, PCWSTR End);
  927. // Returns a pointer to the next non-space character (uses isspace)
  928. PCSTR SkipSpaceA (PCSTR szStr);
  929. PCWSTR SkipSpaceW (PCWSTR szStr);
  930. // Returns a pointer to the first space character at the end of a string,
  931. // or a pointer to the terminating nul if no space exists at the end of the
  932. // string. (Used for trimming space.)
  933. PCSTR SkipSpaceRA (PCSTR szBaseStr, PCSTR szStr);
  934. PCWSTR SkipSpaceRW (PCWSTR szBaseStr, PCWSTR szStr);
  935. // Truncates a string after the last non-whitepace character
  936. VOID TruncateTrailingSpaceA (IN OUT PSTR Str);
  937. VOID TruncateTrailingSpaceW (IN OUT PWSTR Str);
  938. // Returns TRUE if str matches wstrPattern. Case-sensitive, supports
  939. // multiple asterisks and question marks.
  940. BOOL IsPatternMatchA (PCSTR wstrPattern, PCSTR wstrStr);
  941. BOOL IsPatternMatchW (PCWSTR wstrPattern, PCWSTR wstrStr);
  942. // Returns TRUE if str matches wstrPattern. Case-sensitive, supports
  943. // multiple asterisks and question marks.
  944. BOOL IsPatternMatchABA (PCSTR Pattern, PCSTR Start, PCSTR End);
  945. BOOL IsPatternMatchABW (PCWSTR Pattern, PCWSTR Start, PCWSTR End);
  946. BOOL IsPatternContainedA (PCSTR Container, PCSTR Contained);
  947. BOOL IsPatternContainedW (PCWSTR Container, PCWSTR Contained);
  948. //
  949. // More powerful pattern matching
  950. //
  951. #define SEGMENTTYPE_UNKNOWN 0
  952. #define SEGMENTTYPE_EXACTMATCH 1
  953. #define SEGMENTTYPE_OPTIONAL 2
  954. #define SEGMENTTYPE_REQUIRED 3
  955. typedef struct {
  956. UINT Type;
  957. union {
  958. // exact match
  959. struct {
  960. PCSTR LowerCasePhrase;
  961. UINT PhraseBytes;
  962. } Exact;
  963. // optional
  964. struct {
  965. UINT MaxLen; // zero if any length
  966. PCSTR IncludeSet; OPTIONAL
  967. PCSTR ExcludeSet; OPTIONAL
  968. } Wildcard;
  969. };
  970. } SEGMENTA, *PSEGMENTA;
  971. typedef struct {
  972. UINT SegmentCount;
  973. PSEGMENTA Segment;
  974. } PATTERNPROPSA, *PPATTERNPROPSA;
  975. typedef struct {
  976. UINT PatternCount;
  977. PMHANDLE Pool;
  978. PPATTERNPROPSA Pattern;
  979. } PARSEDPATTERNA, *PPARSEDPATTERNA;
  980. typedef struct {
  981. UINT Type;
  982. union {
  983. // exact match
  984. struct {
  985. PCWSTR LowerCasePhrase;
  986. UINT PhraseBytes;
  987. } Exact;
  988. // wildcard
  989. struct {
  990. UINT MaxLen; // zero if any length
  991. PCWSTR IncludeSet; OPTIONAL
  992. PCWSTR ExcludeSet; OPTIONAL
  993. } Wildcard;
  994. };
  995. } SEGMENTW, *PSEGMENTW;
  996. typedef struct {
  997. UINT SegmentCount;
  998. PSEGMENTW Segment;
  999. } PATTERNPROPSW, *PPATTERNPROPSW;
  1000. typedef struct {
  1001. UINT PatternCount;
  1002. PMHANDLE Pool;
  1003. PPATTERNPROPSW Pattern;
  1004. } PARSEDPATTERNW, *PPARSEDPATTERNW;
  1005. BOOL
  1006. IsPatternMatchExA (
  1007. IN PCSTR Pattern,
  1008. IN PCSTR String
  1009. );
  1010. BOOL
  1011. IsPatternMatchExW (
  1012. IN PCWSTR Pattern,
  1013. IN PCWSTR String
  1014. );
  1015. BOOL
  1016. IsPatternMatchExABA (
  1017. IN PCSTR Pattern,
  1018. IN PCSTR Start,
  1019. IN PCSTR End
  1020. );
  1021. BOOL
  1022. IsPatternMatchExABW (
  1023. IN PCWSTR Pattern,
  1024. IN PCWSTR Start,
  1025. IN PCWSTR End
  1026. );
  1027. PPARSEDPATTERNA
  1028. ExplodeParsedPatternA (
  1029. IN PPARSEDPATTERNA Pattern
  1030. );
  1031. PPARSEDPATTERNW
  1032. ExplodeParsedPatternW (
  1033. IN PPARSEDPATTERNW Pattern
  1034. );
  1035. BOOL
  1036. IsPatternContainedExA (
  1037. IN PCSTR Container,
  1038. IN PCSTR Contained
  1039. );
  1040. BOOL
  1041. IsPatternContainedExW (
  1042. IN PCWSTR Container,
  1043. IN PCWSTR Contained
  1044. );
  1045. BOOL
  1046. IsParsedPatternContainedExA (
  1047. IN PPARSEDPATTERNA Container,
  1048. IN PPARSEDPATTERNA Contained
  1049. );
  1050. BOOL
  1051. IsParsedPatternContainedExW (
  1052. IN PPARSEDPATTERNW Container,
  1053. IN PPARSEDPATTERNW Contained
  1054. );
  1055. BOOL
  1056. IsExplodedParsedPatternContainedExA (
  1057. IN PPARSEDPATTERNA Container,
  1058. IN PPARSEDPATTERNA Contained
  1059. );
  1060. BOOL
  1061. IsExplodedParsedPatternContainedExW (
  1062. IN PPARSEDPATTERNW Container,
  1063. IN PPARSEDPATTERNW Contained
  1064. );
  1065. PPARSEDPATTERNA
  1066. CreateParsedPatternA (
  1067. IN PCSTR Pattern
  1068. );
  1069. PPARSEDPATTERNW
  1070. CreateParsedPatternW (
  1071. IN PCWSTR Pattern
  1072. );
  1073. BOOL
  1074. WildCharsPatternA (
  1075. IN PPARSEDPATTERNA ParsedPattern
  1076. );
  1077. BOOL
  1078. WildCharsPatternW (
  1079. IN PPARSEDPATTERNW ParsedPattern
  1080. );
  1081. BOOL
  1082. TestParsedPatternA (
  1083. IN PPARSEDPATTERNA ParsedPattern,
  1084. IN PCSTR StringToTest
  1085. );
  1086. BOOL
  1087. TestParsedPatternW (
  1088. IN PPARSEDPATTERNW ParsedPattern,
  1089. IN PCWSTR StringToTest
  1090. );
  1091. BOOL
  1092. TestParsedPatternABA (
  1093. IN PPARSEDPATTERNA ParsedPattern,
  1094. IN PCSTR StringToTest,
  1095. IN PCSTR EndPlusOne
  1096. );
  1097. BOOL
  1098. TestParsedPatternABW (
  1099. IN PPARSEDPATTERNW ParsedPattern,
  1100. IN PCWSTR StringToTest,
  1101. IN PCWSTR EndPlusOne
  1102. );
  1103. VOID
  1104. PrintPattern (
  1105. PCSTR Pattern,
  1106. PPARSEDPATTERNA Struct
  1107. );
  1108. VOID
  1109. DestroyParsedPatternA (
  1110. IN PPARSEDPATTERNA ParsedPattern
  1111. );
  1112. VOID
  1113. DestroyParsedPatternW (
  1114. IN PPARSEDPATTERNW ParsedPattern
  1115. );
  1116. VOID
  1117. DecodeParsedPatternA (
  1118. IN PPARSEDPATTERNA ParsedPattern
  1119. );
  1120. VOID
  1121. DecodeParsedPatternW (
  1122. IN PPARSEDPATTERNW ParsedPattern
  1123. );
  1124. BOOL
  1125. PatternIncludesPatternA (
  1126. IN PPARSEDPATTERNA IncludingPattern,
  1127. IN PPARSEDPATTERNA IncludedPattern
  1128. );
  1129. BOOL
  1130. PatternIncludesPatternW (
  1131. IN PPARSEDPATTERNW IncludingPattern,
  1132. IN PPARSEDPATTERNW IncludedPattern
  1133. );
  1134. VOID
  1135. GetParsedPatternMinMaxSizeA (
  1136. IN PPARSEDPATTERNA ParsedPattern,
  1137. OUT PDWORD MinSize,
  1138. OUT PDWORD MaxSize
  1139. );
  1140. VOID
  1141. GetParsedPatternMinMaxSizeW (
  1142. IN PPARSEDPATTERNW ParsedPattern,
  1143. OUT PDWORD MinSize,
  1144. OUT PDWORD MaxSize
  1145. );
  1146. __inline
  1147. BOOL
  1148. ParsedPatternIsExactMatchA (
  1149. IN PPARSEDPATTERNA ParsedPattern
  1150. )
  1151. {
  1152. return ParsedPattern->PatternCount == 1 &&
  1153. ParsedPattern->Pattern->SegmentCount == 1 &&
  1154. ParsedPattern->Pattern->Segment[0].Type == SEGMENTTYPE_EXACTMATCH;
  1155. }
  1156. __inline
  1157. BOOL
  1158. ParsedPatternIsExactMatchW (
  1159. IN PPARSEDPATTERNW ParsedPattern
  1160. )
  1161. {
  1162. return ParsedPattern->PatternCount == 1 &&
  1163. ParsedPattern->Pattern->SegmentCount == 1 &&
  1164. ParsedPattern->Pattern->Segment[0].Type == SEGMENTTYPE_EXACTMATCH;
  1165. }
  1166. __inline
  1167. BOOL
  1168. ParsedPatternSegmentIsPureOptionalA (
  1169. IN PSEGMENTA ParsedPatternSegment
  1170. )
  1171. {
  1172. return ParsedPatternSegment->Type == SEGMENTTYPE_OPTIONAL &&
  1173. ParsedPatternSegment->Wildcard.MaxLen == 0 &&
  1174. ParsedPatternSegment->Wildcard.IncludeSet == NULL &&
  1175. ParsedPatternSegment->Wildcard.ExcludeSet == NULL;
  1176. }
  1177. __inline
  1178. BOOL
  1179. ParsedPatternSegmentIsPureOptionalW (
  1180. IN PSEGMENTW ParsedPatternSegment
  1181. )
  1182. {
  1183. return ParsedPatternSegment->Type == SEGMENTTYPE_OPTIONAL &&
  1184. ParsedPatternSegment->Wildcard.MaxLen == 0 &&
  1185. ParsedPatternSegment->Wildcard.IncludeSet == NULL &&
  1186. ParsedPatternSegment->Wildcard.ExcludeSet == NULL;
  1187. }
  1188. __inline
  1189. BOOL
  1190. ParsedPatternIsOptionalA (
  1191. IN PPARSEDPATTERNA ParsedPattern
  1192. )
  1193. {
  1194. return ParsedPattern->PatternCount == 1 &&
  1195. ParsedPattern->Pattern->SegmentCount == 1 &&
  1196. ParsedPatternSegmentIsPureOptionalA (ParsedPattern->Pattern->Segment);
  1197. }
  1198. __inline
  1199. BOOL
  1200. ParsedPatternIsOptionalW (
  1201. IN PPARSEDPATTERNW ParsedPattern
  1202. )
  1203. {
  1204. return ParsedPattern->PatternCount == 1 &&
  1205. ParsedPattern->Pattern->SegmentCount == 1 &&
  1206. ParsedPatternSegmentIsPureOptionalW (ParsedPattern->Pattern->Segment);
  1207. }
  1208. __inline
  1209. BOOL
  1210. ParsedPatternIsRootPlusStarA (
  1211. IN PPARSEDPATTERNA ParsedPattern
  1212. )
  1213. {
  1214. return ParsedPattern->PatternCount == 1 &&
  1215. ParsedPattern->Pattern->SegmentCount == 2 &&
  1216. ParsedPattern->Pattern->Segment[0].Type == SEGMENTTYPE_EXACTMATCH &&
  1217. ParsedPatternSegmentIsPureOptionalA (ParsedPattern->Pattern->Segment + 1);
  1218. }
  1219. __inline
  1220. BOOL
  1221. ParsedPatternIsRootPlusStarW (
  1222. IN PPARSEDPATTERNW ParsedPattern
  1223. )
  1224. {
  1225. return ParsedPattern->PatternCount == 1 &&
  1226. ParsedPattern->Pattern->SegmentCount == 2 &&
  1227. ParsedPattern->Pattern->Segment[0].Type == SEGMENTTYPE_EXACTMATCH &&
  1228. ParsedPatternSegmentIsPureOptionalW (ParsedPattern->Pattern->Segment + 1);
  1229. }
  1230. __inline
  1231. BOOL
  1232. ParsedPatternHasRootA (
  1233. IN PPARSEDPATTERNA ParsedPattern
  1234. )
  1235. {
  1236. return ParsedPattern->PatternCount > 0 &&
  1237. ParsedPattern->Pattern->SegmentCount > 0 &&
  1238. ParsedPattern->Pattern->Segment[0].Type == SEGMENTTYPE_EXACTMATCH;
  1239. }
  1240. __inline
  1241. BOOL
  1242. ParsedPatternHasRootW (
  1243. IN PPARSEDPATTERNW ParsedPattern
  1244. )
  1245. {
  1246. return ParsedPattern->PatternCount > 0 &&
  1247. ParsedPattern->Pattern->SegmentCount > 0 &&
  1248. ParsedPattern->Pattern->Segment[0].Type == SEGMENTTYPE_EXACTMATCH;
  1249. }
  1250. __inline
  1251. PCSTR
  1252. ParsedPatternGetRootA (
  1253. IN PPARSEDPATTERNA ParsedPattern
  1254. )
  1255. {
  1256. if (!ParsedPatternHasRootA (ParsedPattern)) {
  1257. return NULL;
  1258. }
  1259. return ParsedPattern->Pattern->Segment[0].Exact.LowerCasePhrase;
  1260. }
  1261. __inline
  1262. PCWSTR
  1263. ParsedPatternGetRootW (
  1264. IN PPARSEDPATTERNW ParsedPattern
  1265. )
  1266. {
  1267. if (!ParsedPatternHasRootW (ParsedPattern)) {
  1268. return NULL;
  1269. }
  1270. return ParsedPattern->Pattern->Segment[0].Exact.LowerCasePhrase;
  1271. }
  1272. __inline
  1273. BOOL
  1274. ParsedPatternEndsWithStarA (
  1275. IN PPARSEDPATTERNA ParsedPattern
  1276. )
  1277. {
  1278. return ParsedPattern->PatternCount == 1 &&
  1279. ParsedPattern->Pattern->SegmentCount > 0 &&
  1280. ParsedPatternSegmentIsPureOptionalA (
  1281. ParsedPattern->Pattern->Segment + ParsedPattern->Pattern->SegmentCount - 1
  1282. );
  1283. }
  1284. __inline
  1285. BOOL
  1286. ParsedPatternEndsWithStarW (
  1287. IN PPARSEDPATTERNW ParsedPattern
  1288. )
  1289. {
  1290. return ParsedPattern->PatternCount == 1 &&
  1291. ParsedPattern->Pattern->SegmentCount > 0 &&
  1292. ParsedPatternSegmentIsPureOptionalW (
  1293. ParsedPattern->Pattern->Segment + ParsedPattern->Pattern->SegmentCount - 1
  1294. );
  1295. }
  1296. BOOL
  1297. ParsedPatternTrimLastCharA (
  1298. IN OUT PPARSEDPATTERNA ParsedPattern
  1299. );
  1300. BOOL
  1301. ParsedPatternTrimLastCharW (
  1302. IN OUT PPARSEDPATTERNW ParsedPattern
  1303. );
  1304. // Character counters
  1305. UINT CountInstancesOfCharA (PCSTR String, MBCHAR Char);
  1306. UINT CountInstancesOfCharW (PCWSTR String, WCHAR Char);
  1307. UINT CountInstancesOfCharIA (PCSTR String, MBCHAR Char);
  1308. UINT CountInstancesOfCharIW (PCWSTR String, WCHAR Char);
  1309. //
  1310. // Message Functions
  1311. //
  1312. // An AllocTable is an array of HLOCAL pointers that the message routines
  1313. // return. This table is maintained to allow a single function to clean up
  1314. // all strings at once.
  1315. //
  1316. // All "Ex" functions (ParseMessageEx, GetStringResourceEx, and so on)
  1317. // require a valid AllocTable pointer. A caller obtains this pointer by
  1318. // calling CreateAllocTable before processing any message. The caller
  1319. // cleans up the entire table by calling DestroyAllocTable.
  1320. //
  1321. // A set of macros can be used for short-term strings. ParseMessage and
  1322. // GetStringResource work the same as their Ex counterparts, but operate
  1323. // on the process-wide g_ShortTermAllocTable. Short-term strings are
  1324. // freed with FreeStringResource.
  1325. //
  1326. // A routine that calls ParseMessage and/or GetStringResource several times
  1327. // in the same function wrap the calls between BeginMessageProcessing and
  1328. // EndMessageProcessing. Only one thread in the process can do this at a
  1329. // time, and when EndMessageProcessing is called, all strings allocated
  1330. // by ParseMessage or GetResourceString in the processing section are
  1331. // automatically freed.
  1332. //
  1333. // AllocTable creation/deletion
  1334. PGROWBUFFER RealCreateAllocTable (VOID);
  1335. #define CreateAllocTable() TRACK_BEGIN(PGROWBUFFER, CreateAllocTable)\
  1336. RealCreateAllocTable()\
  1337. TRACK_END()
  1338. VOID DestroyAllocTable (PGROWBUFFER AllocTable);
  1339. // The "Ex" functions
  1340. // ParseMessageEx retrieves the string resource via FormatMessage
  1341. PCSTR ParseMessageExA (PGROWBUFFER AllocTable, PCSTR Template, PCSTR ArgArray[]);
  1342. PCWSTR ParseMessageExW (PGROWBUFFER AllocTable, PCWSTR Template, PCWSTR ArgArray[]);
  1343. // GetStringResourceEx retrives an argument-less string resource
  1344. PCSTR GetStringResourceExA (PGROWBUFFER AllocTable, UINT ID);
  1345. PCWSTR GetStringResourceExW (PGROWBUFFER AllocTable, UINT ID);
  1346. // Frees resources allocated by ParseMessageEx, GetStringResourceEx and all macros
  1347. VOID FreeStringResourceExA (PGROWBUFFER AllocTable, PCSTR String);
  1348. VOID FreeStringResourceExW (PGROWBUFFER AllocTable, PCWSTR String);
  1349. // Frees resources allocated by ParseMessageEx, GetStringResourceEx and all macros.
  1350. // Tests String first; nulls when freed.
  1351. VOID FreeStringResourcePtrExA (PGROWBUFFER AllocTable, PCSTR * String);
  1352. VOID FreeStringResourcePtrExW (PGROWBUFFER AllocTable, PCWSTR * String);
  1353. // Macros
  1354. extern PGROWBUFFER g_ShortTermAllocTable;
  1355. #define ParseMessageA(strid,args) ParseMessageExA(g_ShortTermAllocTable, strid, args)
  1356. #define ParseMessageW(strid,args) ParseMessageExW(g_ShortTermAllocTable, strid, args)
  1357. #define ParseMessageIDA(id,args) ParseMessageExA(g_ShortTermAllocTable, (PCSTR) (id), args)
  1358. #define ParseMessageIDW(id,args) ParseMessageExW(g_ShortTermAllocTable, (PCWSTR) (id), args)
  1359. #define ParseMessageIDExA(table,id,args) ParseMessageExA(table, (PCSTR) (id), args)
  1360. #define ParseMessageIDExW(table,id,args) ParseMessageExW(table, (PCWSTR) (id), args)
  1361. #define GetStringResourceA(id) GetStringResourceExA(g_ShortTermAllocTable, id)
  1362. #define GetStringResourceW(id) GetStringResourceExW(g_ShortTermAllocTable, id)
  1363. #define FreeStringResourceA(str) FreeStringResourceExA(g_ShortTermAllocTable, str)
  1364. #define FreeStringResourceW(str) FreeStringResourceExW(g_ShortTermAllocTable, str)
  1365. #define FreeStringResourcePtrA(str) FreeStringResourcePtrExA(g_ShortTermAllocTable, str)
  1366. #define FreeStringResourcePtrW(str) FreeStringResourcePtrExW(g_ShortTermAllocTable, str)
  1367. // Functions for single-threaded message-intensive processing loops
  1368. BOOL BeginMessageProcessing (VOID);
  1369. VOID EndMessageProcessing (VOID);
  1370. //
  1371. // The following message functions do not return strings, so they do not
  1372. // need cleanup.
  1373. //
  1374. // An odd variant--obtains message ID from a window's text and replaces
  1375. // it with the actual message. Useful in dialog box initialization.
  1376. VOID ParseMessageInWndA (HWND hwnd, PCSTR ArgArray[]);
  1377. VOID ParseMessageInWndW (HWND hwnd, PCWSTR ArgArray[]);
  1378. // Displays a message box using a message string
  1379. INT ResourceMessageBoxA (HWND hwndOwner, UINT ID, UINT Flags, PCSTR ArgArray[]);
  1380. INT ResourceMessageBoxW (HWND hwndOwner, UINT ID, UINT Flags, PCWSTR ArgArray[]);
  1381. //
  1382. // Functions that don't care about UNICODE or MBCS
  1383. // and realy shouldn't be in strings.h/.c
  1384. //
  1385. // Pushes dwError on a global error stack
  1386. void PushNewError (DWORD dwError);
  1387. // Pushes the return of GetLastError() on a global error stack
  1388. void PushError (void);
  1389. // Pops the last error from the global error stack, calls SetLastError
  1390. // and returns the popped error code.
  1391. DWORD PopError (void);
  1392. // Returns an int value for chars 0-9, a-f, A-F, and -1 for all others
  1393. int GetHexDigit (IN int c);
  1394. //
  1395. // Inline functions
  1396. //
  1397. // Returns the character at str[pos]
  1398. __inline MBCHAR _mbsgetc(PCSTR str, DWORD pos) {
  1399. return (MBCHAR) _mbsnextc(CharCountToPointerA ((PSTR) str, pos));
  1400. }
  1401. __inline WCHAR _wcsgetc(PCWSTR str, DWORD pos) {
  1402. return *CharCountToPointerW ((PWSTR) str, pos);
  1403. }
  1404. // Sets the character at str[pos]
  1405. // Multibyte version may grow string by one byte.
  1406. __inline void _mbssetc(PSTR str, DWORD pos, MBCHAR c) {
  1407. _setmbchar (CharCountToPointerA (str, pos), c);
  1408. }
  1409. __inline void _wcssetc(PWSTR str, DWORD pos, WCHAR c) {
  1410. *CharCountToPointerW (str, pos) = c;
  1411. }
  1412. // Bug fix for C Runtime _tcsdec
  1413. __inline PWSTR _wcsdec2(PCWSTR base, PCWSTR p) {
  1414. if (base >= p) {
  1415. return NULL;
  1416. }
  1417. return (PWSTR) (p-1);
  1418. }
  1419. // Bug fix for C Runtime _tcsdec
  1420. __inline PSTR _mbsdec2(PCSTR base, PCSTR p) {
  1421. if (base >= p) {
  1422. return NULL;
  1423. }
  1424. return _mbsdec(base,p);
  1425. }
  1426. // Routine that checks string for a prefix
  1427. #define _mbsprefixcmp(str,prefix) _mbsncmp(str,prefix,_mbslen(prefix))
  1428. #define _mbsprefixicmp(str,prefix) _mbsnicmp(str,prefix,_mbslen(prefix))
  1429. #define _wcsprefixcmp(str,prefix) _wcsncmp(str,prefix,_mbslen(prefix))
  1430. #define _wcsprefixicmp(str,prefix) _wcsnicmp(str,prefix,_mbslen(prefix))
  1431. //
  1432. // Sub String Replacement functions.
  1433. //
  1434. BOOL StringReplaceW (PWSTR Buffer,DWORD MaxSize,PWSTR ReplaceStartPos,PWSTR ReplaceEndPos,PCWSTR NewString);
  1435. BOOL StringReplaceA (PSTR Buffer,DWORD MaxSize,PSTR ReplaceStartPos,PSTR ReplaceEndPos,PCSTR NewString);
  1436. //
  1437. // String table population from INF section
  1438. //
  1439. typedef enum {
  1440. CALLBACK_CONTINUE,
  1441. CALLBACK_SKIP,
  1442. CALLBACK_STOP
  1443. } CALLBACK_RESULT;
  1444. typedef CALLBACK_RESULT(ADDINFSECTION_PROTOTYPEA)(PCSTR String, PVOID * DataPtr,
  1445. UINT * DataSizePtr, PVOID CallbackData);
  1446. typedef CALLBACK_RESULT(ADDINFSECTION_PROTOTYPEW)(PCWSTR String, PVOID * DataPtr,
  1447. UINT * DataSizePtr, PVOID CallbackData);
  1448. typedef ADDINFSECTION_PROTOTYPEA * ADDINFSECTION_PROCA;
  1449. typedef ADDINFSECTION_PROTOTYPEW * ADDINFSECTION_PROCW;
  1450. BOOL AddInfSectionToHashTableA (PVOID, HINF, PCSTR, DWORD, ADDINFSECTION_PROCA, PVOID);
  1451. BOOL AddInfSectionToHashTableW (PVOID, HINF, PCWSTR, DWORD, ADDINFSECTION_PROCW, PVOID);
  1452. UINT
  1453. CountInstancesOfSubStringA (
  1454. IN PCSTR SourceString,
  1455. IN PCSTR SearchString
  1456. );
  1457. UINT
  1458. CountInstancesOfSubStringW (
  1459. IN PCWSTR SourceString,
  1460. IN PCWSTR SearchString
  1461. );
  1462. PCSTR
  1463. StringSearchAndReplaceA (
  1464. IN PCSTR SourceString,
  1465. IN PCSTR SearchString,
  1466. IN PCSTR ReplaceString
  1467. );
  1468. PCWSTR
  1469. StringSearchAndReplaceW (
  1470. IN PCWSTR SourceString,
  1471. IN PCWSTR SearchString,
  1472. IN PCWSTR ReplaceString
  1473. );
  1474. typedef struct _MULTISZ_ENUMA {
  1475. PCSTR Buffer;
  1476. PCSTR CurrentString;
  1477. } MULTISZ_ENUMA, *PMULTISZ_ENUMA;
  1478. typedef struct _MULTISZ_ENUMW {
  1479. PCWSTR Buffer;
  1480. PCWSTR CurrentString;
  1481. } MULTISZ_ENUMW, *PMULTISZ_ENUMW;
  1482. BOOL
  1483. EnumNextMultiSzA (
  1484. IN OUT PMULTISZ_ENUMA MultiSzEnum
  1485. );
  1486. BOOL
  1487. EnumNextMultiSzW (
  1488. IN OUT PMULTISZ_ENUMW MultiSzEnum
  1489. );
  1490. BOOL
  1491. EnumFirstMultiSzA (
  1492. OUT PMULTISZ_ENUMA MultiSzEnum,
  1493. IN PCSTR MultiSzStr
  1494. );
  1495. BOOL
  1496. EnumFirstMultiSzW (
  1497. OUT PMULTISZ_ENUMW MultiSzEnum,
  1498. IN PCWSTR MultiSzStr
  1499. );
  1500. VOID
  1501. ToggleWacksW (
  1502. IN OUT PWSTR String,
  1503. IN BOOL Operation
  1504. );
  1505. VOID
  1506. ToggleWacksA (
  1507. IN OUT PSTR String,
  1508. IN BOOL Operation
  1509. );
  1510. PCSTR
  1511. SanitizePathA (
  1512. IN PCSTR FileSpec
  1513. );
  1514. PCWSTR
  1515. SanitizePathW (
  1516. IN PCWSTR FileSpec
  1517. );
  1518. PCSTR
  1519. ConvertSBtoDB (
  1520. PCSTR RootPath,
  1521. PCSTR FullPath,
  1522. PCSTR Limit
  1523. );
  1524. ULONGLONG
  1525. StringToUint64A (
  1526. IN PCSTR String,
  1527. OUT PCSTR *EndOfNumber OPTIONAL
  1528. );
  1529. #define AToU64(str) StringToUint64A(str,NULL)
  1530. ULONGLONG
  1531. StringToUint64W (
  1532. IN PCWSTR String,
  1533. OUT PCWSTR *EndOfNumber OPTIONAL
  1534. );
  1535. #define WToU64(str) StringToUint64W(str,NULL)
  1536. LONGLONG
  1537. StringToInt64A (
  1538. IN PCSTR String,
  1539. OUT PCSTR *EndOfNumber OPTIONAL
  1540. );
  1541. #define AToI64(str) StringToInt64A(str,NULL)
  1542. LONGLONG
  1543. StringToInt64W (
  1544. IN PCWSTR String,
  1545. OUT PCWSTR *EndOfNumber OPTIONAL
  1546. );
  1547. #define WToI64(str) StringToInt64W(str,NULL)
  1548. //
  1549. // TCHAR mappings
  1550. //
  1551. #ifdef UNICODE
  1552. #define EscapedChars EscapedCharsW
  1553. #define CharCount CharCountW
  1554. #define CharCountToPointer CharCountToPointerW
  1555. #define CharCountAB CharCountABW
  1556. #define CharCountInByteRange CharCountInByteRangeW
  1557. #define CharCountToBytes CharCountToBytesW
  1558. #define CharCountToTchars CharCountToTcharsW
  1559. #define ByteCount ByteCountW
  1560. #define SizeOfString SizeOfStringW
  1561. #define SizeOfMultiSz SizeOfMultiSzW
  1562. #define MultiSzSizeInChars MultiSzSizeInCharsW
  1563. #define ByteCountToPointer ByteCountToPointerW
  1564. #define ByteCountAB ByteCountABW
  1565. #define ByteCountToChars ByteCountToCharsW
  1566. #define ByteCountToTchars ByteCountToTcharsW
  1567. #define TcharCount TcharCountW
  1568. #define TcharCountToPointer TcharCountToPointerW
  1569. #define TcharCountAB TcharCountABW
  1570. #define TcharCountToChars TcharCountToCharsW
  1571. #define TcharCountToBytes TcharCountToBytesW
  1572. #define StackStringCopy StackStringCopyW
  1573. #define StringCompare StringCompareW
  1574. #define StringMatch StringMatchW
  1575. #define StringICompare StringICompareW
  1576. #define StringIMatch StringIMatchW
  1577. #define StringCompareByteCount StringCompareByteCountW
  1578. #define StringMatchByteCount StringMatchByteCountW
  1579. #define StringICompareByteCount StringICompareByteCountW
  1580. #define StringIMatchByteCount StringIMatchByteCountW
  1581. #define StringCompareCharCount StringCompareCharCountW
  1582. #define StringMatchCharCount StringMatchCharCountW
  1583. #define StringICompareCharCount StringICompareCharCountW
  1584. #define StringIMatchCharCount StringIMatchCharCountW
  1585. #define StringCompareTcharCount StringCompareTcharCountW
  1586. #define StringMatchTcharCount StringMatchTcharCountW
  1587. #define StringICompareTcharCount StringICompareTcharCountW
  1588. #define StringIMatchTcharCount StringIMatchTcharCountW
  1589. #define StringCompareAB StringCompareABW
  1590. #define StringMatchAB StringMatchABW
  1591. #define StringICompareAB StringICompareABW
  1592. #define StringIMatchAB StringIMatchABW
  1593. #define StringCopy StringCopyW
  1594. #define StringCopyByteCount StringCopyByteCountW
  1595. #define StringCopyCharCount StringCopyCharCountW
  1596. #define StringCopyTcharCount StringCopyTcharCountW
  1597. #define StringCopyAB StringCopyABW
  1598. #define StringCat StringCatW
  1599. #define GetEndOfString GetEndOfStringW
  1600. #define GetPrevChar GetPrevCharW
  1601. #define AllocTextEx AllocTextExW
  1602. #define AllocText AllocTextW
  1603. #define FreeTextEx FreeTextExW
  1604. #define FreeText FreeTextW
  1605. #define DuplicateText DuplicateTextW
  1606. #define DuplicateTextEx DuplicateTextExW
  1607. #define JoinTextEx JoinTextExW
  1608. #define JoinText JoinTextW
  1609. #define ExpandEnvironmentText ExpandEnvironmentTextW
  1610. #define ExpandEnvironmentTextEx ExpandEnvironmentTextExW
  1611. #define CommandLineToArgv CommandLineToArgvW
  1612. #define _tcsdec2 _wcsdec2
  1613. #define _copytchar _copywchar
  1614. #define _settchar _setwchar
  1615. #define _tcsgetc _wcsgetc
  1616. #define _tcssetc _wcssetc
  1617. #define _tcsnum _wcsnum
  1618. #define _tcsappend _wcsappend
  1619. #define _tcsistr _wcsistr
  1620. #define _tcsisprint _wcsisprint
  1621. #define _tcsnzcpy _wcsnzcpy
  1622. #define _tcssafecpy _wcssafecpy
  1623. #define _tcsnzcpyab _wcsnzcpyab
  1624. #define _tcssafecpyab _wcssafecpyab
  1625. #define _tcsprefixcmp _wcsprefixcmp
  1626. #define _tcsprefixicmp _wcsprefixicmp
  1627. #define _tcsctrim _wcsctrim
  1628. #define AppendWack AppendWackW
  1629. #define AppendDosWack AppendDosWackW
  1630. #define AppendUncWack AppendUncWackW
  1631. #define AppendPathWack AppendPathWackW
  1632. #define RemoveWackAtEnd RemoveWackAtEndW
  1633. #define JoinPaths JoinPathsW
  1634. #define JoinPathsInPoolEx JoinPathsInPoolExW
  1635. #define JoinPathsEx JoinPathsExW
  1636. #define BuildPathInPool BuildPathInPoolW
  1637. #define BuildPath BuildPathW
  1638. #define BuildPathEx BuildPathExW
  1639. #define AllocPathString AllocPathStringW
  1640. #define SplitPath SplitPathW
  1641. #define GetFileNameFromPath GetFileNameFromPathW
  1642. #define GetFileExtensionFromPath GetFileExtensionFromPathW
  1643. #define GetDotExtensionFromPath GetDotExtensionFromPathW
  1644. #define DuplicatePathString DuplicatePathStringW
  1645. #define FreePathStringEx FreePathStringExW
  1646. #define FreePathString FreePathStringW
  1647. #define FindLastWack FindLastWackW
  1648. #define GetNodePatternMinMaxLevels GetNodePatternMinMaxLevelsW
  1649. #define GetNextRuleChar GetNextRuleCharW
  1650. #define DecodeRuleChars DecodeRuleCharsW
  1651. #define DecodeRuleCharsAB DecodeRuleCharsABW
  1652. #define EncodeRuleChars EncodeRuleCharsW
  1653. #define SkipSpace SkipSpaceW
  1654. #define SkipSpaceR SkipSpaceRW
  1655. #define TruncateTrailingSpace TruncateTrailingSpaceW
  1656. #define IsPatternMatch IsPatternMatchW
  1657. #define IsPatternMatchAB IsPatternMatchABW
  1658. #define IsPatternContained IsPatternContainedW
  1659. #define PPARSEDPATTERN PPARSEDPATTERNW
  1660. #define PARSEDPATTERN PARSEDPATTERNW
  1661. #define CreateParsedPattern CreateParsedPatternW
  1662. #define WildCharsPattern WildCharsPatternW
  1663. #define IsPatternMatchEx IsPatternMatchExW
  1664. #define IsPatternMatchExAB IsPatternMatchExABW
  1665. #define ExplodeParsedPattern ExplodeParsedPatternW
  1666. #define IsPatternContainedEx IsPatternContainedExW
  1667. #define IsParsedPatternContainedEx IsParsedPatternContainedExW
  1668. #define IsExplodedParsedPatternContainedEx IsExplodedParsedPatternContainedExW
  1669. #define TestParsedPattern TestParsedPatternW
  1670. #define TestParsedPatternAB TestParsedPatternABW
  1671. #define DestroyParsedPattern DestroyParsedPatternW
  1672. #define DestroyParsedPattern DestroyParsedPatternW
  1673. #define DecodeParsedPattern DecodeParsedPatternW
  1674. #define PatternIncludesPattern PatternIncludesPatternW
  1675. #define GetParsedPatternMinMaxSize GetParsedPatternMinMaxSizeW
  1676. #define ParsedPatternIsExactMatch ParsedPatternIsExactMatchW
  1677. #define ParsedPatternIsOptional ParsedPatternIsOptionalW
  1678. #define ParsedPatternIsRootPlusStar ParsedPatternIsRootPlusStarW
  1679. #define ParsedPatternHasRoot ParsedPatternHasRootW
  1680. #define ParsedPatternGetRoot ParsedPatternGetRootW
  1681. #define ParsedPatternSegmentIsPureOptional ParsedPatternSegmentIsPureOptionalW
  1682. #define ParsedPatternEndsWithStar ParsedPatternEndsWithStarW
  1683. #define ParsedPatternTrimLastChar ParsedPatternTrimLastCharW
  1684. #define CountInstancesOfChar CountInstancesOfCharW
  1685. #define CountInstancesOfCharI CountInstancesOfCharIW
  1686. #define StringReplace StringReplaceW
  1687. #define CountInstancesOfSubString CountInstancesOfSubStringW
  1688. #define StringSearchAndReplace StringSearchAndReplaceW
  1689. #define MULTISZ_ENUM MULTISZ_ENUMW
  1690. #define EnumFirstMultiSz EnumFirstMultiSzW
  1691. #define EnumNextMultiSz EnumNextMultiSzW
  1692. #define ParseMessage ParseMessageW
  1693. #define ParseMessageEx ParseMessageExW
  1694. #define ParseMessageID ParseMessageIDW
  1695. #define ParseMessageIDEx ParseMessageIDExW
  1696. #define GetStringResource GetStringResourceW
  1697. #define GetStringResourceEx GetStringResourceExW
  1698. #define FreeStringResource FreeStringResourceW
  1699. #define ParseMessageInWnd ParseMessageInWndW
  1700. #define ResourceMessageBox ResourceMessageBoxW
  1701. #define AddInfSectionToHashTable AddInfSectionToHashTableW
  1702. #define ADDINFSECTION_PROC ADDINFSECTION_PROCW
  1703. #define ReplaceWacks(f) ToggleWacksW(f,FALSE)
  1704. #define RestoreWacks(f) ToggleWacksW(f,TRUE)
  1705. #define SanitizePath SanitizePathW
  1706. #define StringToUint64 StringToUint64W
  1707. #define TToU64 WToU64
  1708. #define StringToInt64 StringToInt64W
  1709. #define TToI64 WToI64
  1710. #else
  1711. #define EscapedChars EscapedCharsA
  1712. #define CharCount CharCountA
  1713. #define CharCountToPointer CharCountToPointerA
  1714. #define CharCountAB CharCountABA
  1715. #define CharCountInByteRange CharCountInByteRangeA
  1716. #define CharCountToBytes CharCountToBytesA
  1717. #define CharCountToTchars CharCountToTcharsA
  1718. #define ByteCount ByteCountA
  1719. #define SizeOfString SizeOfStringA
  1720. #define SizeOfMultiSz SizeOfMultiSzA
  1721. #define MultiSzSizeInChars MultiSzSizeInCharsA
  1722. #define ByteCountToPointer ByteCountToPointerA
  1723. #define ByteCountAB ByteCountABA
  1724. #define ByteCountToChars ByteCountToCharsA
  1725. #define ByteCountToTchars ByteCountToTcharsA
  1726. #define TcharCount TcharCountA
  1727. #define TcharCountToPointer TcharCountToPointerA
  1728. #define TcharCountAB TcharCountABA
  1729. #define TcharCountToChars TcharCountToCharsA
  1730. #define TcharCountToBytes TcharCountToBytesA
  1731. #define StackStringCopy StackStringCopyA
  1732. #define StringCompare StringCompareA
  1733. #define StringMatch StringMatchA
  1734. #define StringICompare StringICompareA
  1735. #define StringIMatch StringIMatchA
  1736. #define StringCompareByteCount StringCompareByteCountA
  1737. #define StringMatchByteCount StringMatchByteCountA
  1738. #define StringICompareByteCount StringICompareByteCountA
  1739. #define StringIMatchByteCount StringIMatchByteCountA
  1740. #define StringCompareCharCount StringCompareCharCountA
  1741. #define StringMatchCharCount StringMatchCharCountA
  1742. #define StringICompareCharCount StringICompareCharCountA
  1743. #define StringIMatchCharCount StringIMatchCharCountA
  1744. #define StringCompareTcharCount StringCompareTcharCountA
  1745. #define StringMatchTcharCount StringMatchTcharCountA
  1746. #define StringICompareTcharCount StringICompareTcharCountA
  1747. #define StringIMatchTcharCount StringIMatchTcharCountA
  1748. #define StringCompareAB StringCompareABA
  1749. #define StringMatchAB StringMatchABA
  1750. #define StringICompareAB StringICompareABA
  1751. #define StringIMatchAB StringIMatchABA
  1752. #define StringCopy StringCopyA
  1753. #define StringCopyByteCount StringCopyByteCountA
  1754. #define StringCopyCharCount StringCopyCharCountA
  1755. #define StringCopyTcharCount StringCopyTcharCountA
  1756. #define StringCopyAB StringCopyABA
  1757. #define StringCat StringCatA
  1758. #define GetEndOfString GetEndOfStringA
  1759. #define GetPrevChar GetPrevCharA
  1760. #define AllocTextEx AllocTextExA
  1761. #define AllocText AllocTextA
  1762. #define FreeTextEx FreeTextExA
  1763. #define FreeText FreeTextA
  1764. #define DuplicateText DuplicateTextA
  1765. #define DuplicateTextEx DuplicateTextExA
  1766. #define JoinTextEx JoinTextExA
  1767. #define JoinText JoinTextA
  1768. #define ExpandEnvironmentText ExpandEnvironmentTextA
  1769. #define ExpandEnvironmentTextEx ExpandEnvironmentTextExA
  1770. #define CommandLineToArgv CommandLineToArgvA
  1771. #define _tcsdec2 _mbsdec2
  1772. #define _copytchar _copymbchar
  1773. #define _settchar _setmbchar
  1774. #define _tcsgetc _mbsgetc
  1775. #define _tcssetc _mbssetc
  1776. #define _tcsnum _mbsnum
  1777. #define _tcsappend _mbsappend
  1778. #define _tcsistr _mbsistr
  1779. #define _tcsisprint _mbsisprint
  1780. #define _tcsnzcpy _mbsnzcpy
  1781. #define _tcssafecpy _mbssafecpy
  1782. #define _tcsnzcpyab _mbsnzcpyab
  1783. #define _tcssafecpyab _mbssafecpyab
  1784. #define _tcsprefixcmp _mbsprefixcmp
  1785. #define _tcsprefixicmp _mbsprefixicmp
  1786. #define _tcsctrim _mbsctrim
  1787. #define AppendWack AppendWackA
  1788. #define AppendDosWack AppendDosWackA
  1789. #define AppendUncWack AppendUncWackA
  1790. #define AppendPathWack AppendPathWackA
  1791. #define RemoveWackAtEnd RemoveWackAtEndA
  1792. #define JoinPaths JoinPathsA
  1793. #define JoinPathsInPoolEx JoinPathsInPoolExA
  1794. #define JoinPathsEx JoinPathsExA
  1795. #define BuildPathInPool BuildPathInPoolA
  1796. #define BuildPath BuildPathA
  1797. #define BuildPathEx BuildPathExA
  1798. #define AllocPathString AllocPathStringA
  1799. #define SplitPath SplitPathA
  1800. #define GetFileNameFromPath GetFileNameFromPathA
  1801. #define GetFileExtensionFromPath GetFileExtensionFromPathA
  1802. #define GetDotExtensionFromPath GetDotExtensionFromPathA
  1803. #define DuplicatePathString DuplicatePathStringA
  1804. #define FindLastWack FindLastWackA
  1805. #define GetNodePatternMinMaxLevels GetNodePatternMinMaxLevelsA
  1806. #define PATH_ENUM PATH_ENUMA
  1807. #define PPATH_ENUM PPATH_ENUMA
  1808. #define EnumFirstPathEx EnumFirstPathExA
  1809. #define EnumFirstPath EnumFirstPathA
  1810. #define EnumNextPath EnumNextPathA
  1811. #define EnumPathAbort EnumPathAbortA
  1812. #define FreePathStringEx FreePathStringExA
  1813. #define FreePathString FreePathStringA
  1814. #define GetNextRuleChar GetNextRuleCharA
  1815. #define DecodeRuleChars DecodeRuleCharsA
  1816. #define DecodeRuleCharsAB DecodeRuleCharsABA
  1817. #define EncodeRuleChars EncodeRuleCharsA
  1818. #define SkipSpace SkipSpaceA
  1819. #define SkipSpaceR SkipSpaceRA
  1820. #define TruncateTrailingSpace TruncateTrailingSpaceA
  1821. #define IsPatternMatch IsPatternMatchA
  1822. #define IsPatternMatchAB IsPatternMatchABA
  1823. #define IsPatternContained IsPatternContainedA
  1824. #define PPARSEDPATTERN PPARSEDPATTERNA
  1825. #define PARSEDPATTERN PARSEDPATTERNA
  1826. #define CreateParsedPattern CreateParsedPatternA
  1827. #define WildCharsPattern WildCharsPatternA
  1828. #define IsPatternMatchEx IsPatternMatchExA
  1829. #define IsPatternMatchExAB IsPatternMatchExABA
  1830. #define ExplodeParsedPattern ExplodeParsedPatternA
  1831. #define IsPatternContainedEx IsPatternContainedExA
  1832. #define IsParsedPatternContainedEx IsParsedPatternContainedExA
  1833. #define IsExplodedParsedPatternContainedEx IsExplodedParsedPatternContainedExA
  1834. #define TestParsedPattern TestParsedPatternA
  1835. #define TestParsedPatternAB TestParsedPatternABA
  1836. #define DestroyParsedPattern DestroyParsedPatternA
  1837. #define DecodeParsedPattern DecodeParsedPatternA
  1838. #define PatternIncludesPattern PatternIncludesPatternA
  1839. #define GetParsedPatternMinMaxSize GetParsedPatternMinMaxSizeA
  1840. #define ParsedPatternIsExactMatch ParsedPatternIsExactMatchA
  1841. #define ParsedPatternIsOptional ParsedPatternIsOptionalA
  1842. #define ParsedPatternIsRootPlusStar ParsedPatternIsRootPlusStarA
  1843. #define ParsedPatternHasRoot ParsedPatternHasRootA
  1844. #define ParsedPatternGetRoot ParsedPatternGetRootA
  1845. #define ParsedPatternSegmentIsPureOptional ParsedPatternSegmentIsPureOptionalA
  1846. #define ParsedPatternEndsWithStar ParsedPatternEndsWithStarA
  1847. #define ParsedPatternTrimLastChar ParsedPatternTrimLastCharA
  1848. #define CountInstancesOfChar CountInstancesOfCharA
  1849. #define CountInstancesOfCharI CountInstancesOfCharIA
  1850. #define StringReplace StringReplaceA
  1851. #define CountInstancesOfSubString CountInstancesOfSubStringA
  1852. #define StringSearchAndReplace StringSearchAndReplaceA
  1853. #define MULTISZ_ENUM MULTISZ_ENUMA
  1854. #define EnumFirstMultiSz EnumFirstMultiSzA
  1855. #define EnumNextMultiSz EnumNextMultiSzA
  1856. #define ParseMessage ParseMessageA
  1857. #define ParseMessageEx ParseMessageExA
  1858. #define ParseMessageID ParseMessageIDA
  1859. #define ParseMessageIDEx ParseMessageIDExA
  1860. #define GetStringResource GetStringResourceA
  1861. #define GetStringResourceEx GetStringResourceExA
  1862. #define FreeStringResource FreeStringResourceA
  1863. #define ParseMessageInWnd ParseMessageInWndA
  1864. #define ResourceMessageBox ResourceMessageBoxA
  1865. #define AddInfSectionToHashTable AddInfSectionToHashTableA
  1866. #define ADDINFSECTION_PROC ADDINFSECTION_PROCA
  1867. #define ReplaceWacks(f) ToggleWacksA(f,FALSE)
  1868. #define RestoreWacks(f) ToggleWacksA(f,TRUE)
  1869. #define SanitizePath SanitizePathA
  1870. #define StringToUint64 StringToUint64A
  1871. #define TToU64 AToU64
  1872. #define StringToInt64 StringToInt64A
  1873. #define TToI64 AToI64
  1874. #endif
  1875. //
  1876. // MessageBox macros
  1877. //
  1878. #define YesNoBox(hwnd,ID) ResourceMessageBox(hwnd,ID,MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND,NULL)
  1879. #define YesNoCancelBox(hwnd,ID) ResourceMessageBox(hwnd,ID,MB_YESNOCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND,NULL)
  1880. #define OkBox(hwnd,ID) ResourceMessageBox(hwnd,ID,MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND,NULL)
  1881. #define OkCancelBox(hwnd,ID) ResourceMessageBox(hwnd,ID,MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND,NULL)
  1882. #define RetryCancelBox(hwnd,ID) ResourceMessageBox(hwnd,ID,MB_RETRYCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND,NULL)