예제 #1
0
// Returns 0 if no match, 1 if a match
static int obj_dir_test(object_attr_t *o, object_attr_t *obj)
{
	// We allow a special 'systemdirs' macro
	if ((o->len == 10) && strcmp(o->o, "systemdirs") == 0)
		return check_dirs(0, obj->o);
	// Execdirs doesn't have /etc in its list
	else if ((o->len == 8) && strcmp(o->o, "execdirs") == 0)
		return check_dirs(1, obj->o);
	else if ((o->len == 10) && strcasecmp(o->o, "unpackaged") == 0) {
		if (check_packaged_from_file(obj->o))
			return 0;
	// Just a normal dir test
	} else if (strncmp(obj->o, o->o, o->len))
		return 0;

	return 1;
}
예제 #2
0
// Returns 0 if no match, 1 if a match
static int subj_dir_test(subject_attr_t *s, subject_attr_t *subj)
{
	unsigned int len = strlen(s->str);

	// We allow a special 'systemdirs' macro
	if ((len == 10) && strcmp(s->str, "systemdirs") == 0)
		return check_dirs(0, subj->str);

	// Execdirs doesn't have /etc in its list
	else if ((len == 8) && strcmp(s->str, "execdirs") == 0)
		return check_dirs(1, subj->str);
	else if ((len == 10) && strcasecmp(s->str, "unpackaged") == 0) {
		if (check_packaged_from_file(subj->str))
			return 0;

	// Just a normal dir test.
	} else if (strncmp(subj->str, s->str, len))
		return 0;
	return 1;
}
예제 #3
0
/* Save the actions treeview to DATADIR/clipit/actions */
static void save_actions()
{
  /* Check config and data directories */
  check_dirs();
  /* Open the file for writing */
  gchar* path = g_build_filename(g_get_user_data_dir(), ACTIONS_FILE, NULL);
  FILE* actions_file = fopen(path, "wb");
  g_free(path);
  /* Check that it opened and begin write */
  if (actions_file)
  {
    GtkTreeIter action_iter;
    /* Get and check if there's a first iter */
    if (gtk_tree_model_get_iter_first((GtkTreeModel*)actions_list, &action_iter))
    {
      do
      {
        /* Get name and command */
        gchar *name, *command;
        gtk_tree_model_get((GtkTreeModel*)actions_list, &action_iter, 0, &name, 1, &command, -1);
        GString* s_name = g_string_new(name);
        GString* s_command = g_string_new(command);
        g_free(name);
        g_free(command);
        /* Check that there's text to save */
        if ((s_name->len == 0) || (s_command->len == 0))
        {
          /* Free strings and skip iteration */
          g_string_free(s_name, TRUE);
          g_string_free(s_command, TRUE);
          continue;
        }
        else
        {
          /* Save action */
          fwrite(&(s_name->len), 4, 1, actions_file);
          fputs(s_name->str, actions_file);
          fwrite(&(s_command->len), 4, 1, actions_file);
          fputs(s_command->str, actions_file);
          /* Free strings */
          g_string_free(s_name, TRUE);
          g_string_free(s_command, TRUE);
        }
      }
      while(gtk_tree_model_iter_next((GtkTreeModel*)actions_list, &action_iter));
    }
    /* End of file write */
    gint end = 0;
    fwrite(&end, 4, 1, actions_file);
    fclose(actions_file);
  }
}
예제 #4
0
int valid_leave(object me, string dir)
{
	if (check_dirs(me, dir))
		return notify_fail("��ȶ��˻��أ�����ɮ�ࡣ\n");

	if (me->query_temp("/bagua/count") == 18)
	{
		me->delete_temp("bagua");
		me->move(__DIR__"bagua");
		return notify_fail("��ȶ��˻��أ��������ҡ�\n");
	}
	return ::valid_leave(me, dir);
}
예제 #5
0
void load_config(god_t* god){
	check_dirs();

	char *home_dir = getenv("HOME");
	char *conf_file = "/.local/share/crunchball/crunchball.cfg";
	char tmp_path[500] = {0};
	
	cp_str(tmp_path, home_dir);	
	cat_to_str(tmp_path, conf_file);

	long int video_mode;
	long int audio_level;
	long int fullscreen;
	long int high_score;

	cfg_opt_t opts[] = {
		CFG_SIMPLE_INT("video_mode", &video_mode),
		CFG_SIMPLE_INT("audio_level", &audio_level),
		CFG_SIMPLE_INT("fullscreen", &fullscreen),
		CFG_SIMPLE_INT("high_score", &high_score),
		CFG_END()
	};
	cfg_t *cfg;

	cfg = cfg_init(opts, 0);
	int rc = cfg_parse(cfg, tmp_path);

	if ( rc != 0 ){
		video_mode = 2;
		audio_level = 5;
		fullscreen = 0;
		high_score = 0;
	}
	
	if (video_mode == 0)
		video_mode = 2;

	god->scalar.scale = video_mode;
	god->state.settings_volume = audio_level;
	god->state.high_score = high_score;
	god->scalar.fs = fullscreen;
	
	FILE *fp = fopen(tmp_path, "w");
	cfg_print(cfg, fp);

	fclose(fp);

	cfg_free(cfg);

}
예제 #6
0
/* Save the actions treeview to DATADIR/clipit/excludes */
static void save_excludes()
{
  /* Check config and data directories */
  check_dirs();
  /* Open the file for writing */
  gchar* path = g_build_filename(g_get_user_data_dir(), EXCLUDES_FILE, NULL);
  FILE* excludes_file = fopen(path, "wb");
  g_free(path);
  /* Check that it opened and begin write */
  if (excludes_file)
  {
    GtkTreeIter action_iter;
    /* Get and check if there's a first iter */
    if (gtk_tree_model_get_iter_first((GtkTreeModel*)exclude_list, &action_iter))
    {
      do
      {
        /* Get name and command */
        gchar *regex;
        gtk_tree_model_get((GtkTreeModel*)exclude_list, &action_iter, 0, &regex, -1);
        GString* s_regex = g_string_new(regex);
        g_free(regex);
        /* Check that there's text to save */
        if (s_regex->len == 0)
        {
          /* Free strings and skip iteration */
          g_string_free(s_regex, TRUE);
          continue;
        }
        else
        {
          /* Save action */
          fwrite(&(s_regex->len), 4, 1, excludes_file);
          fputs(s_regex->str, excludes_file);
          /* Free strings */
          g_string_free(s_regex, TRUE);
        }
      }
      while(gtk_tree_model_iter_next((GtkTreeModel*)exclude_list, &action_iter));
    }
    /* End of file write */
    gint end = 0;
    fwrite(&end, 4, 1, excludes_file);
    fclose(excludes_file);
  }
}
예제 #7
0
/* Save preferences to CONFIGDIR/clipit/clipitrc */
void save_preferences()
{
  /* Create key */
  GKeyFile* rc_key = g_key_file_new();
  
  /* Add values */
  g_key_file_set_boolean(rc_key, "rc", "use_copy", prefs.use_copy);
  g_key_file_set_boolean(rc_key, "rc", "use_primary", prefs.use_primary);
  g_key_file_set_boolean(rc_key, "rc", "synchronize", prefs.synchronize);
  g_key_file_set_boolean(rc_key, "rc", "automatic_paste", prefs.automatic_paste);
  g_key_file_set_boolean(rc_key, "rc", "show_indexes", prefs.show_indexes);
  g_key_file_set_boolean(rc_key, "rc", "save_uris", prefs.save_uris);
  g_key_file_set_boolean(rc_key, "rc", "use_rmb_menu", prefs.use_rmb_menu);
  g_key_file_set_boolean(rc_key, "rc", "save_history", prefs.save_history);
  g_key_file_set_integer(rc_key, "rc", "history_limit", prefs.history_limit);
  g_key_file_set_integer(rc_key, "rc", "items_menu", prefs.items_menu);
  g_key_file_set_boolean(rc_key, "rc", "statics_show", prefs.statics_show);
  g_key_file_set_integer(rc_key, "rc", "statics_items", prefs.statics_items);
  g_key_file_set_boolean(rc_key, "rc", "hyperlinks_only", prefs.hyperlinks_only);
  g_key_file_set_boolean(rc_key, "rc", "confirm_clear", prefs.confirm_clear);
  g_key_file_set_boolean(rc_key, "rc", "single_line", prefs.single_line);
  g_key_file_set_boolean(rc_key, "rc", "reverse_history", prefs.reverse_history);
  g_key_file_set_integer(rc_key, "rc", "item_length", prefs.item_length);
  g_key_file_set_integer(rc_key, "rc", "ellipsize", prefs.ellipsize);
  g_key_file_set_string(rc_key, "rc", "history_key", prefs.history_key);
  g_key_file_set_string(rc_key, "rc", "actions_key", prefs.actions_key);
  g_key_file_set_string(rc_key, "rc", "menu_key", prefs.menu_key);
  g_key_file_set_string(rc_key, "rc", "search_key", prefs.search_key);
  g_key_file_set_string(rc_key, "rc", "offline_key", prefs.offline_key);
  g_key_file_set_boolean(rc_key, "rc", "offline_mode", prefs.offline_mode);
  
  /* Check config and data directories */
  check_dirs();
  /* Save key to file */
  gchar* rc_file = g_build_filename(g_get_user_config_dir(), PREFERENCES_FILE, NULL);
  g_file_set_contents(rc_file, g_key_file_to_data(rc_key, NULL, NULL), -1, NULL);
  g_key_file_free(rc_key);
  g_free(rc_file);
}
예제 #8
0
파일: bagua6.c 프로젝트: heypnus/xkx2001
int valid_leave(object me, string dir)
{
	if (check_dirs(me, dir))
		return notify_fail("��ȶ��˻��أ�����ɮ�ࡣ\n");
	return ::valid_leave(me, dir);
}