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.

390 lines
14 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1999.
  5. //
  6. // File: NtQuery.h
  7. //
  8. // Contents: Main query header; Defines all exported query API
  9. //
  10. //----------------------------------------------------------------------------
  11. #if !defined(__NTQUERY_H__)
  12. #define __NTQUERY_H__
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #if defined(__cplusplus)
  17. extern "C"
  18. {
  19. #endif
  20. //
  21. // Use this path for the null catalog, one that doesn't have an index.
  22. // Use it to search for properties of files that are not indexed.
  23. //
  24. #define CINULLCATALOG L"::_noindex_::"
  25. //
  26. // Use this path to connect to the server for administration work
  27. // (i.e. DocStoreAdmin.) No catalog is associated with the connection
  28. //
  29. #define CIADMIN L"::_nodocstore_::"
  30. //
  31. // Minimal support for persistent handlers.
  32. //
  33. STDAPI LoadIFilter( WCHAR const * pwcsPath,
  34. IUnknown * pUnkOuter,
  35. void ** ppIUnk );
  36. #define LIFF_LOAD_DEFINED_FILTER 1
  37. #define LIFF_IMPLEMENT_TEXT_FILTER_FALLBACK_POLICY 2
  38. #define LIFF_FORCE_TEXT_FILTER_FALLBACK 3
  39. STDAPI LoadIFilterEx( WCHAR const * pwcsPath,
  40. DWORD dwFlags,
  41. REFIID riid,
  42. void ** ppIUnk );
  43. STDAPI BindIFilterFromStorage( IStorage * pStg,
  44. IUnknown * pUnkOuter,
  45. void ** ppIUnk );
  46. STDAPI BindIFilterFromStream( IStream * pStm,
  47. IUnknown * pUnkOuter,
  48. void ** ppIUnk );
  49. STDAPI LocateCatalogsW( WCHAR const * pwszScope,
  50. ULONG iBmk,
  51. WCHAR * pwszMachine,
  52. ULONG * pccMachine,
  53. WCHAR * pwszCat,
  54. ULONG * pccCat );
  55. //
  56. // For calling from VB
  57. //
  58. STDAPI LocateCatalogsA( char const * pwszScope,
  59. ULONG iBmk,
  60. char * pwszMachine,
  61. ULONG * pccMachine,
  62. char * pwszCat,
  63. ULONG * pccCat );
  64. #ifdef UNICODE
  65. #define LocateCatalogs LocateCatalogsW
  66. #else
  67. #define LocateCatalogs LocateCatalogsA
  68. #endif // !UNICODE
  69. // The Index Server Data Source Object CLSID
  70. #define CLSID_INDEX_SERVER_DSO \
  71. { 0xF9AE8980, 0x7E52, 0x11d0, \
  72. { 0x89, 0x64, 0x00, 0xC0, 0x4F, 0xD6, 0x11, 0xD7 } }
  73. // The storage property set
  74. #define PSGUID_STORAGE \
  75. { 0xb725f130, 0x47ef, 0x101a, \
  76. { 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac } }
  77. //#define PID_STG_DICTIONARY ((PROPID) 0x00000000) //reserved
  78. //#define PID_STG_CODEPAGE ((PROPID) 0x00000001) //reserved
  79. #define PID_STG_DIRECTORY ((PROPID) 0x00000002)
  80. #define PID_STG_CLASSID ((PROPID) 0x00000003)
  81. #define PID_STG_STORAGETYPE ((PROPID) 0x00000004)
  82. #define PID_STG_VOLUME_ID ((PROPID) 0x00000005)
  83. #define PID_STG_PARENT_WORKID ((PROPID) 0x00000006)
  84. #define PID_STG_SECONDARYSTORE ((PROPID) 0x00000007)
  85. #define PID_STG_FILEINDEX ((PROPID) 0x00000008)
  86. #define PID_STG_LASTCHANGEUSN ((PROPID) 0x00000009)
  87. #define PID_STG_NAME ((PROPID) 0x0000000a)
  88. #define PID_STG_PATH ((PROPID) 0x0000000b)
  89. #define PID_STG_SIZE ((PROPID) 0x0000000c)
  90. #define PID_STG_ATTRIBUTES ((PROPID) 0x0000000d)
  91. #define PID_STG_WRITETIME ((PROPID) 0x0000000e)
  92. #define PID_STG_CREATETIME ((PROPID) 0x0000000f)
  93. #define PID_STG_ACCESSTIME ((PROPID) 0x00000010)
  94. #define PID_STG_CHANGETIME ((PROPID) 0x00000011)
  95. #define PID_STG_CONTENTS ((PROPID) 0x00000013)
  96. #define PID_STG_SHORTNAME ((PROPID) 0x00000014)
  97. #define PID_STG_MAX PID_STG_SHORTNAME
  98. #define CSTORAGEPROPERTY 0x15
  99. // File System Content Index Framework property set
  100. #define DBPROPSET_FSCIFRMWRK_EXT \
  101. { 0xA9BD1526, 0x6A80, 0x11D0, \
  102. { 0x8C, 0x9D, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E } }
  103. #define DBPROP_CI_CATALOG_NAME 2
  104. #define DBPROP_CI_INCLUDE_SCOPES 3
  105. #define DBPROP_CI_DEPTHS 4 // obsolete
  106. #define DBPROP_CI_SCOPE_FLAGS 4
  107. #define DBPROP_CI_EXCLUDE_SCOPES 5
  108. #define DBPROP_CI_SECURITY_ID 6
  109. #define DBPROP_CI_QUERY_TYPE 7
  110. // Query Extension property set
  111. #define DBPROPSET_QUERYEXT \
  112. { 0xA7AC77ED, 0xF8D7, 0x11CE, \
  113. { 0xA7, 0x98, 0x00, 0x20, 0xF8, 0x00, 0x80, 0x25 } }
  114. #define DBPROP_USECONTENTINDEX 2
  115. #define DBPROP_DEFERNONINDEXEDTRIMMING 3
  116. #define DBPROP_USEEXTENDEDDBTYPES 4
  117. #define DBPROP_FIRSTROWS 7
  118. // Content Index Framework Core property set
  119. #define DBPROPSET_CIFRMWRKCORE_EXT \
  120. { 0xafafaca5, 0xb5d1, 0x11d0, \
  121. { 0x8c, 0x62, 0x00, 0xc0, 0x4f, 0xc2, 0xdb, 0x8d } }
  122. #define DBPROP_MACHINE 2
  123. #define DBPROP_CLIENT_CLSID 3
  124. // MSIDXS Rowset property set
  125. #define DBPROPSET_MSIDXS_ROWSETEXT \
  126. { 0xaa6ee6b0, 0xe828, 0x11d0, \
  127. { 0xb2, 0x3e, 0x00, 0xaa, 0x00, 0x47, 0xfc, 0x01 } }
  128. #define MSIDXSPROP_ROWSETQUERYSTATUS 2
  129. #define MSIDXSPROP_COMMAND_LOCALE_STRING 3
  130. #define MSIDXSPROP_QUERY_RESTRICTION 4
  131. //
  132. // Query status values returned by MSIDXSPROP_ROWSETQUERYSTATUS
  133. //
  134. // Bits Effect
  135. // ----- -----------------------------------------------------
  136. // 00-02 Fill Status: How data is being updated, if at all.
  137. // 03-15 Bitfield query reliability: How accurate the result is
  138. #define STAT_BUSY ( 0 )
  139. #define STAT_ERROR ( 0x1 )
  140. #define STAT_DONE ( 0x2 )
  141. #define STAT_REFRESH ( 0x3 )
  142. #define QUERY_FILL_STATUS(x) ( ( x ) & 0x7 )
  143. #define STAT_PARTIAL_SCOPE ( 0x8 )
  144. #define STAT_NOISE_WORDS ( 0x10 )
  145. #define STAT_CONTENT_OUT_OF_DATE ( 0x20 )
  146. #define STAT_REFRESH_INCOMPLETE ( 0x40 )
  147. #define STAT_CONTENT_QUERY_INCOMPLETE ( 0x80 )
  148. #define STAT_TIME_LIMIT_EXCEEDED ( 0x100 )
  149. #define STAT_SHARING_VIOLATION ( 0x200 )
  150. #define QUERY_RELIABILITY_STATUS(x) ( ( x ) & 0xFFF8 )
  151. // Scope flags
  152. #define QUERY_SHALLOW 0
  153. #define QUERY_DEEP 1
  154. #define QUERY_PHYSICAL_PATH 0
  155. #define QUERY_VIRTUAL_PATH 2
  156. // query property set (PSGUID_QUERY) properties not defined in oledb.h
  157. #define PROPID_QUERY_WORKID 5
  158. #define PROPID_QUERY_UNFILTERED 7
  159. #define PROPID_QUERY_VIRTUALPATH 9
  160. #define PROPID_QUERY_LASTSEENTIME 10
  161. //
  162. // Change or get the current state of a catalog specified.
  163. //
  164. #define CICAT_STOPPED 0x1
  165. #define CICAT_READONLY 0x2
  166. #define CICAT_WRITABLE 0x4
  167. #define CICAT_NO_QUERY 0x8
  168. #define CICAT_GET_STATE 0x10
  169. #define CICAT_ALL_OPENED 0x20
  170. STDAPI SetCatalogState ( WCHAR const * pwcsCat,
  171. WCHAR const * pwcsMachine,
  172. DWORD dwNewState,
  173. DWORD * pdwOldState );
  174. //
  175. // Query catalog state
  176. //
  177. #define CI_STATE_SHADOW_MERGE 0x0001 // Index is performing a shadow merge
  178. #define CI_STATE_MASTER_MERGE 0x0002 // Index is performing a master merge
  179. #define CI_STATE_CONTENT_SCAN_REQUIRED 0x0004 // Index is likely corrupt, and a rescan is required
  180. #define CI_STATE_ANNEALING_MERGE 0x0008 // Index is performing an annealing (optimizing) merge
  181. #define CI_STATE_SCANNING 0x0010 // Scans are in-progress
  182. #define CI_STATE_RECOVERING 0x0020 // Index metadata is being recovered
  183. #define CI_STATE_INDEX_MIGRATION_MERGE 0x0040 // Reserved for future use
  184. #define CI_STATE_LOW_MEMORY 0x0080 // Indexing is paused due to low memory availability
  185. #define CI_STATE_HIGH_IO 0x0100 // Indexing is paused due to a high rate of I/O
  186. #define CI_STATE_MASTER_MERGE_PAUSED 0x0200 // Master merge is paused
  187. #define CI_STATE_READ_ONLY 0x0400 // Indexing has been manually paused (read-only)
  188. #define CI_STATE_BATTERY_POWER 0x0800 // Indexing is paused to conserve battery life
  189. #define CI_STATE_USER_ACTIVE 0x1000 // Indexing is paused due to high user activity (keyboard/mouse)
  190. #define CI_STATE_STARTING 0x2000 // Index is still starting up
  191. #define CI_STATE_READING_USNS 0x4000 // USNs on NTFS volumes are being processed
  192. #ifndef CI_STATE_DEFINED
  193. #define CI_STATE_DEFINED
  194. #include <pshpack4.h>
  195. typedef struct _CI_STATE
  196. {
  197. DWORD cbStruct;
  198. DWORD cWordList;
  199. DWORD cPersistentIndex;
  200. DWORD cQueries;
  201. DWORD cDocuments;
  202. DWORD cFreshTest;
  203. DWORD dwMergeProgress;
  204. DWORD eState;
  205. DWORD cFilteredDocuments;
  206. DWORD cTotalDocuments;
  207. DWORD cPendingScans;
  208. DWORD dwIndexSize;
  209. DWORD cUniqueKeys;
  210. DWORD cSecQDocuments;
  211. DWORD dwPropCacheSize;
  212. } CI_STATE;
  213. #include <poppack.h>
  214. #endif // CI_STATE_DEFINED
  215. STDAPI CIState( WCHAR const * pwcsCat,
  216. WCHAR const * pwcsMachine,
  217. CI_STATE * pCiState );
  218. #if defined __ICommand_INTERFACE_DEFINED__
  219. //
  220. // Create an ICommand, specifying scopes, catalogs, and machines
  221. //
  222. STDAPI CIMakeICommand( ICommand ** ppCommand,
  223. ULONG cScope,
  224. DWORD const * aDepths,
  225. WCHAR const * const * awcsScope,
  226. WCHAR const * const * awcsCatalogs,
  227. WCHAR const * const * awcsMachine );
  228. //
  229. // Create an ICommand, specifying a catalog and machine
  230. //
  231. STDAPI CICreateCommand( IUnknown ** ppCommand, // New object
  232. IUnknown * pUnkOuter, // Outer unknown
  233. REFIID riid, // IID of returned object.
  234. // Must be IID_IUnknown unless pUnkOuter == 0
  235. WCHAR const * pwcsCatalog, // Catalog
  236. WCHAR const * pwcsMachine ); // Machine
  237. #if defined __ICommandTree_INTERFACE_DEFINED__
  238. typedef struct tagCIPROPERTYDEF
  239. {
  240. LPWSTR wcsFriendlyName;
  241. DWORD dbType;
  242. DBID dbCol;
  243. } CIPROPERTYDEF;
  244. //
  245. // Values for ulDialect in CITextToSelectTreeEx and CITextToFullTreeEx
  246. //
  247. #define ISQLANG_V1 1 // Same as the non-Ex versions
  248. #define ISQLANG_V2 2
  249. //
  250. // Convert pwszRestriction in Triplish to a command tree.
  251. //
  252. STDAPI CITextToSelectTree( WCHAR const * pwszRestriction,
  253. DBCOMMANDTREE * * ppTree,
  254. ULONG cProperties,
  255. /*optional*/ CIPROPERTYDEF * pProperties,
  256. LCID LocaleID );
  257. STDAPI CITextToSelectTreeEx( WCHAR const * pwszRestriction,
  258. ULONG ulDialect,
  259. DBCOMMANDTREE * * ppTree,
  260. ULONG cProperties,
  261. /*optional*/ CIPROPERTYDEF * pProperties,
  262. LCID LocaleID );
  263. //
  264. // Convert pwszRestriction in Triplish, project columns, sort columns
  265. // and grouping columns to a command tree.
  266. //
  267. STDAPI CITextToFullTree( WCHAR const * pwszRestriction,
  268. WCHAR const * pwszColumns,
  269. WCHAR const * pwszSortColumns, // may be NULL
  270. WCHAR const * pwszGroupings, // may be NULL
  271. DBCOMMANDTREE * * ppTree,
  272. ULONG cProperties,
  273. /*optional*/ CIPROPERTYDEF * pProperties,
  274. LCID LocaleID );
  275. STDAPI CITextToFullTreeEx( WCHAR const * pwszRestriction,
  276. ULONG ulDialect,
  277. WCHAR const * pwszColumns,
  278. WCHAR const * pwszSortColumns, // may be NULL
  279. WCHAR const * pwszGroupings, // may be NULL
  280. DBCOMMANDTREE * * ppTree,
  281. ULONG cProperties,
  282. /*optional*/ CIPROPERTYDEF * pProperties,
  283. LCID LocaleID );
  284. //
  285. // Build a simple restriction node.
  286. //
  287. STDAPI CIBuildQueryNode( WCHAR const *wcsProperty, // friendly property name
  288. DBCOMMANDOP dbOperator, // enumerated constant
  289. PROPVARIANT const *pvarPropertyValue, // value of the property
  290. DBCOMMANDTREE ** ppTree, // ptr to tree returned here. should be non-null
  291. ULONG cProperties,
  292. CIPROPERTYDEF const * pProperty, // Can be 0.
  293. LCID LocaleID ); // locale id to interpret strings
  294. //
  295. // Build a restriction tree from an existing tree (could be empty) and a newly added node/tree.
  296. //
  297. STDAPI CIBuildQueryTree( DBCOMMANDTREE const *pExistingTree, // existing tree. can be null.
  298. DBCOMMANDOP dbBoolOp, // enumerator constant
  299. ULONG cSiblings, // number of siblings in the array
  300. DBCOMMANDTREE const * const *ppSibsToCombine,
  301. DBCOMMANDTREE ** ppTree); // ptr to tree returned here. should be non-null
  302. //
  303. // Convert restriction tree, project columns, sort columns
  304. // and grouping columns to a command tree.
  305. //
  306. STDAPI CIRestrictionToFullTree( DBCOMMANDTREE const *pTree,
  307. WCHAR const * pwszColumns,
  308. WCHAR const * pwszSortColumns, // may be NULL
  309. WCHAR const * pwszGroupings, // may be NULL
  310. DBCOMMANDTREE * * ppTree,
  311. ULONG cProperties,
  312. /*optional*/ CIPROPERTYDEF * pReserved,
  313. LCID LocaleID );
  314. #endif // __ICommandTree_INTERFACE_DEFINED__
  315. #endif // __ICommand_INTERFACE_DEFINED__
  316. #if defined(__cplusplus)
  317. }
  318. #endif
  319. #endif // __NTQUERY_H__