Beispiel #1
0
/* print members of fixed-length database */
static void mprint(TCFDB *fdb){
  if(fdb->cnt_writerec < 0) return;
  my_my_my_iprintf("minimum ID number: %llu\n", (unsigned long long)tcfdbmin(fdb));
  my_my_my_iprintf("maximum ID number: %llu\n", (unsigned long long)tcfdbmax(fdb));
  my_my_my_iprintf("width of the value: %u\n", (unsigned int)tcfdbwidth(fdb));
  my_my_my_iprintf("limit file size: %llu\n", (unsigned long long)tcfdblimsiz(fdb));
  my_my_my_iprintf("limit ID number: %llu\n", (unsigned long long)tcfdblimid(fdb));
  my_my_my_iprintf("cnt_writerec: %lld\n", (long long)fdb->cnt_writerec);
  my_my_my_iprintf("cnt_readrec: %lld\n", (long long)fdb->cnt_readrec);
  my_my_my_iprintf("cnt_truncfile: %lld\n", (long long)fdb->cnt_truncfile);
}
Beispiel #2
0
/* perform inform command */
static int procinform(const char *path, int omode) {
    TCFDB *fdb = tcfdbnew();
    if (!INVALIDHANDLE(g_dbgfd)) tcfdbsetdbgfd(fdb, g_dbgfd);
    if (!tcfdbopen(fdb, path, FDBOREADER | omode)) {
        printerr(fdb);
        tcfdbdel(fdb);
        return 1;
    }
    bool err = false;
    const char *npath = tcfdbpath(fdb);
    if (!npath) npath = "(unknown)";
    printf("path: %s\n", npath);
    const char *type = "(unknown)";
    switch (tcfdbtype(fdb)) {
        case TCDBTHASH: type = "hash";
            break;
        case TCDBTBTREE: type = "btree";
            break;
        case TCDBTFIXED: type = "fixed";
            break;
        case TCDBTTABLE: type = "table";
            break;
    }
    printf("database type: %s\n", type);
    uint8_t flags = tcfdbflags(fdb);
    printf("additional flags:");
    if (flags & FDBFOPEN) printf(" open");
    if (flags & FDBFFATAL) printf(" fatal");
    printf("\n");
    printf("minimum ID number: %" PRIu64 "\n", (uint64_t) tcfdbmin(fdb));
    printf("maximum ID number: %" PRIu64 "\n", (uint64_t) tcfdbmax(fdb));
    printf("width of the value: %u\n", (unsigned int) tcfdbwidth(fdb));
    printf("limit file size: %" PRIu64 "\n", (uint64_t) tcfdblimsiz(fdb));
    printf("limit ID number: %" PRIu64 "\n", (uint64_t) tcfdblimid(fdb));
    printf("inode number: %" PRId64 "\n", (int64_t) tcfdbinode(fdb));
    char date[48];
    tcdatestrwww(tcfdbmtime(fdb), INT_MAX, date);
    printf("modified time: %s\n", date);
    printf("record number: %" PRIu64 "\n", (uint64_t) tcfdbrnum(fdb));
    printf("file size: %" PRIu64 "\n", (uint64_t) tcfdbfsiz(fdb));
    if (!tcfdbclose(fdb)) {
        if (!err) printerr(fdb);
        err = true;
    }
    tcfdbdel(fdb);
    return err ? 1 : 0;
}