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.

208 lines
5.3 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. #ifdef unix
  20. #include <stddef.h> // For 'offsetof.'
  21. #else
  22. #define offsetof(s,m) (SIZE_T)&(((s *)0)->m)
  23. #endif /* unix */
  24. #define GETPPARENT(pmemb, struc, membname) ((struc FAR *)(((char FAR *)(pmemb))-offsetof(struc, membname)))
  25. #define MAX_URL_SIZE INTERNET_MAX_URL_LENGTH
  26. // this will be in a common header file
  27. #define S_NEEDMOREDATA ((HRESULT)0x00000002L)
  28. #define BSCF_ASYNCDATANOTIFICATION 0x00010000
  29. #define BSCF_DATAFULLYAVAILABLE 0x00020000
  30. class CHttpNegotiate : public IHttpNegotiate
  31. {
  32. public:
  33. // IUnknown methods
  34. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  35. STDMETHODIMP_(ULONG) AddRef(void);
  36. STDMETHODIMP_(ULONG) Release(void);
  37. // *** IHttpNegotiate methods ***
  38. STDMETHOD(BeginningTransaction) (
  39. LPCWSTR szURL,
  40. LPCWSTR szHeaders,
  41. DWORD dwReserved,
  42. LPWSTR *pszAdditionalHeaders);
  43. STDMETHOD(OnResponse) (
  44. DWORD dwResponseCode,
  45. LPCWSTR szResponseHeaders,
  46. LPCWSTR szRequestHeaders,
  47. LPWSTR *pszAdditionalRequestHeaders);
  48. CHttpNegotiate(IHttpNegotiate *pNeg)
  49. {
  50. if (pNeg)
  51. {
  52. _pHttpNegDelegate = pNeg;
  53. _pHttpNegDelegate->AddRef();
  54. }
  55. }
  56. ~CHttpNegotiate()
  57. {
  58. if (_pHttpNegDelegate)
  59. {
  60. _pHttpNegDelegate->Release();
  61. }
  62. }
  63. protected:
  64. CRefCount _CRefs; // the total refcount of this object
  65. IHttpNegotiate *_pHttpNegDelegate;
  66. };
  67. class CBaseProtocol : public IOInetProtocol, public IOInetThreadSwitch, public IOInetPriority, public IServiceProvider
  68. {
  69. public:
  70. // IUnknown methods
  71. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  72. STDMETHODIMP_(ULONG) AddRef(void);
  73. STDMETHODIMP_(ULONG) Release(void);
  74. STDMETHODIMP Start(LPCWSTR szUrl,IOInetProtocolSink *pProtSink,
  75. IOInetBindInfo *pOIBindInfo,DWORD grfSTI, DWORD_PTR dwReserved);
  76. STDMETHODIMP Continue(PROTOCOLDATA *pStateInfo);
  77. STDMETHODIMP Abort(HRESULT hrReason,DWORD dwOptions);
  78. STDMETHODIMP Terminate(DWORD dwOptions);
  79. STDMETHODIMP Suspend();
  80. STDMETHODIMP Resume();
  81. STDMETHODIMP Read(void *pv,ULONG cb,ULONG *pcbRead);
  82. STDMETHODIMP Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin,
  83. ULARGE_INTEGER *plibNewPosition);
  84. STDMETHODIMP LockRequest(DWORD dwOptions);
  85. STDMETHODIMP UnlockRequest();
  86. // IOInetPriority
  87. STDMETHODIMP SetPriority(LONG nPriority);
  88. STDMETHODIMP GetPriority(LONG * pnPriority);
  89. // IOInetThreadSwitch
  90. STDMETHODIMP Prepare();
  91. STDMETHODIMP Continue();
  92. //IServiceProvider
  93. STDMETHODIMP QueryService(REFGUID rsid, REFIID riid, void ** ppvObj);
  94. STDMETHODIMP ObtainService(REFGUID rsid, REFIID riid, void ** ppvObj);
  95. public:
  96. CBaseProtocol(REFCLSID rclsid, IUnknown *pUnkOuter, IUnknown **ppUnkInner);
  97. virtual ~CBaseProtocol();
  98. BOOL OpenTempFile();
  99. BOOL CloseTempFile();
  100. BOOL IsApartmentThread()
  101. {
  102. EProtAssert((_dwThreadID != 0));
  103. return (_dwThreadID == GetCurrentThreadId());
  104. }
  105. protected:
  106. CRefCount _CRefs; // the total refcount of this object
  107. DWORD _dwThreadID;
  108. LPWSTR _pwzUrl;
  109. IOInetProtocolSink *_pProtSink;
  110. IOInetBindInfo *_pOIBindInfo;
  111. IServiceProvider *_pServProvDelegate;
  112. IHttpNegotiate *_pHttpNeg;
  113. REFCLSID _pclsidProtocol;
  114. DWORD _bscf;
  115. DWORD _grfBindF;
  116. DWORD _grfSTI;
  117. BINDINFO _BndInfo;
  118. WCHAR _wzFullURL[MAX_URL_SIZE + 1];
  119. HANDLE _hFile;
  120. char _szTempFile[MAX_PATH];
  121. class CPrivUnknown : public IUnknown
  122. {
  123. public:
  124. STDMETHOD(QueryInterface) ( REFIID riid, LPVOID FAR* ppvObj);
  125. STDMETHOD_(ULONG,AddRef) (void);
  126. STDMETHOD_(ULONG,Release) (void);
  127. ~CPrivUnknown() {}
  128. CPrivUnknown() : _CRefs() {}
  129. private:
  130. CRefCount _CRefs; // the total refcount of this object
  131. };
  132. friend class CPrivUnknown;
  133. CPrivUnknown _Unknown;
  134. IUnknown *_pUnkOuter;
  135. // the next punk is the punkinner in
  136. // another protocol gets loaded by us
  137. // the inner object if the protocol supports aggregation
  138. IUnknown *_pUnkInner;
  139. // the protocol pointer if another protocol gets loaded
  140. IOInetProtocol *_pProt;
  141. STDMETHODIMP_(ULONG) PrivAddRef()
  142. {
  143. return _Unknown.AddRef();
  144. }
  145. STDMETHODIMP_(ULONG) PrivRelease()
  146. {
  147. return _Unknown.Release();
  148. }
  149. };
  150. LPWSTR OLESTRDuplicate(LPWSTR ws);
  151. LPSTR DupW2A(const WCHAR *pwz);
  152. HRESULT CreateAPP(REFCLSID rclsid, IUnknown *pUnkOuter, REFIID riid, IUnknown **ppUnk);
  153. #define RES_STATE_BIND 4711
  154. #endif // _PROTBASE_HXX_