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.

191 lines
5.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: qcanon.hxx
  7. //
  8. // Contents: Structure definitions for canonical output of query results.
  9. //
  10. // Classes: CCiCanonicalOutput, CCiCanonicalQueryRows
  11. //
  12. // History: 6-13-96 srikants Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <sizeser.hxx>
  17. #include <memser.hxx>
  18. const ULONG CI_CANONICAL_VERSION = 1;
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CCiCanonicalOutput
  22. //
  23. // Purpose: Base header definition for data sent in the canonical format
  24. // from CI.
  25. //
  26. // History: 7-01-96 srikants Created
  27. //
  28. //----------------------------------------------------------------------------
  29. class CCiCanonicalOutput
  30. {
  31. public:
  32. enum EOutputType { eQueryRows = 1 };
  33. CCiCanonicalOutput();
  34. void InitVersion() { _ulVersion = CI_CANONICAL_VERSION; }
  35. ULONG GetVersion() const { return _ulVersion; }
  36. void SetOutputType( EOutputType type ) { _type = type; }
  37. EOutputType GetOutputType() const { return _type; }
  38. SCODE GetStatus() const { return _scStatus; }
  39. void SetStatus( SCODE sc) { _scStatus = sc; }
  40. ULONG GetTotalLen() const { return _cbTotal; }
  41. void SetTotalLen( ULONG cbTotal )
  42. {
  43. Win4Assert( cbTotal >= sizeof(CCiCanonicalOutput) );
  44. _cbTotal = cbTotal;
  45. }
  46. static void PutWString( PSerStream & stm, const WCHAR * pwszStr );
  47. static WCHAR * GetWString( PDeSerStream & stm, BOOL & fSuccess );
  48. static WCHAR * AllocAndCopyWString( const WCHAR * pSrc );
  49. protected:
  50. ULONG _ulVersion; // Version Number Information
  51. EOutputType _type; // Type of the data.
  52. SCODE _scStatus; // status of transfer
  53. ULONG _cbTotal; // Total bytes in the buffer
  54. LONGLONG _llSig1; // To force an 8 byte alignment
  55. };
  56. //+---------------------------------------------------------------------------
  57. //
  58. // Class: CCiCanonicalQueryRows
  59. //
  60. // Purpose: Format of the query results returned in the canonical
  61. // format.
  62. //
  63. // History: 7-01-96 srikants Created
  64. //
  65. // Notes: The first value in the variable buffer is the "BookMark" of
  66. // the first row in the result set.
  67. //
  68. //----------------------------------------------------------------------------
  69. class CCiCanonicalQueryRows : public CCiCanonicalOutput
  70. {
  71. public:
  72. void Init();
  73. static ULONG GetResultsBufferOffset()
  74. {
  75. return FIELD_OFFSET( CCiCanonicalQueryRows, _aRows );
  76. }
  77. BYTE * GetResultsBuffer() { return (BYTE *) _aRows; }
  78. ULONG GetResultsBufMaxLen() const
  79. {
  80. Win4Assert( GetTotalLen() >= GetResultsBufferOffset() );
  81. return GetTotalLen() - GetResultsBufferOffset();
  82. }
  83. ULONG GetColumnCount() const { return _nCols; }
  84. void SetColumnCount( ULONG nCols ) { _nCols = nCols; }
  85. void IncrementRowCount() { _cRowsReturned++; }
  86. ULONG GetRowCount() const { return _cRowsReturned; }
  87. void SetRowCount( ULONG nRows ) { _cRowsReturned = nRows; }
  88. void SetMoreRowsAvailable() { _fMoreRows = TRUE; }
  89. BOOL AreMoreRowsAvailable() const { return _fMoreRows; }
  90. void UpdateTotalLen( ULONG cbResults )
  91. {
  92. SetTotalLen( GetResultsBufferOffset() + cbResults );
  93. }
  94. private:
  95. ULONG _nCols; // Number of columns per row
  96. ULONG _cRowsReturned; // number of rows returned in buffer
  97. BOOL _fMoreRows; // Set to TRUE if there are more rows
  98. LONGLONG _aRows[1]; // To force an 8 byte alignment
  99. };
  100. class COutputColumn;
  101. //+---------------------------------------------------------------------------
  102. //
  103. // Class: CQuadByteAlignedBuffer
  104. //
  105. // Purpose: A class that has a quad byte aligned buffer.
  106. //
  107. // History: 7-01-96 srikants Created
  108. //
  109. //----------------------------------------------------------------------------
  110. class CQuadByteAlignedBuffer : INHERIT_UNWIND
  111. {
  112. INLINE_UNWIND( CQuadByteAlignedBuffer );
  113. public:
  114. CQuadByteAlignedBuffer( ULONG cbBuffer = 0x10000 );
  115. ~CQuadByteAlignedBuffer()
  116. {
  117. delete [] _pbAlloc;
  118. }
  119. BYTE * GetBuffer() { return _pbAligned; }
  120. ULONG GetSize() const { return _cbAligned; }
  121. void ZeroFill();
  122. private:
  123. BYTE * _pbAlloc; // Pointer to the allocated buffer
  124. ULONG _cbAlloc; // Actual bytes allocated
  125. BYTE * _pbAligned; // Pointer to the aligned buffer
  126. ULONG _cbAligned; // Number of bytes in the aligned buffer
  127. };
  128. //+---------------------------------------------------------------------------
  129. //
  130. // Class: CWebCanonicalResultsIn
  131. //
  132. // Purpose: A helper class to interpret the data that is returned from
  133. // CI.
  134. //
  135. // History: 6-16-96 srikants Created
  136. //
  137. //----------------------------------------------------------------------------
  138. class CWebCanonicalResultsIn
  139. {
  140. public:
  141. CWebCanonicalResultsIn( CQuadByteAlignedBuffer & buffer );
  142. private:
  143. CQuadByteAlignedBuffer & _buffer;
  144. };