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
6.0 KiB

  1. //-----------------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: caccess.hxx
  7. //
  8. // Contents: Microsoft OleDB/OleDS Data Source Object for ADSI
  9. //
  10. // CImpIAccessor object implementing the IAccessor interface.
  11. //
  12. // History: 08-01-96 shanksh Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef _CACCESS_HXX
  16. #define _CACCESS_HXX
  17. // ADSI accessor structure
  18. typedef struct tagADSACCESSOR {
  19. DBACCESSORFLAGS dwFlags; // accessor flags
  20. DBREFCOUNT cRef; // reference count of the accessor
  21. DBLENGTH cbRowSize; // size of the row in the client's buffer
  22. DBORDINAL *rgcol; // array of cols referenced by the accessor
  23. DBCOUNTITEM cBindings; // # of bindings
  24. DBBINDING rgBindings[1];// array of binding structs
  25. } ADSACCESSOR;
  26. typedef ADSACCESSOR *PADSACCESSOR;
  27. //-----------------------------------------------------------------------------------
  28. //
  29. // class CImpIAccessor | Contained IAccessor class
  30. //
  31. //-----------------------------------------------------------------------------------
  32. class CImpIAccessor : INHERIT_TRACKING,
  33. public IAccessor // public | IAccessor
  34. {
  35. // Immediate user objects are friends
  36. friend class CCommandObject;
  37. private:
  38. void *_pObj;
  39. LPUNKNOWN _pUnkOuter;
  40. ULONG _dwStatus; // status dword
  41. LPEXTBUFF _pextbuffer; // array of accessor ptrs
  42. ULONG _dwGetDataTypeBadHandle; // specifies bad handle accessor type
  43. CRITICAL_SECTION _criticalsectionAccessor;// critical section for CreateAccessor calls
  44. BOOL _fCriticalSectionInitialized;
  45. IDataConvert *_pIDC;
  46. IMalloc *_pIMalloc;
  47. STDMETHODIMP_(void) DetermineTypes (
  48. DBACCESSORFLAGS dwAccessorFlags,
  49. ULONG *pdwGetDataType,
  50. ULONG *pdwSetDataType
  51. );
  52. STDMETHODIMP_(void) DeleteADsAccessor (
  53. PADSACCESSOR pADsaccessor
  54. );
  55. public:
  56. CImpIAccessor(void *, LPUNKNOWN);
  57. ~CImpIAccessor(void);
  58. DECLARE_STD_REFCOUNTING
  59. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) ;
  60. STDMETHODIMP FInit (
  61. void
  62. );
  63. STDMETHODIMP AddRefAccessor(
  64. HACCESSOR hAccessor,
  65. DBREFCOUNT *pcRefCounts
  66. );
  67. STDMETHODIMP CreateAccessor(
  68. DBACCESSORFLAGS dwAccessorFlags,
  69. DBCOUNTITEM cBindings,
  70. const DBBINDING rgBindings[],
  71. DBLENGTH cbRowSize,
  72. HACCESSOR *phAccessor,
  73. DBBINDSTATUS rgStatus[]
  74. );
  75. STDMETHODIMP GetBindings(
  76. HACCESSOR hAccessor,
  77. DBACCESSORFLAGS *pdwAccessorFlags,
  78. DBCOUNTITEM *pcBindings,
  79. DBBINDING **prgBindings
  80. );
  81. STDMETHODIMP ReleaseAccessor(
  82. HACCESSOR hAccessor,
  83. DBREFCOUNT *pcRefCounts
  84. );
  85. // Verifies that a DB type used in a binding is supported.
  86. inline STDMETHODIMP_(BOOL) IsGoodBindingType(
  87. DBTYPE dbtype
  88. )
  89. {
  90. switch ((dbtype & ~(DBTYPE_ARRAY|DBTYPE_BYREF|DBTYPE_VECTOR))) {
  91. case DBTYPE_I1:
  92. case DBTYPE_UI1:
  93. case DBTYPE_I2:
  94. case DBTYPE_UI2:
  95. case DBTYPE_I4:
  96. case DBTYPE_UI4:
  97. case DBTYPE_I8:
  98. case DBTYPE_UI8:
  99. case DBTYPE_R4:
  100. case DBTYPE_R8:
  101. case DBTYPE_CY:
  102. case DBTYPE_GUID:
  103. case DBTYPE_BOOL:
  104. case DBTYPE_VARIANT:
  105. case DBTYPE_DATE:
  106. case DBTYPE_DBDATE:
  107. case DBTYPE_DBTIME:
  108. case DBTYPE_DBTIMESTAMP:
  109. case DBTYPE_BSTR:
  110. case DBTYPE_STR:
  111. case DBTYPE_WSTR:
  112. case DBTYPE_BYTES:
  113. case DBTYPE_NUMERIC:
  114. case DBTYPE_IUNKNOWN:
  115. return TRUE;
  116. break;
  117. default:
  118. return FALSE;
  119. }
  120. }
  121. HRESULT CreateBadAccessor(void);
  122. };
  123. // Accessor status flags (_dwStatus)
  124. //const UDWORD ACCESSORSTAT_UNDERROWSET =0x00000001L;// aggregated under Rowset object
  125. const ULONG ACCESSORSTAT_VALIDATENOW =0x00000002L;// accessors totally validated on
  126. const ULONG ACCESSORSTAT_CANACCESSBLOBS=0x00000004L;// can create accessors for BLOBS
  127. //------ D E F I N E S, M A C R O S A N D I N L I N E F U N C T I O N S -------
  128. // Internal accessor type classifications
  129. // Common types
  130. // Marks an incorrect accessor.
  131. #define ACCESSORTYPE_INERROR 0
  132. // Types used by GetData.
  133. #define GD_ACCESSORTYPE_INERROR ACCESSORTYPE_INERROR
  134. #define GD_ACCESSORTYPE_PARAM_ONLY 1
  135. #define GD_ACCESSORTYPE_READ_BYREF 2
  136. #define GD_ACCESSORTYPE_READ_COLS_BYREF 3
  137. #define GD_ACCESSORTYPE_READ_OPTIMIZED 4
  138. #define GD_ACCESSORTYPE_READ 5
  139. // First good GetData type.
  140. #define GD_ACCESSORTYPE_GOOD GD_ACCESSORTYPE_READ_BYREF
  141. // Types used by SetData.
  142. #define SD_ACCESSORTYPE_INERROR ACCESSORTYPE_INERROR
  143. #define SD_ACCESSORTYPE_PARAM_ONLY 1
  144. #define SD_ACCESSORTYPE_READ_ONLY 2
  145. #define SD_ACCESSORTYPE_READWRITE 3
  146. const ULONG DBACCESSOR_VALID_FLAGS =
  147. (DBACCESSOR_PASSBYREF|DBACCESSOR_ROWDATA|
  148. DBACCESSOR_PARAMETERDATA|DBACCESSOR_OPTIMIZED);
  149. const DBTYPE TYPE_MODIFIERS = (DBTYPE_BYREF | DBTYPE_VECTOR | DBTYPE_ARRAY);
  150. const ULONG INITIAL_NUM_PARAM =256;
  151. // Zero element of the extbuffer of accessors always represents an invalid accessor.
  152. const ULONG_PTR hAccessorBadHandle =0;
  153. // Internal DBACCESSOR flag to mark accessors referencing BLOB columns.
  154. const DBACCESSORFLAGS DBACCESSOR_REFERENCES_BLOB =0x8000;
  155. #endif