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.

103 lines
3.7 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: aqutil.h
  5. //
  6. // Description:
  7. // General AQueue utility functions... like IMailMsg Usage Count
  8. // manipulation, queue mapping functions, and domain name table iterator
  9. // functions.
  10. //
  11. // Author: Mike Swafford (MikeSwa)
  12. //
  13. // History:
  14. // 7/20/98 - MikeSwa Created
  15. // 7/29/98 - MikeSwa Modified (added CalcMsgsPendingRetryIteratorFn)
  16. //
  17. // Copyright (C) 1998 Microsoft Corporation
  18. //
  19. //-----------------------------------------------------------------------------
  20. #ifndef __AQUTIL_H__
  21. #define __AQUTIL_H__
  22. #include "aqincs.h"
  23. #include "msgref.h"
  24. #include "refstr.h"
  25. //Functions to manipulate IMailMsg usage count
  26. HRESULT HrIncrementIMailMsgUsageCount(IUnknown *pIUnknown);
  27. HRESULT HrReleaseIMailMsgUsageCount(IUnknown *pIUnknown);
  28. HRESULT HrDeleteIMailMsg(IUnknown *pIUnknown); //deletes and releases usage count
  29. HRESULT HrWalkMailMsgQueueForShutdown(IN IMailMsgProperties *pIMailMsgProperties,
  30. IN PVOID pvContext, OUT BOOL *pfContinue,
  31. OUT BOOL *pfDelete);
  32. BOOL fMailMsgShutdownCompletion(PVOID pvContext, DWORD dwStatus);
  33. HRESULT HrWalkMsgRefQueueForShutdown(IN CMsgRef *pmsgref,
  34. IN PVOID pvContext, OUT BOOL *pfContinue,
  35. OUT BOOL *pfDelete);
  36. BOOL fMsgRefShutdownCompletion(PVOID pvContext, DWORD dwStatus);
  37. //Domain Name Table iterator function used to count perf counters
  38. VOID CalcDMTPerfCountersIteratorFn(PVOID pvContext, PVOID pvData,
  39. BOOL fWildcard, BOOL *pfContinue,
  40. BOOL *pfDelete);
  41. //Functions to manipulate DWORD's bits in a thread safe manner
  42. DWORD dwInterlockedSetBits(DWORD *pdwTarget, DWORD dwFlagMask);
  43. DWORD dwInterlockedUnsetBits(DWORD *pdwTarget, DWORD dwFlagMask);
  44. HRESULT HrWalkPreLocalQueueForDSN(IN CMsgRef *pmsgref, IN PVOID pvContext,
  45. OUT BOOL *pfContinue, OUT BOOL *pfDelete);
  46. //Used to reget the message type in various retry situations
  47. HRESULT HrReGetMessageType(IN IMailMsgProperties *pIMailMsgProperties,
  48. IN IMessageRouter *pIMessageRouter,
  49. IN OUT DWORD *pdwMessageType);
  50. #define UNIQUEUE_FILENAME_BUFFER_SIZE 35
  51. //Creates a unique filename
  52. void GetUniqueFileName(IN FILETIME *pft, IN LPSTR szFileBuffer, IN LPSTR szExtension);
  53. //Ultility function to link all domains together (primarly to NDR an entire message)
  54. HRESULT HrLinkAllDomains(IN IMailMsgProperties *pIMailMsgProperties);
  55. //Parses a GUID from a string... returns TRUE on success
  56. BOOL fAQParseGuidString(LPSTR szGuid, DWORD cbGuid, GUID *pguid);
  57. inline DWORD dwInterlockedAddSubtractDWORD(DWORD *pdwValue,
  58. DWORD dwNew, BOOL fAdd)
  59. {
  60. return InterlockedExchangeAdd((PLONG) pdwValue,
  61. fAdd ? ((LONG) dwNew) : (-1 * ((LONG) dwNew)));
  62. };
  63. void InterlockedAddSubtractULARGE(ULARGE_INTEGER *puliValue,
  64. ULARGE_INTEGER *puliNew, BOOL fAdd);
  65. //Functions to do simple spin lock manipulations
  66. inline BOOL fTrySpinLock(DWORD *pdwLock, DWORD dwLockBit)
  67. {
  68. return (!(dwLockBit & dwInterlockedSetBits(pdwLock, dwLockBit)));
  69. }
  70. inline void ReleaseSpinLock(DWORD *pdwLock, DWORD dwLockBit)
  71. {
  72. _ASSERT(*pdwLock & dwLockBit);
  73. dwInterlockedUnsetBits(pdwLock, dwLockBit);
  74. }
  75. //
  76. // Same as above but checks content handle. We force a rendering of the
  77. // message
  78. //
  79. HRESULT HrValidateMessageContent(IMailMsgProperties *pIMailMsgProperties);
  80. #endif //__AQUTIL_H__