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.

455 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mbstr.hxx
  5. Abstract:
  6. This module contains the definition of the MBSTR class. The MBSTR
  7. class is a module that provides static methods for operating on
  8. multibyte strings.
  9. Author:
  10. Ramon J. San Andres (ramonsa) 21-Feb-1992
  11. Environment:
  12. ULIB, User Mode
  13. Notes:
  14. --*/
  15. #if ! defined( _MBSTR_ )
  16. #define _MBSTR_
  17. extern "C" {
  18. #include <stdarg.h>
  19. #include <string.h>
  20. #include <memory.h>
  21. }
  22. DECLARE_CLASS( MBSTR );
  23. class MBSTR {
  24. public:
  25. STATIC
  26. PVOID
  27. Memcpy (
  28. INOUT PVOID Src,
  29. INOUT PVOID Dst,
  30. IN DWORD Size
  31. );
  32. STATIC
  33. PVOID
  34. Memset (
  35. INOUT PVOID Src,
  36. IN BYTE Byte,
  37. IN DWORD Size
  38. );
  39. STATIC
  40. PSTR
  41. Strcat (
  42. INOUT PSTR String1,
  43. IN PSTR String2
  44. );
  45. STATIC
  46. PSTR
  47. Strchr (
  48. IN PSTR String,
  49. IN CHAR Char
  50. );
  51. STATIC
  52. INT
  53. Strcmp (
  54. IN PSTR String1,
  55. IN PSTR String2
  56. );
  57. #ifdef FE_SB
  58. //fix kksuzuka: #931
  59. //enabling DBCS with stricmp
  60. STATIC
  61. ULIB_EXPORT
  62. INT
  63. Stricmp (
  64. IN PSTR p1,
  65. IN PSTR p2
  66. );
  67. #else
  68. STATIC
  69. INT
  70. Stricmp (
  71. IN PSTR String1,
  72. IN PSTR String2
  73. );
  74. #endif
  75. STATIC
  76. ULIB_EXPORT
  77. INT
  78. Strcmps (
  79. IN PSTR p1,
  80. IN PSTR p2
  81. );
  82. STATIC
  83. ULIB_EXPORT
  84. INT
  85. Strcmpis (
  86. IN PSTR p1,
  87. IN PSTR p2
  88. );
  89. STATIC
  90. PSTR
  91. Strcpy (
  92. INOUT PSTR String1,
  93. IN PSTR String2
  94. );
  95. STATIC
  96. DWORD
  97. Strcspn (
  98. IN PSTR String1,
  99. IN PSTR String2
  100. );
  101. STATIC
  102. PSTR
  103. Strdup (
  104. IN PSTR String
  105. );
  106. STATIC
  107. DWORD
  108. Strlen (
  109. IN PSTR String
  110. );
  111. STATIC
  112. PSTR
  113. Strlwr (
  114. INOUT PSTR String
  115. );
  116. STATIC
  117. PSTR
  118. Strncat (
  119. INOUT PSTR String1,
  120. IN PSTR String2,
  121. DWORD Size
  122. );
  123. STATIC
  124. INT
  125. Strncmp (
  126. IN PSTR String1,
  127. IN PSTR String2,
  128. IN DWORD Size
  129. );
  130. STATIC
  131. DWORD
  132. Strspn (
  133. IN PSTR String1,
  134. IN PSTR String2
  135. );
  136. #ifdef FE_SB
  137. //fix kksuzuka: #926
  138. //enabling DBCS with strstr
  139. STATIC
  140. ULIB_EXPORT
  141. PSTR
  142. Strstr (
  143. IN PSTR String1,
  144. IN PSTR String2
  145. );
  146. #else
  147. STATIC
  148. PSTR
  149. Strstr (
  150. IN PSTR String1,
  151. IN PSTR String2
  152. );
  153. #endif
  154. STATIC
  155. PSTR
  156. Strupr (
  157. INOUT PSTR String
  158. );
  159. STATIC
  160. PSTR*
  161. MakeLineArray (
  162. INOUT PSTR* Buffer,
  163. INOUT PDWORD BufferSize,
  164. INOUT PDWORD NumberOfLines
  165. );
  166. STATIC
  167. DWORD
  168. Hash(
  169. IN PSTR String,
  170. IN DWORD Buckets DEFAULT 211,
  171. IN DWORD BytesToSum DEFAULT (DWORD)-1
  172. );
  173. STATIC
  174. ULIB_EXPORT
  175. PSTR
  176. CharNext (
  177. IN PSTR String
  178. );
  179. private:
  180. #ifdef FE_SB
  181. STATIC
  182. INT
  183. CheckSpace(
  184. IN PSTR s
  185. );
  186. #endif
  187. STATIC
  188. PSTR
  189. SkipWhite(
  190. IN PSTR p
  191. );
  192. };
  193. INLINE
  194. PVOID
  195. MBSTR::Memcpy (
  196. INOUT PVOID Src,
  197. INOUT PVOID Dst,
  198. IN DWORD Size
  199. )
  200. {
  201. return memcpy( Src, Dst, (size_t)Size );
  202. }
  203. INLINE
  204. PVOID
  205. MBSTR::Memset (
  206. INOUT PVOID Src,
  207. IN BYTE Byte,
  208. IN DWORD Size
  209. )
  210. {
  211. return memset( Src, Byte, (size_t)Size );
  212. }
  213. INLINE
  214. PSTR
  215. MBSTR::Strcat (
  216. INOUT PSTR String1,
  217. IN PSTR String2
  218. )
  219. {
  220. return strcat( String1, String2 );
  221. }
  222. INLINE
  223. PSTR
  224. MBSTR::Strchr (
  225. IN PSTR String,
  226. IN CHAR Char
  227. )
  228. {
  229. return strchr( String, Char );
  230. }
  231. INLINE
  232. INT
  233. MBSTR::Strcmp (
  234. IN PSTR String1,
  235. IN PSTR String2
  236. )
  237. {
  238. return strcmp( String1, String2 );
  239. }
  240. #ifndef FE_SB
  241. //fix kksuzuka: #931
  242. //enabling DBCS with stricmp
  243. INLINE
  244. INT
  245. MBSTR::Stricmp (
  246. IN PSTR String1,
  247. IN PSTR String2
  248. )
  249. {
  250. return _stricmp( String1, String2 );
  251. }
  252. #endif
  253. INLINE
  254. PSTR
  255. MBSTR::Strcpy (
  256. INOUT PSTR String1,
  257. IN PSTR String2
  258. )
  259. {
  260. return strcpy( String1, String2 );
  261. }
  262. INLINE
  263. DWORD
  264. MBSTR::Strcspn (
  265. IN PSTR String1,
  266. IN PSTR String2
  267. )
  268. {
  269. return strcspn( String1, String2 );
  270. }
  271. INLINE
  272. PSTR
  273. MBSTR::Strdup (
  274. IN PSTR String
  275. )
  276. {
  277. return _strdup( String );
  278. }
  279. INLINE
  280. DWORD
  281. MBSTR::Strlen (
  282. IN PSTR String
  283. )
  284. {
  285. return strlen( String );
  286. }
  287. INLINE
  288. PSTR
  289. MBSTR::Strlwr (
  290. INOUT PSTR String
  291. )
  292. {
  293. return _strlwr( String );
  294. }
  295. INLINE
  296. PSTR
  297. MBSTR::Strncat (
  298. INOUT PSTR String1,
  299. IN PSTR String2,
  300. DWORD Size
  301. )
  302. {
  303. return strncat( String1, String2, (unsigned int)Size );
  304. }
  305. INLINE
  306. INT
  307. MBSTR::Strncmp (
  308. IN PSTR String1,
  309. IN PSTR String2,
  310. IN DWORD Size
  311. )
  312. {
  313. return strncmp( String1, String2, (size_t)Size );
  314. }
  315. INLINE
  316. DWORD
  317. MBSTR::Strspn (
  318. IN PSTR String1,
  319. IN PSTR String2
  320. )
  321. {
  322. return strspn( String1, String2 );
  323. }
  324. #ifndef FE_SB
  325. //fix kksuzuka: #926
  326. //enabling DBCS with strstr
  327. INLINE
  328. PSTR
  329. MBSTR::Strstr (
  330. IN PSTR String1,
  331. IN PSTR String2
  332. )
  333. {
  334. return strstr( String1, String2 );
  335. }
  336. #endif
  337. INLINE
  338. PSTR
  339. MBSTR::Strupr (
  340. INOUT PSTR String
  341. )
  342. {
  343. return _strupr( String );
  344. }
  345. INLINE
  346. PSTR
  347. MBSTR::CharNext (
  348. IN PSTR String
  349. )
  350. {
  351. if (IsDBCSLeadByte(*String)) {
  352. String++;
  353. }
  354. if (*String) {
  355. String++;
  356. }
  357. return String;
  358. }
  359. #endif // _MBSTR_