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.

130 lines
3.7 KiB

  1. #ifndef __MULTIUTL_H
  2. #define __MULTIUTL_H
  3. #include <assert.h>
  4. #include "objidl.h"
  5. #include <pstore.h>
  6. #include "multiusr.h"
  7. #ifndef Assert
  8. #ifdef DEBUG
  9. #define Assert(a) assert(a)
  10. #define SideAssert(a) Assert(a)
  11. #define AssertSz(a, sz) Assert(a)
  12. #define ASSERT_MSGA 1 ? (void)0 : (void)
  13. #else // DEBUG
  14. #define ASSERT_MSGA 1 ? (void)0 : (void)
  15. #define Assert(a)
  16. #define SideAssert(a) (a)
  17. #define AssertSz(a, sz)
  18. #endif // DEBUG, else
  19. #endif
  20. #ifdef UNICODE
  21. #define FIsSpace FIsSpaceW
  22. #else
  23. #define FIsSpace FIsSpaceA
  24. #endif
  25. // Context-sensitive Help utility.
  26. typedef struct _tagHELPMAP
  27. {
  28. DWORD id;
  29. DWORD hid;
  30. } HELPMAP, *LPHELPMAP;
  31. BOOL OnContextHelp(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, HELPMAP const * rgCtxMap);
  32. ULONG UlStripWhitespace(LPTSTR lpsz, BOOL fLeading, BOOL fTrailing, ULONG *pcb);
  33. void EncodeUserPassword(TCHAR *lpszPwd, ULONG *cb);
  34. void DecodeUserPassword(TCHAR *lpszPwd, ULONG *cb);
  35. STDAPI WriteIdentityPassword(GUID *puidIdentity, PASSWORD_STORE *pPwdStore);
  36. STDAPI ReadIdentityPassword(GUID *puidIdentity, PASSWORD_STORE *pPwdStore);
  37. STDAPI CreatePStore(IPStore **ppIPStore);
  38. STDAPI ReleasePStore(IPStore *pIPStore);
  39. // --------------------------------------------------------------------------------
  40. // SafeRelease - Releases an object and sets the object to NULL
  41. // --------------------------------------------------------------------------------
  42. #define SafeRelease(_object) \
  43. if (_object) { \
  44. (_object)->Release(); \
  45. (_object) = NULL; \
  46. } else
  47. void MemFree(void* pv);
  48. BOOL MemAlloc(void** ppv, ULONG cb);
  49. BOOL MemRealloc(void** ppv, ULONG cbNew);
  50. // --------------------------------------------------------------------------------
  51. // TraceCall(_pszFunc)
  52. // -------------------------------------------------------------------------------
  53. #ifdef DEBUG
  54. EXTERN_C void DebugStrf(LPTSTR lpszFormat, ...);
  55. #endif
  56. #if defined(FULL_DEBUG)
  57. #define TraceCall(_pszFunc) DebugStrf("%s\r\n", _pszFunc)
  58. #else
  59. #define TraceCall(_pszFunc)
  60. #endif
  61. // --------------------------------------------------------------------------------
  62. // GUID <-> Ascii string functions
  63. // --------------------------------------------------------------------------------
  64. HRESULT GUIDFromAString(TCHAR *lpsz, GUID *puid);
  65. int AStringFromGUID(GUID *rguid, TCHAR *lpsz, int cch);
  66. typedef enum
  67. {
  68. NS_NONE = 0,
  69. NS_PRE_NOTIFY,
  70. NS_NOTIFIED
  71. } NOTIFICATION_STATE;
  72. typedef struct tagUNKLIST_ENTRY
  73. {
  74. HWND hwnd;
  75. DWORD dwThreadId;
  76. DWORD dwCookie;
  77. BYTE bState;
  78. IUnknown *punk;
  79. } UNKLIST_ENTRY;
  80. class CNotifierList
  81. {
  82. public:
  83. CNotifierList();
  84. virtual ~CNotifierList();
  85. STDMETHODIMP_(ULONG) AddRef(void);
  86. STDMETHODIMP_(ULONG) Release(void);
  87. inline DWORD GetLength(void) {return m_count;}
  88. HRESULT Add(IUnknown *punk, DWORD *pdwCookie);
  89. HRESULT RemoveCookie(DWORD dwCookie);
  90. HRESULT Remove(int iIndex);
  91. HRESULT GetAtIndex(int iIndex, IUnknown **ppunk);
  92. HRESULT CreateNotifyWindow();
  93. HRESULT ReleaseWindow();
  94. HRESULT SendNotification(UINT msg, DWORD dwType);
  95. HRESULT PreNotify();
  96. int GetNextNotify();
  97. private:
  98. ULONG m_cRef;
  99. int m_count;
  100. int m_ptrCount;
  101. DWORD m_nextCookie;
  102. UNKLIST_ENTRY *m_entries;
  103. CRITICAL_SECTION m_rCritSect;
  104. };
  105. #endif //__MULTIUTL_H