From 7a0a12520b04c99ac2a97d7da8edb64e56867dcb Mon Sep 17 00:00:00 2001 From: nishi Date: Mon, 20 May 2024 06:19:06 +0000 Subject: [PATCH] markdown time git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@43 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Document/Doxyfile | 3 +- FORMAT | 55 ------------------------------------ FORMATv1.md | 66 +++++++++++++++++++++++++++++++++++++++++++ Library/Makefile | 2 +- Library/dw_database.h | 15 ++++++++++ 5 files changed, 84 insertions(+), 57 deletions(-) delete mode 100644 FORMAT create mode 100644 FORMATv1.md diff --git a/Document/Doxyfile b/Document/Doxyfile index c52b7b1..52d379a 100644 --- a/Document/Doxyfile +++ b/Document/Doxyfile @@ -21,9 +21,10 @@ GENERATE_MAN = YES MAN_OUTPUT = man HTML_OUTPUT = html INPUT += index.md +INPUT += ../FORMATv1.md USE_MDFILE_AS_MAINPAGE = index.md FULL_PATH_NAMES = YES -STRIP_FROM_PATH = ../Library/ +STRIP_FROM_PATH = ../Library/ ../ IMAGE_PATH = .. ENABLED_SECTIONS = YES OUTPUT_LANGUAGE = English diff --git a/FORMAT b/FORMAT deleted file mode 100644 index e85cf7f..0000000 --- a/FORMAT +++ /dev/null @@ -1,55 +0,0 @@ -DataWorks Database Format 1.0 -============================================== -Extension SHOULD be .dwf - -All numbers MUST use big-endiam - -First 3 bytes MUST be 7F 44 57 (\x7F DW) (`signature`) - -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 -fragnum : 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. -Fragment : 0b01000000 Flag this if the entry is fragment. - -Index entry (`indexentry`) MUST be in this format: -flag : 1 byte uint8_t -count : 8 bytes uint64_t -dbname_len : 1 byte 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` - uint64_t for the last modified time - 256 `indexentry` - `dbentry` 0 - `dbentry` 1 - ... - `dbentry` n -============================================== -$Id$ diff --git a/FORMATv1.md b/FORMATv1.md new file mode 100644 index 0000000..a908064 --- /dev/null +++ b/FORMATv1.md @@ -0,0 +1,66 @@ +# DataWorks Database Format 1.0 + +DataWorks is a simple database format designed for DataWorks. + +## Specification + +You SHOULD use `.dwf` for the extension. + +All numbers MUST use big-endian. + +### File structure + +First 3 bytes MUST be 7F 44 57 (\x7F DW) (`signature`) + +Database entry (`dbentry`) MUST be in this format: + +| Name | Size | Type | Info | +| ---- | ----- | ---- | ---- | +| length | 4 bytes | uint32\_t | Size of the entry | +| 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 | | +| fragnum | 8 bytes | uint64\_t | | +| data | \[size\] bytes | ASCII | | + +There are 5 types for `dbentry`: +| Type | Character | Type | Info | +| ---- | --------- | ---- | ---- | +| 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 2 flags for `dbentry`: +| Type | Mask | Info | +| ---- | ---- | ---- | +| Used | 0b10000000 | Flag this if you are using the entry. | +| Fragment | 0b01000000 | Flag this if the entry is fragment. | + +Index entry (`indexentry`) MUST be in this format: +flag : 1 byte uint8_t +count : 8 bytes uint64_t +dbname_len : 1 byte 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` + uint64_t for the last modified time + 256 `indexentry` + `dbentry` 0 + `dbentry` 1 + ... + `dbentry` n diff --git a/Library/Makefile b/Library/Makefile index 9957f5c..60a464f 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -18,4 +18,4 @@ $(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX): $(OBJS) $(CC) $(CFLAGS) -DPLATFORM_M=\"$(PLATFORM_M)\" -DPLATFORM_P=\"$(PLATFORM_P)\" -fPIC -c -o $@ $< clean: - rm -f *.o *.so *.dll + rm -f *.o *.so *.dll *.a diff --git a/Library/dw_database.h b/Library/dw_database.h index 47815ac..cceba01 100644 --- a/Library/dw_database.h +++ b/Library/dw_database.h @@ -71,12 +71,27 @@ struct dataworks_db { uint64_t mtime; }; +/** + * @~english + * @ref FORMAT + * @brief indexentry for v1 database. + * + */ +struct dataworks_db_v1_indexentry { + uint8_t flag; + uint64_t count; + uint8_t dbname_len; + char dbname[256]; + char fields[4096]; +}; + /** * @~english * @brief Creates the database. * @param fname Filename * @return 0 if successful * + * */ int dataworks_database_create(const char* fname); -- 2.43.0