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.

209 lines
7.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: CI.h
  7. //
  8. // Contents: Content index specific definitions
  9. //
  10. // History: 04-Aug-92 KyleP Moved from Win4p.h
  11. // 12-Nov-99 KLam Added assert to AlignBlock
  12. //
  13. //--------------------------------------------------------------------------
  14. #pragma once
  15. typedef ULONG WORKID; // Object ID of a file
  16. typedef ULONG KEYID; // Key ID
  17. typedef unsigned long PARTITIONID; // Persistent ID of a partition
  18. typedef unsigned long INDEXID; // Persistent ID of a sub-index
  19. typedef ULONGLONG FILEID; // Ntfs file id of a file is 64 bits.
  20. #ifdef __cplusplus
  21. //
  22. // These apparently aren't defined in C++ ( __min and __max are )
  23. //
  24. #ifndef max
  25. # define max(a,b) (((a) > (b)) ? (a) : (b))
  26. #endif
  27. #ifndef min
  28. # define min(a,b) (((a) < (b)) ? (a) : (b))
  29. #endif
  30. #ifndef NUMELEM
  31. # define NUMELEM(x) (sizeof(x)/sizeof(*x))
  32. #endif
  33. inline ULONG AlignBlock( ULONG x, ULONG align )
  34. {
  35. ASSERT( ( align & (align-1) ) == 0 );
  36. return ( x + ( align - 1 ) ) & ~( align - 1 );
  37. }
  38. inline ULONG lltoul( IN const LONGLONG & ll )
  39. {
  40. ASSERT( (ULONGLONG) ll <= MAXULONG );
  41. return (ULONG) ll;
  42. }
  43. inline LONGLONG & litoll( IN LARGE_INTEGER &li )
  44. {
  45. return(li.QuadPart);
  46. }
  47. inline LONG lltoHighPart( IN const LONGLONG & ll )
  48. {
  49. return(((PLARGE_INTEGER) &ll)->HighPart);
  50. }
  51. inline ULONG lltoLowPart( IN const LONGLONG & ll)
  52. {
  53. return ((PLARGE_INTEGER) &ll)->LowPart;
  54. }
  55. // CRT calls made by the Property Set code.
  56. #define Prop_wcslen wcslen
  57. #define Prop_wcsnicmp _wcsnicmp
  58. #define Prop_wcscmp wcscmp
  59. #define Prop_wcscpy wcscpy
  60. //
  61. // Convenience macros for signature creation
  62. //
  63. #if !defined( LONGSIG )
  64. #define LONGSIG(c1, c2, c3, c4) \
  65. (((ULONG) (BYTE) (c1)) | \
  66. (((ULONG) (BYTE) (c2)) << 8) | \
  67. (((ULONG) (BYTE) (c3)) << 16) | \
  68. (((ULONG) (BYTE) (c4)) << 24))
  69. #endif // LONGSIG
  70. #if !defined( SHORTSIG )
  71. #define SHORTSIG(c1, c2) \
  72. (((USHORT) (BYTE) (c1)) | \
  73. (((USHORT) (BYTE) (c2)) << 8))
  74. #endif // SHORTSIG
  75. //
  76. // Invalid entries of various kinds.
  77. //
  78. const WORKID widInvalid = 0xFFFFFFFFL; // Invalid WorkID
  79. const WORKID widUnused = 0xFFFFFFFE; // Useful for hash tables
  80. const KEYID kidInvalid = 0xFFFFFFFFL; // Invalid KeyID
  81. const FILEID fileIdInvalid = 0; // Invalid file ID
  82. const PARTITIONID partidInvalid = 0xFFFF;
  83. const PARTITIONID partidKeyList = 0xFFFE;
  84. //
  85. // Internal generate method level(s)
  86. //
  87. const ULONG GENERATE_METHOD_MAX_USER = 0x7FFFFFFF; // No user fuzzy level bigger than this.
  88. const ULONG GENERATE_METHOD_EXACTPREFIXMATCH = 0x80000000; // Uses language-dependent noise-word list.
  89. //
  90. // Properties. These are all the Property Ids that the CI understands.
  91. //
  92. // Note: the sorting algs. insist that pidInvalid == (unsigned) -1
  93. //
  94. #define MK_CISTGPROPID(propid) ((propid) + 1)
  95. #define MK_CIQUERYPROPID(propid) (((propid) + CSTORAGEPROPERTY) + 1)
  96. #define IS_CIQUERYPROPID(propid) ( (propid) >= CSTORAGEPROPERTY + 1 && \
  97. (propid) < CSTORAGEPROPERTY + CQUERYPROPERTY )
  98. #define MK_CIQUERYMETAPROPID(propid) (((propid) + CSTORAGEPROPERTY + \
  99. CQUERYDISPIDS) + 1)
  100. #define MK_CIDBCOLPROPID(propid) (((propid) + CSTORAGEPROPERTY + \
  101. CQUERYDISPIDS + CQUERYMETADISPIDS) + 1)
  102. #define MK_CIDBBMKPROPID(propid) (((propid) + CSTORAGEPROPERTY + \
  103. CQUERYDISPIDS + CQUERYMETADISPIDS + \
  104. CDBCOLDISPIDS) + 1)
  105. #define MK_CIDBSELFPROPID(propid) (((propid) + CSTORAGEPROPERTY + \
  106. CQUERYDISPIDS + CQUERYMETADISPIDS + \
  107. CDBCOLDISPIDS + CDBBMKDISPIDS) + 1)
  108. // Property related type definitions
  109. const PROPID pidInvalid = 0xFFFFFFFF;
  110. const PROPID pidAll = 0;
  111. // security is strictly an internally-used property
  112. const PROPID pidSecurity = MK_CISTGPROPID( PID_DICTIONARY );
  113. const PROPID pidDirectory =MK_CISTGPROPID( PID_STG_DIRECTORY );
  114. const PROPID pidClassId =MK_CISTGPROPID( PID_STG_CLASSID );
  115. const PROPID pidStorageType =MK_CISTGPROPID( PID_STG_STORAGETYPE );
  116. const PROPID pidFileIndex =MK_CISTGPROPID( PID_STG_FILEINDEX );
  117. const PROPID pidVolumeId =MK_CISTGPROPID( PID_STG_VOLUME_ID );
  118. const PROPID pidParentWorkId =MK_CISTGPROPID( PID_STG_PARENT_WORKID );
  119. const PROPID pidSecondaryStorage =MK_CISTGPROPID( PID_STG_SECONDARYSTORE );
  120. const PROPID pidLastChangeUsn =MK_CISTGPROPID( PID_STG_LASTCHANGEUSN );
  121. const PROPID pidName =MK_CISTGPROPID( PID_STG_NAME );
  122. const PROPID pidPath =MK_CISTGPROPID( PID_STG_PATH );
  123. const PROPID pidSize =MK_CISTGPROPID( PID_STG_SIZE );
  124. const PROPID pidAttrib =MK_CISTGPROPID( PID_STG_ATTRIBUTES );
  125. const PROPID pidWriteTime =MK_CISTGPROPID( PID_STG_WRITETIME );
  126. const PROPID pidCreateTime =MK_CISTGPROPID( PID_STG_CREATETIME );
  127. const PROPID pidAccessTime =MK_CISTGPROPID( PID_STG_ACCESSTIME);
  128. const PROPID pidChangeTime =MK_CISTGPROPID( PID_STG_CHANGETIME);
  129. const PROPID pidContents =MK_CISTGPROPID( PID_STG_CONTENTS );
  130. const PROPID pidShortName =MK_CISTGPROPID( PID_STG_SHORTNAME );
  131. const PROPID pidRank = MK_CIQUERYPROPID( DISPID_QUERY_RANK );
  132. const PROPID pidHitCount = MK_CIQUERYPROPID( DISPID_QUERY_HITCOUNT );
  133. const PROPID pidRankVector = MK_CIQUERYPROPID( DISPID_QUERY_RANKVECTOR );
  134. const PROPID pidWorkId = MK_CIQUERYPROPID( DISPID_QUERY_WORKID );
  135. const PROPID pidUnfiltered = MK_CIQUERYPROPID( DISPID_QUERY_UNFILTERED );
  136. const PROPID pidRevName = MK_CIQUERYPROPID( DISPID_QUERY_REVNAME );
  137. const PROPID pidVirtualPath = MK_CIQUERYPROPID( DISPID_QUERY_VIRTUALPATH );
  138. const PROPID pidLastSeenTime = MK_CIQUERYPROPID( DISPID_QUERY_LASTSEENTIME );
  139. const PROPID pidVRootUsed = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_VROOTUSED );
  140. const PROPID pidVRootAutomatic = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_VROOTAUTOMATIC );
  141. const PROPID pidVRootManual = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_VROOTMANUAL );
  142. const PROPID pidPropertyGuid = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_PROPGUID );
  143. const PROPID pidPropertyDispId = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_PROPDISPID );
  144. const PROPID pidPropertyName = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_PROPNAME );
  145. const PROPID pidPropertyStoreLevel = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_STORELEVEL );
  146. const PROPID pidPropDataModifiable = MK_CIQUERYMETAPROPID( DISPID_QUERY_METADATA_PROPMODIFIABLE );
  147. //
  148. // OLE-DB pseudo columns for the columns cursor, row status and bookmarks
  149. //
  150. const PROPID pidRowStatus = MK_CIDBCOLPROPID( 27 );
  151. const PROPID pidBookmark = MK_CIDBBMKPROPID( PROPID_DBBMK_BOOKMARK );
  152. const PROPID pidChapter = MK_CIDBBMKPROPID( PROPID_DBBMK_CHAPTER );
  153. const PROPID pidSelf = MK_CIDBSELFPROPID( PROPID_DBSELF_SELF );
  154. PROPID const INIT_DOWNLEVEL_PID = 0x1000;
  155. inline BOOL IsUserDefinedPid( PROPID pid )
  156. {
  157. return (pid >= INIT_DOWNLEVEL_PID);
  158. }
  159. // Precomputed list of primes
  160. static const ULONG g_aPrimes[] =
  161. { 17, 31, 43, 97, 199, 401, 809, 1621, 3253, 6521, 13049, 26111, 52237, 104479 };
  162. const unsigned g_cPrimes = sizeof g_aPrimes / sizeof g_aPrimes[0];
  163. #endif // __cplusplus