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.

262 lines
8.0 KiB

  1. /*++=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. w3srt.h
  5. Abstract:
  6. Object declarations for the W3Spoof runtime environment.
  7. Author:
  8. Paul M Midgen (pmidge) 03-November-2000
  9. Revision History:
  10. 03-November-2000 pmidge
  11. Created
  12. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--*/
  13. #ifndef __W3SRT_H__
  14. #define __W3SRT_H__
  15. #include "common.h"
  16. typedef class CW3SRuntime RUNTIME;
  17. typedef class CW3SRuntime* PRUNTIME;
  18. typedef class CW3SPropertyBag PROPERTYBAG;
  19. typedef class CW3SPropertyBag* PPROPERTYBAG;
  20. typedef class CW3SFile FILEOBJ;
  21. typedef class CW3SFile* PFILEOBJ;
  22. #define DISPID_RUNTIME_BASE 0x10000000
  23. #define DISPID_PROPERTYBAG_BASE 0x20000000
  24. #define DISPID_FILE_BASE 0x30000000
  25. #define DISPID_RUNTIME_GETFILE (DISPID_RUNTIME_BASE + 1)
  26. #define DISPID_PROPERTYBAG_GET (DISPID_PROPERTYBAG_BASE + 1)
  27. #define DISPID_PROPERTYBAG_SET (DISPID_PROPERTYBAG_BASE + 2)
  28. #define DISPID_PROPERTYBAG_EXPIRES (DISPID_PROPERTYBAG_BASE + 3)
  29. #define DISPID_PROPERTYBAG_FLUSH (DISPID_PROPERTYBAG_BASE + 4)
  30. #define DISPID_FILE_OPEN (DISPID_FILE_BASE + 1)
  31. #define DISPID_FILE_CLOSE (DISPID_FILE_BASE + 2)
  32. #define DISPID_FILE_WRITE (DISPID_FILE_BASE + 3)
  33. #define DISPID_FILE_WRITELINE (DISPID_FILE_BASE + 4)
  34. #define DISPID_FILE_WRITEBLANKLINE (DISPID_FILE_BASE + 5)
  35. #define DISPID_FILE_READ (DISPID_FILE_BASE + 6)
  36. #define DISPID_FILE_READALL (DISPID_FILE_BASE + 7)
  37. #define DISPID_FILE_ATTRIBUTES (DISPID_FILE_BASE + 8)
  38. #define DISPID_FILE_SIZE (DISPID_FILE_BASE + 9)
  39. #define DISPID_FILE_TYPE (DISPID_FILE_BASE + 10)
  40. #define DISPID_FILE_DATELASTMODIFIED (DISPID_FILE_BASE + 11)
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. extern const IID IID_IW3SpoofRuntime;
  45. extern const IID IID_IW3SpoofPropertyBag;
  46. extern const IID IID_IW3SpoofFile;
  47. //-----------------------------------------------------------------------------
  48. // W3Spoof Runtime Interface Declarations
  49. //-----------------------------------------------------------------------------
  50. interface IW3SpoofPropertyBag : public IDispatch
  51. {
  52. virtual HRESULT __stdcall Get(
  53. /*[in]*/ BSTR Name,
  54. /*[out, retval]*/ VARIANT* Value
  55. ) PURE;
  56. virtual HRESULT __stdcall Set(
  57. /*[in]*/ BSTR Name,
  58. /*[in, optional]*/ VARIANT Value
  59. ) PURE;
  60. virtual HRESULT __stdcall get_Expires(
  61. /*[propget]*/
  62. /*[out, retval]*/ VARIANT* Expiry
  63. ) PURE;
  64. virtual HRESULT __stdcall put_Expires(
  65. /*[propput]*/
  66. /*[in, optional]*/ VARIANT Expiry
  67. ) PURE;
  68. virtual HRESULT __stdcall Flush(void) PURE;
  69. };
  70. interface IW3SpoofFile : public IDispatch
  71. {
  72. virtual HRESULT __stdcall Open(
  73. /*[in]*/ BSTR Filename,
  74. /*[in, optional]*/ VARIANT Mode,
  75. /*[out, retval]*/ VARIANT* Success
  76. ) PURE;
  77. virtual HRESULT __stdcall Close(void) PURE;
  78. virtual HRESULT __stdcall Write(
  79. /*[in]*/ VARIANT Data,
  80. /*[out, retval]*/ VARIANT* Success
  81. ) PURE;
  82. virtual HRESULT __stdcall WriteLine(
  83. /*[in]*/ BSTR Line,
  84. /*[out, retval]*/ VARIANT* Success
  85. ) PURE;
  86. virtual HRESULT __stdcall WriteBlankLine(
  87. /*[out, retval]*/ VARIANT* Success
  88. ) PURE;
  89. virtual HRESULT __stdcall Read(
  90. /*[in]*/ VARIANT Bytes,
  91. /*[out, retval]*/ VARIANT* Data
  92. ) PURE;
  93. virtual HRESULT __stdcall ReadAll(
  94. /*[out, retval]*/ VARIANT* Data
  95. ) PURE;
  96. virtual HRESULT __stdcall Attributes(
  97. /*[out, retval]*/ VARIANT* Attributes
  98. ) PURE;
  99. virtual HRESULT __stdcall Size(
  100. /*[out, retval]*/ VARIANT* Size
  101. ) PURE;
  102. virtual HRESULT __stdcall Type(
  103. /*[out, retval]*/ VARIANT* Type
  104. ) PURE;
  105. virtual HRESULT __stdcall DateLastModified(
  106. /*[out, retval]*/ VARIANT* Date
  107. ) PURE;
  108. };
  109. interface IW3SpoofRuntime : public IUnknown
  110. {
  111. virtual HRESULT __stdcall GetFile(IDispatch** ppdisp) PURE;
  112. virtual HRESULT __stdcall GetPropertyBag(BSTR Name, IW3SpoofPropertyBag** ppbag) PURE;
  113. };
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. //-----------------------------------------------------------------------------
  118. // W3Spoof Runtime Object Declarations
  119. //-----------------------------------------------------------------------------
  120. class CW3SRuntime : public IW3SpoofRuntime,
  121. public IDispatch
  122. {
  123. public:
  124. DECLAREIUNKNOWN();
  125. DECLAREIDISPATCH();
  126. public:
  127. // IW3SpoofRuntime
  128. HRESULT __stdcall GetFile(IDispatch** ppdisp);
  129. HRESULT __stdcall GetPropertyBag(BSTR Name, IW3SpoofPropertyBag** ppbag);
  130. CW3SRuntime();
  131. ~CW3SRuntime();
  132. HRESULT Terminate(void);
  133. static HRESULT Create(PRUNTIME* pprt);
  134. private:
  135. HRESULT _Initialize(void);
  136. LONG m_cRefs;
  137. PSTRINGMAP m_propertybags;
  138. };
  139. class CW3SPropertyBag : public IW3SpoofPropertyBag
  140. {
  141. public :
  142. DECLAREIUNKNOWN();
  143. DECLAREIDISPATCH();
  144. public:
  145. HRESULT __stdcall Get(BSTR Name, VARIANT* Value);
  146. HRESULT __stdcall Set(BSTR Name, VARIANT Value);
  147. HRESULT __stdcall get_Expires(VARIANT* Expiry);
  148. HRESULT __stdcall put_Expires(VARIANT Expiry);
  149. HRESULT __stdcall Flush(void);
  150. CW3SPropertyBag();
  151. ~CW3SPropertyBag();
  152. HRESULT GetBagName(LPWSTR* ppwsz);
  153. HRESULT Terminate(void);
  154. static HRESULT Create(LPWSTR name, PPROPERTYBAG* ppbag);
  155. private:
  156. HRESULT _Initialize(LPWSTR name);
  157. void _Reset(void);
  158. BOOL _IsStale(void);
  159. LONG m_cRefs;
  160. LPWSTR m_name;
  161. BOOL m_stale;
  162. DWORD m_expiry;
  163. DWORD m_created;
  164. PSTRINGMAP m_propertybag;
  165. };
  166. class CW3SFile : public IW3SpoofFile
  167. {
  168. public:
  169. DECLAREIUNKNOWN();
  170. DECLAREIDISPATCH();
  171. public:
  172. HRESULT __stdcall Open(BSTR Filename, VARIANT Mode, VARIANT* Success);
  173. HRESULT __stdcall Close(void);
  174. HRESULT __stdcall Write(VARIANT Data, VARIANT* Success);
  175. HRESULT __stdcall WriteLine(BSTR Line, VARIANT* Success);
  176. HRESULT __stdcall WriteBlankLine(VARIANT* Success);
  177. HRESULT __stdcall Read(VARIANT Bytes, VARIANT* Data);
  178. HRESULT __stdcall ReadAll(VARIANT* Data);
  179. HRESULT __stdcall Attributes(VARIANT* Attributes);
  180. HRESULT __stdcall Size(VARIANT* Size);
  181. HRESULT __stdcall Type(VARIANT* Type);
  182. HRESULT __stdcall DateLastModified(VARIANT* Date);
  183. CW3SFile();
  184. ~CW3SFile();
  185. static HRESULT Create(IW3SpoofFile** ppw3sf);
  186. private:
  187. void _Cleanup(void);
  188. BOOL _CacheHttpResponse(void);
  189. LONG m_cRefs;
  190. BOOL m_bFileOpened;
  191. BOOL m_bReadOnly;
  192. BOOL m_bAsciiData;
  193. BOOL m_bHttpResponseCached;
  194. HANDLE m_hFile;
  195. IWinHttpRequest* m_pWHR;
  196. VARIANT m_vHttpResponse;
  197. DWORD m_cHttpBytesRead;
  198. BHFI m_bhfi;
  199. };
  200. #endif /* __W3SRT_H__ */