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.

294 lines
11 KiB

  1. /***
  2. * mbstring.h - MBCS string manipulation macros and functions
  3. *
  4. * Copyright (c) 1990-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains macros and function declarations for the MBCS
  8. * string manipulation functions.
  9. *
  10. * [Public]
  11. *
  12. *Revision History:
  13. * 11-19-92 KRS Ported from 16-bit sources.
  14. * 02-23-93 SKS Update copyright to 1993
  15. * 05-24-93 KRS Added new functions from Ikura.
  16. * 07-09-93 KRS Put proper switches around _ismbblead/trail.
  17. * 07-14-93 KRS Add new mbsnbxxx functions: byte-count versions.
  18. * 08-12-93 CFW Fix ifstrip macro name.
  19. * 10-07-93 GJF Merged Cuda and NT versions. Added _CRTIMP.
  20. * 10-13-93 GJF Deleted obsolete COMBOINC check.
  21. * 10-19-93 CFW Remove _MBCS test and SBCS defines.
  22. * 10-22-93 CFW Add new ismbc* function prototypes.
  23. * 12-08-93 CFW Remove type-safe macros.
  24. * 12-17-93 CFW Remove wide char version mappings.
  25. * 04-11-94 CFW Add _NLSCMPERROR.
  26. * 05-23-94 CFW Add _mbs*coll.
  27. * 11-03-94 GJF Ensure 8 byte alignment.
  28. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  29. * 02-14-95 CFW Clean up Mac merge.
  30. * 12-14-95 JWM Add "#pragma once".
  31. * 02-20-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  32. * Also, detab-ed.
  33. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  34. * 10-07-97 RDL Added IA64.
  35. * 04-21-98 GJF Added support for per-thread mbc information.
  36. * 12-15-98 GJF Changes for 64-bit size_t.
  37. * 05-13-99 PML Remove _CRTAPI1
  38. * 05-17-99 PML Remove all Macintosh support.
  39. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  40. * 64 bits in Win64.
  41. * 11-03-99 PML Add va_list definition for _M_CEE.
  42. * 06-08-00 PML Remove threadmbcinfo.{pprev,pnext}. Rename
  43. * THREADMBCINFO to _THREADMBCINFO.
  44. * 09-07-00 PML Remove va_list definition for _M_CEE (vs7#159777)
  45. *
  46. ****/
  47. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  48. #pragma once
  49. #endif
  50. #ifndef _INC_MBSTRING
  51. #define _INC_MBSTRING
  52. #if !defined(_WIN32)
  53. #error ERROR: Only Win32 target supported!
  54. #endif
  55. #ifndef _CRTBLD
  56. /* This version of the header files is NOT for user programs.
  57. * It is intended for use when building the C runtimes ONLY.
  58. * The version intended for public use will not have this message.
  59. */
  60. #error ERROR: Use of C runtime library internal header file.
  61. #endif /* _CRTBLD */
  62. #ifdef _MSC_VER
  63. /*
  64. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  65. * alignment.
  66. */
  67. #pragma pack(push,8)
  68. #endif /* _MSC_VER */
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72. #if !defined(_W64)
  73. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  74. #define _W64 __w64
  75. #else
  76. #define _W64
  77. #endif
  78. #endif
  79. /* Define _CRTIMP */
  80. #ifndef _CRTIMP
  81. #ifdef CRTDLL
  82. #define _CRTIMP __declspec(dllexport)
  83. #else /* ndef CRTDLL */
  84. #ifdef _DLL
  85. #define _CRTIMP __declspec(dllimport)
  86. #else /* ndef _DLL */
  87. #define _CRTIMP
  88. #endif /* _DLL */
  89. #endif /* CRTDLL */
  90. #endif /* _CRTIMP */
  91. /* Define __cdecl for non-Microsoft compilers */
  92. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  93. #define __cdecl
  94. #endif
  95. #ifndef _SIZE_T_DEFINED
  96. #ifdef _WIN64
  97. typedef unsigned __int64 size_t;
  98. #else
  99. typedef _W64 unsigned int size_t;
  100. #endif
  101. #define _SIZE_T_DEFINED
  102. #endif
  103. #ifndef _NLSCMP_DEFINED
  104. #define _NLSCMPERROR 2147483647 /* currently == INT_MAX */
  105. #define _NLSCMP_DEFINED
  106. #endif
  107. #ifndef _VA_LIST_DEFINED
  108. #ifdef _M_ALPHA
  109. typedef struct {
  110. char *a0; /* pointer to first homed integer argument */
  111. int offset; /* byte offset of next parameter */
  112. } va_list;
  113. #else
  114. typedef char * va_list;
  115. #endif
  116. #define _VA_LIST_DEFINED
  117. #endif
  118. #ifndef _FILE_DEFINED
  119. struct _iobuf {
  120. char *_ptr;
  121. int _cnt;
  122. char *_base;
  123. int _flag;
  124. int _file;
  125. int _charbuf;
  126. int _bufsiz;
  127. char *_tmpfname;
  128. };
  129. typedef struct _iobuf FILE;
  130. #define _FILE_DEFINED
  131. #endif
  132. /*
  133. * MBCS - Multi-Byte Character Set
  134. */
  135. #ifndef _INTERNAL_IFSTRIP_
  136. #ifdef _MT
  137. #ifndef _THREADMBCINFO
  138. typedef struct threadmbcinfostruct {
  139. int refcount;
  140. int mbcodepage;
  141. int ismbcodepage;
  142. int mblcid;
  143. unsigned short mbulinfo[6];
  144. char mbctype[257];
  145. char mbcasemap[256];
  146. } threadmbcinfo;
  147. typedef threadmbcinfo * pthreadmbcinfo;
  148. #define _THREADMBCINFO
  149. #endif
  150. extern pthreadmbcinfo __ptmbcinfo;
  151. pthreadmbcinfo __cdecl __updatetmbcinfo(void);
  152. #endif
  153. #endif /* _INTERNAL_IFSTRIP_ */
  154. #ifndef _MBSTRING_DEFINED
  155. /* function prototypes */
  156. _CRTIMP unsigned int __cdecl _mbbtombc(unsigned int);
  157. _CRTIMP int __cdecl _mbbtype(unsigned char, int);
  158. _CRTIMP unsigned int __cdecl _mbctombb(unsigned int);
  159. _CRTIMP int __cdecl _mbsbtype(const unsigned char *, size_t);
  160. _CRTIMP unsigned char * __cdecl _mbscat(unsigned char *, const unsigned char *);
  161. _CRTIMP unsigned char * __cdecl _mbschr(const unsigned char *, unsigned int);
  162. _CRTIMP int __cdecl _mbscmp(const unsigned char *, const unsigned char *);
  163. _CRTIMP int __cdecl _mbscoll(const unsigned char *, const unsigned char *);
  164. _CRTIMP unsigned char * __cdecl _mbscpy(unsigned char *, const unsigned char *);
  165. _CRTIMP size_t __cdecl _mbscspn(const unsigned char *, const unsigned char *);
  166. _CRTIMP unsigned char * __cdecl _mbsdec(const unsigned char *, const unsigned char *);
  167. _CRTIMP unsigned char * __cdecl _mbsdup(const unsigned char *);
  168. _CRTIMP int __cdecl _mbsicmp(const unsigned char *, const unsigned char *);
  169. _CRTIMP int __cdecl _mbsicoll(const unsigned char *, const unsigned char *);
  170. _CRTIMP unsigned char * __cdecl _mbsinc(const unsigned char *);
  171. _CRTIMP size_t __cdecl _mbslen(const unsigned char *);
  172. _CRTIMP unsigned char * __cdecl _mbslwr(unsigned char *);
  173. _CRTIMP unsigned char * __cdecl _mbsnbcat(unsigned char *, const unsigned char *, size_t);
  174. _CRTIMP int __cdecl _mbsnbcmp(const unsigned char *, const unsigned char *, size_t);
  175. _CRTIMP int __cdecl _mbsnbcoll(const unsigned char *, const unsigned char *, size_t);
  176. _CRTIMP size_t __cdecl _mbsnbcnt(const unsigned char *, size_t);
  177. _CRTIMP unsigned char * __cdecl _mbsnbcpy(unsigned char *, const unsigned char *, size_t);
  178. _CRTIMP int __cdecl _mbsnbicmp(const unsigned char *, const unsigned char *, size_t);
  179. _CRTIMP int __cdecl _mbsnbicoll(const unsigned char *, const unsigned char *, size_t);
  180. _CRTIMP unsigned char * __cdecl _mbsnbset(unsigned char *, unsigned int, size_t);
  181. _CRTIMP unsigned char * __cdecl _mbsncat(unsigned char *, const unsigned char *, size_t);
  182. _CRTIMP size_t __cdecl _mbsnccnt(const unsigned char *, size_t);
  183. _CRTIMP int __cdecl _mbsncmp(const unsigned char *, const unsigned char *, size_t);
  184. _CRTIMP int __cdecl _mbsncoll(const unsigned char *, const unsigned char *, size_t);
  185. _CRTIMP unsigned char * __cdecl _mbsncpy(unsigned char *, const unsigned char *, size_t);
  186. _CRTIMP unsigned int __cdecl _mbsnextc (const unsigned char *);
  187. _CRTIMP int __cdecl _mbsnicmp(const unsigned char *, const unsigned char *, size_t);
  188. _CRTIMP int __cdecl _mbsnicoll(const unsigned char *, const unsigned char *, size_t);
  189. _CRTIMP unsigned char * __cdecl _mbsninc(const unsigned char *, size_t);
  190. _CRTIMP unsigned char * __cdecl _mbsnset(unsigned char *, unsigned int, size_t);
  191. _CRTIMP unsigned char * __cdecl _mbspbrk(const unsigned char *, const unsigned char *);
  192. _CRTIMP unsigned char * __cdecl _mbsrchr(const unsigned char *, unsigned int);
  193. _CRTIMP unsigned char * __cdecl _mbsrev(unsigned char *);
  194. _CRTIMP unsigned char * __cdecl _mbsset(unsigned char *, unsigned int);
  195. _CRTIMP size_t __cdecl _mbsspn(const unsigned char *, const unsigned char *);
  196. _CRTIMP unsigned char * __cdecl _mbsspnp(const unsigned char *, const unsigned char *);
  197. _CRTIMP unsigned char * __cdecl _mbsstr(const unsigned char *, const unsigned char *);
  198. _CRTIMP unsigned char * __cdecl _mbstok(unsigned char *, const unsigned char *);
  199. _CRTIMP unsigned char * __cdecl _mbsupr(unsigned char *);
  200. _CRTIMP size_t __cdecl _mbclen(const unsigned char *);
  201. _CRTIMP void __cdecl _mbccpy(unsigned char *, const unsigned char *);
  202. #define _mbccmp(_cpc1, _cpc2) _mbsncmp((_cpc1),(_cpc2),1)
  203. /* character routines */
  204. _CRTIMP int __cdecl _ismbcalnum(unsigned int);
  205. _CRTIMP int __cdecl _ismbcalpha(unsigned int);
  206. _CRTIMP int __cdecl _ismbcdigit(unsigned int);
  207. _CRTIMP int __cdecl _ismbcgraph(unsigned int);
  208. _CRTIMP int __cdecl _ismbclegal(unsigned int);
  209. _CRTIMP int __cdecl _ismbclower(unsigned int);
  210. _CRTIMP int __cdecl _ismbcprint(unsigned int);
  211. _CRTIMP int __cdecl _ismbcpunct(unsigned int);
  212. _CRTIMP int __cdecl _ismbcspace(unsigned int);
  213. _CRTIMP int __cdecl _ismbcupper(unsigned int);
  214. _CRTIMP unsigned int __cdecl _mbctolower(unsigned int);
  215. _CRTIMP unsigned int __cdecl _mbctoupper(unsigned int);
  216. #ifndef _INTERNAL_IFSTRIP_
  217. #ifdef _MT
  218. int __cdecl __mbbtype_mt(pthreadmbcinfo, unsigned char, int);
  219. int __cdecl __mbsbtype_mt(pthreadmbcinfo, const unsigned char *, size_t);
  220. size_t __cdecl __mbscspn_mt(pthreadmbcinfo, const unsigned char *, const unsigned char *);
  221. size_t __cdecl __mbsnbcnt_mt(pthreadmbcinfo, const unsigned char *, size_t);
  222. unsigned char * __cdecl __mbspbrk_mt(pthreadmbcinfo, const unsigned char *, const unsigned char *);
  223. size_t __cdecl __mbsspn_mt(pthreadmbcinfo, const unsigned char *, const unsigned char *);
  224. unsigned char * __cdecl __mbsspnp_mt(pthreadmbcinfo, const unsigned char *, const unsigned char *);
  225. #endif
  226. #endif /* _INTERNAL_IFSTRIP_ */
  227. #define _MBSTRING_DEFINED
  228. #endif
  229. #ifndef _MBLEADTRAIL_DEFINED
  230. _CRTIMP int __cdecl _ismbblead(unsigned int);
  231. _CRTIMP int __cdecl _ismbbtrail(unsigned int);
  232. _CRTIMP int __cdecl _ismbslead(const unsigned char *, const unsigned char *);
  233. _CRTIMP int __cdecl _ismbstrail(const unsigned char *, const unsigned char *);
  234. #ifndef _INTERNAL_IFSTRIP_
  235. #ifdef _MT
  236. _CRTIMP int __cdecl __ismbslead_mt(pthreadmbcinfo, const unsigned char *,
  237. const unsigned char *);
  238. #endif
  239. #endif /* _INTERNAL_IFSTRIP_ */
  240. #define _MBLEADTRAIL_DEFINED
  241. #endif
  242. /* Kanji specific prototypes. */
  243. _CRTIMP int __cdecl _ismbchira(unsigned int);
  244. _CRTIMP int __cdecl _ismbckata(unsigned int);
  245. _CRTIMP int __cdecl _ismbcsymbol(unsigned int);
  246. _CRTIMP int __cdecl _ismbcl0(unsigned int);
  247. _CRTIMP int __cdecl _ismbcl1(unsigned int);
  248. _CRTIMP int __cdecl _ismbcl2(unsigned int);
  249. _CRTIMP unsigned int __cdecl _mbcjistojms(unsigned int);
  250. _CRTIMP unsigned int __cdecl _mbcjmstojis(unsigned int);
  251. _CRTIMP unsigned int __cdecl _mbctohira(unsigned int);
  252. _CRTIMP unsigned int __cdecl _mbctokata(unsigned int);
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #ifdef _MSC_VER
  257. #pragma pack(pop)
  258. #endif /* _MSC_VER */
  259. #endif /* _INC_MBSTRING */