From: nishi Date: Sat, 18 May 2024 00:28:39 +0000 (+0000) Subject: check endian and stuff X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=fa2b7a036f7d703015ec0a36dc51ca324de837bf;p=dataworks.git check endian and stuff git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@19 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/main.c b/Client/main.c index af8d04c..3259232 100644 --- a/Client/main.c +++ b/Client/main.c @@ -77,6 +77,11 @@ int main(int argc, char** argv) { fflush(stdout); } printf("DataWorks version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform()); + if(dataworks_get_endian() == 'L') { + printf("This system is little-endian.\n"); + } else { + printf("This system is big-endian.\n"); + } printf("\n"); printf("Copyright (c) Nishi 2024\n"); printf("All rights reserved.\n"); diff --git a/FORMAT b/FORMAT index e29b2fa..443503d 100644 --- a/FORMAT +++ b/FORMAT @@ -1,6 +1,12 @@ DataWorks Database Format ============================================== Extension should be .dwf + + First 3 bytes should be 7F 44 57 (\x7F DW) + +Every entries should look like this: +type: 1 byte ASCII +length: 4, uint32_t ============================================== $Id$ diff --git a/Library/dataworks.c b/Library/dataworks.c index 899d43e..15eb4d9 100644 --- a/Library/dataworks.c +++ b/Library/dataworks.c @@ -40,8 +40,12 @@ const char* dataworks_platform = "Linux/" #else const char* dataworks_platform = "Unknown/" #endif -PLATFORM_M " (" PLATFORM_P ")"; + PLATFORM_M " (" PLATFORM_P ")"; 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; + return *(char*)&n == 1 ? 'L' : 'B'; +} diff --git a/Library/dataworks.h b/Library/dataworks.h index 4725a75..b3d1021 100644 --- a/Library/dataworks.h +++ b/Library/dataworks.h @@ -64,6 +64,14 @@ const char* dataworks_get_compile_date(void); */ const char* dataworks_get_platform(void); +/** + * @~english + * @brief Get the compilation endian of DataWorks + * @return Compilation endian of DataWorks + * + */ +char dataworks_get_endian(void); + #ifdef __cplusplus } #endif