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.

2849 lines
106 KiB

  1. /*++
  2. Copyright (c) 1991-2000, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. nls.h
  5. Abstract:
  6. This file contains the header information shared by all of the modules
  7. of NLS.
  8. Revision History:
  9. 05-31-91 JulieB Created.
  10. 03-07-00 lguindon Began Geo API port
  11. --*/
  12. #ifndef _NLS_
  13. #define _NLS_
  14. ////////////////////////////////////////////////////////////////////////////
  15. //
  16. // RTL Includes Files.
  17. //
  18. ////////////////////////////////////////////////////////////////////////////
  19. #ifndef RC_INVOKED
  20. #include <nt.h>
  21. #include <ntrtl.h>
  22. #include <nturtl.h>
  23. #endif
  24. ////////////////////////////////////////////////////////////////////////////
  25. //
  26. // Include Files.
  27. //
  28. ////////////////////////////////////////////////////////////////////////////
  29. #include <base.h>
  30. #include <ntcsrdll.h>
  31. #include <ntcsrsrv.h>
  32. #include <basemsg.h>
  33. #include <windows.h>
  34. #include <winnlsp.h>
  35. #include <winerror.h>
  36. #include <string.h>
  37. #include <stdlib.h>
  38. ////////////////////////////////////////////////////////////////////////////
  39. //
  40. // Constant Declarations.
  41. //
  42. ////////////////////////////////////////////////////////////////////////////
  43. //
  44. // Code Page Ranges.
  45. //
  46. #define NLS_CP_TABLE_RANGE 0 // begin code page Table range
  47. #define NLS_CP_DLL_RANGE 50000 // begin code page DLL range
  48. #define NLS_CP_ALGORITHM_RANGE 60000 // begin code page Algorithm range
  49. //
  50. // Table Values.
  51. //
  52. #define MB_TBL_SIZE 256 // size of MB tables
  53. #define GLYPH_TBL_SIZE 256 // size of GLYPH tables
  54. #define DBCS_TBL_SIZE 256 // size of DBCS tables
  55. #define CP_TBL_SIZE 197 // size of code page hash table (prime #)
  56. #define LOC_TBL_SIZE 197 // size of locale hash table (prime #)
  57. //
  58. // String Constants.
  59. //
  60. #define MAX_PATH_LEN 512 // max length of path name
  61. #define MAX_STRING_LEN 128 // max string length for static buffer
  62. #define MAX_SMALL_BUF_LEN 64 // max length of small buffer
  63. #define MAX_COMPOSITE 5 // max number of composite characters
  64. #define MAX_EXPANSION 3 // max number of expansion characters
  65. #define MAX_TBL_EXPANSION 2 // max expansion chars per table entry
  66. #define MAX_WEIGHTS 9 // max number of words in all weights
  67. #define MAX_SECURITY_BUF_LEN 128 // max length of security descriptor buffer
  68. // length of sortkey static buffer
  69. #define MAX_SORTKEY_BUF_LEN ( MAX_SMALL_BUF_LEN * MAX_EXPANSION * MAX_WEIGHTS )
  70. #define MAX_FONTSIGNATURE 16 // length of font signature string
  71. // SetLocaleInfo string constants
  72. #define MAX_SLIST 4 // max wide chars in sList
  73. #define MAX_IMEASURE 2 // max wide chars in iMeasure
  74. #define MAX_SDECIMAL 4 // max wide chars in sDecimal
  75. #define MAX_STHOUSAND 4 // max wide chars in sThousand
  76. #define MAX_SGROUPING 10 // max wide chars in sGrouping
  77. #define MAX_IDIGITS 2 // max wide chars in iDigits
  78. #define MAX_ILZERO 2 // max wide chars in iLZero
  79. #define MAX_INEGNUMBER 2 // max wide chars in iNegNumber
  80. #define MAX_SNATIVEDIGITS 11 // max wide chars in sNativeDigits
  81. #define MAX_IDIGITSUBST 2 // max wide chars in iDigitSubstitution
  82. #define MAX_SCURRENCY 6 // max wide chars in sCurrency
  83. #define MAX_SMONDECSEP 4 // max wide chars in sMonDecimalSep
  84. #define MAX_SMONTHOUSEP 4 // max wide chars in sMonThousandSep
  85. #define MAX_SMONGROUPING 10 // max wide chars in sMonGrouping
  86. #define MAX_ICURRENCY 2 // max wide chars in iCurrency
  87. #define MAX_SPOSSIGN 5 // max wide chars in sPositiveSign
  88. #define MAX_SNEGSIGN 5 // max wide chars in sNegativeSign
  89. #define MAX_STIMEFORMAT MAX_REG_VAL_SIZE // max wide chars in sTimeFormat
  90. #define MAX_STIME 4 // max wide chars in sTime
  91. #define MAX_ITIME 2 // max wide chars in iTime
  92. #define MAX_S1159 15 // max wide chars in s1159
  93. #define MAX_S2359 15 // max wide chars in s2359
  94. #define MAX_SSHORTDATE MAX_REG_VAL_SIZE // max wide chars in sShortDate
  95. #define MAX_SDATE 4 // max wide chars in sDate
  96. #define MAX_SYEARMONTH MAX_REG_VAL_SIZE // max wide chars in sYearMonth
  97. #define MAX_SLONGDATE MAX_REG_VAL_SIZE // max wide chars in sLongDate
  98. #define MAX_ICALTYPE 3 // max wide chars in iCalendarType
  99. #define MAX_IFIRSTDAY 2 // max wide chars in iFirstDayOfWeek
  100. #define MAX_IFIRSTWEEK 2 // max wide chars in iFirstWeekOfYear
  101. //
  102. // NOTE: If any of the MAX_VALUE_ values change, then the corresponding
  103. // MAX_CHAR_ value must also change.
  104. //
  105. #define MAX_VALUE_IMEASURE 1 // max value for iMeasure
  106. #define MAX_VALUE_IDIGITS 9 // max value for iDigits
  107. #define MAX_VALUE_ILZERO 1 // max value for iLZero
  108. #define MAX_VALUE_INEGNUMBER 4 // max value for iNegNumber
  109. #define MAX_VALUE_IDIGITSUBST 2 // max value for iDigitSubstitution
  110. #define MAX_VALUE_ICURRDIGITS 99 // max value for iCurrDigits
  111. #define MAX_VALUE_ICURRENCY 3 // max value for iCurrency
  112. #define MAX_VALUE_INEGCURR 15 // max value for iNegCurr
  113. #define MAX_VALUE_ITIME 1 // max value for iTime
  114. #define MAX_VALUE_IFIRSTDAY 6 // max value for iFirstDayOfWeek
  115. #define MAX_VALUE_IFIRSTWEEK 2 // max value for iFirstWeekOfYear
  116. #define MAX_CHAR_IMEASURE L'1' // max char value for iMeasure
  117. #define MAX_CHAR_IDIGITS L'9' // max char value for iDigits
  118. #define MAX_CHAR_ILZERO L'1' // max char value for iLZero
  119. #define MAX_CHAR_INEGNUMBER L'4' // max char value for iNegNumber
  120. #define MAX_CHAR_IDIGITSUBST L'2' // max char value for iDigitSubstitution
  121. #define MAX_CHAR_ICURRENCY L'3' // max char value for iCurrency
  122. #define MAX_CHAR_ITIME L'1' // max char value for iTime
  123. #define MAX_CHAR_IFIRSTDAY L'6' // max char value for iFirstDayOfWeek
  124. #define MAX_CHAR_IFIRSTWEEK L'2' // max char value for iFirstWeekOfYear
  125. // SetCalendarInfo string constants
  126. #define MAX_ITWODIGITYEAR 5 // max wide chars in TwoDigitYearMax
  127. #define NLS_CHAR_ZERO L'0' // digit 0 character
  128. #define NLS_CHAR_ONE L'1' // digit 1 character
  129. #define NLS_CHAR_NINE L'9' // digit 9 character
  130. #define NLS_CHAR_SEMICOLON L';' // semicolon character
  131. #define NLS_CHAR_PERIOD L'.' // period character
  132. #define NLS_CHAR_QUOTE L'\'' // single quote character
  133. #define NLS_CHAR_SPACE L' ' // space character
  134. #define NLS_CHAR_HYPHEN L'-' // hyphen/minus character
  135. #define NLS_CHAR_OPEN_PAREN L'(' // open parenthesis character
  136. #define NLS_CHAR_CLOSE_PAREN L')' // close parenthesis character
  137. #define MAX_BLANKS 1 // max successive blanks in number string
  138. //
  139. // RC File Constants.
  140. //
  141. #define NLS_SORT_RES_PREFIX L"SORT_"
  142. #define NLS_SORT_RES_DEFAULT L"SORT_00000000"
  143. //
  144. // Size of stack buffer for PKEY_VALUE_FULL_INFORMATION pointer.
  145. //
  146. #define MAX_KEY_VALUE_FULLINFO \
  147. ( FIELD_OFFSET( KEY_VALUE_FULL_INFORMATION, Name ) + MAX_PATH_LEN )
  148. //
  149. // Paths to registry keys.
  150. //
  151. #define NLS_HKLM_SYSTEM L"\\Registry\\Machine\\System\\CurrentControlSet\\Control"
  152. #define NLS_HKLM_SOFTWARE L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion"
  153. //
  154. // Names of Registry Key Entries.
  155. //
  156. #define NLS_CODEPAGE_KEY L"\\Nls\\Codepage"
  157. #define NLS_LANGUAGE_GROUPS_KEY L"\\Nls\\Language Groups"
  158. #define NLS_LOCALE_KEY L"\\Nls\\Locale"
  159. #define NLS_ALT_SORTS_KEY L"\\Nls\\Locale\\Alternate Sorts"
  160. #define NLS_MUILANG_KEY L"\\Nls\\MUILanguages"
  161. //
  162. // User Info.
  163. //
  164. #define NLS_CTRL_PANEL_KEY L"Control Panel\\International"
  165. #define NLS_CALENDARS_KEY L"Control Panel\\International\\Calendars"
  166. #define NLS_TWO_DIGIT_YEAR_KEY L"Control Panel\\International\\Calendars\\TwoDigitYearMax"
  167. #define NLS_POLICY_TWO_DIGIT_YEAR_KEY L"Software\\Policies\\Microsoft\\Control Panel\\International\\Calendars\\TwoDigitYearMax"
  168. //
  169. // GEO Registry Keys.
  170. //
  171. #define GEO_REG_KEY L"Control Panel\\International\\Geo"
  172. #define GEO_REG_NATION L"Nation"
  173. #define GEO_REG_REGION L"Region"
  174. #define GEO_REG_STATE L"State"
  175. #define GEO_REG_CITY L"City"
  176. //
  177. // Name of NLS Object Directory.
  178. // Must create this in order to have "create access" on the fly.
  179. //
  180. #define NLS_OBJECT_DIRECTORY_NAME L"\\NLS"
  181. //
  182. // Default values.
  183. //
  184. #define NLS_DEFAULT_ACP 1252
  185. #define NLS_DEFAULT_OEMCP 437
  186. #define NLS_DEFAULT_MACCP 10000
  187. #define NLS_DEFAULT_LANGID 0x0409
  188. #define NLS_DEFAULT_UILANG 0x0409
  189. //
  190. // DLL Translation Function Names.
  191. //
  192. // **** Must be an ANSI string for GetProcAddress call. ****
  193. //
  194. #define NLS_CP_DLL_PROC_NAME "NlsDllCodePageTranslation"
  195. //
  196. // Flag Constants.
  197. //
  198. #define MSB_FLAG 0x80000000 // most significant bit set
  199. //
  200. // Table Header Constants (all sizes in WORDS).
  201. //
  202. #define CP_HEADER 1 // size of CP Info table header
  203. #define MB_HEADER 1 // size of MB table header
  204. #define GLYPH_HEADER 1 // size of GLYPH table header
  205. #define DBCS_HEADER 1 // size of DBCS table header
  206. #define WC_HEADER 1 // size of WC table header
  207. #define CT_HEADER 2 // size of CTYPE table header
  208. #define LANG_HDR_OFFSET 0 // offset to LANGUAGE file header
  209. #define LANG_HEADER 1 // size of language file header
  210. #define UP_HEADER 1 // size of UPPERCASE table header
  211. #define LO_HEADER 1 // size of LOWERCASE table header
  212. #define L_EXCEPT_HDR_OFFSET 2 // offset to LANGUAGE EXCEPTION header
  213. #define AD_HEADER 1 // size of ASCIIDIGITS table header
  214. #define CZ_HEADER 1 // size of FOLDCZONE table header
  215. #define HG_HEADER 1 // size of HIRAGANA table header
  216. #define KK_HEADER 1 // size of KATAKANA table header
  217. #define HW_HEADER 1 // size of HALF WIDTH table header
  218. #define FW_HEADER 1 // size of FULL WIDTH table header
  219. #define TR_HEADER 1 // size of TRADITIONAL CHINESE table header
  220. #define SP_HEADER 1 // size of SIMPLIFIED CHINESE table header
  221. #define PC_HEADER 1 // size of PRECOMPOSED table header
  222. #define CO_HEADER 3 // size of COMPOSITE table header
  223. #define SORTKEY_HEADER 2 // size of SORTKEY table header
  224. #define REV_DW_HEADER 2 // size of REVERSE DW table header
  225. #define DBL_COMP_HEADER 2 // size of DOUBLE COMPRESS table header
  226. #define IDEO_LCID_HEADER 2 // size of IDEOGRAPH LCID table header
  227. #define EXPAND_HEADER 2 // size of EXPANSION table header
  228. #define COMPRESS_HDR_OFFSET 2 // offset to COMPRESSION header
  229. #define EXCEPT_HDR_OFFSET 2 // offset to EXCEPTION header
  230. #define MULTI_WT_HEADER 1 // size of MULTIPLE WEIGHTS table header
  231. #define JAMO_INDEX_HEADER 1 // size of Jamo Index table header
  232. #define JAMO_COMPOSITION_HEADER 1 // size of Jamo Composition state machine table hader
  233. //
  234. // Invalid Flag Checks.
  235. //
  236. #define MB_INVALID_FLAG (~(MB_PRECOMPOSED | MB_COMPOSITE | \
  237. MB_USEGLYPHCHARS | MB_ERR_INVALID_CHARS))
  238. #define WC_INVALID_FLAG (~(WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | \
  239. WC_DISCARDNS | WC_SEPCHARS | WC_DEFAULTCHAR))
  240. #define CS_INVALID_FLAG (~(NORM_IGNORECASE | NORM_IGNORENONSPACE | \
  241. NORM_IGNORESYMBOLS | NORM_IGNOREKANATYPE | \
  242. NORM_IGNOREWIDTH | SORT_STRINGSORT | \
  243. LOCALE_USE_CP_ACP | NORM_STOP_ON_NULL))
  244. #define FS_INVALID_FLAG (~(MAP_FOLDCZONE | MAP_PRECOMPOSED | \
  245. MAP_COMPOSITE | MAP_FOLDDIGITS))
  246. #define LCMS_INVALID_FLAG (~(LCMAP_LOWERCASE | LCMAP_UPPERCASE | \
  247. LCMAP_LINGUISTIC_CASING | \
  248. LCMAP_SORTKEY | LCMAP_BYTEREV | \
  249. LCMAP_HIRAGANA | LCMAP_KATAKANA | \
  250. LCMAP_HALFWIDTH | LCMAP_FULLWIDTH | \
  251. LCMAP_TRADITIONAL_CHINESE | \
  252. LCMAP_SIMPLIFIED_CHINESE | \
  253. NORM_IGNORECASE | NORM_IGNORENONSPACE | \
  254. NORM_IGNORESYMBOLS | NORM_IGNOREKANATYPE | \
  255. NORM_IGNOREWIDTH | SORT_STRINGSORT | \
  256. LOCALE_USE_CP_ACP))
  257. #define GTF_INVALID_FLAG (~(LOCALE_NOUSEROVERRIDE | LOCALE_USE_CP_ACP | \
  258. TIME_NOMINUTESORSECONDS | \
  259. TIME_NOSECONDS | TIME_NOTIMEMARKER | \
  260. TIME_FORCE24HOURFORMAT))
  261. #define GDF_INVALID_FLAG (~(LOCALE_NOUSEROVERRIDE | LOCALE_USE_CP_ACP | \
  262. DATE_LTRREADING | DATE_RTLREADING | \
  263. DATE_SHORTDATE | DATE_LONGDATE | \
  264. DATE_YEARMONTH | DATE_USE_ALT_CALENDAR |\
  265. DATE_ADDHIJRIDATETEMP))
  266. #define IVLG_INVALID_FLAG (~(LGRPID_INSTALLED | LGRPID_SUPPORTED))
  267. #define IVL_INVALID_FLAG (~(LCID_INSTALLED | LCID_SUPPORTED))
  268. #define GNF_INVALID_FLAG (~(LOCALE_NOUSEROVERRIDE | LOCALE_USE_CP_ACP))
  269. #define GCF_INVALID_FLAG (~(LOCALE_NOUSEROVERRIDE | LOCALE_USE_CP_ACP))
  270. #define ESLG_INVALID_FLAG (~(LGRPID_INSTALLED | LGRPID_SUPPORTED))
  271. #define ESL_INVALID_FLAG (~(LCID_INSTALLED | LCID_SUPPORTED | \
  272. LCID_ALTERNATE_SORTS))
  273. #define ESCP_INVALID_FLAG (~(CP_INSTALLED | CP_SUPPORTED))
  274. #define ETF_INVALID_FLAG (~(LOCALE_USE_CP_ACP))
  275. //
  276. // Single Flags (only one at a time is valid).
  277. //
  278. #define LCMS1_SINGLE_FLAG (LCMAP_LOWERCASE | LCMAP_UPPERCASE | \
  279. LCMAP_SORTKEY)
  280. #define LCMS2_SINGLE_FLAG (LCMAP_HIRAGANA | LCMAP_KATAKANA | \
  281. LCMAP_SORTKEY)
  282. #define LCMS3_SINGLE_FLAG (LCMAP_HALFWIDTH | LCMAP_FULLWIDTH | \
  283. LCMAP_SORTKEY)
  284. #define LCMS4_SINGLE_FLAG (LCMAP_TRADITIONAL_CHINESE | \
  285. LCMAP_SIMPLIFIED_CHINESE | \
  286. LCMAP_SORTKEY)
  287. #define GDF_SINGLE_FLAG (DATE_LTRREADING | DATE_RTLREADING)
  288. #define IVLG_SINGLE_FLAG (LGRPID_INSTALLED | LGRPID_SUPPORTED)
  289. #define IVL_SINGLE_FLAG (LCID_INSTALLED | LCID_SUPPORTED)
  290. #define ESLG_SINGLE_FLAG (LGRPID_INSTALLED | LGRPID_SUPPORTED)
  291. #define ESL_SINGLE_FLAG (LCID_INSTALLED | LCID_SUPPORTED)
  292. #define ESCP_SINGLE_FLAG (CP_INSTALLED | CP_SUPPORTED)
  293. //
  294. // Flag combinations.
  295. //
  296. #define WC_COMPCHK_FLAGS (WC_DISCARDNS | WC_SEPCHARS | WC_DEFAULTCHAR)
  297. #define NORM_ALL (NORM_IGNORECASE | NORM_IGNORENONSPACE | \
  298. NORM_IGNORESYMBOLS | NORM_IGNOREKANATYPE | \
  299. NORM_IGNOREWIDTH)
  300. #define NORM_SORTKEY_ONLY (NORM_IGNORECASE | NORM_IGNOREKANATYPE | \
  301. NORM_IGNOREWIDTH | SORT_STRINGSORT)
  302. #define NORM_ALL_CASE (NORM_IGNORECASE | NORM_IGNOREKANATYPE | \
  303. NORM_IGNOREWIDTH)
  304. #define LCMAP_NO_NORM (LCMAP_LOWERCASE | LCMAP_UPPERCASE | \
  305. LCMAP_HIRAGANA | LCMAP_KATAKANA | \
  306. LCMAP_HALFWIDTH | LCMAP_FULLWIDTH | \
  307. LCMAP_TRADITIONAL_CHINESE | \
  308. LCMAP_SIMPLIFIED_CHINESE)
  309. //
  310. // Get the LCType value from an LCType.
  311. //
  312. #define NLS_GET_LCTYPE_VALUE(x) (x & ~(LOCALE_NOUSEROVERRIDE | \
  313. LOCALE_USE_CP_ACP | \
  314. LOCALE_RETURN_NUMBER))
  315. //
  316. // Get the CalType value from a CalType.
  317. //
  318. #define NLS_GET_CALTYPE_VALUE(x) (x & ~(CAL_NOUSEROVERRIDE | \
  319. CAL_USE_CP_ACP | \
  320. CAL_RETURN_NUMBER))
  321. //
  322. // Separator and Terminator Values - Sortkey String.
  323. //
  324. #define SORTKEY_SEPARATOR 0x01
  325. #define SORTKEY_TERMINATOR 0x00
  326. //
  327. // Lowest weight values.
  328. // Used to remove trailing DW and CW values.
  329. //
  330. #define MIN_DW 2
  331. #define MIN_CW 2
  332. //
  333. // Bit mask values.
  334. //
  335. // Case Weight (CW) - 8 bits:
  336. // bit 0 => width
  337. // bit 1,2 => small kana, sei-on
  338. // bit 3,4 => upper/lower case
  339. // bit 5 => kana
  340. // bit 6,7 => compression
  341. //
  342. #define COMPRESS_3_MASK 0xc0 // compress 3-to-1 or 2-to-1
  343. #define COMPRESS_2_MASK 0x80 // compress 2-to-1
  344. #define CASE_MASK 0x3f // zero out compression bits
  345. #define CASE_UPPER_MASK 0xe7 // zero out case bits
  346. #define CASE_SMALL_MASK 0xf9 // zero out small modifier bits
  347. #define CASE_KANA_MASK 0xdf // zero out kana bit
  348. #define CASE_WIDTH_MASK 0xfe // zero out width bit
  349. #define SW_POSITION_MASK 0x8003 // avoid 0 or 1 in bytes of word
  350. //
  351. // Bit Mask Values for CompareString.
  352. //
  353. // NOTE: Due to intel byte reversal, the DWORD value is backwards:
  354. // CW DW SM AW
  355. //
  356. // Case Weight (CW) - 8 bits:
  357. // bit 0 => width
  358. // bit 4 => case
  359. // bit 5 => kana
  360. // bit 6,7 => compression
  361. //
  362. #define CMP_MASKOFF_NONE 0xffffffff
  363. #define CMP_MASKOFF_DW 0xff00ffff
  364. #define CMP_MASKOFF_CW 0xe7ffffff
  365. #define CMP_MASKOFF_DW_CW 0xe700ffff
  366. #define CMP_MASKOFF_COMPRESSION 0x3fffffff
  367. #define CMP_MASKOFF_KANA 0xdfffffff
  368. #define CMP_MASKOFF_WIDTH 0xfeffffff
  369. #define CMP_MASKOFF_KANA_WIDTH 0xdeffffff
  370. //
  371. // Masks to isolate the various bits in the case weight.
  372. //
  373. // NOTE: Bit 2 must always equal 1 to avoid getting a byte value
  374. // of either 0 or 1.
  375. //
  376. #define CASE_XW_MASK 0xc4
  377. #define ISOLATE_SMALL ( (BYTE)((~CASE_SMALL_MASK) | CASE_XW_MASK) )
  378. #define ISOLATE_KANA ( (BYTE)((~CASE_KANA_MASK) | CASE_XW_MASK) )
  379. #define ISOLATE_WIDTH ( (BYTE)((~CASE_WIDTH_MASK) | CASE_XW_MASK) )
  380. //
  381. // UW Mask for Cho-On:
  382. // Leaves bit 7 on in AW, so it becomes Repeat if it follows Kana N.
  383. //
  384. #define CHO_ON_UW_MASK 0xff87
  385. //
  386. // Values for fareast special case alphanumeric weights.
  387. //
  388. #define AW_REPEAT 0
  389. #define AW_CHO_ON 1
  390. #define MAX_SPECIAL_AW AW_CHO_ON
  391. //
  392. // Values for weight 5 - East Asia Extra Weights.
  393. //
  394. #define WT_FIVE_KANA 3
  395. #define WT_FIVE_REPEAT 4
  396. #define WT_FIVE_CHO_ON 5
  397. //
  398. // Values for CJK Unified Ideographs Extension A range.
  399. // 0x3400 thru 0x4dbf
  400. //
  401. #define SM_EXT_A 254 // SM for Extension A
  402. #define AW_EXT_A 255 // AW for Extension A
  403. //
  404. // Values for UW extra weights (e.g. Jamo (old Hangul)).
  405. //
  406. #define SM_UW_XW 255 // SM for extra UW weights
  407. //
  408. // Script Member Values.
  409. //
  410. #define UNSORTABLE 0
  411. #define NONSPACE_MARK 1
  412. #define EXPANSION 2
  413. #define FAREAST_SPECIAL 3
  414. #define JAMO_SPECIAL 4
  415. #define EXTENSION_A 5
  416. #define PUNCTUATION 6
  417. #define SYMBOL_1 7
  418. #define SYMBOL_2 8
  419. #define SYMBOL_3 9
  420. #define SYMBOL_4 10
  421. #define SYMBOL_5 11
  422. #define NUMERIC_1 12
  423. #define NUMERIC_2 13
  424. #define LATIN 14
  425. #define GREEK 15
  426. #define CYRILLIC 16
  427. #define ARMENIAN 17
  428. #define HEBREW 18
  429. #define ARABIC 19
  430. #define DEVANAGARI 20
  431. #define BENGALI 21
  432. #define GURMUKKHI 22
  433. #define GUJARATI 23
  434. #define ORIYA 24
  435. #define TAMIL 25
  436. #define TELUGU 26
  437. #define KANNADA 27
  438. #define MALAYLAM 28
  439. #define SINHALESE 29
  440. #define THAI 30
  441. #define LAO 31
  442. #define TIBETAN 32
  443. #define GEORGIAN 33
  444. #define KANA 34
  445. #define BOPOMOFO 35
  446. #define HANGUL 36
  447. #define IDEOGRAPH 128
  448. #define MAX_SPECIAL_CASE SYMBOL_5
  449. #define FIRST_SCRIPT LATIN
  450. //
  451. // Calendar Type Values.
  452. //
  453. #define CAL_NO_OPTIONAL 0 // no optional calendars
  454. #define CAL_LAST CAL_GREGORIAN_XLIT_FRENCH // greatest calendar value
  455. //
  456. // The following calendars are defined in winnls.w:
  457. //
  458. // #define CAL_GREGORIAN 1
  459. // #define CAL_GREGORIAN_US 2
  460. // #define CAL_JAPAN 3
  461. // #define CAL_TAIWAN 4
  462. // #define CAL_KOREA 5
  463. // #define CAL_HIJRI 6
  464. // #define CAL_THAI 7
  465. // #define CAL_HEBREW 8
  466. // #define CAL_GREGORIAN_ME_FRENCH 9
  467. // #define CAL_GREGORIAN_ARABIC 10
  468. // #define CAL_GREGORIAN_XLIT_ENGLISH 11
  469. // #define CAL_GREGORIAN_XLIT_FRENCH 12
  470. //
  471. //
  472. // Constants to define range of Unicode private use area.
  473. //
  474. #define PRIVATE_USE_BEGIN 0xe000
  475. #define PRIVATE_USE_END 0xf8ff
  476. //
  477. // Internal flag for SpecialMBToWC routine.
  478. //
  479. #define MB_INVALID_CHAR_CHECK MB_ERR_INVALID_CHARS
  480. //
  481. // Geo values.
  482. //
  483. #define MAX_GEO_STRING_SIZE 1024
  484. //
  485. // Resource String Table Values.
  486. //
  487. #define RC_STRING_SEPARATOR '$'
  488. #define RC_LANGUAGE_NAME 0
  489. #define RC_COUNTRY_NAME 1
  490. #define RC_LANGUAGE_GROUP_NAME 2
  491. #define RC_CODE_PAGE_NAME 3
  492. #define RC_GEO_FRIENDLY_NAME 4
  493. #define RC_GEO_OFFICIAL_NAME 5
  494. #define RC_SORT_NAMES 6
  495. ////////////////////////////////////////////////////////////////////////////
  496. //
  497. // Typedef Declarations.
  498. //
  499. ////////////////////////////////////////////////////////////////////////////
  500. //
  501. // Constant Types
  502. //
  503. typedef LPWORD P844_TABLE; // ptr to 8:4:4 table
  504. typedef LPWORD PMB_TABLE; // ptr to MB translation table
  505. typedef PMB_TABLE PGLYPH_TABLE; // ptr to GLYPH translation table
  506. typedef LPWORD PDBCS_RANGE; // ptr to DBCS range
  507. typedef LPWORD PDBCS_OFFSETS; // ptr to DBCS offset section
  508. typedef LPWORD PDBCS_TABLE; // ptr to DBCS translation table
  509. typedef PVOID PWC_TABLE; // ptr to WC translation table
  510. typedef P844_TABLE PCTYPE; // ptr to Character Type table
  511. typedef P844_TABLE PCASE; // ptr to Lower or Upper Case table
  512. typedef P844_TABLE PADIGIT; // ptr to Ascii Digits table
  513. typedef P844_TABLE PCZONE; // ptr to Fold Compat. Zone table
  514. typedef P844_TABLE PKANA; // ptr to Hiragana/Katakana table
  515. typedef P844_TABLE PHALFWIDTH; // ptr to Half Width table
  516. typedef P844_TABLE PFULLWIDTH; // ptr to Full Width table
  517. typedef P844_TABLE PCHINESE; // ptr to Traditional/Simplified Chinese table
  518. typedef P844_TABLE PPRECOMP; // ptr to PreComposed table
  519. typedef LPWORD PCOMP_GRID; // ptr to Composite table 2D grid
  520. typedef LPWORD PLOC_INFO; // ptr to locale information
  521. typedef LPWORD PCAL_INFO; // ptr to calendar information
  522. typedef DWORD REVERSE_DW; // reverse diacritic table
  523. typedef REVERSE_DW *PREVERSE_DW; // ptr to reverse diacritic table
  524. typedef DWORD DBL_COMPRESS; // double compression table
  525. typedef DBL_COMPRESS *PDBL_COMPRESS; // ptr to double compression table
  526. typedef LPWORD PCOMPRESS; // ptr to compression table (2 or 3)
  527. //
  528. // Proc Definition for Code Page DLL Routine.
  529. //
  530. typedef DWORD (*LPFN_CP_PROC)(DWORD, DWORD, LPSTR, int, LPWSTR, int, LPCPINFO);
  531. //
  532. // CP Information Table Structure (as it is in the data file).
  533. //
  534. typedef struct cp_table_s {
  535. WORD CodePage; // code page number
  536. WORD MaxCharSize; // max length (bytes) of a char
  537. WORD wDefaultChar; // default character (MB)
  538. WORD wUniDefaultChar; // default character (Unicode)
  539. WORD wTransDefaultChar; // translation of wDefaultChar (Unicode)
  540. WORD wTransUniDefaultChar; // translation of wUniDefaultChar (MB)
  541. BYTE LeadByte[MAX_LEADBYTES]; // lead byte ranges
  542. } CP_TABLE, *PCP_TABLE;
  543. //
  544. // Composite Information Structure.
  545. //
  546. typedef struct comp_info_s {
  547. BYTE NumBase; // number base chars in grid
  548. BYTE NumNonSp; // number non space chars in grid
  549. P844_TABLE pBase; // ptr to base char table
  550. P844_TABLE pNonSp; // ptr to nonspace char table
  551. PCOMP_GRID pGrid; // ptr to 2D grid
  552. } COMP_INFO, *PCOMP_INFO;
  553. //
  554. // Code Page Hash Table Structure.
  555. //
  556. typedef struct cp_hash_s {
  557. UINT CodePage; // codepage ID
  558. LPFN_CP_PROC pfnCPProc; // ptr to code page function proc
  559. PCP_TABLE pCPInfo; // ptr to CPINFO table
  560. PMB_TABLE pMBTbl; // ptr to MB translation table
  561. PGLYPH_TABLE pGlyphTbl; // ptr to GLYPH translation table
  562. PDBCS_RANGE pDBCSRanges; // ptr to DBCS ranges
  563. PDBCS_OFFSETS pDBCSOffsets; // ptr to DBCS offsets
  564. PWC_TABLE pWC; // ptr to WC table
  565. struct cp_hash_s *pNext; // ptr to next CP hash node
  566. } CP_HASH, *PCP_HASH;
  567. //
  568. // Language Exception Header Structure.
  569. //
  570. typedef struct l_except_hdr_s {
  571. DWORD Locale; // locale id
  572. DWORD Offset; // offset to exception nodes (words)
  573. DWORD NumUpEntries; // number of upper case entries
  574. DWORD NumLoEntries; // number of lower case entries
  575. } L_EXCEPT_HDR, *PL_EXCEPT_HDR;
  576. //
  577. // Language Exception Structure.
  578. //
  579. typedef struct l_except_s
  580. {
  581. WORD UCP; // unicode code point
  582. WORD AddAmount; // amount to add to code point
  583. } L_EXCEPT, *PL_EXCEPT;
  584. //
  585. // CType header structure.
  586. //
  587. typedef struct ctype_hdr_s {
  588. WORD TblSize; // size of ctype table
  589. WORD MapSize; // size of mapping table
  590. } CTYPE_HDR, *PCTYPE_HDR;
  591. //
  592. // CType Table Structure (Mapping table structure).
  593. //
  594. typedef struct ct_values_s {
  595. WORD CType1; // ctype 1 value
  596. WORD CType2; // ctype 2 value
  597. WORD CType3; // ctype 3 value
  598. } CT_VALUES, *PCT_VALUES;
  599. //
  600. // Sortkey Structure.
  601. //
  602. typedef struct sortkey_s {
  603. union {
  604. struct sm_aw_s {
  605. BYTE Alpha; // alphanumeric weight
  606. BYTE Script; // script member
  607. } SM_AW;
  608. WORD Unicode; // unicode weight
  609. } UW;
  610. BYTE Diacritic; // diacritic weight
  611. BYTE Case; // case weight (with COMP)
  612. } SORTKEY, *PSORTKEY;
  613. //
  614. // Extra Weight Structure.
  615. //
  616. typedef struct extra_wt_s {
  617. BYTE Four; // weight 4
  618. BYTE Five; // weight 5
  619. BYTE Six; // weight 6
  620. BYTE Seven; // weight 7
  621. } EXTRA_WT, *PEXTRA_WT;
  622. //
  623. // Compression Header Structure.
  624. // This is the header for the compression tables.
  625. //
  626. typedef struct compress_hdr_s {
  627. DWORD Locale; // locale id
  628. DWORD Offset; // offset (in words)
  629. WORD Num2; // Number of 2 compressions
  630. WORD Num3; // Number of 3 compressions
  631. } COMPRESS_HDR, *PCOMPRESS_HDR;
  632. //
  633. // Compression 2 Structure.
  634. // This is for a 2 code point compression - 2 code points
  635. // compress to ONE weight.
  636. //
  637. typedef struct compress_2_s {
  638. WCHAR UCP1; // Unicode code point 1
  639. WCHAR UCP2; // Unicode code point 2
  640. SORTKEY Weights; // sortkey weights
  641. } COMPRESS_2, *PCOMPRESS_2;
  642. //
  643. // Compression 3 Structure.
  644. // This is for a 3 code point compression - 3 code points
  645. // compress to ONE weight.
  646. //
  647. typedef struct compress_3_s {
  648. WCHAR UCP1; // Unicode code point 1
  649. WCHAR UCP2; // Unicode code point 2
  650. WCHAR UCP3; // Unicode code point 3
  651. WCHAR Reserved; // dword alignment
  652. SORTKEY Weights; // sortkey weights
  653. } COMPRESS_3, *PCOMPRESS_3;
  654. //
  655. // Multiple Weight Structure.
  656. //
  657. typedef struct multiwt_s {
  658. BYTE FirstSM; // value of first script member
  659. BYTE NumSM; // number of script members in range
  660. } MULTI_WT, *PMULTI_WT;
  661. //
  662. // Ideograph Lcid Exception Structure.
  663. //
  664. typedef struct ideograph_lcid_s {
  665. DWORD Locale; // locale id
  666. WORD pFileName[14]; // ptr to file name
  667. } IDEOGRAPH_LCID, *PIDEOGRAPH_LCID;
  668. //
  669. // Expansion Structure.
  670. //
  671. typedef struct expand_s {
  672. WCHAR UCP1; // Unicode code point 1
  673. WCHAR UCP2; // Unicode code point 2
  674. } EXPAND, *PEXPAND;
  675. //
  676. // Exception Header Structure.
  677. // This is the header for the exception tables.
  678. //
  679. typedef struct except_hdr_s {
  680. DWORD Locale; // locale id
  681. DWORD Offset; // offset to exception nodes (words)
  682. DWORD NumEntries; // number of entries for locale id
  683. } EXCEPT_HDR, *PEXCEPT_HDR;
  684. //
  685. // Exception Structure.
  686. //
  687. // NOTE: May also be used for Ideograph Exceptions (4 column tables).
  688. //
  689. typedef struct except_s
  690. {
  691. WORD UCP; // unicode code point
  692. WORD Unicode; // unicode weight
  693. BYTE Diacritic; // diacritic weight
  694. BYTE Case; // case weight
  695. } EXCEPT, *PEXCEPT;
  696. //
  697. // Ideograph Exception Header Structure.
  698. //
  699. typedef struct ideograph_except_hdr_s
  700. {
  701. DWORD NumEntries; // number of entries in table
  702. DWORD NumColumns; // number of columns in table (2 or 4)
  703. } IDEOGRAPH_EXCEPT_HDR, *PIDEOGRAPH_EXCEPT_HDR;
  704. //
  705. // Ideograph Exception Structure.
  706. //
  707. typedef struct ideograph_except_s
  708. {
  709. WORD UCP; // unicode code point
  710. WORD Unicode; // unicode weight
  711. } IDEOGRAPH_EXCEPT, *PIDEOGRAPH_EXCEPT;
  712. //
  713. // Locale Information Structures.
  714. //
  715. // This is the format in which the locale information is kept in the
  716. // locale data file. These structures are only used for offsets into
  717. // the data file, not to store information.
  718. //
  719. //
  720. // Header at the top of the locale.nls file.
  721. //
  722. typedef struct loc_cal_hdr_s
  723. {
  724. DWORD NumLocales; // number of locales
  725. DWORD NumCalendars; // number of calendars
  726. DWORD CalOffset; // offset to calendar info (words)
  727. } LOC_CAL_HDR, *PLOC_CAL_HDR;
  728. #define LOCALE_HDR_OFFSET (sizeof(LOC_CAL_HDR) / sizeof(WORD))
  729. //
  730. // Per entry locale header.
  731. //
  732. // The locale header structure contains the information given in one entry
  733. // of the header for the locale information.
  734. //
  735. typedef struct locale_hdr_s {
  736. DWORD Locale; // locale ID
  737. DWORD Offset; // offset to locale information
  738. } LOCALE_HDR, *PLOCALE_HDR;
  739. #define LOCALE_HDR_SIZE (sizeof(LOCALE_HDR) / sizeof(WORD))
  740. //
  741. // The fixed structure contains the locale information that is of
  742. // fixed length and in the order in which it is given in the file.
  743. //
  744. typedef struct locale_fixed_s
  745. {
  746. WORD DefaultACP; // default ACP - integer format
  747. WORD szILanguage[5]; // language id
  748. WORD szICountry[6]; // country id
  749. WORD szIGeoID[8]; // geographical location identifier
  750. WORD szIDefaultLang[5]; // default language ID
  751. WORD szIDefaultCtry[6]; // default country ID
  752. WORD szIDefaultACP[6]; // default ansi code page ID
  753. WORD szIDefaultOCP[6]; // default oem code page ID
  754. WORD szIDefaultMACCP[6]; // default mac code page ID
  755. WORD szIDefaultEBCDICCP[6]; // default ebcdic code page ID
  756. WORD szIMeasure[2]; // system of measurement
  757. WORD szIPaperSize[2]; // default paper size
  758. WORD szIDigits[3]; // number of fractional digits
  759. WORD szILZero[2]; // leading zeros for decimal
  760. WORD szINegNumber[2]; // negative number format
  761. WORD szIDigitSubstitution[2]; // digit substitution
  762. WORD szICurrDigits[3]; // # local monetary fractional digits
  763. WORD szIIntlCurrDigits[3]; // # intl monetary fractional digits
  764. WORD szICurrency[2]; // positive currency format
  765. WORD szINegCurr[3]; // negative currency format
  766. WORD szIPosSignPosn[2]; // format of positive sign
  767. WORD szIPosSymPrecedes[2]; // if mon symbol precedes positive
  768. WORD szIPosSepBySpace[2]; // if mon symbol separated by space
  769. WORD szINegSignPosn[2]; // format of negative sign
  770. WORD szINegSymPrecedes[2]; // if mon symbol precedes negative
  771. WORD szINegSepBySpace[2]; // if mon symbol separated by space
  772. WORD szITime[2]; // time format
  773. WORD szITLZero[2]; // leading zeros for time field
  774. WORD szITimeMarkPosn[2]; // time marker position
  775. WORD szIDate[2]; // short date order
  776. WORD szICentury[2]; // century format (short date)
  777. WORD szIDayLZero[2]; // leading zeros for day field (short date)
  778. WORD szIMonLZero[2]; // leading zeros for month field (short date)
  779. WORD szILDate[2]; // long date order
  780. WORD szICalendarType[3]; // type of calendar
  781. WORD szIFirstDayOfWk[2]; // first day of week
  782. WORD szIFirstWkOfYr[2]; // first week of year
  783. WORD szFontSignature[MAX_FONTSIGNATURE];
  784. } LOCALE_FIXED, *PLOCALE_FIXED;
  785. //
  786. // The variable structure contains the offsets to the various pieces of
  787. // locale information that is of variable length. It is in the order
  788. // in which it is given in the file.
  789. //
  790. typedef struct locale_var_s
  791. {
  792. WORD SEngLanguage; // English language name
  793. WORD SAbbrevLang; // abbreviated language name
  794. WORD SAbbrevLangISO; // ISO abbreviated language name
  795. WORD SNativeLang; // native language name
  796. WORD SEngCountry; // English country name
  797. WORD SAbbrevCtry; // abbreviated country name
  798. WORD SAbbrevCtryISO; // ISO abbreviated country name
  799. WORD SNativeCtry; // native country name
  800. WORD SList; // list separator
  801. WORD SDecimal; // decimal separator
  802. WORD SThousand; // thousands separator
  803. WORD SGrouping; // grouping of digits
  804. WORD SNativeDigits; // native digits 0-9
  805. WORD SCurrency; // local monetary symbol
  806. WORD SIntlSymbol; // international monetary symbol
  807. WORD SEngCurrName; // English currency name
  808. WORD SNativeCurrName; // native currency name
  809. WORD SMonDecSep; // monetary decimal separator
  810. WORD SMonThousSep; // monetary thousands separator
  811. WORD SMonGrouping; // monetary grouping of digits
  812. WORD SPositiveSign; // positive sign
  813. WORD SNegativeSign; // negative sign
  814. WORD STimeFormat; // time format
  815. WORD STime; // time separator
  816. WORD S1159; // AM designator
  817. WORD S2359; // PM designator
  818. WORD SShortDate; // short date format
  819. WORD SDate; // date separator
  820. WORD SYearMonth; // year month format
  821. WORD SLongDate; // long date format
  822. WORD IOptionalCal; // additional calendar type(s)
  823. WORD SDayName1; // day name 1
  824. WORD SDayName2; // day name 2
  825. WORD SDayName3; // day name 3
  826. WORD SDayName4; // day name 4
  827. WORD SDayName5; // day name 5
  828. WORD SDayName6; // day name 6
  829. WORD SDayName7; // day name 7
  830. WORD SAbbrevDayName1; // abbreviated day name 1
  831. WORD SAbbrevDayName2; // abbreviated day name 2
  832. WORD SAbbrevDayName3; // abbreviated day name 3
  833. WORD SAbbrevDayName4; // abbreviated day name 4
  834. WORD SAbbrevDayName5; // abbreviated day name 5
  835. WORD SAbbrevDayName6; // abbreviated day name 6
  836. WORD SAbbrevDayName7; // abbreviated day name 7
  837. WORD SMonthName1; // month name 1
  838. WORD SMonthName2; // month name 2
  839. WORD SMonthName3; // month name 3
  840. WORD SMonthName4; // month name 4
  841. WORD SMonthName5; // month name 5
  842. WORD SMonthName6; // month name 6
  843. WORD SMonthName7; // month name 7
  844. WORD SMonthName8; // month name 8
  845. WORD SMonthName9; // month name 9
  846. WORD SMonthName10; // month name 10
  847. WORD SMonthName11; // month name 11
  848. WORD SMonthName12; // month name 12
  849. WORD SMonthName13; // month name 13 (if exists)
  850. WORD SAbbrevMonthName1; // abbreviated month name 1
  851. WORD SAbbrevMonthName2; // abbreviated month name 2
  852. WORD SAbbrevMonthName3; // abbreviated month name 3
  853. WORD SAbbrevMonthName4; // abbreviated month name 4
  854. WORD SAbbrevMonthName5; // abbreviated month name 5
  855. WORD SAbbrevMonthName6; // abbreviated month name 6
  856. WORD SAbbrevMonthName7; // abbreviated month name 7
  857. WORD SAbbrevMonthName8; // abbreviated month name 8
  858. WORD SAbbrevMonthName9; // abbreviated month name 9
  859. WORD SAbbrevMonthName10; // abbreviated month name 10
  860. WORD SAbbrevMonthName11; // abbreviated month name 11
  861. WORD SAbbrevMonthName12; // abbreviated month name 12
  862. WORD SAbbrevMonthName13; // abbreviated month name 13 (if exists)
  863. WORD SEndOfLocale; // end of locale information
  864. } LOCALE_VAR, *PLOCALE_VAR;
  865. //
  866. // Per entry calendar header.
  867. //
  868. // The calendar header structure contains the information given in one entry
  869. // of the header for the calendar information.
  870. //
  871. typedef struct calendar_hdr_s
  872. {
  873. WORD Calendar; // calendar id
  874. WORD Offset; // offset to calendar info (words)
  875. } CALENDAR_HDR, *PCALENDAR_HDR;
  876. #define CALENDAR_HDR_SIZE (sizeof(CALENDAR_HDR) / sizeof(WORD))
  877. //
  878. // The variable structure contains the offsets to the various pieces of
  879. // calendar information that is of variable length. It is in the order
  880. // in which it is given in the file.
  881. //
  882. // The NumRanges value is the number of era ranges. If this value is zero,
  883. // then there are no year offsets.
  884. //
  885. // The IfNames value is a boolean. If it is 0, then there are NO special
  886. // day or month names for the calendar. If it is 1, then there ARE
  887. // special day and month names for the calendar.
  888. //
  889. // The rest of the values are offsets to the appropriate strings.
  890. //
  891. typedef struct calendar_var_s
  892. {
  893. WORD NumRanges; // number of era ranges
  894. WORD IfNames; // if any day or month names exist
  895. WORD SCalendar; // calendar id
  896. WORD STwoDigitYearMax; // two digit year max
  897. WORD SEraRanges; // era ranges
  898. WORD SShortDate; // short date format
  899. WORD SYearMonth; // year month format
  900. WORD SLongDate; // long date format
  901. WORD SDayName1; // day name 1
  902. WORD SDayName2; // day name 2
  903. WORD SDayName3; // day name 3
  904. WORD SDayName4; // day name 4
  905. WORD SDayName5; // day name 5
  906. WORD SDayName6; // day name 6
  907. WORD SDayName7; // day name 7
  908. WORD SAbbrevDayName1; // abbreviated day name 1
  909. WORD SAbbrevDayName2; // abbreviated day name 2
  910. WORD SAbbrevDayName3; // abbreviated day name 3
  911. WORD SAbbrevDayName4; // abbreviated day name 4
  912. WORD SAbbrevDayName5; // abbreviated day name 5
  913. WORD SAbbrevDayName6; // abbreviated day name 6
  914. WORD SAbbrevDayName7; // abbreviated day name 7
  915. WORD SMonthName1; // month name 1
  916. WORD SMonthName2; // month name 2
  917. WORD SMonthName3; // month name 3
  918. WORD SMonthName4; // month name 4
  919. WORD SMonthName5; // month name 5
  920. WORD SMonthName6; // month name 6
  921. WORD SMonthName7; // month name 7
  922. WORD SMonthName8; // month name 8
  923. WORD SMonthName9; // month name 9
  924. WORD SMonthName10; // month name 10
  925. WORD SMonthName11; // month name 11
  926. WORD SMonthName12; // month name 12
  927. WORD SMonthName13; // month name 13
  928. WORD SAbbrevMonthName1; // abbreviated month name 1
  929. WORD SAbbrevMonthName2; // abbreviated month name 2
  930. WORD SAbbrevMonthName3; // abbreviated month name 3
  931. WORD SAbbrevMonthName4; // abbreviated month name 4
  932. WORD SAbbrevMonthName5; // abbreviated month name 5
  933. WORD SAbbrevMonthName6; // abbreviated month name 6
  934. WORD SAbbrevMonthName7; // abbreviated month name 7
  935. WORD SAbbrevMonthName8; // abbreviated month name 8
  936. WORD SAbbrevMonthName9; // abbreviated month name 9
  937. WORD SAbbrevMonthName10; // abbreviated month name 10
  938. WORD SAbbrevMonthName11; // abbreviated month name 11
  939. WORD SAbbrevMonthName12; // abbreviated month name 12
  940. WORD SAbbrevMonthName13; // abbreviated month name 13
  941. WORD SEndOfCalendar; // end of calendar information
  942. } CALENDAR_VAR, *PCALENDAR_VAR;
  943. //
  944. // IOptionalCalendar structure (locale info).
  945. //
  946. typedef struct opt_cal_s
  947. {
  948. WORD CalId; // calendar id
  949. WORD Offset; // offset to next optional calendar
  950. WORD pCalStr[1]; // calendar id string (variable length)
  951. // WORD pCalNameStr[1]; // calendar name string (variable length)
  952. } OPT_CAL, *POPT_CAL;
  953. //
  954. // SEraRanges structure inside calendar info.
  955. //
  956. typedef struct era_range_s
  957. {
  958. WORD Month; // month of era beginning
  959. WORD Day; // day of era beginning
  960. WORD Year; // year of era beginning
  961. WORD Offset; // offset to next era info block
  962. WORD pYearStr[1]; // year string (variable length)
  963. // WORD pEraNameStr[1]; // era name string (variable length)
  964. } ERA_RANGE, *PERA_RANGE;
  965. //
  966. // Locale Hash Table Structure.
  967. //
  968. typedef struct loc_hash_s {
  969. LCID Locale; // locale ID
  970. PLOCALE_VAR pLocaleHdr; // ptr to locale header info
  971. PLOCALE_FIXED pLocaleFixed; // ptr to locale fixed size info
  972. PCASE pUpperCase; // ptr to Upper Case table
  973. PCASE pLowerCase; // ptr to Lower Case table
  974. PCASE pUpperLinguist; // ptr to Upper Case Linguistic table
  975. PCASE pLowerLinguist; // ptr to Lower Case Linguistic table
  976. PSORTKEY pSortkey; // ptr to sortkey table
  977. BOOL IfReverseDW; // if DW should go from right to left
  978. BOOL IfCompression; // if compression code points exist
  979. BOOL IfDblCompression; // if double compression exists
  980. BOOL IfIdeographFailure; // if ideograph table failed to load
  981. PCOMPRESS_HDR pCompHdr; // ptr to compression header
  982. PCOMPRESS_2 pCompress2; // ptr to 2 compression table
  983. PCOMPRESS_3 pCompress3; // ptr to 3 compression table
  984. struct loc_hash_s *pNext; // ptr to next locale hash node
  985. } LOC_HASH, *PLOC_HASH;
  986. //
  987. // Hash Table Pointers.
  988. //
  989. typedef PCP_HASH *PCP_HASH_TBL; // ptr to a code page hash table
  990. typedef PLOC_HASH *PLOC_HASH_TBL; // ptr to a locale hash table
  991. //
  992. // Geo Information structure. This structure holds information about
  993. // a geographical location on earth.
  994. //
  995. typedef struct tagGeoInfo {
  996. GEOID GeoId;
  997. WCHAR szLatitude[12];
  998. WCHAR szLongitude[12];
  999. GEOCLASS GeoClass;
  1000. GEOID ParentGeoId;
  1001. WCHAR szISO3166Abbrev2[4];
  1002. WCHAR szISO3166Abbrev3[4];
  1003. WORD wISO3166;
  1004. WORD Reserved; // dword alignment
  1005. } GEOINFO, *PGEOINFO;
  1006. //
  1007. // GEOID/LCID structure. This structure is used to navigate through
  1008. // the table that maps corresponding Language ID and Geo ID.
  1009. //
  1010. typedef struct tagGEOIDLCID {
  1011. LCID lcid;
  1012. GEOID GeoId;
  1013. LANGID LangId;
  1014. WORD Reserved; // dword alignment
  1015. } GEOLCID, *PGEOLCID;
  1016. //
  1017. // GEO tables structure. This structure is used to get information
  1018. // related to all geo tables.
  1019. //
  1020. typedef struct tagGeoTableHdr {
  1021. WCHAR szSig[4];
  1022. unsigned long nFileSize;
  1023. DWORD dwOffsetGeoInfo;
  1024. long nGeoInfo;
  1025. DWORD dwOffsetGeoLCID;
  1026. long nGeoLCID;
  1027. } GEOTABLEHDR, *PGEOTABLEHDR;
  1028. //
  1029. // Jamo Sequence Sorting Info.
  1030. //
  1031. typedef struct {
  1032. BYTE m_bOld; // sequence occurs only in old Hangul flag
  1033. CHAR m_chLeadingIndex; // indices used to locate prior modern Hangul syllable
  1034. CHAR m_chVowelIndex;
  1035. CHAR m_chTrailingIndex;
  1036. BYTE m_ExtraWeight; // extra weights that distinguish this from
  1037. // other old Hangul syllables, depending
  1038. // on the jamo, this can be a weight for
  1039. // leading jamo, vowel jamo, or trailing jamo.
  1040. } JAMO_SORT_INFO, *PJAMO_SORT_INFO;
  1041. //
  1042. // Jamo Index Table Entry.
  1043. //
  1044. typedef struct {
  1045. JAMO_SORT_INFO SortInfo; // sequence sorting info
  1046. BYTE Index; // index into the composition array
  1047. BYTE TransitionCount; // # of possible transitions from this state
  1048. BYTE Reserved; // word alignment
  1049. } JAMO_TABLE, *PJAMO_TABLE;
  1050. //
  1051. // Jamo Combination Table Entry.
  1052. //
  1053. // NOTE: Make sure this structure is WORD aligned. Otherwise, code will
  1054. // fail in GetDefaultSortTable().
  1055. //
  1056. typedef struct {
  1057. WCHAR m_wcCodePoint; // Code point value that enters this state
  1058. JAMO_SORT_INFO m_SortInfo; // Sequence sorting info
  1059. BYTE m_bTransitionCount; // # of possible transitions from this state
  1060. } JAMO_COMPOSE_STATE, *PJAMO_COMPOSE_STATE;
  1061. //
  1062. // Table Pointers Structure. This structure contains pointers to
  1063. // the various tables needed for the NLS APIs. There should be only
  1064. // ONE of these for each process, and the information should be
  1065. // global to the process.
  1066. //
  1067. #define NUM_SM 256 // total number of script members
  1068. #define NUM_CAL 64 // total number calendars allowed
  1069. typedef struct tbl_ptrs_s {
  1070. PCP_HASH_TBL pCPHashTbl; // ptr to Code Page hash table
  1071. PLOC_HASH_TBL pLocHashTbl; // ptr to Locale hash table
  1072. PLOC_INFO pLocaleInfo; // ptr to locale table (all locales)
  1073. DWORD NumCalendars; // number of calendars
  1074. PCAL_INFO pCalendarInfo; // ptr to beginning of calendar info
  1075. PCAL_INFO pCalTbl[NUM_CAL]; // ptr to calendar table array
  1076. P844_TABLE pDefaultLanguage; // ptr to default language table
  1077. P844_TABLE pLinguistLanguage; // ptr to default linguistic lang table
  1078. LARGE_INTEGER LinguistLangSize; // size of linguistic lang table
  1079. int NumLangException; // number of language exceptions
  1080. PL_EXCEPT_HDR pLangExceptHdr; // ptr to lang exception table header
  1081. PL_EXCEPT pLangException; // ptr to lang exception tables
  1082. PCT_VALUES pCTypeMap; // ptr to Ctype Mapping table
  1083. PCTYPE pCType844; // ptr to Ctype 8:4:4 table
  1084. PADIGIT pADigit; // ptr to Ascii Digits table
  1085. PCZONE pCZone; // ptr to Compatibility Zone table
  1086. PKANA pHiragana; // ptr to Hiragana table
  1087. PKANA pKatakana; // ptr to Katakana table
  1088. PHALFWIDTH pHalfWidth; // ptr to Half Width table
  1089. PFULLWIDTH pFullWidth; // ptr to Full Width table
  1090. PCHINESE pTraditional; // ptr to Traditional Chinese table
  1091. PCHINESE pSimplified; // ptr to Simplified Chinese table
  1092. PPRECOMP pPreComposed; // ptr to PreComposed Table
  1093. PCOMP_INFO pComposite; // ptr to Composite info structure
  1094. DWORD NumReverseDW; // number of REVERSE DIACRITICS
  1095. DWORD NumDblCompression; // number of DOUBLE COMPRESSION locales
  1096. DWORD NumIdeographLcid; // number of IDEOGRAPH LCIDs
  1097. DWORD NumExpansion; // number of EXPANSIONS
  1098. DWORD NumCompression; // number of COMPRESSION locales
  1099. DWORD NumException; // number of EXCEPTION locales
  1100. DWORD NumMultiWeight; // number of MULTIPLE WEIGHTS
  1101. int NumJamoIndex; // number of entires for Jamo Index Table
  1102. int NumJamoComposition; // number of entires for Jamo Composition Table
  1103. PSORTKEY pDefaultSortkey; // ptr to default sortkey table
  1104. LARGE_INTEGER DefaultSortkeySize; // size of default sortkey section
  1105. PREVERSE_DW pReverseDW; // ptr to reverse diacritic table
  1106. PDBL_COMPRESS pDblCompression; // ptr to double compression table
  1107. PIDEOGRAPH_LCID pIdeographLcid; // ptr to ideograph lcid table
  1108. PEXPAND pExpansion; // ptr to expansion table
  1109. PCOMPRESS_HDR pCompressHdr; // ptr to compression table header
  1110. PCOMPRESS pCompression; // ptr to compression tables
  1111. PEXCEPT_HDR pExceptHdr; // ptr to exception table header
  1112. PEXCEPT pException; // ptr to exception tables
  1113. PMULTI_WT pMultiWeight; // ptr to multiple weights table
  1114. BYTE SMWeight[NUM_SM]; // script member weights
  1115. PJAMO_TABLE pJamoIndex; // ptr ot Jamo Index table
  1116. PJAMO_COMPOSE_STATE pJamoComposition; // ptr to Jamo Composition state machine table
  1117. long nGeoInfo; // number of GEOINFO entries
  1118. PGEOINFO pGeoInfo; // ptr to gegraphical info location table
  1119. long nGeoLCID; // number of GEOID/LCID entries
  1120. PGEOLCID pGeoLCID; // ptr to GEOID/LCID mapping table
  1121. } TBL_PTRS, *PTBL_PTRS;
  1122. typedef struct nls_locale_cache
  1123. {
  1124. NLS_USER_INFO NlsInfo; // NLS cached information
  1125. HKEY CurrentUserKeyHandle; // Cached key handle thread impersonation
  1126. } NLS_LOCAL_CACHE, *PNLS_LOCAL_CACHE;
  1127. //
  1128. // Generic Enum Proc Definitions.
  1129. //
  1130. typedef BOOL (CALLBACK* NLS_ENUMPROC)(PVOID);
  1131. typedef BOOL (CALLBACK* NLS_ENUMPROCEX)(PVOID, DWORD);
  1132. typedef BOOL (CALLBACK* NLS_ENUMPROC2)(DWORD, DWORD, PVOID, LONG_PTR);
  1133. typedef BOOL (CALLBACK* NLS_ENUMPROC3)(DWORD, PVOID, PVOID, DWORD, LONG_PTR);
  1134. typedef BOOL (CALLBACK* NLS_ENUMPROC4)(PVOID, LONG_PTR);
  1135. ////////////////////////////////////////////////////////////////////////////
  1136. //
  1137. // Macro Definitions.
  1138. //
  1139. ////////////////////////////////////////////////////////////////////////////
  1140. //
  1141. // Get the wide character count from a byte count.
  1142. //
  1143. #define GET_WC_COUNT(bc) ((bc) / sizeof(WCHAR))
  1144. //
  1145. // Get the data pointer for the KEY_VALUE_FULL_INFORMATION structure.
  1146. //
  1147. #define GET_VALUE_DATA_PTR(p) ((LPWSTR)((PBYTE)(p) + (p)->DataOffset))
  1148. //
  1149. // Macros For High and Low Nibbles of a BYTE.
  1150. //
  1151. #define LO_NIBBLE(b) ((BYTE)((BYTE)(b) & 0xF))
  1152. #define HI_NIBBLE(b) ((BYTE)(((BYTE)(b) >> 4) & 0xF))
  1153. //
  1154. // Macros for Extracting the 8:4:4 Index Values.
  1155. //
  1156. #define GET8(w) (HIBYTE(w))
  1157. #define GETHI4(w) (HI_NIBBLE(LOBYTE(w)))
  1158. #define GETLO4(w) (LO_NIBBLE(LOBYTE(w)))
  1159. //
  1160. // Macros for setting and checking most significant bit of flag.
  1161. //
  1162. #define SET_MSB(fl) (fl |= MSB_FLAG)
  1163. #define IS_MSB(fl) (fl & MSB_FLAG)
  1164. //
  1165. // Macro to check if more than one bit is set.
  1166. // Returns 1 if more than one bit set, 0 otherwise.
  1167. //
  1168. #define MORE_THAN_ONE(f, bits) (((f & bits) - 1) & (f & bits))
  1169. //
  1170. // Macros for single and double byte code pages.
  1171. //
  1172. #define IS_SBCS_CP(pHash) (pHash->pCPInfo->MaxCharSize == 1)
  1173. #define IS_DBCS_CP(pHash) (pHash->pCPInfo->MaxCharSize == 2)
  1174. ////////////////////////////////////////////////////////////////////////////
  1175. //
  1176. // TRAVERSE_844_B
  1177. //
  1178. // Traverses the 8:4:4 translation table for the given wide character. It
  1179. // returns the final value of the 8:4:4 table, which is a BYTE in length.
  1180. //
  1181. // NOTE: Offsets in table are in BYTES.
  1182. //
  1183. // Broken Down Version:
  1184. // --------------------
  1185. // Incr = pTable[GET8(wch)] / sizeof(WORD);
  1186. // Incr = pTable[Incr + GETHI4(wch)];
  1187. // Value = (BYTE *)pTable[Incr + GETLO4(wch)];
  1188. //
  1189. // DEFINED AS A MACRO.
  1190. //
  1191. // 05-31-91 JulieB Created.
  1192. ////////////////////////////////////////////////////////////////////////////
  1193. #define TRAVERSE_844_B(pTable, wch) \
  1194. (((BYTE *)pTable)[pTable[(pTable[GET8(wch)] / sizeof(WORD)) + \
  1195. GETHI4(wch)] + \
  1196. GETLO4(wch)])
  1197. ////////////////////////////////////////////////////////////////////////////
  1198. //
  1199. // TRAVERSE_844_W
  1200. //
  1201. // Traverses the 8:4:4 translation table for the given wide character. It
  1202. // returns the final value of the 8:4:4 table, which is a WORD in length.
  1203. //
  1204. // Broken Down Version:
  1205. // --------------------
  1206. // Incr = pTable[GET8(wch)];
  1207. // Incr = pTable[Incr + GETHI4(wch)];
  1208. // Value = pTable[Incr + GETLO4(wch)];
  1209. //
  1210. // DEFINED AS A MACRO.
  1211. //
  1212. // 05-31-91 JulieB Created.
  1213. ////////////////////////////////////////////////////////////////////////////
  1214. #define TRAVERSE_844_W(pTable, wch) \
  1215. (pTable[pTable[pTable[GET8(wch)] + GETHI4(wch)] + GETLO4(wch)])
  1216. ////////////////////////////////////////////////////////////////////////////
  1217. //
  1218. // TRAVERSE_844_D
  1219. //
  1220. // Traverses the 8:4:4 translation table for the given wide character. It
  1221. // fills in the final word values, Value1 and Value2. The final value of the
  1222. // 8:4:4 table is a DWORD, so both Value1 and Value2 are filled in.
  1223. //
  1224. // Broken Down Version:
  1225. // --------------------
  1226. // Incr = pTable[GET8(wch)];
  1227. // Incr = pTable[Incr + GETHI4(wch)];
  1228. // pTable += Incr + (GETLO4(wch) * 2);
  1229. // Value1 = pTable[0];
  1230. // Value2 = pTable[1];
  1231. //
  1232. // DEFINED AS A MACRO.
  1233. //
  1234. // 05-31-91 JulieB Created.
  1235. ////////////////////////////////////////////////////////////////////////////
  1236. #define TRAVERSE_844_D(pTable, wch, Value1, Value2) \
  1237. { \
  1238. pTable += pTable[pTable[GET8(wch)] + GETHI4(wch)] + (GETLO4(wch) * 2); \
  1239. Value1 = pTable[0]; \
  1240. Value2 = pTable[1]; \
  1241. }
  1242. ////////////////////////////////////////////////////////////////////////////
  1243. //
  1244. // GET_INCR_VALUE
  1245. //
  1246. // Gets the value of a given wide character from the given 8:4:4 table. It
  1247. // then uses the value as an increment by adding it to the given wide
  1248. // character code point.
  1249. //
  1250. // NOTE: Whenever there is no translation for the given code point, the
  1251. // tables will return an increment value of 0. This way, the
  1252. // wide character passed in is the same value that is returned.
  1253. //
  1254. // DEFINED AS A MACRO.
  1255. //
  1256. // 05-31-91 JulieB Created.
  1257. ////////////////////////////////////////////////////////////////////////////
  1258. #define GET_INCR_VALUE(p844Tbl, wch) \
  1259. ((WCHAR)(wch + TRAVERSE_844_W(p844Tbl, wch)))
  1260. ////////////////////////////////////////////////////////////////////////////
  1261. //
  1262. // GET_LOWER_UPPER_CASE
  1263. //
  1264. // Gets the lower/upper case value of a given wide character. If a
  1265. // lower/upper case value exists, it returns the lower/upper case wide
  1266. // character. Otherwise, it returns the same character passed in wch.
  1267. //
  1268. // DEFINED AS A MACRO.
  1269. //
  1270. // 05-31-91 JulieB Created.
  1271. ////////////////////////////////////////////////////////////////////////////
  1272. #define GET_LOWER_UPPER_CASE(pCaseTbl, wch) \
  1273. (GET_INCR_VALUE(pCaseTbl, wch))
  1274. ////////////////////////////////////////////////////////////////////////////
  1275. //
  1276. // GET_ASCII_DIGITS
  1277. //
  1278. // Gets the ascii translation for the given digit character. If no
  1279. // translation is found, then the given character is returned.
  1280. //
  1281. // DEFINED AS A MACRO.
  1282. //
  1283. // 05-31-91 JulieB Created.
  1284. ////////////////////////////////////////////////////////////////////////////
  1285. #define GET_ASCII_DIGITS(pADigit, wch) \
  1286. (GET_INCR_VALUE(pADigit, wch))
  1287. ////////////////////////////////////////////////////////////////////////////
  1288. //
  1289. // GET_FOLD_CZONE
  1290. //
  1291. // Gets the translation for the given compatibility zone character. If no
  1292. // translation is found, then the given character is returned.
  1293. //
  1294. // DEFINED AS A MACRO.
  1295. //
  1296. // 05-31-91 JulieB Created.
  1297. ////////////////////////////////////////////////////////////////////////////
  1298. #define GET_FOLD_CZONE(pCZone, wch) \
  1299. (GET_INCR_VALUE(pCZone, wch))
  1300. ////////////////////////////////////////////////////////////////////////////
  1301. //
  1302. // GET_KANA
  1303. //
  1304. // Gets the Hiragana/Katakana equivalent for the given Katakana/Hiragana
  1305. // character. If no translation is found, then the given character is
  1306. // returned.
  1307. //
  1308. // DEFINED AS A MACRO.
  1309. //
  1310. // 07-14-93 JulieB Created.
  1311. ////////////////////////////////////////////////////////////////////////////
  1312. #define GET_KANA(pKana, wch) \
  1313. (GET_INCR_VALUE(pKana, wch))
  1314. ////////////////////////////////////////////////////////////////////////////
  1315. //
  1316. // GET_HALF_WIDTH
  1317. //
  1318. // Gets the Half Width equivalent for the given Full Width character. If no
  1319. // translation is found, then the given character is returned.
  1320. //
  1321. // DEFINED AS A MACRO.
  1322. //
  1323. // 07-14-93 JulieB Created.
  1324. ////////////////////////////////////////////////////////////////////////////
  1325. #define GET_HALF_WIDTH(pHalf, wch) \
  1326. (GET_INCR_VALUE(pHalf, wch))
  1327. ////////////////////////////////////////////////////////////////////////////
  1328. //
  1329. // GET_FULL_WIDTH
  1330. //
  1331. // Gets the Full Width equivalent for the given Half Width character. If no
  1332. // translation is found, then the given character is returned.
  1333. //
  1334. // DEFINED AS A MACRO.
  1335. //
  1336. // 07-14-93 JulieB Created.
  1337. ////////////////////////////////////////////////////////////////////////////
  1338. #define GET_FULL_WIDTH(pFull, wch) \
  1339. (GET_INCR_VALUE(pFull, wch))
  1340. ////////////////////////////////////////////////////////////////////////////
  1341. //
  1342. // GET_CHINESE
  1343. //
  1344. // Gets the Traditional/Simplified Chinese translation for the given
  1345. // Simplified/Traditional Chinese character. If no translation is found,
  1346. // then the given character is returned.
  1347. //
  1348. // DEFINED AS A MACRO.
  1349. //
  1350. // 05-07-96 JulieB Created.
  1351. ////////////////////////////////////////////////////////////////////////////
  1352. #define GET_CHINESE(pChinese, wch) \
  1353. (GET_INCR_VALUE(pChinese, wch))
  1354. ////////////////////////////////////////////////////////////////////////////
  1355. //
  1356. // GET_CTYPE
  1357. //
  1358. // Gets the ctype information for a given wide character. If the ctype
  1359. // information exists, it returns it. Otherwise, it returns 0.
  1360. //
  1361. // DEFINED AS A MACRO.
  1362. //
  1363. // 05-31-91 JulieB Created.
  1364. ////////////////////////////////////////////////////////////////////////////
  1365. #define GET_CTYPE(wch, offset) \
  1366. ((((PCT_VALUES)(pTblPtrs->pCTypeMap)) + \
  1367. (TRAVERSE_844_B((pTblPtrs->pCType844), wch)))->offset)
  1368. ////////////////////////////////////////////////////////////////////////////
  1369. //
  1370. // GET_BASE_CHAR
  1371. //
  1372. // Gets the base character of a given precomposed character. If the
  1373. // composite form is found, it returns the base character. Otherwise,
  1374. // it returns 0 for failure.
  1375. //
  1376. // DEFINED AS A MACRO.
  1377. //
  1378. // 05-31-91 JulieB Created.
  1379. ////////////////////////////////////////////////////////////////////////////
  1380. #define GET_BASE_CHAR(wch, Base) \
  1381. { \
  1382. WCHAR NonSp; /* nonspacing character */ \
  1383. WCHAR NewBase; /* base character - temp holder */ \
  1384. \
  1385. \
  1386. /* \
  1387. * Get composite characters. \
  1388. */ \
  1389. if (GetCompositeChars(wch, &NonSp, &Base)) \
  1390. { \
  1391. while (GetCompositeChars(Base, &NonSp, &NewBase)) \
  1392. { \
  1393. Base = NewBase; \
  1394. } \
  1395. } \
  1396. else \
  1397. { \
  1398. /* \
  1399. * Return failure - no composite form. \
  1400. */ \
  1401. Base = 0; \
  1402. } \
  1403. }
  1404. ////////////////////////////////////////////////////////////////////////////
  1405. //
  1406. // SORTKEY WEIGHT MACROS
  1407. //
  1408. // Parse out the different sortkey weights from a DWORD value.
  1409. //
  1410. // 05-31-91 JulieB Created.
  1411. ////////////////////////////////////////////////////////////////////////////
  1412. #define GET_SCRIPT_MEMBER(pwt) ( (BYTE)(((PSORTKEY)(pwt))->UW.SM_AW.Script) )
  1413. #define GET_ALPHA_NUMERIC(pwt) ( (BYTE)(((PSORTKEY)(pwt))->UW.SM_AW.Alpha) )
  1414. #define GET_UNICODE(pwt) ( (WORD)(((PSORTKEY)(pwt))->UW.Unicode) )
  1415. #define GET_UNICODE_SM(pwt, sm) ( (WORD)(((PSORTKEY)(pwt))->UW.Unicode) )
  1416. #define GET_UNICODE_MOD(pwt, modify_sm) \
  1417. ( (modify_sm) ? \
  1418. ((WORD) \
  1419. ((((WORD)((pTblPtrs->SMWeight)[GET_SCRIPT_MEMBER(pwt)])) << 8) | \
  1420. (WORD)GET_ALPHA_NUMERIC(pwt))) : \
  1421. ((WORD)(((PSORTKEY)(pwt))->UW.Unicode)) )
  1422. #define GET_UNICODE_SM_MOD(pwt, sm, modify_sm) \
  1423. ( (modify_sm) ? \
  1424. ((WORD) \
  1425. ((((WORD)((pTblPtrs->SMWeight)[sm])) << 8) | \
  1426. (WORD)GET_ALPHA_NUMERIC(pwt))) : \
  1427. ((WORD)(((PSORTKEY)(pwt))->UW.Unicode)) )
  1428. #define MAKE_UNICODE_WT(sm, aw, modify_sm) \
  1429. ( (modify_sm) ? \
  1430. ((WORD)((((WORD)((pTblPtrs->SMWeight)[sm])) << 8) | (WORD)(aw))) : \
  1431. ((WORD)((((WORD)(sm)) << 8) | (WORD)(aw))) )
  1432. #define UNICODE_WT(pwt) ( (WORD)(((PSORTKEY)(pwt))->UW.Unicode) )
  1433. #define GET_DIACRITIC(pwt) ( (BYTE)(((PSORTKEY)(pwt))->Diacritic) )
  1434. #define GET_CASE(pwt) ( (BYTE)((((PSORTKEY)(pwt))->Case) & CASE_MASK) )
  1435. #define CASE_WT(pwt) ( (BYTE)(((PSORTKEY)(pwt))->Case) )
  1436. #define GET_COMPRESSION(pwt) ( (BYTE)((((PSORTKEY)(pwt))->Case) & COMPRESS_3_MASK) )
  1437. #define GET_EXPAND_INDEX(pwt) ( (BYTE)(((PSORTKEY)(pwt))->UW.SM_AW.Alpha) )
  1438. #define GET_SPECIAL_WEIGHT(pwt) ( (WORD)(((PSORTKEY)(pwt))->UW.Unicode) )
  1439. // position returned is backwards - byte reversal
  1440. #define GET_POSITION_SW(pos) ( (WORD)(((pos) << 2) | SW_POSITION_MASK) )
  1441. #define GET_WT_FOUR(pwt) ( (BYTE)(((PEXTRA_WT)(pwt))->Four) )
  1442. #define GET_WT_FIVE(pwt) ( (BYTE)(((PEXTRA_WT)(pwt))->Five) )
  1443. #define GET_WT_SIX(pwt) ( (BYTE)(((PEXTRA_WT)(pwt))->Six) )
  1444. #define GET_WT_SEVEN(pwt) ( (BYTE)(((PEXTRA_WT)(pwt))->Seven) )
  1445. #define MAKE_SORTKEY_DWORD(wt) ( (DWORD)(*((LPDWORD)(&(wt)))) )
  1446. #define MAKE_EXTRA_WT_DWORD(wt) ( (DWORD)(*((LPDWORD)(&(wt)))) )
  1447. #define GET_DWORD_WEIGHT(pHashN, wch) \
  1448. ( MAKE_SORTKEY_DWORD(((pHashN)->pSortkey)[wch]) )
  1449. #define GET_EXPANSION_1(pwt) \
  1450. ( ((pTblPtrs->pExpansion)[GET_EXPAND_INDEX(pwt)]).UCP1 )
  1451. #define GET_EXPANSION_2(pwt) \
  1452. ( ((pTblPtrs->pExpansion)[GET_EXPAND_INDEX(pwt)]).UCP2 )
  1453. #define IS_SYMBOL(pSkey, wch) \
  1454. ( (GET_SCRIPT_MEMBER(&((pSkey)[wch])) >= PUNCTUATION) && \
  1455. (GET_SCRIPT_MEMBER(&((pSkey)[wch])) <= SYMBOL_5) )
  1456. #define IS_NONSPACE_ONLY(pSkey, wch) \
  1457. ( GET_SCRIPT_MEMBER(&((pSkey)[wch])) == NONSPACE_MARK )
  1458. #define IS_NONSPACE(pSkey, wch) \
  1459. ( (GET_SCRIPT_MEMBER(&((pSkey)[wch])) == NONSPACE_MARK) || \
  1460. (GET_DIACRITIC(&((pSkey)[wch])) > MIN_DW) )
  1461. #define IS_ALPHA(ctype1) ( (ctype1) & C1_ALPHA )
  1462. #define IS_KOREAN(lcid) \
  1463. ( LANGIDFROMLCID(lcid) == MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN) )
  1464. ////////////////////////////////////////////////////////////////////////////
  1465. //
  1466. // CHECK_SPECIAL_LOCALES
  1467. //
  1468. // Checks for the special locale values and sets the Locale to the
  1469. // appropriate value.
  1470. //
  1471. // DEFINED AS A MACRO.
  1472. //
  1473. // 05-31-91 JulieB Created.
  1474. ////////////////////////////////////////////////////////////////////////////
  1475. #define CHECK_SPECIAL_LOCALES(Locale, UseCachedLocaleId) \
  1476. { \
  1477. /* \
  1478. * Check for special locale values. \
  1479. */ \
  1480. if (Locale == LOCALE_SYSTEM_DEFAULT) \
  1481. { \
  1482. /* \
  1483. * Get the System Default locale value. \
  1484. */ \
  1485. Locale = gSystemLocale; \
  1486. } \
  1487. else if ((Locale == LOCALE_NEUTRAL) || (Locale == LOCALE_USER_DEFAULT)) \
  1488. { \
  1489. /* \
  1490. * Get the User locale value. \
  1491. */ \
  1492. if (!UseCachedLocaleId) \
  1493. { \
  1494. Locale = GetUserDefaultLCID(); \
  1495. } \
  1496. else \
  1497. { \
  1498. Locale = pNlsUserInfo->UserLocaleId; \
  1499. } \
  1500. } \
  1501. /* \
  1502. * Check for a valid primary language and a neutral sublanguage. \
  1503. */ \
  1504. else if (SUBLANGID(LANGIDFROMLCID(Locale)) == SUBLANG_NEUTRAL) \
  1505. { \
  1506. /* \
  1507. * Re-form the locale id using the primary language and the \
  1508. * default sublanguage. \
  1509. */ \
  1510. Locale = MAKELCID(MAKELANGID(PRIMARYLANGID(LANGIDFROMLCID(Locale)), \
  1511. SUBLANG_DEFAULT), \
  1512. SORTIDFROMLCID(Locale)); \
  1513. } \
  1514. }
  1515. ////////////////////////////////////////////////////////////////////////////
  1516. //
  1517. // IS_INVALID_LOCALE
  1518. //
  1519. // Checks to see that only the proper bits are used in the locale.
  1520. //
  1521. // DEFINED AS A MACRO.
  1522. //
  1523. // 05-31-91 JulieB Created.
  1524. ////////////////////////////////////////////////////////////////////////////
  1525. #define NLS_VALID_LOCALE_MASK 0x000fffff
  1526. #define IS_INVALID_LOCALE(Locale) ( Locale & ~NLS_VALID_LOCALE_MASK )
  1527. ////////////////////////////////////////////////////////////////////////////
  1528. //
  1529. // VALIDATE_LANGUAGE
  1530. //
  1531. // Checks that the given Locale contains a valid language id. It does so
  1532. // by making sure the appropriate casing and sorting tables are present.
  1533. // If the language is valid, pLocHashN will be non-NULL. Otherwise,
  1534. // pLocHashN will be NULL.
  1535. //
  1536. // DEFINED AS A MACRO.
  1537. //
  1538. // 05-31-91 JulieB Created.
  1539. ////////////////////////////////////////////////////////////////////////////
  1540. #define VALIDATE_LANGUAGE(Locale, pLocHashN, dwFlags, UseCachedLocaleId) \
  1541. { \
  1542. /* \
  1543. * Check the system locale first for speed. This is the most \
  1544. * likely one to be used. \
  1545. */ \
  1546. if (Locale == gSystemLocale) \
  1547. { \
  1548. pLocHashN = gpSysLocHashN; \
  1549. } \
  1550. /* \
  1551. * Check the invariant locale second for speed. This is the second \
  1552. * most likely one to be used. \
  1553. */ \
  1554. else if (Locale == LOCALE_INVARIANT) \
  1555. { \
  1556. pLocHashN = gpInvLocHashN; \
  1557. } \
  1558. else \
  1559. { \
  1560. /* \
  1561. * Check special locale values. \
  1562. */ \
  1563. CHECK_SPECIAL_LOCALES(Locale, UseCachedLocaleId); \
  1564. \
  1565. /* \
  1566. * If the locale is the system default, then the hash node is \
  1567. * already stored in a global. \
  1568. */ \
  1569. if (Locale == gSystemLocale) \
  1570. { \
  1571. pLocHashN = gpSysLocHashN; \
  1572. } \
  1573. else if (IS_INVALID_LOCALE(Locale)) \
  1574. { \
  1575. pLocHashN = NULL; \
  1576. } \
  1577. else \
  1578. { \
  1579. /* \
  1580. * Need to make sure the locale value is valid. Need to \
  1581. * check the locale file to see if the locale is supported. \
  1582. */ \
  1583. pLocHashN = GetLocHashNode(Locale); \
  1584. \
  1585. if (pLocHashN != NULL) \
  1586. { \
  1587. /* \
  1588. * Make sure the appropriate casing and sorting tables \
  1589. * are in the system. \
  1590. * \
  1591. * NOTE: If the call fails, pLocHashN will be NULL. \
  1592. */ \
  1593. pLocHashN = GetLangHashNode(Locale, dwFlags); \
  1594. } \
  1595. } \
  1596. } \
  1597. \
  1598. /* \
  1599. * Make sure we don't need to get the linguistic tables. \
  1600. */ \
  1601. if ((dwFlags) && (pLocHashN) && (pLocHashN->pLowerLinguist == NULL)) \
  1602. { \
  1603. /* \
  1604. * Get locale hash node to make sure the appropriate \
  1605. * casing and sorting tables are in the system. \
  1606. */ \
  1607. pLocHashN = GetLangHashNode(Locale, dwFlags); \
  1608. } \
  1609. }
  1610. ////////////////////////////////////////////////////////////////////////////
  1611. //
  1612. // VALIDATE_LOCALE
  1613. //
  1614. // Checks that the given LCID contains a valid locale id. It does so
  1615. // by making sure the appropriate locale information is present. If the
  1616. // locale is valid, pLocHashN will be non-NULL. Otherwise, pLocHashN
  1617. // will be NULL.
  1618. //
  1619. // DEFINED AS A MACRO.
  1620. //
  1621. // 05-31-91 JulieB Created.
  1622. ////////////////////////////////////////////////////////////////////////////
  1623. #define VALIDATE_LOCALE(Locale, pLocHashN, UseCachedLocaleId) \
  1624. { \
  1625. /* \
  1626. * Check the system locale first for speed. This is the most \
  1627. * likely one to be used. \
  1628. */ \
  1629. if (Locale == gSystemLocale) \
  1630. { \
  1631. pLocHashN = gpSysLocHashN; \
  1632. } \
  1633. /* \
  1634. * Check the invariant locale second for speed. This is the second \
  1635. * most likely one to be used. \
  1636. */ \
  1637. else if (Locale == LOCALE_INVARIANT) \
  1638. { \
  1639. pLocHashN = gpInvLocHashN; \
  1640. } \
  1641. else \
  1642. { \
  1643. /* \
  1644. * Check special locale values. \
  1645. */ \
  1646. CHECK_SPECIAL_LOCALES(Locale, UseCachedLocaleId); \
  1647. \
  1648. /* \
  1649. * If the locale is the system default, then the hash node \
  1650. * is already stored in a global. \
  1651. */ \
  1652. if (Locale == gSystemLocale) \
  1653. { \
  1654. pLocHashN = gpSysLocHashN; \
  1655. } \
  1656. else if (IS_INVALID_LOCALE(Locale)) \
  1657. { \
  1658. pLocHashN = NULL; \
  1659. } \
  1660. else \
  1661. { \
  1662. /* \
  1663. * Get locale hash node to make sure the appropriate \
  1664. * locale table is in the system. \
  1665. * \
  1666. * NOTE: If the call fails, pLocHashN will be NULL. \
  1667. */ \
  1668. pLocHashN = GetLocHashNode(Locale); \
  1669. } \
  1670. } \
  1671. }
  1672. ////////////////////////////////////////////////////////////////////////////
  1673. //
  1674. // OPEN_CODEPAGE_KEY
  1675. //
  1676. // Opens the key for the code page section of the registry for read access.
  1677. //
  1678. // DEFINED AS A MACRO.
  1679. //
  1680. // 09-01-93 JulieB Created.
  1681. ////////////////////////////////////////////////////////////////////////////
  1682. #define OPEN_CODEPAGE_KEY(ReturnVal) \
  1683. { \
  1684. /* \
  1685. * Make sure code page key is open. \
  1686. */ \
  1687. if (hCodePageKey == NULL) \
  1688. { \
  1689. RtlEnterCriticalSection(&gcsTblPtrs); \
  1690. if (hCodePageKey == NULL) \
  1691. { \
  1692. if (OpenRegKey( &hCodePageKey, \
  1693. NLS_HKLM_SYSTEM, \
  1694. NLS_CODEPAGE_KEY, \
  1695. KEY_READ )) \
  1696. { \
  1697. SetLastError(ERROR_BADDB); \
  1698. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1699. return (ReturnVal); \
  1700. } \
  1701. } \
  1702. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1703. } \
  1704. }
  1705. ////////////////////////////////////////////////////////////////////////////
  1706. //
  1707. // OPEN_LOCALE_KEY
  1708. //
  1709. // Opens the key for the locale section of the registry for read access.
  1710. //
  1711. // DEFINED AS A MACRO.
  1712. //
  1713. // 09-01-93 JulieB Created.
  1714. ////////////////////////////////////////////////////////////////////////////
  1715. #define OPEN_LOCALE_KEY(ReturnVal) \
  1716. { \
  1717. /* \
  1718. * Make sure locale key is open. \
  1719. */ \
  1720. if (hLocaleKey == NULL) \
  1721. { \
  1722. RtlEnterCriticalSection(&gcsTblPtrs); \
  1723. if (hLocaleKey == NULL) \
  1724. { \
  1725. if (OpenRegKey( &hLocaleKey, \
  1726. NLS_HKLM_SYSTEM, \
  1727. NLS_LOCALE_KEY, \
  1728. KEY_READ )) \
  1729. { \
  1730. SetLastError(ERROR_BADDB); \
  1731. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1732. return (ReturnVal); \
  1733. } \
  1734. } \
  1735. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1736. } \
  1737. }
  1738. ////////////////////////////////////////////////////////////////////////////
  1739. //
  1740. // OPEN_ALT_SORTS_KEY
  1741. //
  1742. // Opens the key for the alternate sorts section of the registry for read
  1743. // access.
  1744. //
  1745. // DEFINED AS A MACRO.
  1746. //
  1747. // 11-15-96 JulieB Created.
  1748. ////////////////////////////////////////////////////////////////////////////
  1749. #define OPEN_ALT_SORTS_KEY(ReturnVal) \
  1750. { \
  1751. /* \
  1752. * Make sure alternate sorts key is open. \
  1753. */ \
  1754. if (hAltSortsKey == NULL) \
  1755. { \
  1756. RtlEnterCriticalSection(&gcsTblPtrs); \
  1757. if (hAltSortsKey == NULL) \
  1758. { \
  1759. if (OpenRegKey( &hAltSortsKey, \
  1760. NLS_HKLM_SYSTEM, \
  1761. NLS_ALT_SORTS_KEY, \
  1762. KEY_READ )) \
  1763. { \
  1764. SetLastError(ERROR_BADDB); \
  1765. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1766. return (ReturnVal); \
  1767. } \
  1768. } \
  1769. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1770. } \
  1771. }
  1772. ////////////////////////////////////////////////////////////////////////////
  1773. //
  1774. // OPEN_LANG_GROUPS_KEY
  1775. //
  1776. // Opens the key for the language groups section of the registry for
  1777. // read access.
  1778. //
  1779. // DEFINED AS A MACRO.
  1780. //
  1781. // 09-01-93 JulieB Created.
  1782. ////////////////////////////////////////////////////////////////////////////
  1783. #define OPEN_LANG_GROUPS_KEY(ReturnVal) \
  1784. { \
  1785. /* \
  1786. * Make sure language groups key is open. \
  1787. */ \
  1788. if (hLangGroupsKey == NULL) \
  1789. { \
  1790. RtlEnterCriticalSection(&gcsTblPtrs); \
  1791. if (hLangGroupsKey == NULL) \
  1792. { \
  1793. if (OpenRegKey( &hLangGroupsKey, \
  1794. NLS_HKLM_SYSTEM, \
  1795. NLS_LANGUAGE_GROUPS_KEY, \
  1796. KEY_READ )) \
  1797. { \
  1798. SetLastError(ERROR_BADDB); \
  1799. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1800. return (ReturnVal); \
  1801. } \
  1802. } \
  1803. RtlLeaveCriticalSection(&gcsTblPtrs); \
  1804. } \
  1805. }
  1806. ////////////////////////////////////////////////////////////////////////////
  1807. //
  1808. // OPEN_MUILANG_KEY
  1809. //
  1810. // Opens the key for the multilingual UI language section of the registry
  1811. // for read access. It is acceptable if this key is not in the registry,
  1812. // so do not call SetLastError if the key cannot be opened.
  1813. //
  1814. // DEFINED AS A MACRO.
  1815. //
  1816. // 03-10-98 JulieB Created.
  1817. ////////////////////////////////////////////////////////////////////////////
  1818. #define OPEN_MUILANG_KEY(hKey, ReturnVal) \
  1819. { \
  1820. if ((hKey) == NULL) \
  1821. { \
  1822. if (OpenRegKey( &(hKey), \
  1823. NLS_HKLM_SYSTEM, \
  1824. NLS_MUILANG_KEY, \
  1825. KEY_READ )) \
  1826. { \
  1827. return (ReturnVal); \
  1828. } \
  1829. } \
  1830. }
  1831. ////////////////////////////////////////////////////////////////////////////
  1832. //
  1833. // OPEN_CPANEL_INTL_KEY
  1834. //
  1835. // Opens the key for the control panel international section of the
  1836. // registry for the given access.
  1837. //
  1838. // DEFINED AS A MACRO.
  1839. //
  1840. // 09-01-93 JulieB Created.
  1841. ////////////////////////////////////////////////////////////////////////////
  1842. #define OPEN_CPANEL_INTL_KEY(hKey, ReturnVal, Access) \
  1843. { \
  1844. if ((hKey) == NULL) \
  1845. { \
  1846. if (OpenRegKey( &(hKey), \
  1847. NULL, \
  1848. NLS_CTRL_PANEL_KEY, \
  1849. Access )) \
  1850. { \
  1851. SetLastError(ERROR_BADDB); \
  1852. return (ReturnVal); \
  1853. } \
  1854. } \
  1855. }
  1856. ////////////////////////////////////////////////////////////////////////////
  1857. //
  1858. // OPEN_GEO_KEY
  1859. //
  1860. // Opens the key for the geographic information section of the registry
  1861. // for read access.
  1862. //
  1863. // DEFINED AS A MACRO.
  1864. //
  1865. // 03-10-00 lguindon Created.
  1866. ////////////////////////////////////////////////////////////////////////////
  1867. #define OPEN_GEO_KEY(hKey, ReturnVal, Access) \
  1868. { \
  1869. if ((hKey) == NULL) \
  1870. { \
  1871. if (OpenRegKey( &(hKey), \
  1872. NULL, \
  1873. GEO_REG_KEY, \
  1874. Access )) \
  1875. { \
  1876. SetLastError(ERROR_BADDB); \
  1877. return (ReturnVal); \
  1878. } \
  1879. } \
  1880. }
  1881. ////////////////////////////////////////////////////////////////////////////
  1882. //
  1883. // CLOSE_REG_KEY
  1884. //
  1885. // Closes the given registry key.
  1886. //
  1887. // DEFINED AS A MACRO.
  1888. //
  1889. // 09-01-93 JulieB Created.
  1890. ////////////////////////////////////////////////////////////////////////////
  1891. #define CLOSE_REG_KEY(hKey) \
  1892. { \
  1893. if ((hKey) != NULL) \
  1894. { \
  1895. NtClose(hKey); \
  1896. hKey = NULL; \
  1897. } \
  1898. }
  1899. ////////////////////////////////////////////////////////////////////////////
  1900. //
  1901. // NLS_ALLOC_MEM
  1902. //
  1903. // Allocates the given number of bytes of memory from the process heap,
  1904. // zeros the memory buffer, and returns the handle.
  1905. //
  1906. // DEFINED AS A MACRO.
  1907. //
  1908. // 05-31-91 JulieB Created.
  1909. ////////////////////////////////////////////////////////////////////////////
  1910. #define NLS_ALLOC_MEM(dwBytes) \
  1911. ( RtlAllocateHeap( RtlProcessHeap(), \
  1912. HEAP_ZERO_MEMORY, \
  1913. dwBytes ) )
  1914. ////////////////////////////////////////////////////////////////////////////
  1915. //
  1916. // NLS_FREE_MEM
  1917. //
  1918. // Frees the memory of the given handle from the process heap.
  1919. //
  1920. // DEFINED AS A MACRO.
  1921. //
  1922. // 05-31-91 JulieB Created.
  1923. ////////////////////////////////////////////////////////////////////////////
  1924. #define NLS_FREE_MEM(hMem) \
  1925. ( (hMem) ? (RtlFreeHeap( RtlProcessHeap(), \
  1926. 0, \
  1927. (PVOID)hMem )) \
  1928. : 0 )
  1929. ////////////////////////////////////////////////////////////////////////////
  1930. //
  1931. // NLS_FREE_TMP_BUFFER
  1932. //
  1933. // Checks to see if the buffer is the same as the static buffer. If it
  1934. // is NOT the same, then the buffer is freed.
  1935. //
  1936. // 11-04-92 JulieB Created.
  1937. ////////////////////////////////////////////////////////////////////////////
  1938. #define NLS_FREE_TMP_BUFFER(pBuf, pStaticBuf) \
  1939. { \
  1940. if (pBuf != pStaticBuf) \
  1941. { \
  1942. NLS_FREE_MEM(pBuf); \
  1943. } \
  1944. }
  1945. ////////////////////////////////////////////////////////////////////////////
  1946. //
  1947. // ARRAYSIZE
  1948. //
  1949. // Hnady utility macro to get the size of an array (such as an array of
  1950. // WCHARs).
  1951. ////////////////////////////////////////////////////////////////////////////
  1952. #ifndef ARRAYSIZE
  1953. #define ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0]))
  1954. #endif
  1955. ////////////////////////////////////////////////////////////////////////////
  1956. //
  1957. // Function Prototypes
  1958. //
  1959. ////////////////////////////////////////////////////////////////////////////
  1960. //
  1961. // Table Routines - tables.c.
  1962. //
  1963. ULONG
  1964. AllocTables(void);
  1965. ULONG
  1966. GetUnicodeFileInfo(void);
  1967. ULONG
  1968. GetGeoFileInfo(void);
  1969. ULONG
  1970. GetCTypeFileInfo(void);
  1971. ULONG
  1972. GetDefaultSortkeyFileInfo(void);
  1973. ULONG
  1974. GetDefaultSortTablesFileInfo(void);
  1975. ULONG
  1976. GetSortkeyFileInfo(
  1977. LCID Locale,
  1978. PLOC_HASH pHashN);
  1979. void
  1980. GetSortTablesFileInfo(
  1981. LCID Locale,
  1982. PLOC_HASH pHashN);
  1983. ULONG
  1984. GetCodePageFileInfo(
  1985. UINT CodePage,
  1986. PCP_HASH *ppNode);
  1987. ULONG
  1988. GetLanguageFileInfo(
  1989. LCID Locale,
  1990. PLOC_HASH *ppNode,
  1991. BOOLEAN fCreateNode,
  1992. DWORD dwFlags);
  1993. ULONG
  1994. GetLocaleFileInfo(
  1995. LCID Locale,
  1996. PLOC_HASH *ppNode,
  1997. BOOLEAN fCreateNode);
  1998. ULONG
  1999. MakeCPHashNode(
  2000. UINT CodePage,
  2001. LPWORD pBaseAddr,
  2002. PCP_HASH *ppNode,
  2003. BOOL IsDLL,
  2004. LPFN_CP_PROC pfnCPProc);
  2005. ULONG
  2006. MakeLangHashNode(
  2007. LCID Locale,
  2008. LPWORD pBaseAddr,
  2009. PLOC_HASH *ppNode,
  2010. BOOLEAN fCreateNode);
  2011. ULONG
  2012. MakeLocHashNode(
  2013. LCID Locale,
  2014. LPWORD pBaseAddr,
  2015. PLOC_HASH *ppNode,
  2016. BOOLEAN fCreateNode);
  2017. PCP_HASH FASTCALL
  2018. GetCPHashNode(
  2019. UINT CodePage);
  2020. PLOC_HASH FASTCALL
  2021. GetLangHashNode(
  2022. LCID Locale,
  2023. DWORD dwFlags);
  2024. BOOL
  2025. IsCPHashNodeLoaded(
  2026. UINT CodePage);
  2027. PLOC_HASH FASTCALL
  2028. GetLocHashNode(
  2029. LCID Locale);
  2030. ULONG
  2031. GetCalendar(
  2032. CALID Calendar,
  2033. PCAL_INFO *ppCalInfo);
  2034. //
  2035. // Section Routines - section.c.
  2036. //
  2037. ULONG
  2038. CreateNlsObjectDirectory(void);
  2039. ULONG
  2040. CreateRegKey(
  2041. PHANDLE phKeyHandle,
  2042. LPWSTR pBaseName,
  2043. LPWSTR pKey,
  2044. ULONG fAccess);
  2045. ULONG
  2046. OpenRegKey(
  2047. PHANDLE phKeyHandle,
  2048. LPWSTR pBaseName,
  2049. LPWSTR pKey,
  2050. ULONG fAccess);
  2051. ULONG
  2052. QueryRegValue(
  2053. HANDLE hKeyHandle,
  2054. LPWSTR pValue,
  2055. PKEY_VALUE_FULL_INFORMATION *ppKeyValueFull,
  2056. ULONG Length,
  2057. LPBOOL pIfAlloc);
  2058. ULONG
  2059. SetRegValue(
  2060. HANDLE hKeyHandle,
  2061. LPCWSTR pValue,
  2062. LPCWSTR pData,
  2063. ULONG DataLength);
  2064. ULONG
  2065. CreateSectionTemp(
  2066. HANDLE *phSec,
  2067. LPWSTR pwszFileName);
  2068. ULONG
  2069. OpenSection(
  2070. HANDLE *phSec,
  2071. PUNICODE_STRING pObSectionName,
  2072. PVOID *ppBaseAddr,
  2073. ULONG AccessMask,
  2074. BOOL bCloseHandle);
  2075. ULONG
  2076. MapSection(
  2077. HANDLE hSec,
  2078. PVOID *ppBaseAddr,
  2079. ULONG PageProtection,
  2080. BOOL bCloseHandle);
  2081. ULONG
  2082. UnMapSection(
  2083. PVOID pBaseAddr);
  2084. ULONG
  2085. GetNlsSectionName(
  2086. UINT Value,
  2087. UINT Base,
  2088. UINT Padding,
  2089. LPWSTR pwszPrefix,
  2090. LPWSTR pwszSecName,
  2091. UINT cchSecName);
  2092. ULONG
  2093. GetCodePageDLLPathName(
  2094. UINT CodePage,
  2095. LPWSTR pDllName,
  2096. USHORT cchLen);
  2097. //
  2098. // Utility Routines - util.c.
  2099. //
  2100. BOOL GetCPFileNameFromRegistry(
  2101. UINT CodePage,
  2102. LPWSTR pResultBuf,
  2103. UINT Size);
  2104. BOOL GetUserInfoFromRegistry(
  2105. LPWSTR pValue,
  2106. LPWSTR pOutput,
  2107. LCID Locale);
  2108. int
  2109. GetStringTableEntry(
  2110. UINT ResourceID,
  2111. LANGID UILangId,
  2112. LPWSTR pBuffer,
  2113. int cchBuffer,
  2114. int WhichString);
  2115. BOOL
  2116. IsValidSeparatorString(
  2117. LPCWSTR pString,
  2118. ULONG MaxLength,
  2119. BOOL fCheckZeroLen);
  2120. BOOL
  2121. IsValidGroupingString(
  2122. LPCWSTR pString,
  2123. ULONG MaxLength,
  2124. BOOL fCheckZeroLen);
  2125. LPWORD
  2126. IsValidCalendarType(
  2127. PLOC_HASH pHashN,
  2128. CALID CalId);
  2129. LPWORD
  2130. IsValidCalendarTypeStr(
  2131. PLOC_HASH pHashN,
  2132. LPCWSTR pCalStr);
  2133. BOOL
  2134. GetUserInfo(
  2135. LCID Locale,
  2136. LCTYPE LCType ,
  2137. SIZE_T CacheOffset,
  2138. LPWSTR pValue,
  2139. LPWSTR pOutput,
  2140. size_t cchOutput,
  2141. BOOL fCheckNull);
  2142. WCHAR FASTCALL
  2143. GetPreComposedChar(
  2144. WCHAR wcNonSp,
  2145. WCHAR wcBase);
  2146. BOOL FASTCALL
  2147. GetCompositeChars(
  2148. WCHAR wch,
  2149. WCHAR *pNonSp,
  2150. WCHAR *pBase);
  2151. int FASTCALL
  2152. InsertPreComposedForm(
  2153. LPCWSTR pWCStr,
  2154. LPWSTR pEndWCStr,
  2155. LPWSTR pPreComp);
  2156. int FASTCALL
  2157. InsertFullWidthPreComposedForm(
  2158. LPCWSTR pWCStr,
  2159. LPWSTR pEndWCStr,
  2160. LPWSTR pPreComp,
  2161. PCASE pCase);
  2162. int FASTCALL
  2163. InsertCompositeForm(
  2164. LPWSTR pWCStr,
  2165. LPWSTR pEndWCStr);
  2166. ULONG
  2167. NlsConvertIntegerToString(
  2168. UINT Value,
  2169. UINT Base,
  2170. UINT Padding,
  2171. LPWSTR pResultBuf,
  2172. UINT Size);
  2173. BOOL FASTCALL
  2174. NlsConvertIntegerToHexStringW(
  2175. UINT Value,
  2176. BOOL UpperCase,
  2177. PWSTR Str,
  2178. UINT Width);
  2179. BOOL FASTCALL
  2180. NlsConvertStringToIntegerW(
  2181. PWSTR str,
  2182. UINT Base,
  2183. int CharCount,
  2184. UINT* Result);
  2185. BOOL FASTCALL
  2186. NlsIsDll(
  2187. LPCWSTR pFileName);
  2188. LPWSTR FASTCALL
  2189. NlsStrCpyW(
  2190. LPWSTR pwszDest,
  2191. LPCWSTR pwszSrc);
  2192. LPWSTR FASTCALL
  2193. NlsStrCatW(
  2194. LPWSTR pwsz1,
  2195. LPCWSTR pwsz2);
  2196. int FASTCALL
  2197. NlsStrLenW(
  2198. LPCWSTR pwsz);
  2199. LPWSTR FASTCALL
  2200. NlsStrNCatW(
  2201. LPWSTR pwszFront,
  2202. LPCWSTR pwszBack,
  2203. int Count);
  2204. int FASTCALL
  2205. NlsStrEqualW(
  2206. LPCWSTR pwszFirst,
  2207. LPCWSTR pwszSecond);
  2208. int FASTCALL
  2209. NlsStrNEqualW(
  2210. LPCWSTR pwszFirst,
  2211. LPCWSTR pwszSecond,
  2212. int Count);
  2213. //
  2214. // Security Routines - security.c.
  2215. //
  2216. NTSTATUS
  2217. NlsCheckForInteractiveUser();
  2218. NTSTATUS
  2219. NlsIsInteractiveUserProcess();
  2220. NTSTATUS
  2221. NlsGetUserLocale(
  2222. LCID *Lcid);
  2223. NTSTATUS
  2224. NlsGetCurrentUserNlsInfo(
  2225. LCID Locale,
  2226. LCTYPE LCType,
  2227. PWSTR RegistryValue,
  2228. PWSTR pOutputBuffer,
  2229. BOOL IgnoreLocaleValue);
  2230. NTSTATUS
  2231. NlsQueryCurrentUserInfo(
  2232. PNLS_LOCAL_CACHE pNlsCache,
  2233. LPWSTR pValue,
  2234. LPWSTR pOutput);
  2235. NTSTATUS
  2236. NlsFlushProcessCache(
  2237. LCTYPE LCType);
  2238. //
  2239. // Internal Enumeration routines - enum.c.
  2240. //
  2241. BOOL
  2242. Internal_EnumSystemLanguageGroups(
  2243. NLS_ENUMPROC lpLanguageGroupEnumProc,
  2244. DWORD dwFlags,
  2245. LONG_PTR lParam,
  2246. BOOL fUnicodeVer);
  2247. BOOL
  2248. Internal_EnumLanguageGroupLocales(
  2249. NLS_ENUMPROC lpLangGroupLocaleEnumProc,
  2250. LGRPID LanguageGroup,
  2251. DWORD dwFlags,
  2252. LONG_PTR lParam,
  2253. BOOL fUnicodeVer);
  2254. BOOL
  2255. Internal_EnumUILanguages(
  2256. NLS_ENUMPROC lpUILanguageEnumProc,
  2257. DWORD dwFlags,
  2258. LONG_PTR lParam,
  2259. BOOL fUnicodeVer);
  2260. BOOL
  2261. Internal_EnumSystemLocales(
  2262. NLS_ENUMPROC lpLocaleEnumProc,
  2263. DWORD dwFlags,
  2264. BOOL fUnicodeVer);
  2265. BOOL
  2266. Internal_EnumSystemCodePages(
  2267. NLS_ENUMPROC lpCodePageEnumProc,
  2268. DWORD dwFlags,
  2269. BOOL fUnicodeVer);
  2270. BOOL
  2271. Internal_EnumCalendarInfo(
  2272. NLS_ENUMPROC lpCalInfoEnumProc,
  2273. LCID Locale,
  2274. CALID Calendar,
  2275. CALTYPE CalType,
  2276. BOOL fUnicodeVer,
  2277. BOOL fExVersion);
  2278. BOOL
  2279. Internal_EnumTimeFormats(
  2280. NLS_ENUMPROC lpTimeFmtEnumProc,
  2281. LCID Locale,
  2282. DWORD dwFlags,
  2283. BOOL fUnicodeVer);
  2284. BOOL
  2285. Internal_EnumDateFormats(
  2286. NLS_ENUMPROC lpDateFmtEnumProc,
  2287. LCID Locale,
  2288. DWORD dwFlags,
  2289. BOOL fUnicodeVer,
  2290. BOOL fExVersion);
  2291. //
  2292. // Ansi routines - ansi.c.
  2293. //
  2294. BOOL
  2295. NlsDispatchAnsiEnumProc(
  2296. LCID Locale,
  2297. NLS_ENUMPROC pNlsEnumProc,
  2298. DWORD dwFlags,
  2299. LPWSTR pUnicodeBuffer1,
  2300. LPWSTR pUnicodeBuffer2,
  2301. DWORD dwValue1,
  2302. DWORD dwValue2,
  2303. LONG_PTR lParam,
  2304. BOOL fVersion);
  2305. //
  2306. // Translation Routines - mbcs.c.
  2307. //
  2308. int
  2309. SpecialMBToWC(
  2310. PCP_HASH pHashN,
  2311. DWORD dwFlags,
  2312. LPCSTR lpMultiByteStr,
  2313. int cbMultiByte,
  2314. LPWSTR lpWideCharStr,
  2315. int cchWideChar);
  2316. //
  2317. // UTF Translation Routines - utf.c.
  2318. //
  2319. BOOL
  2320. UTFCPInfo(
  2321. UINT CodePage,
  2322. LPCPINFO lpCPInfo,
  2323. BOOL fExVer);
  2324. int
  2325. UTFToUnicode(
  2326. UINT CodePage,
  2327. DWORD dwFlags,
  2328. LPCSTR lpMultiByteStr,
  2329. int cbMultiByte,
  2330. LPWSTR lpWideCharStr,
  2331. int cchWideChar);
  2332. int
  2333. UnicodeToUTF(
  2334. UINT CodePage,
  2335. DWORD dwFlags,
  2336. LPCWSTR lpWideCharStr,
  2337. int cchWideChar,
  2338. LPSTR lpMultiByteStr,
  2339. int cbMultiByte,
  2340. LPCSTR lpDefaultChar,
  2341. LPBOOL lpUsedDefaultChar);
  2342. //
  2343. // Locale/Calendar Info (locale.c)
  2344. //
  2345. BOOL
  2346. GetTwoDigitYearInfo(
  2347. CALID Calendar,
  2348. LPWSTR pYearInfo,
  2349. PWSTR pwszKeyPath);
  2350. ////////////////////////////////////////////////////////////////////////////
  2351. //
  2352. // Global Variables
  2353. //
  2354. // All of the global variables for the NLSAPI should be put here. These are
  2355. // all instance-specific. In general, there shouldn't be much reason to
  2356. // create instance globals.
  2357. //
  2358. // Globals are included last because they may require some of the types
  2359. // being defined above.
  2360. //
  2361. ////////////////////////////////////////////////////////////////////////////
  2362. extern PTBL_PTRS pTblPtrs; // ptr to structure of table ptrs
  2363. extern HANDLE hModule; // handle to module
  2364. extern RTL_CRITICAL_SECTION gcsTblPtrs; // critical section for tbl ptrs
  2365. extern UINT gAnsiCodePage; // Ansi code page value
  2366. extern UINT gOemCodePage; // OEM code page value
  2367. extern UINT gMacCodePage; // MAC code page value
  2368. extern LCID gSystemLocale; // system locale value
  2369. extern LANGID gSystemInstallLang; // system's original install language
  2370. extern PLOC_HASH gpSysLocHashN; // ptr to system loc hash node
  2371. extern PLOC_HASH gpInvLocHashN; // ptr to invariant loc hash node
  2372. extern PCP_HASH gpACPHashN; // ptr to ACP hash node
  2373. extern PCP_HASH gpOEMCPHashN; // ptr to OEMCP hash node
  2374. extern PCP_HASH gpMACCPHashN; // ptr to MAC hash node
  2375. extern HANDLE hCodePageKey; // handle to System\Nls\CodePage key
  2376. extern HANDLE hLocaleKey; // handle to System\Nls\Locale key
  2377. extern HANDLE hAltSortsKey; // handle to Locale\Alternate Sorts key
  2378. extern HANDLE hLangGroupsKey; // handle to System\Nls\Language Groups key
  2379. extern PNLS_USER_INFO pNlsUserInfo; // ptr to the user info cache
  2380. extern BOOL gInteractiveLogonUserProcess; // running in interactive user session or not.
  2381. extern RTL_CRITICAL_SECTION gcsNlsProcessCache; // Nls process cache critical section
  2382. ////////////////////////////////////////////////////////////////////////////
  2383. //
  2384. // Functions used to communicate with CSRSS.
  2385. //
  2386. ////////////////////////////////////////////////////////////////////////////
  2387. NTSTATUS
  2388. CsrBasepNlsGetUserInfo(
  2389. IN LCID Locale,
  2390. IN SIZE_T CacheOffset,
  2391. OUT LPWSTR pData,
  2392. IN ULONG DataLength);
  2393. NTSTATUS
  2394. CsrBasepNlsSetUserInfo(
  2395. IN LCTYPE LCType,
  2396. IN LPWSTR pData,
  2397. IN ULONG DataLength);
  2398. NTSTATUS
  2399. CsrBasepNlsSetMultipleUserInfo(
  2400. IN DWORD dwFlags,
  2401. IN int cchData,
  2402. IN LPCWSTR pPicture,
  2403. IN LPCWSTR pSeparator,
  2404. IN LPCWSTR pOrder,
  2405. IN LPCWSTR pTLZero,
  2406. IN LPCWSTR pTimeMarkPosn);
  2407. NTSTATUS
  2408. CsrBasepNlsCreateSection(
  2409. IN UINT uiType,
  2410. IN LCID Locale,
  2411. OUT PHANDLE phSection);
  2412. NTSTATUS
  2413. CsrBasepNlsUpdateCacheCount(VOID);
  2414. #endif // _NLS_