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.

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