dbf_struct.inc 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. const
  2. //====================================================================
  3. FieldPropType_Required = $01;
  4. FieldPropType_Min = $02;
  5. FieldPropType_Max = $03;
  6. FieldPropType_Default = $04;
  7. FieldPropType_Constraint = $06;
  8. FieldDescVII_AutoIncOffset = 42;
  9. //====================================================================
  10. // File structures
  11. //====================================================================
  12. type
  13. PDbfHdr = ^rDbfHdr;
  14. rDbfHdr = packed record
  15. VerDBF : Byte; // 0
  16. Year : Byte; // 1 year last updated
  17. Month : Byte; // 2 month last updated
  18. Day : Byte; // 3 day last updated
  19. RecordCount : Integer; // 4-7 number of records in file
  20. FullHdrSize : Word; // 8-9
  21. RecordSize : Word; // 10-11 sum of all field sizes, including delete flag
  22. Dummy1 : Word; // 12-13
  23. IncTrans : Byte; // 14
  24. Encrypt : Byte; // 15 DBase encryption flag
  25. MultiUse : Integer; // 16-19
  26. LastUserID : Integer; // 20-23
  27. Dummy2 : array[24..27] of Byte;
  28. MDXFlag : Byte; // 28 Flags:
  29. // $01: mdx (or cdx for VFP) index file present
  30. // $02: (Visual FoxPro): associated memo file?
  31. // $04: (Visual FoxPro): is this a dbc/database container
  32. Language : Byte; // 29 code page mark
  33. Dummy3 : Word; // 30-31
  34. end;
  35. //====================================================================
  36. PAfterHdrIII = ^rAfterHdrIII;
  37. rAfterHdrIII = packed record // Empty
  38. end;
  39. //====================================================================
  40. PAfterHdrVII = ^rAfterHdrVII;
  41. rAfterHdrVII = packed record
  42. LanguageDriverName : array[32..63] of Char;
  43. Dummy : array[64..67] of Byte;
  44. end;
  45. //====================================================================
  46. // DBase III,IV,FoxPro,VisualFoxPro field description
  47. PFieldDescIII = ^rFieldDescIII;
  48. rFieldDescIII = packed record
  49. FieldName : array[0..10] of Char;
  50. FieldType : Char; // 11
  51. // FieldOffset: (V)FoxPro only: displacement of field in record
  52. // DBase III uses it for address in memory
  53. FieldOffset : Integer; // 12..15
  54. FieldSize : Byte; // 16
  55. FieldPrecision : Byte; // 17, also known as decimal count
  56. VisualFoxProFlags : Byte; // 18 Field Flags; flags can be combined
  57. // $01: system solumn (not user-visible)
  58. // $02: column can store null values
  59. // $04: binary column, e.g. don't interpret codepage (char/memo fields)
  60. // $0C: column is autoincrementing (only integer fields)
  61. AutoIncrementNext : Byte; // 19 VFP only: autoincrement value
  62. // (!!not the next value for a new record!!); the next is calculated by
  63. // adding AutoIncrementStep first.
  64. // Value covers bytes 19..22 (so no WorkAreaID,Reserved1 for VFP)
  65. WorkAreaID : Byte; // 20
  66. // WorkAreaID only for DBase III, is always $01
  67. Reserved1 : array[21..22] of Byte;
  68. AutoIncrementStep : Byte; // 23 VFP only: step value for autoincrement
  69. Reserved2 : array[24..30] of Byte;
  70. MDXIndexField : Byte; //31
  71. // DBase IV:
  72. // $00: no key for this field;
  73. // $01: key exists for this field in MDX index file
  74. // todo: implement this??
  75. end;
  76. //====================================================================
  77. // OH 2000-11-15 dBase7 support. Header Update (add fields like Next AutoInc Value)
  78. rFieldDescVII = packed record
  79. FieldName : array [0..31] of Char;
  80. FieldType : Char; // 32
  81. FieldSize : Byte; // 33
  82. FieldPrecision : Byte; // 34
  83. Reserved1 : Word; // 35-36
  84. MDXFlag : Byte; // 37
  85. // NOTE: the docs say Reserved2 is 2 bytes, and Reserved3 is 4 bytes
  86. // but testing shows BDE has them the other way around
  87. // be BDE compatible :S
  88. Reserved2 : Cardinal; // 38-41
  89. NextAutoInc : Cardinal; // 42-45
  90. Reserved3 : Word; // 46-47
  91. end;
  92. //====================================================================
  93. PFieldPropsHdr = ^rFieldPropsHdr;
  94. rFieldPropsHdr = packed record
  95. NumStdProps : Word; // 0..1
  96. StartStdProps : Word; // 2..3
  97. NumCustomProps : Word; // 4..5
  98. StartCustomProps : Word; // 6..7
  99. NumRIProps : Word; // 8..9
  100. StartRIProps : Word; // 10..11
  101. StartData : Word; // 12..13 ; this points past the Descriptor arrays to data used by the arrays - for example Custom property names are stored here.
  102. Size : Word; // 14..15 ; Actual size of structure, including data
  103. end;
  104. //====================================================================
  105. PStdPropEntry = ^rStdPropEntry;
  106. rStdPropEntry = packed record
  107. GenNumber : Word; // 0..1 ; Generational number. More than one value may exist for a property. The current value is the value with the highest generational number.
  108. FieldOffset : Word; // 2..3 ; Table field offset - base one. 01 for the first field in the table, 02 for the second field, etc. Note: this will be 0 in the case of a constraint.
  109. PropType : Byte; // 4 ; Which property is described in this record:
  110. // 01 Required
  111. // 02 Min
  112. // 03 Max
  113. // 04 Default
  114. // 06 Database constraint
  115. FieldType : Byte; // 5 ; Field Type:
  116. // 00 No type - constraint
  117. // 01 Char
  118. // 02 Numeric
  119. // 03 Memo
  120. // 04 Logical
  121. // 05 Date
  122. // 06 Float
  123. // 08 OLE
  124. // 09 Binary
  125. // 11 Long
  126. // 12 Timestamp
  127. // 13 Double
  128. // 14 AutoIncrement (not settable from the Inspector)
  129. IsConstraint : Byte; // 6 ; 0x00 if the array element is a constraint, 0x02 otherwise.
  130. Reserved : array[7..10] of Char;
  131. DataOffset : Word; // 11..12 ; Offset from the start of this structure to the data for the property. The Required property has no data associated with it, so it is always 0.
  132. DataSize : Word; // 13..14 ; Width of database field associated with the property, and hence size of the data (includes 0 terminator in the case of a constraint).
  133. end;
  134. //====================================================================
  135. PCustomPropEntry = ^rCustomPropEntry;
  136. rCustomPropEntry = packed record
  137. GenNumber : Word; // 0..1 ; same as standard
  138. FieldOffset : Word; // 2..3 ; same as standard
  139. FieldType : Byte; // 4 ; same as standard
  140. Reserved : Byte; // 5
  141. NameOffset : Word; // 6..7 ; Offset from the start of this structure to the Custom property name.
  142. NameLength : Word; // 8..9 ; Length of the Custom property name.
  143. DataOffset : Word; // 10..11 ; Offset from the start of this structure to the Custom property data.
  144. DataLength : Word; // 12..13 ; Length of the Custom property data (does not include null terminator).
  145. end;
  146. //====================================================================
  147. PRIPropEntry = ^rRIPropEntry;
  148. rRIPropEntry = packed record
  149. RelationType : Byte; // 0 ; 0x07 if Master (parent), 0x08 if Dependent (child).
  150. Number : Word; // 1..2 ; Sequential number, 1 based counting. If this number is 0, this RI rule has been dropped.
  151. NameOffset : Word; // 3..4 ; Offset of the RI rule name - 0 terminated.
  152. NameSize : Word; // 5..6 ; Size of ...
  153. ForeignOffset : Word; // 7..8 ; Offset of the name of the Foreign Table - 0 terminated.
  154. ForeignSize : Word; // 9..10 ; Size of ...
  155. UpdateType : Byte; // 11 ; Update & delete behaviour: Update Cascade=0x10, Delete Cascade=0x01
  156. NumFieldsKey : Word; // 12..13 ; Number of fields in the linking key.
  157. LocalTagOffset : Word; // 14..15 ; Offset of the Local Table tag name - 0 terminated.
  158. LocalTagSize : Word; // 16..17 ; Size of ...
  159. ForeignTagOffset: Word; // 18..19 ; Offset of the Foreign Table tag name - 0 terminated.
  160. ForeignTagSize : Word; // 20..21 ; Size of ...
  161. end;