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.

150 lines
4.0 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: dsnevent.h
  5. //
  6. // Description: Define dsnevent structure. Used to pass parameters to DSN sink
  7. // with intelligent defaults
  8. //
  9. // Author: Mike Swafford (MikeSwa)
  10. //
  11. // History:
  12. // 7/11/98 - MikeSwa Created
  13. //
  14. // Copyright (C) 1998 Microsoft Corporation
  15. //
  16. //-----------------------------------------------------------------------------
  17. #ifndef __DSNEVENT_H__
  18. #define __DSNEVENT_H__
  19. class CAQSvrInst;
  20. #define DSN_PARAMS_SIG 'PnsD'
  21. const CHAR DEFAULT_MTA_TYPE[] = "dns";
  22. #define DSN_DEBUG_CONTEXT_MAX_SIZE 50
  23. #define DSN_DEBUG_CONTEXT_FORMAT "12345678 - line#"
  24. #define DSN_LINE_PREFIX " - "
  25. //
  26. // We will encode the filename using the same hash we use for domhash.
  27. // This way, we can always have supplemental info useful for debugging DSNs
  28. //
  29. #define SET_DEBUG_DSN_CONTEXT(x, linenum) \
  30. { \
  31. register LPSTR szCurrent = (x).szDebugContext; \
  32. _itoa(dwDSNContextHash(__FILE__, sizeof(__FILE__)), \
  33. szCurrent, 16); \
  34. szCurrent += strlen((x).szDebugContext);\
  35. strcpy(szCurrent, DSN_LINE_PREFIX); \
  36. szCurrent += (sizeof(DSN_LINE_PREFIX)-1); \
  37. _itoa(linenum, szCurrent, 10); \
  38. }
  39. //---[ CDSNParams ]------------------------------------------------------------
  40. //
  41. //
  42. // Description:
  43. // Encapsulated DSN Parameters in a class
  44. // Hungarian:
  45. // dsnparams, *pdsnparams
  46. //
  47. //-----------------------------------------------------------------------------
  48. class CDSNParams :
  49. public IDSNSubmission
  50. {
  51. private:
  52. DWORD m_dwSignature;
  53. public: //actual parameters of DSN Generation event
  54. IMailMsgProperties *pIMailMsgProperties;
  55. DWORD dwStartDomain; //starting index used to init context
  56. DWORD dwDSNActions; //type(s) of DSN to generate
  57. DWORD dwRFC821Status; //global RFC821 status
  58. HRESULT hrStatus; //global HRESULT
  59. //OUT param(s)
  60. DWORD dwDSNTypesGenerated;
  61. DWORD cRecips; //# of recipients DSN'd
  62. CAQSvrInst *paqinst;
  63. CHAR szDebugContext[DSN_DEBUG_CONTEXT_MAX_SIZE]; //debug context stampted as "x=" header
  64. public:
  65. inline CDSNParams();
  66. public: // IDSNSubmission
  67. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj)
  68. {
  69. *ppvObj = NULL;
  70. if(riid == IID_IUnknown)
  71. {
  72. *ppvObj = (IUnknown *)this;
  73. }
  74. else if(riid == IID_IDSNSubmission)
  75. {
  76. *ppvObj = (IDSNSubmission *)this;
  77. }
  78. else
  79. {
  80. return E_NOINTERFACE;
  81. }
  82. AddRef();
  83. return S_OK;
  84. }
  85. //
  86. // This class is always allocated on the stack
  87. //
  88. STDMETHOD_(ULONG, AddRef)(void) { return 2; }
  89. STDMETHOD_(ULONG, Release)(void) { return 1; }
  90. STDMETHOD(HrAllocBoundMessage)(
  91. OUT IMailMsgProperties **ppMsg,
  92. OUT PFIO_CONTEXT *phContent);
  93. STDMETHOD(HrSubmitDSN)(
  94. IN DWORD dwDSNAction,
  95. IN DWORD cRecipsDSNd,
  96. IN IMailMsgProperties *pDSNMsg);
  97. };
  98. CDSNParams::CDSNParams()
  99. {
  100. _ASSERT(sizeof(DSN_DEBUG_CONTEXT_FORMAT) < DSN_DEBUG_CONTEXT_MAX_SIZE);
  101. m_dwSignature = DSN_PARAMS_SIG;
  102. pIMailMsgProperties = NULL;
  103. dwStartDomain = 0;
  104. dwDSNActions = 0;
  105. dwRFC821Status = 0;
  106. hrStatus = S_OK;
  107. dwDSNTypesGenerated = 0;
  108. cRecips = 0;
  109. paqinst = NULL;
  110. szDebugContext[0] = '\0';
  111. }
  112. inline DWORD dwDSNContextHash(LPCSTR szString, DWORD cbString)
  113. {
  114. DWORD dwHash = 0;
  115. LPCSTR szStringEnd = szString+cbString-1;
  116. if (szStringEnd && cbString)
  117. {
  118. //
  119. // Loop until the end of the string or we hit a file separation
  120. // character.
  121. //
  122. while (szStringEnd &&
  123. (szStringEnd >= szString) &&
  124. ('\\' != *szStringEnd))
  125. {
  126. //Use Hash from Domhash.lib
  127. dwHash *= 131; //First prime after ASCII character codes
  128. dwHash += *szStringEnd;
  129. szStringEnd--;
  130. }
  131. }
  132. return dwHash;
  133. }
  134. #endif //__DSNEVENT_H__