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.

76 lines
3.5 KiB

  1. // --------------------------------------------------------------------------------
  2. // ByteBuff.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #ifndef _BYTEBUFF_H
  7. #define _BYTEBUFF_H
  8. // --------------------------------------------------------------------------------
  9. // Default Grow Amount
  10. // --------------------------------------------------------------------------------
  11. #define BYTEBUFF_GROW 256
  12. // --------------------------------------------------------------------------------
  13. // WBS_xxx - WebBuffer State
  14. // --------------------------------------------------------------------------------
  15. #define BBS_LAST 0x00000001 // Last Buffer
  16. // --------------------------------------------------------------------------------
  17. // BUFFERINFO
  18. // --------------------------------------------------------------------------------
  19. typedef struct tagBUFFERINFO {
  20. LPBYTE pb; // Current buffer
  21. DWORD cb; // Current Byte Count
  22. DWORD i; // Current Index
  23. DWORD cbAlloc; // Sizeof(m_pb)
  24. LPBYTE pbStatic; // Passed in, dont free
  25. } BUFFERINFO, *LPBUFFERINFO;
  26. // --------------------------------------------------------------------------------
  27. // CByteBuffer
  28. // --------------------------------------------------------------------------------
  29. class CByteBuffer : public IUnknown
  30. {
  31. public:
  32. // ----------------------------------------------------------------------------
  33. // Construction
  34. // ----------------------------------------------------------------------------
  35. CByteBuffer(LPBYTE pb=NULL, ULONG cbAlloc=0, ULONG cb=0, ULONG i=0);
  36. ~CByteBuffer(void);
  37. // ----------------------------------------------------------------------------
  38. // IUnknown Members
  39. // ----------------------------------------------------------------------------
  40. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv) { return TrapError(E_NOTIMPL); }
  41. STDMETHODIMP_(ULONG) AddRef(void) { return ++m_cRef; }
  42. STDMETHODIMP_(ULONG) Release(void);
  43. // ----------------------------------------------------------------------------
  44. // CByteBuffer Methods
  45. // ----------------------------------------------------------------------------
  46. void Init(LPBYTE pb=NULL, ULONG cbAlloc=0, ULONG cb=0, ULONG i=0);
  47. void SetGrowBy(DWORD cbGrow) { m_cbGrow = cbGrow; }
  48. const LPBYTE PbData(void) { return ((0 == m_buffer.cb) ? NULL : (const LPBYTE)(m_buffer.pb)); }
  49. const DWORD CbData(void) { return m_buffer.cb; }
  50. void SetIndex(DWORD i) { m_buffer.i = i; }
  51. HRESULT SetSize(DWORD cb);
  52. HRESULT Append(LPBYTE pbData, ULONG cbData);
  53. private:
  54. // ----------------------------------------------------------------------------
  55. // Private Members
  56. // ----------------------------------------------------------------------------
  57. HRESULT _HrRealloc(DWORD cbAlloc);
  58. private:
  59. // ----------------------------------------------------------------------------
  60. // Private Data
  61. // ----------------------------------------------------------------------------
  62. ULONG m_cRef; // Reference count
  63. DWORD m_dwState; // State
  64. DWORD m_cbGrow; // Grow Amount
  65. BUFFERINFO m_buffer; // Buffer
  66. };
  67. #endif // _BYTEBUFF_H