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.

72 lines
2.0 KiB

  1. #include "precomp.h"
  2. #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  3. #include "interop.h"
  4. #include <stdio.h>
  5. #include "cpls.h"
  6. static int g_nRefCount = 0;
  7. LPInteropLogger INTEROP_EXPORT InteropLoad(CPLProtocol Protocol)
  8. {
  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. (Logger)->CPLInitialize = (CPLInitialize_t)GetProcAddress((Logger)->hInst, "CPLInitialize");
  19. (Logger)->CPLUninitialize = (CPLUninitialize_t)GetProcAddress((Logger)->hInst, "CPLUninitialize");
  20. (Logger)->CPLOpen = (CPLOpen_t)GetProcAddress((Logger)->hInst, "CPLOpen");
  21. (Logger)->CPLClose = (CPLClose_t)GetProcAddress((Logger)->hInst, "CPLClose");
  22. (Logger)->CPLOutput = (CPLOutput_t)GetProcAddress((Logger)->hInst, "CPLOutput");
  23. Logger->g_ProtocolLogID = Logger->CPLInitialize(Protocol);
  24. Logger->g_ComplianceProtocolLogger = Logger->CPLOpen(Logger->g_ProtocolLogID,
  25. NULL,
  26. CPLS_CREATE | CPLS_APPEND);
  27. }
  28. else
  29. {
  30. GlobalFree((Logger));
  31. (Logger) = NULL;
  32. }
  33. return Logger;
  34. }
  35. void INTEROP_EXPORT InteropUnload(LPInteropLogger Logger)
  36. {
  37. if ((Logger))
  38. {
  39. if ((INT_PTR)(Logger)->hInst > HINSTANCE_ERROR)
  40. {
  41. Logger->CPLClose(Logger->g_ComplianceProtocolLogger);
  42. Logger->CPLUninitialize(Logger->g_ProtocolLogID);
  43. if (--g_nRefCount <= 0)
  44. FreeLibrary((Logger)->hInst);
  45. }
  46. GlobalFree((Logger));
  47. (Logger) = NULL;
  48. }
  49. }
  50. void INTEROP_EXPORT InteropOutput(LPInteropLogger Logger, BYTE* buf,
  51. int length, unsigned long userData)
  52. {
  53. if (!Logger)
  54. return;
  55. Logger->CPLOutput(Logger->g_ComplianceProtocolLogger, buf, length,userData);
  56. }
  57. #endif // #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  58.