예제 #1
0
int main(int argc, char **argv)
{
/* if you want to mount a file with a password */
    sqlfs_init("/tmp/fsdata");

/* if you want to mount a file with a password */
//    sqlfs_init_key("tests/.tests/c_thread_api_key.db",
//                   "mysupersecretpassword");

    return sqlfs_fuse_main(argc, argv);
}
예제 #2
0
파일: main.c 프로젝트: AlexandrMov/SQLFuse
int main (int argc, char **argv)
{
  int res = 0;
  struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
  sqlprofile = g_try_new0(struct sqlprofile, 1);
  g_mutex_init(&cache.m);
  
  cache.open_table = g_hash_table_new_full(g_int64_hash, g_int64_equal,
					   g_free, free_sqlfs_file);

  if (fuse_opt_parse(&args, sqlprofile, sqlfs_opts, sqlfs_opt_proc) == -1)
    res = 1;

  if (!res && !sqlprofile->profile)
    res = 1;

  if (!res) {
    GError *terr = NULL;
    
    init_keyfile(sqlprofile->profile, &terr);
    if (terr != NULL)
      res = 1;
    
    if (!res) {
      init_cache(&terr);
      
      if (terr != NULL)
	res = 2;
    }

    if (!res) {
      res = sqlfs_fuse_main(&args);
      fuse_opt_free_args(&args);

      if (terr != NULL)
	res = 3;
    }

    if (!res || res > 2)
      destroy_cache(&terr);

    if (!res || res > 1)
      close_keyfile();

    if (sqlprofile != NULL) {
      if (sqlprofile->profile != NULL)
	g_free(sqlprofile->profile);

      g_free(sqlprofile);
    }

    if (terr != NULL) {
      g_error("Position %d - #%d: %s",
		res, terr->code, terr->message);
      g_error_free(terr);
    }
  }
  else {
    g_error("Position %d - #%d: %s",
	    res, 0, "Invalid arguments");
  }

  g_hash_table_destroy(cache.open_table);
  
  g_mutex_clear(&cache.m);
  
  return res;
}