Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name:
  4. encrypt.c
  5. Abstract:
  6. Contains functions that detect the run system is french locale.
  7. Author:
  8. Madan Appiah (madana) 16-May-1998
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. #include <seccom.h>
  14. #ifdef OS_WIN32
  15. BOOL
  16. IsFrenchSystem(
  17. VOID
  18. )
  19. /*++
  20. Routine Description:
  21. French laws are strict with respect to the import of software products which
  22. contain cryptography. Therefore many Microsoft products must check for a locale
  23. of France and disable cryptographic services if this is the case. There is the
  24. possibility that forms of cryptography currently restricted may eventually be
  25. allowed in France. For this reason it is valuable to implement a check for a
  26. crypto approval indicator which could easily be installed on a Windows system in
  27. the future. The indicator tells the software that it is OK to enable specific
  28. cryptographic services which may not have been approved for import to France
  29. when the software was released, but have been subsequently allowed. Below are
  30. two code fragments, the first indicates how to check for the locale of France.
  31. The second code fragment is a simple example of how a check for a cryptographic
  32. approval indicator might be implemented.
  33. This function implements France Locale detection.
  34. Arguments:
  35. None.
  36. Return Value:
  37. TURE - if the system is French.
  38. FALSE - if not.
  39. --*/
  40. {
  41. #define MAX_INT_SIZE 16
  42. LCID dwDefaultSystemLCID;
  43. LANGID wCurrentLangID;
  44. DWORD dwLen;
  45. TCHAR achCountryCode[MAX_INT_SIZE];
  46. DWORD dwCountryCode;
  47. //
  48. // Get system default locale ID.
  49. //
  50. dwDefaultSystemLCID = GetSystemDefaultLCID();
  51. //
  52. // get language ID from locale ID.
  53. //
  54. wCurrentLangID = LANGIDFROMLCID(dwDefaultSystemLCID);
  55. //
  56. // check to see the system is running with french locale.
  57. //
  58. if( ( PRIMARYLANGID(wCurrentLangID) == LANG_FRENCH) &&
  59. ( SUBLANGID(wCurrentLangID) == SUBLANG_FRENCH) ) {
  60. return( TRUE );
  61. }
  62. //
  63. // check to see the user's country code is set to CTRY_FRENCH.
  64. //
  65. dwLen =
  66. GetLocaleInfo(
  67. dwDefaultSystemLCID,
  68. LOCALE_ICOUNTRY,
  69. achCountryCode,
  70. sizeof(achCountryCode) / sizeof(TCHAR));
  71. if( dwLen == 0 ) {
  72. //
  73. // we could not read the country code ..
  74. //
  75. return( FALSE );
  76. }
  77. //
  78. // convert the country code string to integer.
  79. //
  80. dwCountryCode = (DWORD)_ttol(achCountryCode);
  81. if( dwCountryCode != CTRY_FRANCE ) {
  82. return( FALSE );
  83. }
  84. //
  85. // if we are here, then the system is french locale system.
  86. //
  87. return( TRUE );
  88. }
  89. #else // OS_WIN32
  90. BOOL
  91. IsFrenchSystem(
  92. VOID
  93. )
  94. /*++
  95. Routine Description:
  96. This function implements France Locale detection for win3.1.
  97. Arguments:
  98. None.
  99. Return Value:
  100. TURE - if the system is French.
  101. FALSE - if not.
  102. --*/
  103. {
  104. #define MAX_LANG_STRING_SIZE 16
  105. DWORD dwLen;
  106. CHAR achLangStr[MAX_LANG_STRING_SIZE];
  107. //
  108. // read [intl] section in the win.ini to determine the
  109. // system locale.
  110. //
  111. dwLen =
  112. GetProfileString(
  113. "intl",
  114. "sLanguage",
  115. "",
  116. achLangStr,
  117. sizeof(achLangStr));
  118. if( (dwLen == 3) &&
  119. (_stricmp(achLangStr, "fra") == 0) ) {
  120. //
  121. // french system.
  122. //
  123. return( TRUE );
  124. }
  125. //
  126. // now read country code.
  127. //
  128. dwLen =
  129. GetProfileString(
  130. "intl",
  131. "iCountry",
  132. "",
  133. achLangStr,
  134. sizeof(achLangStr));
  135. if( (dwLen == 2) &&
  136. (_stricmp(achLangStr, "33") == 0) ) {
  137. //
  138. // french system.
  139. //
  140. return( TRUE );
  141. }
  142. //
  143. // not a french system.
  144. //
  145. return( FALSE );
  146. }
  147. #endif // OS_WIN32
  148. BOOL
  149. FindIsFrenchSystem(
  150. VOID
  151. )
  152. /*++
  153. Routine Description:
  154. The function implements a check for the locale of France.
  155. Note : it makes system calls to determine the system locale once
  156. and remembers it for later calls.
  157. Arguments:
  158. None.
  159. Return Value:
  160. TURE - if the system is French.
  161. FALSE - if not.
  162. --*/
  163. {
  164. typedef enum {
  165. Uninitialized = 0,
  166. FrenchSystem = 1,
  167. NotFrenchSystem = 2
  168. } FrenchSystemType;
  169. static FrenchSystemType g_dwIsFrenchSystem = Uninitialized;
  170. if( g_dwIsFrenchSystem == Uninitialized ) {
  171. if( IsFrenchSystem() ) {
  172. g_dwIsFrenchSystem = FrenchSystem;
  173. }
  174. else {
  175. g_dwIsFrenchSystem = NotFrenchSystem;
  176. }
  177. }
  178. if( g_dwIsFrenchSystem == FrenchSystem ) {
  179. return( TRUE );
  180. }
  181. return( FALSE );
  182. }