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.

89 lines
2.4 KiB

  1. #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  2. #include "interop.h"
  3. #include <stdio.h>
  4. #include "cpls.h"
  5. static int g_nRefCount = 0;
  6. LPInteropLogger INTEROP_EXPORT InteropLoad(CPLProtocol Protocol)
  7. {
  8. OutputDebugString("Loading CPLS\n");
  9. LPInteropLogger Logger = (LPInteropLogger) GlobalAlloc (GMEM_FIXED | GMEM_ZEROINIT, sizeof(InteropLogger));
  10. if (!(Logger))
  11. return NULL;
  12. UINT oldMode = SetErrorMode(SEM_NOOPENFILEERRORBOX);
  13. (Logger)->hInst = LoadLibrary(DLLName);
  14. SetErrorMode(oldMode);
  15. if ((INT_PTR)(Logger)->hInst > HINSTANCE_ERROR)
  16. {
  17. g_nRefCount++;
  18. #ifdef _DEBUG
  19. char buf[80];
  20. wsprintf (buf, "Loading Generic Protocol Logger: %s\n",DLLName);
  21. OutputDebugString(buf);
  22. #endif
  23. (Logger)->CPLInitialize = (CPLInitialize_t)GetProcAddress((Logger)->hInst, "CPLInitialize");
  24. (Logger)->CPLUninitialize = (CPLUninitialize_t)GetProcAddress((Logger)->hInst, "CPLUninitialize");
  25. (Logger)->CPLOpen = (CPLOpen_t)GetProcAddress((Logger)->hInst, "CPLOpen");
  26. (Logger)->CPLClose = (CPLClose_t)GetProcAddress((Logger)->hInst, "CPLClose");
  27. (Logger)->CPLOutput = (CPLOutput_t)GetProcAddress((Logger)->hInst, "CPLOutput");
  28. Logger->g_ProtocolLogID = Logger->CPLInitialize(Protocol);
  29. Logger->g_ComplianceProtocolLogger = Logger->CPLOpen(Logger->g_ProtocolLogID,
  30. NULL,
  31. CPLS_CREATE | CPLS_APPEND);
  32. }
  33. else
  34. {
  35. GlobalFree((Logger));
  36. (Logger) = NULL;
  37. #ifdef _DEBUG
  38. char buf[80];
  39. wsprintf (buf, "Loading Generic Protocol Logger %s Failed\n",DLLName);
  40. OutputDebugString(buf);
  41. #endif
  42. }
  43. return Logger;
  44. }
  45. void INTEROP_EXPORT InteropUnload(LPInteropLogger Logger)
  46. {
  47. #ifdef _DEBUG
  48. char buf[80];
  49. wsprintf (buf, "Unloading Generic Protocol Logger: %s\n",DLLName);
  50. OutputDebugString(buf);
  51. #endif
  52. if ((Logger))
  53. {
  54. if ((INT_PTR)(Logger)->hInst > HINSTANCE_ERROR)
  55. {
  56. Logger->CPLClose(Logger->g_ComplianceProtocolLogger);
  57. Logger->CPLUninitialize(Logger->g_ProtocolLogID);
  58. if (--g_nRefCount <= 0)
  59. FreeLibrary((Logger)->hInst);
  60. }
  61. GlobalFree((Logger));
  62. (Logger) = NULL;
  63. }
  64. }
  65. void INTEROP_EXPORT InteropOutput(LPInteropLogger Logger, BYTE* buf,
  66. int length, unsigned long userData)
  67. {
  68. if (!Logger)
  69. return;
  70. Logger->CPLOutput(Logger->g_ComplianceProtocolLogger, buf, length,userData);
  71. }
  72. #endif // #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  73.