]> Nishi Git Mirror - dataworks.git/commitdiff
trying to fix
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 22 May 2024 01:07:55 +0000 (01:07 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 22 May 2024 01:07:55 +0000 (01:07 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@61 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Library/database.c
Library/dw_database.h

index 98c3a196ed7db6c71d41c0ff333baf1c657515f0..721d2ff0fef42384f994336cc2ff5ecfb32552f7 100644 (file)
@@ -123,6 +123,19 @@ char** dataworks_database_get_table_list(struct dataworks_db* db){
        if(db->version == 1){
                __dw_lockfile(db->fp);
                fseek(db->fp, sizeof(sig) + 10, SEEK_SET);
+               struct dataworks_db_v1_indexentry index;
+               printf("%d\n", sizeof(index));
+               int i;
+               for(i = 0; i < 256; i++){
+                       fread(&index, 1, sizeof(index), db->fp);
+                       if(index.flag & DATAWORKS_V1_INDEXENTRY_USED){
+                               printf("%d\n", index.dbname_len);
+                               printf("[");
+                               fflush(stdout);
+                               fwrite(index.dbname, 1, index.dbname_len, stdout);
+                               printf("]\n");
+                       }
+               }
                __dw_unlockfile(db->fp);
        }else{
                /* Not implemented for the version */
index fd21d13978dec018b37301e8bd30014118162ce1..9b5ed2a38787f43d880d8c2873cf6292a6f42469 100644 (file)
@@ -43,6 +43,8 @@ extern "C" {
 #include <stdint.h>
 #include <stdio.h>
 
+#define PACKED __attribute__((packed))
+
 /**
  * @~english
  * @brief Database struct
@@ -77,6 +79,7 @@ struct dataworks_db {
  * @note See \ref FORMATv1 for more info.
  *
  */
+PACKED
 struct dataworks_db_v1_indexentry {
        uint8_t flag;
        uint64_t count;
@@ -85,12 +88,21 @@ struct dataworks_db_v1_indexentry {
        char fields[4096];
 };
 
+/**
+ * @~english
+ * @brief "Used" bitmask for indexentry for v1 database.
+ * @note See \ref FORMATv1 for more info.
+ *
+ */
+#define DATAWORKS_V1_INDEXENTRY_USED (1 << 7)
+
 /**
  * @~english
  * @brief infoentry for database.
  * @note See \ref FORMATv1 for more info.
  *
  */
+PACKED
 struct dataworks_db_infoentry {
        uint16_t version;
        uint64_t mtime;