From: nishi Date: Wed, 22 May 2024 01:07:55 +0000 (+0000) Subject: trying to fix X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f416d9e4a32257088bce5c69152621b47abb194e;p=dataworks.git trying to fix git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@61 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Library/database.c b/Library/database.c index 98c3a19..721d2ff 100644 --- a/Library/database.c +++ b/Library/database.c @@ -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 */ diff --git a/Library/dw_database.h b/Library/dw_database.h index fd21d13..9b5ed2a 100644 --- a/Library/dw_database.h +++ b/Library/dw_database.h @@ -43,6 +43,8 @@ extern "C" { #include #include +#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;