Source code of Windows XP (NT5)
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.

170 lines
5.4 KiB

  1. #define cbLVIntrinsicMost 1024
  2. #define cbRECRecordMin (sizeof(RECHDR) + sizeof(WORD))
  3. // 2 + 2 (for offset to tagged fields) = 4
  4. #define cbRECRecordMost (cbNodeMost - cbNullKeyData - JET_cbKeyMost)
  5. // 4047 - 8 - 255 = 3784
  6. // For fixed columns, if null bit is 0, then column is null. If null bit is 1,
  7. // then column is non-null (opposite is true for variable columns -- great design!).
  8. // Note that the fid passed in should already be converted to an index (ie. should
  9. // subtract fidFixedLeast first).
  10. #define FixedNullBit( ifid ) ( 1 << ( (ifid) % 8 ) )
  11. #define FFixedNullBit( pbitNullity, ifid ) \
  12. ( !( *(pbitNullity) & FixedNullBit( ifid ) ) ) // True if NULL
  13. #define SetFixedNullBit( pbitNullity, ifid ) \
  14. ( *(pbitNullity) &= ~FixedNullBit( ifid ) ) // Set to 0 (null).
  15. #define ResetFixedNullBit( pbitNullity, ifid ) \
  16. ( *(pbitNullity) |= FixedNullBit( ifid ) ) // Set to 1 (non-null)
  17. // Used to get offset from 2-byte VarOffset which includes null-bit.
  18. // For variable columns, if null bit is 0, then column is non-null. If null bit is 1,
  19. // then column is null (opposite is true for variable columns -- great design!).
  20. #define ibVarOffset(ibVarOffs) ( (ibVarOffs) & 0x0fff)
  21. #define FVarNullBit(ibVarOffs) ( (ibVarOffs) & 0x8000) // True if NULL
  22. #define SetVarNullBit(ibVarOffs) ( (ibVarOffs) |= 0x8000) // Set to 1 (null)
  23. #define ResetVarNullBit(ibVarOffs) ( (ibVarOffs) &= 0x7fff) // Set to 0 (non-null)
  24. // Used to flip highest bit of signed fields when transforming.
  25. #define maskByteHighBit (1 << (sizeof(BYTE)*8-1))
  26. #define maskWordHighBit (1 << (sizeof(WORD)*8-1))
  27. #define maskDWordHighBit (1L << (sizeof(ULONG)*8-1))
  28. #define bFlipHighBit(b) ((BYTE)((b) ^ maskByteHighBit))
  29. #define wFlipHighBit(w) ((WORD)((w) ^ maskWordHighBit))
  30. #define ulFlipHighBit(ul) ((ULONG)((ul) ^ maskDWordHighBit))
  31. /* The following are disk structures -- so pack 'em
  32. /**/
  33. #pragma pack(1)
  34. /* long column id is big-endian long
  35. /**/
  36. typedef LONG LID;
  37. /* long value column in record format
  38. /**/
  39. typedef struct
  40. {
  41. BYTE fSeparated;
  42. union
  43. {
  44. LID lid;
  45. BYTE rgb[];
  46. };
  47. } LV;
  48. /* long value root data format
  49. /**/
  50. typedef struct
  51. {
  52. ULONG ulReference;
  53. ULONG ulSize;
  54. } LVROOT;
  55. #pragma pack()
  56. #define fIntrinsic (BYTE)0
  57. #define fSeparate (BYTE)1
  58. #define FFieldIsSLong( pb ) ( ((LV *)(pb))->fSeparated )
  59. #define LidOfLV( pb ) ( ((LV *)(pb))->lid )
  60. #define FlagIntrinsic( pb ) ( ((LV *)(pb))->fSeparated = fIntrinsic )
  61. #define FlagSeparate( pb ) ( ((LV *)(pb))->fSeparated = fSeparate )
  62. #define fLVReference 0
  63. #define fLVDereference 1
  64. /* The following are disk structures -- so pack 'em
  65. /**/
  66. #pragma pack(1)
  67. // Record header (beginning of every data record)
  68. typedef struct _rechdr
  69. {
  70. BYTE fidFixedLastInRec; // highest fixed fid represented in record
  71. BYTE fidVarLastInRec; // highest var fid represented in record
  72. } RECHDR;
  73. // Structure imposed upon a tagged field occurance in a record
  74. typedef struct _tagfld
  75. {
  76. FID fid; // field id of occurance
  77. union
  78. {
  79. WORD cbData; // length of data, including null bit
  80. struct
  81. {
  82. WORD cb:15; // length of following data (null bit stripped)
  83. WORD fNull:1; // Null instance (only occurs if default value set)
  84. };
  85. };
  86. BYTE rgb[]; // data (extends off the end of the structure)
  87. } TAGFLD;
  88. #pragma pack()
  89. ULONG UlChecksum( BYTE *pb, ULONG cb );
  90. ERR ErrRECSetCurrentIndex( FUCB *pfucb, CHAR *szIndex );
  91. BOOL FRECIIllegalNulls( FDB *pfdb, LINE *plineRec );
  92. ERR ErrRECRetrieveColumn( FUCB *pfucb, FID *pfid, ULONG itagSequence, LINE *plineField, ULONG grbit );
  93. ERR ErrRECSetColumn( FUCB *pfucb, FID fid, ULONG itagSequence, LINE *plineField );
  94. VOID FLDFreeLVBuf( FUCB *pfucb );
  95. ERR ErrRECSetLongField(
  96. FUCB *pfucb,
  97. FID fid,
  98. ULONG itagSequence,
  99. LINE *plineField,
  100. JET_GRBIT grbit,
  101. LONG ibOffset,
  102. ULONG ulMax );
  103. ERR ErrRECRetrieveSLongField(
  104. FUCB *pfucb,
  105. LID lid,
  106. ULONG ibGraphic,
  107. BYTE *pb,
  108. ULONG cbMax,
  109. ULONG *pcbActual );
  110. ERR ErrRECDeleteLongFields( FUCB *pfucb, LINE *plineRecord );
  111. ERR ErrRECAffectLongFields( FUCB *pfucb, LINE *plineRecord, INT fAll );
  112. ERR ErrRECSeparateLV( FUCB *pfucb, LINE *plineField, LID *plid, FUCB **ppfucb );
  113. ERR ErrRECAOSeparateLV( FUCB *pfucb, LID *plid, LINE *plineField, JET_GRBIT grbit, LONG ibLongValue, ULONG ulMax );
  114. ERR ErrRECAffectSeparateLV( FUCB *pfucb, LID *plid, ULONG fLVAffect );
  115. ERR ErrRECAOIntrinsicLV(
  116. FUCB *pfucb,
  117. FID fid,
  118. ULONG itagSequence,
  119. LINE *pline,
  120. LINE *plineField,
  121. JET_GRBIT grbit,
  122. LONG ibLongValue );
  123. #define fSeparateAll (INT)0
  124. #define fReference (INT)1
  125. #define fDereference (INT)2
  126. #define fDereferenceRemoved (INT)3
  127. #define fDereferenceAdded (INT)4
  128. #define PtagfldNext( ptagfld ) ( (TAGFLD UNALIGNED *)( (BYTE *)( (ptagfld) + 1 ) + (ptagfld)->cb ) )
  129. #define FRECLastTaggedInstance( fidCurr, ptagfld, pbRecMax ) \
  130. ( (BYTE *)PtagfldNext( (ptagfld) ) == (pbRecMax) || \
  131. PtagfldNext( (ptagfld) )->fid > (fidCurr) )
  132. #define PibRECVarOffsets( pbRec, pibFixOffs ) \
  133. ( (WORD UNALIGNED *)( (pbRec) + \
  134. (pibFixOffs)[((RECHDR *)(pbRec))->fidFixedLastInRec] + \
  135. ( ((RECHDR *)(pbRec))->fidFixedLastInRec + 7 ) / 8 ) )
  136. #define ibTaggedOffset( pbRec, pibFixOffs ) \
  137. ( PibRECVarOffsets( pbRec, pibFixOffs )[((RECHDR *)(pbRec))->fidVarLastInRec+1-fidVarLeast] )
  138. #define ErrRECIRetrieveDefaultValue( pfdb, pfid, plineField ) \
  139. ErrRECIRetrieveColumn( pfdb, &(pfdb)->lineDefaultRecord, pfid, NULL, 1, plineField, 0 )