]> Nishi Git Mirror - dataworks.git/commitdiff
check endian and stuff
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 00:28:39 +0000 (00:28 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 00:28:39 +0000 (00:28 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@19 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/main.c
FORMAT
Library/dataworks.c
Library/dataworks.h

index af8d04c58a619473375abeb07258c7ecc1cc5732..32592329b8ed8206ef3b76d328a5a2bac763c505 100644 (file)
@@ -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 e29b2faa662ee31867ff18f15b96adfbb9d482cb..443503df75fe96d028a554fe2cc04f3dc24ffe56 100644 (file)
--- 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$
index 899d43ed1957c2531bfaac11158ec5b3f6d1e5ff..15eb4d9210737e6045830cd820d5438763ee3f89 100644 (file)
@@ -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';
+}
index 4725a7557963ca64552dc583a82066325e292308..b3d10212d82f0ed590eb7ded42a58cf2461dacde 100644 (file)
@@ -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