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.

118 lines
4.9 KiB

  1. #include <windows.h>
  2. #define OLEDBVER 0x0250 // enable ICommandTree interface
  3. #include <ole2.h>
  4. #include <oledb.h>
  5. #include <cmdtree.h>
  6. #include <ntquery.h>
  7. // the maximum number of columns that the user can request in their
  8. // comma delimited list
  9. #define MAX_COLUMNS 6
  10. #define MAX_FRIENDLYNAME 128
  11. typedef HRESULT
  12. (STDAPICALLTYPE *PCIMAKEICOMMAND)(ICommand ** ppQuery,
  13. ULONG cScope,
  14. DWORD const * aDepths,
  15. WCHAR const * const * awcsScope,
  16. WCHAR const * const * awcsCat,
  17. WCHAR const * const * awcsMachine );
  18. typedef HRESULT
  19. (STDAPICALLTYPE *PCITEXTTOFULLTREE)(WCHAR const * pwszRestriction,
  20. WCHAR const * pwszColumns,
  21. WCHAR const * pwszSortColumns, // may be NULL
  22. WCHAR const * pwszGroupings, // may be NULL
  23. DBCOMMANDTREE * * ppTree,
  24. ULONG cProperties,
  25. /*optional*/ CIPROPERTYDEF * pReserved,
  26. LCID LocaleID );
  27. class CIndexServerQuery {
  28. public:
  29. // This is used to globally initalize the CIndexServerQuery classes
  30. // by having it load the necessary bits that it needs from Tripoli.
  31. // It should be called on service startup by any service which
  32. // expects to use CIndexServerQuery
  33. static HRESULT GlobalInitialize();
  34. // This is the global shutdown code... it should be called on service
  35. // shutdown
  36. static HRESULT GlobalShutdown();
  37. // constructor
  38. CIndexServerQuery();
  39. //
  40. // start the query going.
  41. //
  42. // arguments:
  43. // [in] bDeepQuery - TRUE if deep query, FALSE if shallow
  44. // [in] pwszQueryString - the tripoli query string
  45. // [in] pwszMachine - the machine to query against (NULL for localhost)
  46. // [in] pwszCatalog - the tripoli catalog to query against (name or
  47. // path is okay).
  48. // [in] pwszScope - the tripoli scope to query against. NULL for the
  49. // default scope (\).
  50. // [in] pwszColumns - the columns to return. supported columns are
  51. // filename,newsarticleid,newsgroup,newsmsgid.
  52. // note: this string gets altered internally, so
  53. // it might change from what you pass in.
  54. // [in] pwszSortOrder - sort priority for the columns. NULL to return
  55. // unsorted
  56. //
  57. HRESULT MakeQuery( BOOL bDeepQuery, WCHAR const *pwszQueryString,
  58. WCHAR const *pwszMachine, WCHAR const *pwszCatalog,
  59. WCHAR const *pwszScope, WCHAR *pwszColumns, WCHAR const *pwszSortOrder,
  60. LCID LocaleID = GetSystemDefaultLCID(), DWORD cMaxRows = 0);
  61. //
  62. // get the results from the query
  63. //
  64. // arguments:
  65. // [in] pcResults - pointer to the a size of the ppvResults array
  66. // [out] pcResults - the number of items put into ppvResults
  67. // [in/out] ppvResults - an array of pointers to PROPVARIANTS. this is
  68. // filled in by column for up to *pcResults
  69. // rows.
  70. // [out] pfMore - set to TRUE if there are more results, FALSE if
  71. // this is the last set of results.
  72. //
  73. // usage:
  74. // DWORD cResults;
  75. // PROPVARIANT *rgpvResults[COLUMNS * ROWS];
  76. // BOOL fMore;
  77. // cResults = ROWS;
  78. // HRESULT hr;
  79. // hr = GetQueryResults(&cResults, rgpvResults, &fMore);
  80. // if (FAILED(hr)) /* handle error */
  81. // else {
  82. // for (i = 0; i < ROWS; i++) {
  83. // PROPVARIANT **ppvColumn = rgpvResults + (j * ROWS);
  84. // /* ppvColumn[0] has column 0 in row j */
  85. // /* ppvColumn[1] has column 1 in row j */
  86. // /* etc... */
  87. // }
  88. // }
  89. //
  90. HRESULT GetQueryResults(DWORD *pcResults, PROPVARIANT **ppvResults,
  91. BOOL *pfMore);
  92. ~CIndexServerQuery();
  93. private:
  94. // class globals
  95. static HMODULE m_hmQuery;
  96. static PCIMAKEICOMMAND m_pfnCIMakeICommand;
  97. static PCITEXTTOFULLTREE m_pfnCITextToFullTree;
  98. // class variables
  99. HACCESSOR m_hAccessor;
  100. IRowset *m_pRowset;
  101. DWORD m_cCols;
  102. BOOL m_fNoMoreRows;
  103. HROW *m_phRows;
  104. DBCOUNTITEM m_cRowHandlesAllocated;
  105. DBCOUNTITEM m_cRowHandlesInUse;
  106. struct tagCIPROPERTYDEF *m_pPropDef;
  107. DWORD m_cPropDef;
  108. HRESULT CreateAccessor(WCHAR *szColumns);
  109. HRESULT BuildFriendlyNames(const WCHAR *pwszQueryString);
  110. void ReleaseAccessor();
  111. };
  112.