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.

236 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. c_other.c
  5. Abstract:
  6. This file contains the main functions for this module.
  7. External Routines in this file:
  8. DllEntry
  9. NlsDllCodePageTranslation
  10. Revision History:
  11. 10-30-96 JulieB Created.
  12. --*/
  13. //
  14. // Include Files.
  15. //
  16. #include <share.h>
  17. //
  18. // Global Variables.
  19. //
  20. //
  21. // Forward Declarations.
  22. //
  23. DWORD
  24. TranslateCP_50000(
  25. DWORD dwFlags,
  26. LPSTR lpMultiByteStr,
  27. int cchMultiByte,
  28. LPWSTR lpWideCharStr,
  29. int cchWideChar,
  30. LPCPINFO lpCPInfo);
  31. //-------------------------------------------------------------------------//
  32. // DLL ENTRY POINT //
  33. //-------------------------------------------------------------------------//
  34. ////////////////////////////////////////////////////////////////////////////
  35. //
  36. // DllEntry
  37. //
  38. // DLL Entry initialization procedure.
  39. //
  40. // 10-30-96 JulieB Created.
  41. ////////////////////////////////////////////////////////////////////////////
  42. BOOL DllEntry(
  43. HANDLE hModule,
  44. DWORD dwReason,
  45. LPVOID lpRes)
  46. {
  47. switch (dwReason)
  48. {
  49. case ( DLL_THREAD_ATTACH ) :
  50. {
  51. return (TRUE);
  52. }
  53. case ( DLL_THREAD_DETACH ) :
  54. {
  55. return (TRUE);
  56. }
  57. case ( DLL_PROCESS_ATTACH ) :
  58. {
  59. return (TRUE);
  60. }
  61. case ( DLL_PROCESS_DETACH ) :
  62. {
  63. return (TRUE);
  64. }
  65. }
  66. return (FALSE);
  67. hModule;
  68. lpRes;
  69. }
  70. //-------------------------------------------------------------------------//
  71. // EXTERNAL ROUTINES //
  72. //-------------------------------------------------------------------------//
  73. ////////////////////////////////////////////////////////////////////////////
  74. //
  75. // NlsDllCodePageTranslation
  76. //
  77. // This routine is the main exported procedure for the functionality in
  78. // this DLL. All calls to this DLL must go through this function.
  79. //
  80. // 10-30-96 JulieB Created.
  81. ////////////////////////////////////////////////////////////////////////////
  82. DWORD NlsDllCodePageTranslation(
  83. DWORD CodePage,
  84. DWORD dwFlags,
  85. LPSTR lpMultiByteStr,
  86. int cchMultiByte,
  87. LPWSTR lpWideCharStr,
  88. int cchWideChar,
  89. LPCPINFO lpCPInfo)
  90. {
  91. switch (CodePage)
  92. {
  93. case ( 50000 ) :
  94. {
  95. return ( TranslateCP_50000( dwFlags,
  96. lpMultiByteStr,
  97. cchMultiByte,
  98. lpWideCharStr,
  99. cchWideChar,
  100. lpCPInfo ) );
  101. }
  102. default :
  103. {
  104. //
  105. // Invalid code page value.
  106. //
  107. SetLastError(ERROR_INVALID_PARAMETER);
  108. return (0);
  109. }
  110. }
  111. }
  112. //-------------------------------------------------------------------------//
  113. // INTERNAL ROUTINES //
  114. //-------------------------------------------------------------------------//
  115. ////////////////////////////////////////////////////////////////////////////
  116. //
  117. // TranslateCP_50000
  118. //
  119. // This routine does the translations for code page 50000.
  120. //
  121. // **** This is a BOGUS routine - for testing purposes only. ****
  122. //
  123. // 10-30-96 JulieB Created.
  124. ////////////////////////////////////////////////////////////////////////////
  125. DWORD TranslateCP_50000(
  126. DWORD dwFlags,
  127. LPSTR lpMultiByteStr,
  128. int cchMultiByte,
  129. LPWSTR lpWideCharStr,
  130. int cchWideChar,
  131. LPCPINFO lpCPInfo)
  132. {
  133. int ctr;
  134. switch (dwFlags)
  135. {
  136. case ( NLS_CP_CPINFO ) :
  137. {
  138. lpCPInfo->MaxCharSize = 1;
  139. lpCPInfo->DefaultChar[0] = '?';
  140. lpCPInfo->DefaultChar[1] = (BYTE)0;
  141. for (ctr = 0; ctr < MAX_LEADBYTES; ctr++)
  142. {
  143. lpCPInfo->LeadByte[ctr] = 0;
  144. }
  145. return (TRUE);
  146. }
  147. case ( NLS_CP_MBTOWC ) :
  148. {
  149. if (cchWideChar == 0)
  150. {
  151. return (cchMultiByte);
  152. }
  153. for (ctr = 0; (ctr < cchMultiByte) && (ctr < cchWideChar); ctr++)
  154. {
  155. lpWideCharStr[ctr] = (WORD)(lpMultiByteStr[ctr]);
  156. }
  157. return (ctr);
  158. }
  159. case ( NLS_CP_WCTOMB ) :
  160. {
  161. if (cchMultiByte == 0)
  162. {
  163. return (cchWideChar);
  164. }
  165. for (ctr = 0; (ctr < cchWideChar) && (ctr < cchMultiByte); ctr++)
  166. {
  167. lpMultiByteStr[ctr] = LOBYTE(lpWideCharStr[ctr]);
  168. }
  169. return (ctr);
  170. }
  171. default :
  172. {
  173. //
  174. // This shouldn't happen since this function gets called by
  175. // the NLS API routines.
  176. //
  177. SetLastError(ERROR_INVALID_PARAMETER);
  178. return (0);
  179. }
  180. }
  181. }