/* perform inform command */ static int procinform(const char *path, int omode) { TCBDB *bdb = tcbdbnew(); if (!INVALIDHANDLE(g_dbgfd)) tcbdbsetdbgfd(bdb, g_dbgfd); tcbdbsetcmpfunc(bdb, mycmpfunc, NULL); tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL); if (!tcbdbopen(bdb, path, BDBOREADER | omode)) { printerr(bdb); tcbdbdel(bdb); return 1; } bool err = false; const char *npath = tcbdbpath(bdb); if (!npath) npath = "(unknown)"; printf("path: %s\n", npath); printf("database type: btree\n"); uint8_t flags = tcbdbflags(bdb); printf("additional flags:"); if (flags & BDBFOPEN) printf(" open"); if (flags & BDBFFATAL) printf(" fatal"); printf("\n"); TCCMP cmp = tcbdbcmpfunc(bdb); printf("comparison function: "); if (cmp == tccmplexical) { printf("lexical"); } else if (cmp == tccmpdecimal) { printf("decimal"); } else if (cmp == tccmpint32) { printf("int32"); } else if (cmp == tccmpint64) { printf("int64"); } else { printf("custom"); } printf("\n"); printf("max leaf member: %d\n", tcbdblmemb(bdb)); printf("max node member: %d\n", tcbdbnmemb(bdb)); printf("leaf number: %" PRIuMAX "\n", (uint64_t) tcbdblnum(bdb)); printf("node number: %" PRIuMAX "\n", (uint64_t) tcbdbnnum(bdb)); printf("bucket number: %" PRIuMAX "\n", (uint64_t) tcbdbbnum(bdb)); #ifndef NDEBUG if (bdb->hdb->cnt_writerec >= 0) printf("used bucket number: %" PRIdMAX "\n", (int64_t) tcbdbbnumused(bdb)); #endif printf("alignment: %u\n", tcbdbalign(bdb)); printf("free block pool: %u\n", tcbdbfbpmax(bdb)); printf("inode number: %" PRIdMAX "\n", (int64_t) tcbdbinode(bdb)); char date[48]; tcdatestrwww(tcbdbmtime(bdb), INT_MAX, date); printf("modified time: %s\n", date); uint8_t opts = tcbdbopts(bdb); printf("options:"); if (opts & BDBTLARGE) printf(" large"); if (opts & BDBTDEFLATE) printf(" deflate"); if (opts & BDBTBZIP) printf(" bzip"); if (opts & BDBTTCBS) printf(" tcbs"); if (opts & BDBTEXCODEC) printf(" excodec"); printf("\n"); printf("record number: %" PRIuMAX "\n", (uint64_t) tcbdbrnum(bdb)); printf("file size: %" PRIuMAX "\n", (uint64_t) tcbdbfsiz(bdb)); if (!tcbdbclose(bdb)) { if (!err) printerr(bdb); err = true; } tcbdbdel(bdb); return err ? 1 : 0; }
/* Get the inode number of the database file of a word database object. */ uint64_t tcwdbinode(TCWDB *wdb){ assert(wdb); return tcbdbinode(wdb->idx); }