From: nishi Date: Sat, 18 May 2024 02:37:25 +0000 (+0000) Subject: format update X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0ef49823664a482c3dea3012e2376e5ad6d294d3;p=dataworks.git format update git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@20 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/FORMAT b/FORMAT index 443503d..3f70d55 100644 --- a/FORMAT +++ b/FORMAT @@ -1,12 +1,52 @@ -DataWorks Database Format +DataWorks Database Format 1.0 ============================================== Extension should be .dwf +All numbers MUST use big-endiam -First 3 bytes should be 7F 44 57 (\x7F DW) +First 3 bytes MUST be 7F 44 57 (\x7F DW) (`signature`) -Every entries should look like this: -type: 1 byte ASCII -length: 4, uint32_t +Database entry (`dbentry`) MUST be in this format: +length : 4 bytes uint32_t +size : 4 bytes uint32_t +type : 1 byte ASCII +flag : 1 byte uint8_t +field_index: 1 byte uint8_t +db_index : 1 byte uint8_t +count : 8 bytes uint64_t +data : [size] bytes ASCII (but you SHOULD read only [length] bytes. Use [size] to skip paddings!) + +There are 5 types for `dbentry`: +String : 'S' ASCII +Integer : 'I' uint64_t +Double : 'D' double +Logical : 'L' uint8_t (0 for false, other value for true) +Help : '?' ASCII, should be just ignored + +and 1 flag for `dbentry`: +Used : 0b10000000 Flag this if you are using the entry. + +Index entry (`indexentry`) MUST be in this format: +flag : 1 byte uint8_t +count : 8 bytes uint64_t +dbname_len : 8 bytes uint8_t +dbname : 256 bytes ASCII +fields : 4096 bytes ASCII (Separate field names using NUL. Put NUL twice on the last field name.) + +There is 1 flag for `indexentry`: +Used : 0b10000000 Flag this if you are using the entry. + +Info entry (`infoentry`) MUST be in this format: +version : 2 bytes uint16_t (MUST be 1 for 1.0) +`infoentry` IS the only thing which SHOULD be compatible in later format. + +File MUST look like this: + `signature` + `infoentry` + 256 `indexentry` + `dbentry` 0 + `dbentry` 1 + ... + `dbentry` n ============================================== $Id$ diff --git a/Library/dataworks.c b/Library/dataworks.c index 15eb4d9..2399f12 100644 --- a/Library/dataworks.c +++ b/Library/dataworks.c @@ -46,6 +46,6 @@ const char* dataworks_get_version(void) { return dataworks_version; } const char* dataworks_get_compile_date(void) { return dataworks_compile_date; } const char* dataworks_get_platform(void) { return dataworks_platform; } char dataworks_get_endian(void) { - unsigned short n = 1; + volatile unsigned short n = 1; return *(char*)&n == 1 ? 'L' : 'B'; }