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.

100 lines
3.2 KiB

  1. #if !defined(_FUSION_SXS_CTEESTREAM_H_INCLUDED_)
  2. #define _FUSION_SXS_CTEESTREAM_H_INCLUDED_
  3. /*++
  4. Copyright (c) Microsoft Corporation
  5. Module Name:
  6. CTeeStream.h
  7. Abstract:
  8. This implementation of IStream is intended for when you want to copy the
  9. stream you are reading to a file.
  10. We read from a stream you specify.
  11. We write to a file you specify.
  12. You can delay specifying the file; we buffer anything read until you specify
  13. a file; we actually needed this delay feature in the first client of
  14. CTeeStream.
  15. The Unix utility tee writes it standard input to its standard output, and
  16. to the specified file (or files?); "tee" as in a fork in a road, or a juncture
  17. in pipes (the input/output kind, analogous to the kind that water flows through..
  18. ascii text is computer water..)
  19. A simple working tee can be found at \\scratch\scratch\a-JayK\t.c
  20. Author:
  21. Jay Krell (a-JayK, JayKrell) May 2000
  22. Revision History:
  23. --*/
  24. #pragma once
  25. #include "fusionhandle.h"
  26. #include "fusionbytebuffer.h"
  27. #include "smartref.h"
  28. #include "sxsp.h"
  29. class CTeeStream : public IStream
  30. {
  31. public:
  32. inline CTeeStream() : m_cRef(0), m_fBuffer(TRUE), m_hresult(NOERROR) { }
  33. virtual ~CTeeStream();
  34. VOID SetSource(IStream*);
  35. BOOL SetSink(
  36. const CImpersonationData &ImpersonationData,
  37. const CBaseStringBuffer &rbuff,
  38. DWORD openOrCreate = CREATE_NEW
  39. );
  40. BOOL SetSink(const CBaseStringBuffer &rbuff, DWORD openOrCreate = CREATE_NEW)
  41. {
  42. return this->SetSink(CImpersonationData(), rbuff, openOrCreate);
  43. }
  44. BOOL Close();
  45. // IUnknown methods:
  46. virtual ULONG __stdcall AddRef();
  47. virtual ULONG __stdcall Release();
  48. virtual HRESULT __stdcall QueryInterface(REFIID riid, LPVOID *ppvObj);
  49. // ISequentialStream methods:
  50. virtual HRESULT __stdcall Read(PVOID pv, ULONG cb, ULONG *pcbRead);
  51. virtual HRESULT __stdcall Write(const VOID *pv, ULONG cb, ULONG *pcbWritten);
  52. // IStream methods:
  53. virtual HRESULT __stdcall Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
  54. virtual HRESULT __stdcall SetSize(ULARGE_INTEGER libNewSize);
  55. virtual HRESULT __stdcall CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
  56. virtual HRESULT __stdcall Commit(DWORD grfCommitFlags);
  57. virtual HRESULT __stdcall Revert();
  58. virtual HRESULT __stdcall LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  59. virtual HRESULT __stdcall UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  60. virtual HRESULT __stdcall Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  61. virtual HRESULT __stdcall Clone(IStream **ppIStream);
  62. protected:
  63. LONG m_cRef;
  64. CFusionFile m_fileSink;
  65. CByteBuffer m_buffer;
  66. CSmartRef<IStream> m_streamSource;
  67. BOOL m_fBuffer;
  68. HRESULT m_hresult;
  69. CStringBuffer m_bufferSinkPath;
  70. CImpersonationData m_ImpersonationData;
  71. private: // intentionally not implemented
  72. CTeeStream(const CTeeStream&);
  73. void operator=(const CTeeStream&);
  74. };
  75. #endif // !defined(_FUSION_SXS_CTEESTREAM_H_INCLUDED_)