예제 #1
0
파일: db2.c 프로젝트: zhengshuxin/hamsterdb
int
main(int argc, char **argv) {
  ham_status_t st;
  ham_env_t *env = 0;
  ham_db_t *src_db = 0;
  ham_db_t *dest_db = 0;
  ham_u16_t src_name;
  ham_u16_t dest_name;
  const char *env_path = 0;

  /* check and parse the command line parameters */
  if (argc != 4)
    usage();
  env_path = argv[1];
  src_name = atoi(argv[2]);
  dest_name = atoi(argv[3]);
  if (src_name == 0 || dest_name == 0)
    usage();

  /* open the Environment */
  st = ham_env_open(&env, env_path, 0, 0);
  if (st)
    error("ham_env_open", st);

  /* open the source database */
  st = ham_env_open_db(env, &src_db, src_name, 0, 0);
  if (st)
    error("ham_env_open_db", st);

  /* create the destination database */
  st = ham_env_create_db(env, &dest_db, dest_name,
                  HAM_ENABLE_DUPLICATE_KEYS, 0);
  if (st)
    error("ham_env_create_db", st);

  /* copy the data */
  copy_db(src_db, dest_db);

  /* clean up and return */
  st = ham_env_close(env, HAM_AUTO_CLEANUP);
  if (st)
    error("ham_env_close", st);

  printf("\nsuccess!\n");
  return (0);
}
예제 #2
0
파일: test-gom-find.c 프로젝트: GNOME/gom
static void
find (void)
{
   GomAdapter *adapter;
   gboolean success = FALSE;
   char *uri;

   /* Copy the DB to a temp file to avoid modifying the
    * git repo */
   uri = copy_db();

   adapter = gom_adapter_new();
   gom_adapter_open_async(adapter, uri, open_cb, &success);
   g_free (uri);
   g_object_unref(adapter);

   g_main_loop_run(gMainLoop);

   g_assert(success);
}