DBF Structure
Byte Value
0 0x30 VFP 8.0 Format
1-3 Number of records
8-9 Position of first record
10-11 Length of first record (one)
12-27 Reserved
28 Table flag
32+n Subfield records
32-41 0-10 Field Name
11 Field Type
12-15 Displacement
16 Field Length
17 Number of decimals
18-31 Ignore in our case
Last record is having 0x0D value which indicates end of header record.
Each field is constructed as follows after header record:
Byte Value
0 Delete Flag C 1
1-14 FIELNAME1 C 14
15-18 FIELNAME2 C 4
Field Types
C Character
T Date/Time
P Picture
Y Currency
N Numeric
B Double
I Integer
F Float
L Logical
D date
M Memo
struct db_header
{
char db_type;
char db_date[6];
unsigned long no_records;
int position_of_first_record;
int length_of_record;
char reserved[15];
char table_flag;
char none[3];
};
struct sub_records
{
char fieldname[10];
char displacement;
char field_length;
char field_decimals;
char field_reserved[15];
};
Now you can read the header structure and details in program. Note that on Celeron 1.7 the integer byte size=4 bytes. Therefore, do no use long to read in the structure, as long will read 8 bytes at a time.