#### #### ###### ## ## ## ## ## ## ## ## ###### ###### ##### ### ###### ## ## ## ## ## ## ## ## ####### ######## ####### ## ## ## ## ## ## ## ## #### #### ###### ######## ####### ##### Xbase file format description by Erik Bachmann Clickety Click Software 1996-10-18 WHAT IS XBASE ------------- "Generic term for the dBASE family of database languages. Coined in=20 response to threatened litigation over use of the copyrighted trademark 'dBASE'." http://wombat.doc.ic.ac.uk/ Xbase is a complex of data files, indexes and eventually note files for= storing large amounts of formatted data in a structured form. Basically Xbase is three different types of files: NN.dbf Data files NN.dbt Memo files (i.e. a separate file containing full text fields) *.ndx Index files pointing to a field in the *.dbf Xbase is almost compatible with dBASE and is actually a clone of dBASE.=20 The creator of dBASE Ashton-Tate (and later Borland) has the copyright for= =20 the name dBASE, but NOT the structure.=20 Therefore the name Xbase (It smells like - but it's not :-) has been widely= used=20 for look-alike data structures. There has been an attempt to create a standard for Xbase. I've found a lot= of dead links while searching on Alta Vista's World Wide Web search engine. I'm at the moment not aware of the result of the Xbase comity=92s work. Xbase has - like most dBASE clones - it's offspring in the dBASE III+ file structure. I've tried to add all later enhancements as notes to the= structure. WHY THIS DOCUMENT ----------------- I've been looking for a simple database tool for my work with C programming and bibliographical database systems. During my investigation of a lot of BBS's, FTP sites, toolboxes etc. I've discovered at lot of= almost-ready-to-fly Xbase clones. This made me wonder why no one has collected a description of Xbase files AND made a simple package of C functions to handle this type of data files. THAT was my goal - and THIS is the result. ____________________________________________________________________________= __ NOTICE ! ! ! .----. =20 ((*)(*)) DO NOT attempt to manipulate any critical database files= WITHOUT \ /\ / making a proper and validated backup first. #### DO NOT access any database files in a multiuser environment! \__/ =20 ____________________________________________________________________________= __ Any comments, corrections, additions etc. are welcome. You can reach me at: ebp@dde.dk or by snail mail: Erik Bachmann Grydehoejvej 62 DK-4000 Roskilde Denmark Europe =09 Third stone from the Sun - and turn left :-) =0CWHAT SORT OF DATA CAN BE HANDLED -------------------------------- Data files (*.dbf) contains a header with information on the data structure AND the record themselves. The data field is predefined as carrying data of a specific type ( Character, Numbers, Longs, Dates, Memo). Each data type has its limitations: C Character ASCII text < 254 characters long. Character fields can be up to 32 KB long (in=20 Clipper and FoxPro) using decimal count as=20 high byte in field length. N Number ASCII text < 20 characters long. Number fields can be up to 20 characters long=20 in FoxPro and Clipper. L Logical Boolean/byte (8 bit) Legal values: ? Not initialised (default) Y,y Yes N,n No F,f False T,f True Logical fields are always displayed using T/F/?. D Date Date in format YYYYMMDD M Memo Pointer to ASCII text field in memo file 10 digits representing a pointer to a DBT block=20 (default is blanks). F Floating point (dBASE IV and later, FoxPro, Clipper) 2 digits N/A Character name variable 1-254 characters (64 KB in FoxBase and Clipper) B Binary (dBASE V) Like Memo fields, but not for text processing. G General (dBASE V: like Memo) OLE Objects in MS Windows versions P Picture (FoxPro) Like Memo fields, but not for text processing. Index files (*.ndx) are sorted references to fields in the data files. There might be more than one index for each data file. dBASE III Memo files are primitive 512 byte hunks of ASCII text data= creating a=20 way for text fields to exceed the 255 characters barrier of ordinary text= fields. Other versions may store up til 64 KB of text in a fixed sized text field. Larger amounts of text (and binary data) is still stored in memo-like files. The size og the blocks can be user defined while creating the memo file (see byte 4-7 of the memo file structure). =0CWHAT DO THE FILES LOOK LIKE --------------------------- They all look brown to me :-) All Xbase files have a header describing the structure of the data in the= file. Schematically they look like this: The structure of data files (*.dbf) ---------------------------------- _______________________ _______ 0 | Version number *1| ^ |-----------------------| | =20 1 | Date of last update | | 2 | YYMMDD | | 3 | | | |-----------------------| | 4 | Number of records | Record 5 | in data file | header 6 | ( 32 bits ) | | 7 | | | |-----------------------| | 8 | Length of header | | 9 | structure ( 16 bits ) | | |-----------------------| | 10| Length of each record | | 11| ( 16 bits ) *2| | |-----------------------| | 12| ( Reserved ) *3| | 13| | | |-----------------------| | 14| Incomplete transac.*12| | |-----------------------| | 15| Encryption flag *13| | |-----------------------| | 16| ( Reserved for | | _ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| _______ | multi-user dBASE ) | | / 0| Field name in ASCII | ^= =20 : ( dBASE III+ - ) : | / : (terminated by 00h) : | : : | | | | | 27| | | | 10| | | |-----------------------| | | |-----------------------| For 28| MDX flag (dBASE IV) *4| | | 11| Field type in ASCII | each |-----------------------| | | |-----------------------|= field 29| Language driver *5| | / 12| Field data address | | |-----------------------| | / | *6| | 30| ( Reserved ) | | / | (in memory !!!) | | 31| *3| | / 15| (dBASE III+) | | |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|__= |____/ |-----------------------| | <- 32| | | ^ 16| Field length (binary)| | = | |- - - - - - - - - - - -| | | |-----------------------| | = | *7 | | | | 17| Decimal count (binary)| | = | |- - - - - - - - - - - -| | Field |-----------------------| |= <- | | | Descriptor 18| ( Reserved for | | :. . . . . . . . . . . .: | |array 19| multi-user dBASE ) | | : : | | |-----------------------| | n | |__|__v_ 20| Work area ID | | |-----------------------| | \ |-----------------------| | n+1| Terminator (0Dh) | | \ 21| ( Reserved for | | |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v____ \ 22| multi-user dBASE ) | | | | ^ \ |-----------------------| | | | | \ 23| Flag for SET FIELDS | | | | | | |-----------------------| | | Record structure | | | 24| ( Reserved ) | | : : | | : : | : : | | : : | | | | | 30| | | | | | | |-----------------------| | | | | | 31| Index field flag *8| | | | | | |-----------------------| | | | | \ 32| Terminator ( 0Dh ) | | | | | \_ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| _v_____ | | Records |-----------------------| | =20 | | | _ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| _______ | | | / 0| Field deleted flag *9| ^= =20 | | | / |-----------------------| | | | | / | Data *10| One | | | / : := record | |____|_____/ | | | : : | | |= _v_____ : :____|_____ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| : : | \ | Field deleted flag *9| | | | \ |-----------------------| | | | \ | | | | | \ | | | | | \_ |-----------------------| | | | |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| = | |__End_of_File__________| ___v____ End of file ( 1Ah ) *11 *1 dBASE III+: 03h file without DBT. 83h file with DBT. i.e. bit 0-3 version, 3-5 SQL, 7 DBT flag =09 dBASE IV: bit 0-2 Version no. 3 Presence of memo file 4-6 Presence of SQL table 7 DBT flag =09 Examples: 03h dBASE III w/o memo file 83h dBASE III+ with memo file F5h FoxPro w. memo file 8Bh dBASE IV w. memo 8Eh dBASE IV w. SQL table *2 Sum of lengths of all fields + 1 (deletion flag) *3 (dBASE IV) Filled with 00h. *4 (dBASE IV) Production index 01h MDX file present 00h no MDX file. (FoxBase) 01h CDX compound index file present,=20 00h no CDX file. *5 (Foxpro) Code page: 01h DOS USA code page 437 02h DOS Multi lingual code page 850 03h Windows ANSI code page 1251 C8h Windows EE code page 1250 *6 (FoxPro) 12-13. offset of field from beginning of record. *7 (FoxPro, Clipper) 16-17: Field length for non-numerical fields. Byte 16 is normally field length (0-255) and byte 17 represents the=20 high byte for field length (256-65535). *8 (dBASE IV) Index field flag:=20 00h No key for this field 01h Key exists for this field *9 2Ah record is deleted, 20h record is NOT deleted *10 There are no field separators for record terminators. *11 dBASE II regards any End-of-File 1Ah value as the end of the file. dBASE III regard an End-of-File as an ordinary character, however it appends an extra End-of-File character at the physical end of the file. *12 (dBASE IV) Incomplete transaction 00h Transaction ended (or rolled back) 01h Transaction started *13 (dBASE IV) Encryption flag 00h Not encrypted 01h Data encrypted =0CThe Structure of Index files ---------------------------- The index file is a B+ tree. The essential structure is in an inverted tree, with an anchor note, multiple root nodes, and leaf nodes. The header is=20 called the anchor node. NOTE! Normally the header is read once only by the application, when the=20 file is opened. The size of a page is ( as far as I know ) alway 512 bytes. _______________________ _______ 0 | Starting page no | ^ 1 | | | 2 | | | 3 | | | |-----------------------| | 4 | Total no of pages | File 5 | | header 6 | | | 7 | | (page 0) |-----------------------| | 8 | (Reserved) | | 9 | | | 10 | | | 11 | | | |-----------------------| | 12 | Key length | | 13 | | | |-----------------------| | 14 | No of keys per page | | 15 | | | |-----------------------| | 16 | Key type: 0 =3D char | | 17 | 1 =3D Num | | |-----------------------| | 18 | Size of key record | | 19 | | | 20 | | | 21 | | | |-----------------------| | 22 | (Reserved) | | |-----------------------| | 23 | Unique flag | | |-----------------------| | 24 | String defining the | | | key | | : : | __ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| : : | / 0| Pointer to lower level| | | | / 1| (next page) | 511| | | / 2| | |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v_____ / 3| | 0| | ^ / |-----------------------| 1| | _|_____/ 4| Record number in | 2| Array of key entries | | 5| data file | 3| | Page 6| | 4| | | 7| | | | | |-----------------------| | | _|_____ 8| Key data | : : | \ : : : : | \ N| | 511| | | \_____ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v_____ Search algorithm for index files -------------------------------- 1) The anchor node always resides in memory, while the file is open and=20 determines which root node to access for at given key. =20 2) The root node is read and sequentially scanned until a key is found=20 that is >=3D to the desired key. 3) A second-level node is accessed and scanned in a manner similar to=20 the root node. 4) The process continues until the pointer to the next-lower-level node=20 has a value of zero. If the key matches the leaf key at this level,=20 the record number for the key is returned. That's a diciplin NOT to be discussed here :-) Way out of the scope fore this document and way too complex. One of the advances of the B+ tree is that the higher levels of the tree= does not have to be updated when a certain node is changed - unless the tree has become unbalanced. =0CThe Structure of Memo Field Files (*.dbt) ----------------------------------------- _______________________ _______ 0 | Number of next | ^ ^ 1 | available block | | | 2 | for appending data | | Header 3 | (binary) | | | |-----------------------| _|__v__ 4 | ( Reserved ) | | =20 | Size of blocks *1 | | | | | 7 | | | |-----------------------| | 8 | ( Reserved ) | | =20 | | | | (i.e. garbage) | | : : First block : : | =20 511| | | =20 |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v_____ 512| | ^ =20 | | | | | 512 Bytes | | text blocks : : | : : | | | | |-----------------------| _|_____ | Field terminator (1Ah)| | ^ |-----------------------| | |Terminating field | Field terminator (1Ah)| | |within the block |-----------------------| _|__v__ : ( Unused ) : | 1023 : | |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v_____ | | ^ | | | | | 512 Bytes | | text blocks : : | : : | | | | | | _v_____ |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| *1) (FoxBase, dBASE IV ??) Size of blocks in memo file (SET BLOCKSIZE). Default is 512 bytes. A memo field can be longer than the 512 byte block. It simply continues=20 through the next block. The field is logically terminated by two End-of-file marks in the field. The reminder of the block is unused. NOTE! Every time you re-write a memo field to the memo file in dBASE the=20 field is APPENDED to the memo file (i.e. the file expands for each update). dBASE V for DOS (and perhaps others) may reuse the space from the deleted= text. The Memo file itself tells nothing about it's use. You need the= corresponding DBF file to interpret the content of the memo file. Many of the clones and dBASE 5 have binary elements stored in the memo file marked with file type B or G. ____________________________________________________________________________= __ .----. ((*)(*)) \ /\ / DO NOT attempt to treat these binary data as simple text ! ! ! #### \__/ ____________________________________________________________________________= __ =0CThe Record Lock Field on a dBASE IV Table ----------------------------------------- In a DOS multiuser environment, each user can place record locks on a shared table. For example, if user JSMITH is editing record number 12 of Stock,= user MBROWN cannot access that record until it is unlocked. This prohibits one= user from unintentionally overwriting another user's work. The dBASE table type gives you the Record Lock option to show you= information about a locked record. If you check Record Lock, Database Desktop adds a= hidden character field named _DBASELOCK to the table. This field shows you when a record was locked and by whom. NOTE: Although Database Desktop adds the Record Lock field to the table, you will= not see it when you view the table. You see a record's Record Lock field only if= you are locked out of that record. Use the Create dBASE Table dialog box to create the Record Lock field for a dBASE table. Record Lock is not available for dBASE III+ tables. The information you see when you find a locked field=20 depends on the Info Size you specify. The Record Lock field=20 can be from 8 to 24 characters. The default is 16. 0-1 The first two bytes (binary integer) tell whether a user has changed the record. Every commited change is counted encreasing the count by one. 2-4 The next three characters tell the time a user placed the lock.=20 (10h 09h 07h i.e. 16:09:07) 5-7 The next three characters tell the date a user placed the lock. ( 60h 09h 0Bh i.e. (19)96-09-11 ) 8-24 The remaining 16 characters are optional. They tell the name of the=20 user that placed the lock. The default size of 16 displays the changed status of the record, the time= and date of the lock, and the first 8 characters of the user who placed the= lock. NOTE! You cannot see from the locking info if the user releases the record=20 again. You have to test the record locking. =09 On DOS systems SHARE has to be loaded.=20 Turbo C, DJGPP and compatible C compilers have functions like: lock() _dos_lock() locking() for setting locks on a region of a file and unlock() _dos_unlock() unlocking for removing the lock again. It's important that YOU remove the locks BEFORE closing the file. =09 Read/write locks using share by Phil Barnett (philb@iag.net) ---------------------------- Share holds the locks, but it doesn't know anything about the structure or program that is requesting the lock. All share does is record the lock offset, type (record or file) and file name with path and where (station) it came from, and remove it when the correct station requests removal. Lets make a scenario. You have a 1000 byte header on your dbf file, and each record is 99 bytes + one for the delete flag. (this is to make the math simple) If you locked record one at the actual offset it would lock a range from byte 1001 to 1100. Any other station requesting READ or WRITE would be denied. Of course, we can read through locks in xBase, so how do they do it? The xBase languages add an arbitrary number to the actual offset. Originally, Clipper used 1,000,000,000 + record offset. Fox used another offset, and I am not sure but I think it was 4,000,000,000. We'll call this huge number the Lock Offset. Later, Clipper changed the Lock Offset to the same as Fox for certain RDD's. (.CDX and .IDX) For years, even though Clipper could create .NDX indexes, it was not Lock Offset compatible with dBase, and using both platforms on the same data caused incorrect locking. The Lock Offset numbers are arbitrarily large to keep actual data files from crossing the limit. (hopefully, we aren't creating any 1 trillion byte files) (or 4 trillion for newer schemes) So, in an xBase file, record locks and writes are at Lock Offset + File Offset and reads are at File Offset, so they do not run into a lock. This allows "read through" Locks between xBase systems are only able to be used concurrently when the arbitrary Lock Offset is the same in both systems. So, in the above example, to lock the first record the Lock Offset would be 4,000,001,001 to 4,000,001,100. If both languages used the same offset, then the write lock would be correctly enforced. =0CdBASE II FILES -------------- The structure of dBASE II data files (*.dbf) -------------------------------------------- _______________________ _______ 0 | Version number *1| ^ |-----------------------| | =20 1 | Number of records | Record 2 | in data file (16 bit) | header |-----------------------| | _ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| _______ 3 | Date of last update | | / 0| Field name in ASCII | ^= =20 4 | YYMMDD | | / : (terminated by 00h) : | 5 | | | | | | | |-----------------------| | | 10| | | 6 | Length of each record | | | |-----------------------| For 7 | ( 16 bits ) *2| | | 11| Field type in ASCII *4| each |-----------------------|--|--- | |-----------------------|= field 8 | | | ^ | 12| Field length (binary)| | 9 | Field descriptor | | | ____/ |-----------------------| | : Array : | | 13| Field adress in memory| | : (Terminated by 0Dh) : | | 14| | | : : | | ______ |-----------------------| | : : | | \ 15| Field decimal count | | : : | | \_ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| _v_____ | | | | 519| | | | |-----------------------| | =20 520| Terminator *3|__|__v_ |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| = | 521| Records | | : : | : : | : : | : : | n| | | |__End_of_File__________| ___v____ End of file ( 1Ah ) *11 *1 dBASE II version no: 02h=20 =09 *2 Sum of lengths of all fields + 1 (deletion flag) *3 0Dh if all 32 fields present, otherwise 00h. *4 Field type: C, N or L =0CThe Structure of dBASE II index file ------------------------------------ This was previously precented as the structure of dBASE III index files. Checking with the actual header of an index made it obvious, that it did NOT fit with dBASE III index files ( In that case several of the most essential= =20 key fields should be NULL values ). _______________________ _______ 0 | (Reserved) | ^ 1 | | | |-----------------------| | 2 | Node number of | | 3 | root node | | |-----------------------| | 4 | Node number of | Anchor 5 | next available node | node |-----------------------| description 6 | Length of key | | |-----------------------| | 7 | Size of key entry | | |-----------------------| | 8 | Maximum keys/node | | |-----------------------| | 9 | Field type | | |-----------------------| | 10| Key expression in | | | ASCII | | : : | : : | | | | 109| (00h terminated) | | |-----------------------| | 110| (Unused) | | | | | _ : : | / |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| : : | / 0| Pointer to lower level| | | | / 1| (next page) | 511| ( 16 bits ) | | / |-----------------------| |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v_____ / 2| Record number | 0| No.of keys in node | ^ / 3| | |-----------------------| _|_____/ |-----------------------| 1| Array of key entries | | 4| Key expression | | | Index | | | | record : : |-----------------------| _|_____ : : : : | \ N| | 511| | | \______ |=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D| |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|= _v_____ =0CExamples -------- Description of test.dbf ----------------------- Name of data file : test.dbf Version no. : 5 Memo file present : 131 No. of records : 3 Length of header : 193 Length of records : 279 Date for latest change : 19960814 No. of fields : 5 Current record : 0 Crypted : no mdx/cdx file : no broken transaction : no Multi user information : 00 00 00 00 00 00 00 00 00 00 00 00 00 Field descriptions : Name Type length Decimal # ID N 5 0 # MSG C 254 0 # NOTE M 10 0 # BOOLEAN L 1 0 # DATES D 8 0 Description of test.ndx ----------------------- A index made on ID field in test.dbf Description of test.dbt ----------------------- A memo file containing the NOTE field from test.dbf =0CHex dump of test.dbf -------------------- 000000 83600811 03000000 C1001701 00000000 .`.............. 000010 00000000 00000000 00000000 00000000 ................ 000020 49440000 00000000 0000004E 0700DA3F ID.........N...? 000030 05000000 01000000 00000000 00000000 ................ 000040 4D534700 00000000 00000043 0C00DA3F MSG........C...? 000050 FE000000 01000000 00000000 00000000 ................ 000060 4E4F5445 00000000 0000004D 0A01DA3F NOTE.......M...? 000070 0A000000 01000000 00000000 00000000 ................ 000080 424F4F4C 45414E00 0000004C 1401DA3F BOOLEAN....L...? 000090 01000000 01000000 00000000 00000000 ................ 0000A0 44415445 53000000 00000044 1501DA3F DATES......D...? 0000B0 08000000 01000000 00000000 00000000 ................ 0000C0 0D202020 20203152 65636F72 64206E6F . 1Record no 0000D0 20312020 20202020 20202020 20202020 1 =20 0000E0 20202020 20202020 20202020 20202020 =20 0000F0 20202020 20202020 20202020 20202020 =20 000100 20202020 20202020 20202020 20202020 =20 000110 20202020 20202020 20202020 20202020 =20 000120 20202020 20202020 20202020 20202020 =20 000130 20202020 20202020 20202020 20202020 =20 000140 20202020 20202020 20202020 20202020 =20 000150 20202020 20202020 20202020 20202020 =20 000160 20202020 20202020 20202020 20202020 =20 000170 20202020 20202020 20202020 20202020 =20 000180 20202020 20202020 20202020 20202020 =20 000190 20202020 20202020 20202020 20202020 =20 0001A0 20202020 20202020 20202020 20202020 =20 0001B0 20202020 20202020 20202020 20202020 =20 0001C0 20202020 20202020 20202020 20203120 1=20 0001D0 31393936 30383133 2A202020 20324E6F 19960813* 2No 0001E0 20322020 20202020 20202020 20202020 2 =20 0001F0 20202020 20202020 20202020 20202020 =20 000200 20202020 20202020 20202020 20202020 =20 000210 20202020 20202020 20202020 20202020 =20 000220 20202020 20202020 20202020 20202020 =20 000230 20202020 20202020 20202020 20202020 =20 000240 20202020 20202020 20202020 20202020 =20 000250 20202020 20202020 20202020 20202020 =20 000260 20202020 20202020 20202020 20202020 =20 000270 20202020 20202020 20202020 20202020 =20 000280 20202020 20202020 20202020 20202020 =20 000290 20202020 20202020 20202020 20202020 =20 0002A0 20202020 20202020 20202020 20202020 =20 0002B0 20202020 20202020 20202020 20202020 =20 0002C0 20202020 20202020 20202020 20202020 =20 0002D0 20202020 20202020 20202020 20202020 =20 0002E0 20202020 20325931 39393630 38313420 2Y19960814=20 0002F0 20202020 334D6573 73616765 206E6F20 3Message no=20 000300 33202020 20202020 20202020 20202020 3 =20 000310 20202020 20202020 20202020 20202020 =20 000320 20202020 20202020 20202020 20202020 =20 000330 20202020 20202020 20202020 20202020 =20 000340 20202020 20202020 20202020 20202020 =20 000350 20202020 20202020 20202020 20202020 =20 000360 20202020 20202020 20202020 20202020 =20 000370 20202020 20202020 20202020 20202020 =20 000380 20202020 20202020 20202020 20202020 =20 000390 20202020 20202020 20202020 20202020 =20 0003A0 20202020 20202020 20202020 20202020 =20 0003B0 20202020 20202020 20202020 20202020 =20 0003C0 20202020 20202020 20202020 20202020 =20 0003D0 20202020 20202020 20202020 20202020 =20 0003E0 20202020 20202020 20202020 20202020 =20 0003F0 20202020 20202020 20202020 334E3139 3N19 000400 39363031 30321A 960102. =0CHex dump of test.ndx -------------------- 000000 01000000 02000000 00000000 08001F00 ................ 000010 01001000 00000000 49442000 80028403 ........ID ..... 000020 31002B00 03000100 03000100 01000100 1.+............. 000030 01000100 01000100 01000100 01000100 ................ 000040 01000100 01000100 01000100 01000100 ................ 000050 01000100 01000100 01000100 01000100 ................ 000060 01000100 01000100 01000100 01000100 ................ 000070 01000100 01000100 01000100 01000100 ................ 000080 01000100 01000100 01000100 01000100 ................ 000090 01000100 01000100 01000100 01000100 ................ 0000A0 01000100 01000100 01000100 01000100 ................ 0000B0 01000100 01000100 01000100 01000100 ................ 0000C0 01000100 01000100 01000100 01000100 ................ 0000D0 01000100 01000100 01000100 01000100 ................ 0000E0 01000100 01000100 01000100 01000100 ................ 0000F0 01000100 01D3EA03 DABA5800 03D03BDA ..........X...;. 000100 770CB8FE FFA20E69 5F5E8BE5 5DCB33DB w......i_^..].3. 000110 8EC3B452 CD218CC0 0BC37410 268E47FE ...R.!....t.&.G. 000120 26803E00 004D7504 8C060069 8E060269 &.>..Mu....i...i 000130 8CC1268B 1E010026 8B160300 83EA58BE ..&....&......X. 000140 00008B3E 0669A100 69C70600 6900008E ...>.i..i...i... 000150 C03BC174 153BC774 1C263B1E 01007515 .;.t.;.t.&;...u. 000160 4626A103 00050200 03D0833E 00690075 F&.........>.i.u 000170 048C0600 6926803E 00004D75 0A8CC026 ....i&.>..Mu...& 000180 03060300 40EBC889 56FE8936 0C69F746 ....@...V..6.i.F 000190 06100075 6AF74606 0100745C 1EB067B4 ...uj.F...t\..g. 0001A0 35CD218C C88ED8BE 15A5BF0A 00B90800 5.!............. 0001B0 F3A61F75 43B440CD 670AE475 3BB446CD ...uC.@.g..u;.F. 0001C0 670AE475 33C86F7C 26D632D6 326A01A5 g..u3.o|&.2.2j.. 0001D0 3420007C 26E4326C 10881411 346431F0 4 .|&.2l....4d1. 0001E0 32643104 00FA3340 07881415 34643133 2d1...3@....4d13 0001F0 003000EB 3F494400 F7460610 00754BF7 .0..?ID..F...uK. 000200 03000000 00000000 01000000 00000000 ................ 000210 0000F03F 00000000 02000000 00000000 ...?............ 000220 00000040 00000000 03000000 00000000 ...@............ 000230 00000840 00000000 5F03C102 5F035101 ...@...._..._.Q. 000240 7B007C00 7D005101 6C036D03 57026E03 {.|.}.Q.l.m.W.n. 000250 AE025702 54025101 A7025101 FB015900 ..W.T.Q...Q...Y. 000260 31005101 0C025D03 5101C302 C402C502 1.Q...].Q....... 000270 C602C702 C802C902 CA025101 C5010802 ..........Q..... 000280 AE034201 9B000902 2F02DA00 0A02FD02 ..B...../....... 000290 06000800 09000A00 0B000C00 0D000E00 ................ 0002A0 0F000700 AB00AD00 AE00AF00 B000B100 ................ 0002B0 B200B300 B400AC00 C5011F03 51014201 ............Q.B. 0002C0 5101DD01 5101DA00 5101FD02 C5015101 Q...Q...Q.....Q. 0002D0 51014201 51015101 51015101 5101FD02 Q.B.Q.Q.Q.Q.Q... 0002E0 51015101 51015101 51015101 43035101 Q.Q.Q.Q.Q.Q.C.Q. 0002F0 5101FD02 D2025F03 DC025F03 E0025F03 Q....._..._..._. 000300 DB025F03 DF025F03 DD025F03 DE025F03 .._..._..._..._. 000310 5702E102 57025402 51015602 E202D302 W...W.T.Q.V..... 000320 5201D402 AE02AF02 B002B102 B202B302 R............... 000330 52015402 51015E00 5F006000 61005101 R.T.Q.^._.`.a.Q. 000340 5602D502 D3025201 D802D902 5201DA02 V.....R.....R... 000350 AF02B002 52015702 54025101 CB02CC02 ....R.W.T.Q..... 000360 CD02CE02 CF02D002 51015602 AD02AE02 ........Q.V..... 000370 AF02B002 B102B202 54025702 51015602 ........T.W.Q.V. 000380 D602D302 5201AE02 D7025402 57025101 ....R.....T.W.Q. 000390 80023100 51018002 84033100 51018002 ..1.Q.....1.Q... 0003A0 31005101 11015F03 51014800 49005101 1.Q..._.Q.H.I.Q. 0003B0 A600C102 51014C03 31005101 4C038602 ....Q.L.1.Q.L... 0003C0 31005101 56021B00 54021D00 56025201 1.Q.V...T...V.R. 0003D0 5F031C00 51025602 AE02AF02 5802B002 _...Q.V.....X... 0003E0 B1025002 52015702 54025101 50025402 ..P.R.W.T.Q.P.T. 0003F0 1E001F00 51022000 5602B102 B302B502 ....Q. .V....... =0CHex dump of test.dbt -------------------- *1 *2 vvvvvvvv vvvvvvvv 000000 04000000 8701021D 03000002 5E126431 ............^.d1 000010 03000000 00000300 00008701 021D0300 ................ \ 000020 00025E12 64310300 00000000 02000000 ..^.d1.......... | 000030 8701021D 03000002 5E126431 03000000 ........^.d1.... | 000040 00000100 00006572 69632020 44617465 ......eric Date | 000050 20202020 204C6F67 6963616C 20204D65 Logical Me | 000060 6D6F2020 20202000 FF7604E8 26CF83C4 mo ..v..&... | 000070 0C5E5FC9 C3908B76 048B4606 50568976 .^_....v..F.PV.v | 000080 EA8946EC 900EE855 9B83C404 C45EEA2A ..F....U.....^.* | 000090 E4268A47 24C45E0A 268907C4 5EEA268A .&.G$.^.&...^.&. | Header 0000A0 47048E46 10268905 C45EEA26 F6471610 G..F.&...^.&.G.. | (mostly 0000B0 7503E9A3 00C45E0A 26832F02 5E5FC9C3 u.....^.&./.^_.. | garbage) 0000C0 6A01EB9A 16261F11 1F110300 C1009219 j....&.......... | 0000D0 00B8D80A BE197C26 16262411 24110300 ......|&.&$.$... | 0000E0 D500A619 00B8E20A D2197C26 BF186DD0 ..........|&..m. | 0000F0 0670A107 A1080672 CC026431 7C26BA19 .p.....r..d1|&.. | 000100 DC01CC19 D2196431 2F001100 21002F00 ......d1/...!./. | 000110 6D00D21A 0318CC19 21000300 D2196431 m.......!.....d1 | 000120 11002100 1E1B6431 03002020 20006163 ..!...d1.. .ac | 000130 74657200 5E5FC9C3 8B760023 2300268A ter.^_...v.##.&. | 000140 44032AE4 8CC1C45E 0A268907 8EC1268A D.*....^.&....&. | 000150 44028E46 10268905 5E5FC9C3 C8060000 D..F.&..^_...... | 000160 57568B4E 108B7E14 32C0F406 F10A1200 WV.N..~.2....... | 000170 F10A4400 8E1A3C1A F6006C22 08000F00 ..D...<...l".... | 000180 07000002 0A00246F 0A02DE13 D0367C26 ......$o.....6|& | 000190 2E018221 06727C26 0814820A F10A0700 ...!.r|&........ | 0001A0 0A00D036 00020A00 D0360000 00020700 ...6.....6...... | 0001B0 00060000 0000D136 2C14E707 F10A0F00 .......6,....... | 0001C0 10001900 D036726D 7C260000 07000000 .....6rm|&...... | 0001D0 00008C6D 08002A14 00007C26 9A018221 ...m..*...|&...! | 0001E0 46727C26 4614CB00 F10A0700 00000000 Fr|&F........... | 0001F0 00000700 0F060000 00008C6D 7C264E14 ...........m|&N. / 000200 54686973 20697320 61206D65 6D6F2066 This is a memo f \ <- 000210 6F726520 7265636F 7264206E 6F206F6E ore record no on | | *3 000220 651A1A11 C4D92E20 4C656176 65206D65 e...... Leave me |<- 000230 6E75202D 201B1A2E 20426C61 636B626F nu - ... Blackbo | 000240 61726420 2D204631 302E0052 616E6765 ard - F10..Range | 000250 2076616C 7565206D 75737420 6265206E value must be n | 000260 756D6572 69632E20 20507265 73732061 umeric. Press a | 000270 6E79206B 65792074 6F20636F 6E74696E ny key to contin | 000280 75652E00 2500EA08 00AA209A D0027F1D ue..%..... ..... | 000290 2400EA00 00911F9A D0027F1D 1100EA00 $............... | 0002A0 00451E9A D0027F1D 0800EA14 08D21D9A .E.............. | 0002B0 D0027F1D 1000EA00 00451E9A D0027F1D .........E...... | 0002C0 1900EA00 00D21D9A D0027F1D 0C00EA00 ................ | 0002D0 00D21D9A D0027F1D 1800EA00 00D21D9A ................ | 0002E0 D0027F1D 0A00EA00 00D21D9A D0027F1D ................ | 0002F0 1300EA00 0068219A D0027F1D 1200EA00 .....h!......... | 000300 0068219A D0027F1D 1400EA00 0068219A .h!..........h!. | 000310 D0027F1D 1600EA00 0068219A D0027F1D .........h!..... | 000320 1600EA05 0368219A D0027F1D 1500EA00 .....h!......... | 000330 0068219A D0027F1D 1200EA24 0968219A .h!........$.h!. | 000340 D0027F1D 1200EAC8 0E68219A D0027F1D .........h!..... | 000350 1200EA82 1268219A D0027F1D 1200EABD .....h!......... | 000360 0168219A D0027F1D 1200EAA8 1468219A .h!..........h!. | 000370 D0027F1D 1200EA7D 0068219A D0027F1D .......}.h!..... | 000380 1200EA3D 0068219A D0027F1D 1200EAB2 ...=3D.h!......... | 000390 0068219A D0027F1D 1200EA1A 0D68219A .h!..........h!. | 0003A0 D0027F1D 1200EAE3 1268219A D0027F1D .........h!..... | 0003B0 1200EA44 1368219A D0027F1D 2400EA35 ...D.h!.....$..5 | 0003C0 09911F9A D0027F1D 2400EA4F 0B911F9A ........$..O.... | 0003D0 D0027F1D 2400EA56 1E911F9A D0027F1D ....$..V........ | 0003E0 2400EAC7 1E911F00 00000000 00000000 $............... | 0003F0 BE000026 8B8C0400 41742E26 8B940800 ...&....At.&.... _| 000400 54686973 20697320 6D656D6F 20666F72 This is memo for \ <- Second 000410 20726563 6F726420 321A1A1C 00040000 record 2....... |<- entry 000420 E54F5445 30332020 4E445800 00000000 .OTE03 NDX..... | 000430 00000000 00002099 8C1F8945 00040000 ...... ....E.... | 000440 E54F5445 30202020 44425400 00000000 .OTE0 DBT..... | 000450 00000000 00009C94 821F9345 00040000 ...........E.... | 000460 E54F5445 30202020 44424600 00000000 .OTE0 DBF..... | Second=20 000470 00000000 00009C94 821F9445 28020000 ...........E(... | block 000480 E54F5445 30342020 4E445800 00000000 .OTE04 NDX..... | 000490 00000000 00002232 8D1F6E1C 00040000 ......"2..n..... | 0004A0 E5455820 20202020 20202000 00000000 .EX ..... | 0004B0 00000000 00004C32 8D1F8A45 FD2F0000 ......L2...E./.. | 0004C0 E545447B 45442020 45444320 00000000 .ED{ED EDC .... | 0004D0 00000000 00008532 8D1F0000 00000000 .......2........ | 0004E0 E545447B 45443120 45445420 00000000 .ED{ED1 EDT .... | 0004F0 00000000 00008532 8D1F0000 00000000 .......2........ | 000500 E545447B 45443120 45444220 00000000 .ED{ED1 EDB .... | 000510 00000000 00008532 8D1F0000 00000000 .......2........ | 000520 E545447B 45442020 45445320 00000000 .ED{ED EDS .... | 000530 00000000 00008532 8D1F8D45 00100000 .......2...E.... | 000540 00000000 00000000 00000000 00000000 ................ | 000550 00000000 00000000 00000000 00000000 ................ | 000560 00000000 00000000 00000000 00000000 ................ | 000570 00000000 00000000 00000000 00000000 ................ | 000580 00000000 00000000 00000000 00000000 ................ | 000590 00000000 00000000 00000000 00000000 ................ | 0005A0 00000000 00000000 00000000 00000000 ................ | 0005B0 00000000 00000000 00000000 00000000 ................ | 0005C0 00000000 00000000 00000000 00000000 ................ | 0005D0 00000000 00000000 00000000 00000000 ................ | 0005E0 00000000 00000000 00000000 00000000 ................ | 0005F0 00000000 00000000 00000000 00000000 ................ _| 000600 54686973 20697320 6D656D6F 20331A1A This is memo 3.. <- 3rd entry= *4) *1) First 4 bytes indicates no. of next free block *2) (FoxBase) Size of blocks. This is a dBASE III+ file and byte 4-511 is just garbage. *3) First entry (terminated by 1Ah 1Ah) *4) NOTE! Last entry is NOT a complete block. dBASE does not write the full block to the memo file. The block contains the memo + terminator (1Ah 1Ah) =0CdBASE Specifications -------------------- dBASE II dBASE III dBASE IV Max. no. of records 1,000,000,000 1,000,000,000 Max. fields per record 128 255 Max. data files open 10 10 Max. index files per open database 7 47 Max. record size 4,000 bytes 4000 bytes Max. records per file 65,535 Max. bytes per file 8,000,000 Max. memory variables 256 Max. memory for variables 6,000 bytes *3 No. of data types 5 6 Max. size of MEMO file 5000 bytes 64000 bytes Max. character field size 254 bytes 254 bytes Max. numerical field size 19 bytes 20 bytes Size of logical field 1 byte 1 byte Size of date field 8 bytes 8 bytes Size of memo pointer in DBF 10 bytes Size of floating point - - 1-2 *3 Can be expanded to 31 KB using CONFIG, 6 KB is mentioned as= default. HOW DO THEY WORK ---------------- Still under construction. Please ignore this page. Field Descriptor Array (*.dbf) _______________________ _______ 0| Field name in ASCII | ^ | | | | | | : : Field=20 : : Description | | (for each field) 10| | | |-----------------------| | 11| Field type in ASCII | | |-----------------------| | 12| Field data address | | | | | | | | 15| | | |-----------------------| | 16| Field length (binary)| | |-----------------------| | 17| Decimal count (binary)| | |-----------------------| | 18| ( Reserved ) | | | | | : : | | | | 31| | | |-----------------------| _v______ =0CHISTORY ------- 1996-10-18 Chapter on read/write locks using share by Phil Barnett= (philb@iag.net) 1996-10-15 Change in description of structure of index files.=20 Major mistake! The previous version described the structure for dBASE II index files. Only excuse: This mistake was made by several of my sources :-( 1996-10-03 First public version of this document (as far as I remember :-) =0CREFERENCE LIST -------------- 1 Bachmann, Erik: =20 Xbase : File format description / Erik Bachmann. - Copenhagen : Clickety Click Software, 1996. - aprox. 13 pg. ; ASCII text file 2 Castro, L.: =20 Advanced programmer's guide featuring dBASE III and dBASE II / L. Castro. - Culver City, California, USA : Ashton-Tate, 1985. - 10+664 pg. - ISBN 0-912677-05-8 =20 Note: Litterature list and Terminology list =20 3=20 dBASE .DBF File Structure. - (Borland Technical Documents ; TI12821) =20 URL: http://loki.borland.com/winbin/bds.exe?getdoc+2821+Delphi =20 4 Eacker, Brad: =20 DBF : A set of tools and library routines to manipulate xbase files= / Brad Eacker : Silicon Graphics, 1994. - Computer files ; C= source ; ASCII text =20 Note: UUNET vol. 43 1994 =20 =20 Abstract: UUnet : volume43 (Period: 08 Jun 94 - 24 Jul 94),=20 dbf/part0[1-2] : dbf - xbase manipulation package =20 URL: ftp://ftp.uu.net/usenet/comp.sources.misc/volumen43/dbf/part01 =20 5=20 Err : "Not a Database File". - (Microsoft Knowledge Base. ; Article Q98743) =20 URL: http://www.microsoft.com/kb/developr/fox/q98742.htm =20 6 Gmelch, Rasca: =20 libdbf : simple routines for accessing xbase data files / Rasca Gmelch. - Berlin, 1996. - Computer files ; C source ; ASCII text =20 URL: http://home.pages.de/~rasca/dbflib/ =20 7 Hogan, T.: =20 The Programmes's PC sourcebook : Reference tables for IBM PCs and compatibles, PS/2 systems, EISA-based systems, MS-DOS operating system through version 5, Microsoft Windows through version 3 : Hundred of new charts and tables / T. Hogan. - Redmond, Washington, USA : Microsoft Press, 1991. - Multiple pagination.= - ISBN 1-55615-321-X 8=20 How to Modify the Table Header from FoxPro. - (Microsoft Knowledge Base. ; Article Q139758 ; ) =20 URL: http://www.microsoft.com/kb/developr/fox/q139758.htm =20 9 Simpson, Alan: =20 dBASE III PLUS : Programmer's Reference Guide / Alan Simpson. - Almeda : Sybex Inc., 1987. - 1029 pg. - ISBN 0-89588-301-5 =20 Abstract: Data file structure and memo file structure for xBase 10 Stevens, A.: =20 Turbo C : Memory-resistent utilities, screen I/O and programming techniques / A. Stevens. - Portland, Origon, USA : MIS Press, 1987. - 10+315 pg. - ISBN 0-943518-35-0 =20 Note: Video Windows and TSR utility programs =20 11 Townsend, Carl: =20 Mastering dBASE III : A Structured Apporach / Carl Townsend. - Berkeley : Sybex Inc., 1985. - ISBN 0-89588-301-5 =20 Abstract: Data file structure and index file structure for xBase 12 Walden, J.: =20 File formats for popular PC software : A programmer's reference / J. Walden. - New York, New York, USA : Wiley, 1986. - 16+287 pg. - ISBN 0-471-83671-0 /*** End of File= ************************************************************/