Binary databases
From Acarsd
acarsd binary databases - extension .db
acarsd use binary databases. Why?
With indexes the search within our databases is very fast. The fixed record format is easy to handle and to use within acarsd and can also be included into other programs.
How to read binary acarsd database?
To read the databases you should write a small program in your favorite computer language (C, Pascal, C++, Java or something else). All databases have a binary header of 13 bytes. These 13 bytes contains the following:
- count of collection items (long integer)
- count of collection limit (long integer)
- count of items to increment the database content (long integer)
- collection revision and dupe settings (unsigned char, dupes on/off is bit 0)
after this header you can read the main content (every single record) of the database. Please note, that there are special formats for our databases.
Record format of the main acarsd database acarsd.db
struct acarsdata {
time_t timestamp;
int day, month, year;
unsigned char mode, blockid;
char label[3], reg[8], msgno[5], flightnum[7];
char from[5], to[5], via[5];
char *message, *type, *flight, *operator;
/* Original data before translation */
char *oflight, *oreg;
};
To read a record from the database you can read first all items with one read command until char *message. From here you have todo the following steps: Read a single integer from the file. Now read X bytes from the file. X is the integer from the first read operation. If X is 0 than the following string is empty (NULL) and you have to read the next integer until oreg.
Now you have a complete ACARS record.
Be carefull if you modify these databases. acarsd has a small errorchecking for corrupt databases but under some circumstances acarsd can crash.
The format of the airlines, groundstation and ACARS modes database is the following:
struct dbstruct {
char *idx, *full;
long count;
};
The flight database has the following structure:
typedef struct {
char *flight; // Flightnumber
char *route; // Route (Style: FROM-VIA-VIA-VIA-TO)
char *remark; // Remarks
unsigned char days; // Flight valid only on X marked days
// the next flight is new from acarsd 1.65Beta1
time_t validuntil; // Entry is valid until...
} FlDB;
The aircraft (and of cause the second important database for acarsd) is defined as:
typedef struct {
char *reg; // Main Key
char *ac, *acshort, *acfull; // Aircraft types
char *cn; // ConNum
char *opiata, *opicao; // Operator (IATA Code and ICAO Code)
char *trans; // Actual registration
char *remark; // Remarks, Infos
} AcDB;
and the last one, the acarsd airport database:
typedef struct {
char *idx, *name;
double north, east;
} Airports;

