Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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