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.

109 lines
2.7 KiB

  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1997, Microsoft Corporation.
  4. //
  5. // Routine: DllMain
  6. //
  7. // Description:
  8. //
  9. // Returns: True if successful, else False.
  10. // History: Weibz, 10-Nov-1997, created it.
  11. //
  12. //---------------------------------------------------------------------------
  13. #include <pch.cxx>
  14. #include "thwbint.h"
  15. #include "resource.h"
  16. CRITICAL_SECTION ThCritSect;
  17. //SCRIPTITEMIZE ScriptItemize;
  18. //SCRIPTBREAK ScriptBreak;
  19. HMODULE hUsp;
  20. BOOL InitWordBreakEngine(HINSTANCE hInstance)
  21. {
  22. LPBYTE lpLexicon = NULL;
  23. LPBYTE lpTrigram = NULL;
  24. HGLOBAL hLexicon = NULL;
  25. HGLOBAL hTrigram = NULL;
  26. HRSRC hrsrcLexicon = FindResource(hInstance,(LPSTR) MAKEINTRESOURCE(IDR_LEXICON1),"LEXICON");
  27. HRSRC hrsrcTrigram = FindResource(hInstance,(LPSTR) MAKEINTRESOURCE(IDR_LEXICON2),"LEXICON");
  28. // Check if we were able to find resource.
  29. if (NULL == hrsrcLexicon || NULL == hrsrcTrigram)
  30. {
  31. assert(false);
  32. return FALSE;
  33. }
  34. hLexicon = LoadResource(hInstance, hrsrcLexicon);
  35. hTrigram = LoadResource(hInstance, hrsrcTrigram);
  36. // Check if we were able to load resource.
  37. if (NULL == hLexicon || NULL == hTrigram)
  38. {
  39. assert(false);
  40. return FALSE;
  41. }
  42. lpLexicon = (LPBYTE) LockResource(hLexicon);
  43. lpTrigram = (LPBYTE) LockResource(hTrigram);
  44. if (ThaiWordBreakInitResource(lpLexicon,lpTrigram, FALSE) != ptecNoErrors)
  45. {
  46. assert(false);
  47. return FALSE;
  48. }
  49. return TRUE;
  50. }
  51. BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
  52. {
  53. CHAR szUSPPath[MAX_PATH];
  54. switch(dwReason)
  55. {
  56. case DLL_PROCESS_ATTACH :
  57. DisableThreadLibraryCalls(hDLL);
  58. InitializeCriticalSection (&ThCritSect);
  59. /*
  60. GetSystemDirectory ( szUSPPath, MAX_PATH );
  61. strcat ( szUSPPath, "\\USP.DLL" );
  62. hUsp = LoadLibrary (szUSPPath);
  63. if ( hUsp == NULL )
  64. return FALSE;
  65. ScriptItemize = (SCRIPTITEMIZE)GetProcAddress(hUsp,"ScriptItemize");
  66. ScriptBreak = (SCRIPTBREAK) GetProcAddress(hUsp,"ScriptBreak");
  67. if ( (ScriptItemize==NULL) || (ScriptBreak==NULL) )
  68. return FALSE;
  69. */
  70. return InitWordBreakEngine(hDLL);
  71. break ;
  72. case DLL_THREAD_ATTACH:
  73. break;
  74. case DLL_THREAD_DETACH:
  75. break;
  76. case DLL_PROCESS_DETACH :
  77. /*
  78. if (hUsp != NULL )
  79. FreeLibrary(hUsp);
  80. hUsp = NULL;
  81. */
  82. ThaiWordBreakTerminate();
  83. DeleteCriticalSection (&ThCritSect);
  84. break ;
  85. } //switch
  86. return TRUE ;
  87. }