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.

154 lines
4.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: protbase.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 11-07-1996 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef _PROTBASE_HXX_
  18. #define _PROTBASE_HXX_
  19. #define offsetof(s,m) (size_t)&(((s *)0)->m)
  20. #define GETPPARENT(pmemb, struc, membname) ((struc FAR *)(((char FAR *)(pmemb))-offsetof(struc, membname)))
  21. #define MAX_URL_SIZE INTERNET_MAX_URL_LENGTH
  22. // this will be in a common header file
  23. #define S_NEEDMOREDATA ((HRESULT)0x00000002L)
  24. #define BSCF_ASYNCDATANOTIFICATION 0x00010000
  25. #define BSCF_DATAFULLYAVAILABLE 0x00020000
  26. class CBaseProtocol : public IOInetProtocol, public IOInetThreadSwitch, public IOInetPriority
  27. {
  28. public:
  29. // IUnknown methods
  30. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  31. STDMETHODIMP_(ULONG) AddRef(void);
  32. STDMETHODIMP_(ULONG) Release(void);
  33. STDMETHODIMP Start(LPCWSTR szUrl,IOInetProtocolSink *pProtSink,
  34. IOInetBindInfo *pOIBindInfo,DWORD grfSTI,DWORD dwReserved);
  35. STDMETHODIMP Continue(PROTOCOLDATA *pStateInfo);
  36. STDMETHODIMP Abort(HRESULT hrReason,DWORD dwOptions);
  37. STDMETHODIMP Terminate(DWORD dwOptions);
  38. STDMETHODIMP Suspend();
  39. STDMETHODIMP Resume();
  40. STDMETHODIMP Read(void *pv,ULONG cb,ULONG *pcbRead);
  41. STDMETHODIMP Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin,
  42. ULARGE_INTEGER *plibNewPosition);
  43. STDMETHODIMP LockRequest(DWORD dwOptions);
  44. STDMETHODIMP UnlockRequest();
  45. // IOInetPriority
  46. STDMETHODIMP SetPriority(LONG nPriority);
  47. STDMETHODIMP GetPriority(LONG * pnPriority);
  48. // IOInetThreadSwitch
  49. STDMETHODIMP Prepare();
  50. STDMETHODIMP Continue();
  51. public:
  52. CBaseProtocol(REFCLSID rclsid, IUnknown *pUnkOuter, IUnknown **ppUnkInner);
  53. virtual ~CBaseProtocol();
  54. BOOL OpenTempFile();
  55. BOOL CloseTempFile();
  56. BOOL IsApartmentThread()
  57. {
  58. TransAssert((_dwThreadID != 0));
  59. return (_dwThreadID == GetCurrentThreadId());
  60. }
  61. protected:
  62. CRefCount _CRefs; // the total refcount of this object
  63. DWORD _dwThreadID;
  64. LPTSTR _pszUrl;
  65. TCHAR _szNewUrl[MAX_URL_SIZE + 1];
  66. IOInetProtocolSink *_pProtSink;
  67. IOInetBindInfo *_pOIBindInfo;
  68. REFCLSID _pclsidProtocol;
  69. DWORD _bscf;
  70. DWORD _grfBindF;
  71. BINDINFO _BndInfo;
  72. IOInetProtocol *_pProt;
  73. class CPrivUnknown : public IUnknown
  74. {
  75. public:
  76. STDMETHOD(QueryInterface) ( REFIID riid, LPVOID FAR* ppvObj);
  77. STDMETHOD_(ULONG,AddRef) (void);
  78. STDMETHOD_(ULONG,Release) (void);
  79. ~CPrivUnknown() {}
  80. CPrivUnknown() : _CRefs() {}
  81. private:
  82. CRefCount _CRefs; // the total refcount of this object
  83. };
  84. friend class CPrivUnknown;
  85. CPrivUnknown _Unknown;
  86. IUnknown *_pUnkOuter;
  87. STDMETHODIMP_(ULONG) PrivAddRef()
  88. {
  89. return _Unknown.AddRef();
  90. }
  91. STDMETHODIMP_(ULONG) PrivRelease()
  92. {
  93. return _Unknown.Release();
  94. }
  95. };
  96. LPWSTR OLESTRDuplicate(LPWSTR ws);
  97. LPSTR DupW2A(const WCHAR *pwz);
  98. LPWSTR DupA2W(const LPSTR psz);
  99. HRESULT CreateAPP(REFCLSID rclsid, IUnknown *pUnkOuter, REFIID riid, IUnknown **ppUnk);
  100. inline void W2A(LPCWSTR lpwszWide, LPSTR lpszAnsi, int cchAnsi)
  101. {
  102. WideCharToMultiByte(CP_ACP,0,lpwszWide,-1,lpszAnsi,cchAnsi,NULL,NULL);
  103. }
  104. inline void A2W(LPSTR lpszAnsi,LPWSTR lpwszWide, int cchAnsi)
  105. {
  106. MultiByteToWideChar(CP_ACP,0,lpszAnsi,-1,lpwszWide,cchAnsi);
  107. }
  108. #ifndef ARRAYSIZE
  109. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  110. #endif
  111. #endif // _PROTBASE_HXX_