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.

114 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. winfax.c
  5. Abstract:
  6. This module contains routines for the winfax dllinit.
  7. Author:
  8. Wesley Witt (wesw) 22-Jan-1996
  9. --*/
  10. #include "faxapi.h"
  11. #pragma hdrstop
  12. HINSTANCE g_MyhInstance;
  13. static BOOL gs_fFXSAPIInit;
  14. #define FAX_API_DEBUG_LOG_FILE _T("FXSAPIDebugLogFile.txt")
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. DWORD
  19. DllMain(
  20. HINSTANCE hInstance,
  21. DWORD Reason,
  22. LPVOID Context
  23. )
  24. /*++
  25. Routine Description:
  26. DLL initialization function.
  27. Arguments:
  28. hInstance - Instance handle
  29. Reason - Reason for the entrypoint being called
  30. Context - Context record
  31. Return Value:
  32. TRUE - Initialization succeeded
  33. FALSE - Initialization failed
  34. --*/
  35. {
  36. if (Reason == DLL_PROCESS_ATTACH)
  37. {
  38. OPEN_DEBUG_FILE(FAX_API_DEBUG_LOG_FILE);
  39. g_MyhInstance = hInstance;
  40. DisableThreadLibraryCalls( hInstance );
  41. gs_fFXSAPIInit = FXSAPIInitialize();
  42. return gs_fFXSAPIInit;
  43. }
  44. if (Reason == DLL_PROCESS_DETACH)
  45. {
  46. FXSAPIFree();
  47. CLOSE_DEBUG_FILE;
  48. }
  49. return TRUE;
  50. }
  51. //
  52. // FXSAPIInitialize and FXSAPIFree are private and are called by the service only
  53. // Becuase the process is not always terminated when the service is stopped, and not all DLL are freed,
  54. // DLL_PROCESS_ATTACH is not always called when the service starts. Therefore it calls FXSAPIInitialize().
  55. //
  56. BOOL
  57. FXSAPIInitialize(
  58. VOID
  59. )
  60. {
  61. if (TRUE == gs_fFXSAPIInit)
  62. {
  63. return TRUE;
  64. }
  65. if (!FaxClientInitRpcServer())
  66. {
  67. return FALSE;
  68. }
  69. return TRUE;
  70. }
  71. VOID
  72. FXSAPIFree(
  73. VOID
  74. )
  75. {
  76. FaxClientTerminateRpcServer();
  77. HeapCleanup();
  78. gs_fFXSAPIInit = FALSE;
  79. return;
  80. }
  81. #ifdef __cplusplus
  82. }
  83. #endif