コード例 #1
0
ファイル: tokyocabinettest.c プロジェクト: mita/Test
static void close_db(void *db)
{
	if (adb != db)
		return;

	if (!tcadbclose(adb))
		die("close error: %s", tcadbpath(adb));

	tcadbdel(adb);
	adb = NULL;
}
コード例 #2
0
ファイル: tcamgr.c プロジェクト: Fleurer/nanodb
/* perform inform command */
static int procinform(const char *name){
  TCADB *adb = tcadbnew();
  ADBSKEL skel;
  if(*name == '@'){
    setskeltran(&skel);
    if(!tcadbsetskel(adb, &skel)){
      printerr(adb);
      skel.del(skel.opq);
      tcadbdel(adb);
      return 1;
    }
    name++;
  } else if(*name == '%'){
    if(!tcadbsetskelmulti(adb, 8)){
      printerr(adb);
      tcadbdel(adb);
      return 1;
    }
    name++;
  }
  if(!tcadbopen(adb, name)){
    printerr(adb);
    tcadbdel(adb);
    return 1;
  }
  bool err = false;
  const char *path = tcadbpath(adb);
  if(!path) path = "(unknown)";
  printf("path: %s\n", path);
  const char *type = "(unknown)";
  switch(tcadbomode(adb)){
  case ADBOVOID: type = "not opened"; break;
  case ADBOMDB: type = "on-memory hash database"; break;
  case ADBONDB: type = "on-memory tree database"; break;
  case ADBOHDB: type = "hash database"; break;
  case ADBOBDB: type = "B+ tree database"; break;
  case ADBOFDB: type = "fixed-length database"; break;
  case ADBOTDB: type = "table database"; break;
  case ADBOSKEL: type = "skeleton database"; break;
  }
  printf("database type: %s\n", type);
  printf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
  printf("size: %llu\n", (unsigned long long)tcadbsize(adb));
  if(!tcadbclose(adb)){
    printerr(adb);
    err = true;
  }
  tcadbdel(adb);
  return err ? 1 : 0;
}
コード例 #3
0
ファイル: tcamttest.c プロジェクト: Fleurer/nanodb
/* print error message of abstract database */
static void eprint(TCADB *adb, int line, const char *func){
  const char *path = adb ? tcadbpath(adb) : NULL;
  fprintf(stderr, "%s: %s: %d: %s: error\n", g_progname, path ? path : "-", line, func);
}
コード例 #4
0
ファイル: tcamgr.c プロジェクト: Fleurer/nanodb
/* print error information */
static void printerr(TCADB *adb){
  const char *path = tcadbpath(adb);
  fprintf(stderr, "%s: %s: error\n", g_progname, path ? path : "-");
}