/* PROGRAM: fixnbyte.c USAGE: fixnbyte This program fixes the block_dir_entry.block_nbytes and block_hdr.block_nbytes fields in a CODAS3 database to correctly reflect the size of the referenced block file. This fixes a bug in the old CODAS3 source that caused the block_hdr.block_nbytes field to be underreported by the size of the profile directory at load time, and to be overreported by some multiple of the profile directory size depending on what kind of updating has been done to the block file. */ #include "dbinc.h" #include "use_db.h" int main(int argc, char *argv[]) { FILE_NAME_TYPE dbname; int iblkprf[2]; if (argc < 2) { printf("\n Enter database name ==> "); gets_ok(dbname, sizeof(dbname)); } else strcpy(dbname, argv[1]); if (dbopen_cnf(1, dbname, READ_WRITE, DIR_IN_MEMORY)) return 1; iblkprf[0] = iblkprf[1] = 0; do { fseek(db_ptr->fpblkdata, 0L, 2); db_ptr->block_hdr.block_nbytes = ftell(db_ptr->fpblkdata); db_ptr->block_dir_entry.block_nbytes = db_ptr->block_hdr.block_nbytes; write_block_hdr(); write_block_dir_entry(); ++iblkprf[0]; } while (dbsrch_cnf(BLOCK_PROFILE_SEARCH, (char *) iblkprf) == 0); dbclose_cnf(); return 0; }