Source code of Windows XP (NT5)
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.

96 lines
2.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: STREAMS.CXX
  7. //
  8. // Contents: CStream functions needed for IDSMgr, Filter, and OFS.
  9. //
  10. // Classes: CStreamA, CStreamW, and CStreamASCIIStr
  11. //
  12. // History: 16-Dec-92 AmyA Created from streams.hxx
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include <streams.hxx>
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CStreamA::GetBuf, public
  21. //
  22. // Synopsis: Refills the buffer by calling the virtual function FillBuf,
  23. // then if the buffer was not filled, returns EOF, otherwise
  24. // returns the first char in buffer and increments _pCur.
  25. //
  26. // History: 15-Dec-92 AmyA Created
  27. //
  28. //----------------------------------------------------------------------------
  29. EXPORTIMP int APINOT
  30. CStreamA::GetBuf()
  31. {
  32. if ( !FillBuf() )
  33. {
  34. _eof = TRUE;
  35. return EOF;
  36. }
  37. return *_pCur++;
  38. }
  39. //+---------------------------------------------------------------------------
  40. //
  41. // Member: CStreamW::GetBuf, public
  42. //
  43. // Synopsis: Refills the buffer by calling the virtual function FillBuf,
  44. // then if the buffer was not filled, returns EOF, otherwise
  45. // returns the first wchar in buffer and increments _pCur.
  46. //
  47. // History: 15-Dec-92 AmyA Created
  48. //
  49. //----------------------------------------------------------------------------
  50. EXPORTIMP int APINOT
  51. CStreamW::GetBuf()
  52. {
  53. if ( !FillBuf() )
  54. {
  55. _eof = TRUE;
  56. return EOF;
  57. }
  58. return *_pCur++;
  59. }
  60. //+---------------------------------------------------------------------------
  61. //
  62. // Member: CStreamASCIIStr::Read, public
  63. //
  64. // Synopsis: Copies chars from the buffer into dest and returns the number
  65. // of chars copied.
  66. //
  67. // Arguments: [dest] -- buffer to copy chars into
  68. // [size] -- size of the buffer (max # of chars to copy)
  69. //
  70. // History: 04-Aug-92 MikeHew Modified for new streams
  71. // 22-Sep-92 AmyA Rewrote for non-NULL term. strings
  72. //
  73. //----------------------------------------------------------------------------
  74. EXPORTIMP unsigned APINOT
  75. CStreamASCIIStr::Read( void* dest, unsigned size )
  76. {
  77. if ( Eof() )
  78. return 0;
  79. unsigned count = (unsigned)(_pEnd-_pCur);
  80. if ( size < count )
  81. count = size;
  82. memcpy ( dest, _pCur, count );
  83. _pCur += count;
  84. return count;
  85. }