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.

188 lines
5.9 KiB

  1. /***
  2. *mbdata.h - MBCS lib data
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines data for use when building MBCS libs and routines
  8. *
  9. * [Internal].
  10. *
  11. *Revision History:
  12. * 11-19-92 KRS Ported from 16-bit sources.
  13. * 02-23-93 SKS Update copyright to 1993
  14. * 08-03-93 KRS Move _ismbbtruelead() from mbctype.h. Internal-only.
  15. * 10-13-93 GJF Deleted obsolete COMBOINC check.
  16. * 10-19-93 CFW Remove _MBCS test and SBCS defines.
  17. * 04-15-93 CFW Remove _mbascii, add _mbcodepage and _mblcid.
  18. * 04-21-93 CFW _mbcodepage and _mblcid shouldn't be _CRTIMP.
  19. * 04-21-94 GJF Made declarations of __mbcodepage and __mblcid
  20. * conditional on ndef DLL_FOR_WIN32S. Added conditional
  21. * include of win32s.h. Also, made safe for multiple or
  22. * nested includes.
  23. * 05-12-94 CFW Add full-width-latin upper/lower info.
  24. * 05-16-94 CFW Add _mbbtolower/upper.
  25. * 05-19-94 CFW Mac-enable, remove _KANJI/_MBCS_OS check.
  26. * 02-14-95 CFW Clean up Mac merge.
  27. * 03-29-95 CFW Add error message to internal headers.
  28. * 12-14-95 JWM Add "#pragma once".
  29. * 03-17-97 RDK Change _mbbisXXXXX and _mbbtoXXXX macros.
  30. * 03-26-97 GJF Cleaned out obsolete support for Win32s.
  31. * 09-08-97 GJF Added __ismbcodepage, and the _ISMBCP and _ISNOTMBCP
  32. * macros.
  33. * 09-26-97 BWT Fix POSIX
  34. * 04-17-98 GJF Added support for per-thread mbc information.
  35. * 06-08-00 PML Remove threadmbcinfo.{pprev,pnext}. Rename
  36. * THREADMBCINFO to _THREADMBCINFO.
  37. *
  38. ****/
  39. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  40. #pragma once
  41. #endif
  42. #ifndef _INC_MBDATA
  43. #define _INC_MBDATA
  44. #ifndef _CRTBLD
  45. /*
  46. * This is an internal C runtime header file. It is used when building
  47. * the C runtimes only. It is not to be used as a public header file.
  48. */
  49. #error ERROR: Use of C runtime library internal header file.
  50. #endif /* _CRTBLD */
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. #if defined(_WIN32) && !defined (_POSIX_)
  55. #define NUM_ULINFO 6 /* multibyte full-width-latin upper/lower info */
  56. #else /* _WIN32 && !_POSIX */
  57. #define NUM_ULINFO 12 /* multibyte full-width-latin upper/lower info */
  58. #endif /* _WIN32 && !_POSIX */
  59. #ifdef _MT
  60. #ifndef _THREADMBCINFO
  61. typedef struct threadmbcinfostruct {
  62. int refcount;
  63. int mbcodepage;
  64. int ismbcodepage;
  65. int mblcid;
  66. unsigned short mbulinfo[6];
  67. char mbctype[257];
  68. char mbcasemap[256];
  69. } threadmbcinfo;
  70. typedef threadmbcinfo * pthreadmbcinfo;
  71. #define _THREADMBCINFO
  72. #endif
  73. #endif
  74. /* global variable to indicate current code page */
  75. extern int __mbcodepage;
  76. /* global flag indicating if the current code page is a multibyte code page */
  77. extern int __ismbcodepage;
  78. #if defined(_WIN32) && !defined (_POSIX_)
  79. /* global variable to indicate current LCID */
  80. extern int __mblcid;
  81. #endif /* _WIN32 && !_POSIX */
  82. /* global variable to indicate current full-width-latin upper/lower info */
  83. extern unsigned short __mbulinfo[NUM_ULINFO];
  84. #ifdef _MT
  85. /* global variable pointing to the current mbc information structure */
  86. extern pthreadmbcinfo __ptmbcinfo;
  87. /* function to update mbc info used by the current thread */
  88. pthreadmbcinfo __cdecl __updatetmbcinfo(void);
  89. #endif
  90. /*
  91. * MBCS - Multi-Byte Character Set
  92. */
  93. /*
  94. * general use macros for model dependent/independent versions.
  95. */
  96. #define _ISMBCP (__ismbcodepage != 0)
  97. #define _ISNOTMBCP (__ismbcodepage == 0)
  98. #ifdef _MT
  99. #define _ISMBCP_MT(p) (p->ismbcodepage != 0)
  100. #define _ISNOTMBCP_MT(p) (p->ismbcodepage == 0)
  101. #endif
  102. #define _ismbbtruelead(_lb,_ch) (!(_lb) && _ismbblead((_ch)))
  103. /* internal use macros since tolower/toupper are locale-dependent */
  104. #define _mbbisupper(_c) ((_mbctype[(_c) + 1] & _SBUP) == _SBUP)
  105. #define _mbbislower(_c) ((_mbctype[(_c) + 1] & _SBLOW) == _SBLOW)
  106. #define _mbbtolower(_c) (_mbbisupper(_c) ? _mbcasemap[_c] : _c)
  107. #define _mbbtoupper(_c) (_mbbislower(_c) ? _mbcasemap[_c] : _c)
  108. #ifdef _MT
  109. #define __ismbbtruelead_mt(p,_lb,_ch) (!(_lb) && __ismbblead_mt(p, (_ch)))
  110. #define __mbbisupper_mt(p, _c) ((p->mbctype[(_c) + 1] & _SBUP) == _SBUP)
  111. #define __mbbislower_mt(p, _c) ((p->mbctype[(_c) + 1] & _SBLOW) == _SBLOW)
  112. #define __mbbtolower_mt(p, _c) (__mbbisupper_mt(p, _c) ? p->mbcasemap[_c] : _c)
  113. #define __mbbtoupper_mt(p, _c) (__mbbislower_mt(p, _c) ? p->mbcasemap[_c] : _c)
  114. #endif
  115. /* define full-width-latin upper/lower ranges */
  116. #define _MBUPPERLOW1 __mbulinfo[0]
  117. #define _MBUPPERHIGH1 __mbulinfo[1]
  118. #define _MBCASEDIFF1 __mbulinfo[2]
  119. #define _MBUPPERLOW2 __mbulinfo[3]
  120. #define _MBUPPERHIGH2 __mbulinfo[4]
  121. #define _MBCASEDIFF2 __mbulinfo[5]
  122. #ifdef _MT
  123. #define _MBUPPERLOW1_MT(p) p->mbulinfo[0]
  124. #define _MBUPPERHIGH1_MT(p) p->mbulinfo[1]
  125. #define _MBCASEDIFF1_MT(p) p->mbulinfo[2]
  126. #define _MBUPPERLOW2_MT(p) p->mbulinfo[3]
  127. #define _MBUPPERHIGH2_MT(p) p->mbulinfo[4]
  128. #define _MBCASEDIFF2_MT(p) p->mbulinfo[5]
  129. #endif
  130. #if !defined(_WIN32) || defined(_POSIX_)
  131. #define _MBLOWERLOW1 __mbulinfo[6]
  132. #define _MBLOWERHIGH1 __mbulinfo[7]
  133. #define _MBLOWERLOW2 __mbulinfo[8]
  134. #define _MBLOWERHIGH2 __mbulinfo[9]
  135. #define _MBDIGITLOW __mbulinfo[10]
  136. #define _MBDIGITHIGH __mbulinfo[11]
  137. #endif /* !_WIN32 || _POSIX */
  138. /* Kanji-specific ranges */
  139. #define _MBHIRALOW 0x829f /* hiragana */
  140. #define _MBHIRAHIGH 0x82f1
  141. #define _MBKATALOW 0x8340 /* katakana */
  142. #define _MBKATAHIGH 0x8396
  143. #define _MBKATAEXCEPT 0x837f /* exception */
  144. #define _MBKIGOULOW 0x8141 /* kanji punctuation */
  145. #define _MBKIGOUHIGH 0x81ac
  146. #define _MBKIGOUEXCEPT 0x817f /* exception */
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150. #endif /* _INC_MBDATA */