コード例 #1
0
ファイル: setup.c プロジェクト: CyberShadow/mc
void
done_setup (void)
{
    size_t i;

    g_free (clipboard_store_path);
    g_free (clipboard_paste_path);
    g_free (global_profile_name);
    g_free (mc_global.tty.color_terminal_string);
    g_free (mc_global.tty.term_color_string);
    g_free (mc_global.tty.setup_color_string);
    g_free (profile_name);
    g_free (panels_profile_name);
    mc_config_deinit (mc_main_config);
    mc_config_deinit (mc_panels_config);

    g_free (user_recent_timeformat);
    g_free (user_old_timeformat);

    for (i = 0; str_options[i].opt_name != NULL; i++)
        g_free (*str_options[i].opt_addr);

    done_hotlist ();
    done_panelize ();
    /*    directory_history_free (); */

#ifdef HAVE_CHARSET
    g_free (autodetect_codeset);
    free_codepages_list ();
#endif

#ifdef HAVE_ASPELL
    g_free (spell_language);
#endif /* HAVE_ASPELL */
}
コード例 #2
0
ファイル: setup.c プロジェクト: CyberShadow/mc
static void
setup__move_panels_config_into_separate_file (const char *profile)
{
    mc_config_t *tmp_cfg;
    char **groups, **curr_grp;

    if (!exist_file (profile))
        return;

    tmp_cfg = mc_config_init (profile, FALSE);
    if (!tmp_cfg)
        return;

    curr_grp = groups = mc_config_get_groups (tmp_cfg, NULL);
    if (!groups)
    {
        mc_config_deinit (tmp_cfg);
        return;
    }

    while (*curr_grp)
    {
        if (setup__is_cfg_group_must_panel_config (*curr_grp) == NULL)
            mc_config_del_group (tmp_cfg, *curr_grp);
        curr_grp++;
    }

    mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL);
    mc_config_deinit (tmp_cfg);

    tmp_cfg = mc_config_init (profile, FALSE);
    if (!tmp_cfg)
    {
        g_strfreev (groups);
        return;
    }

    curr_grp = groups;

    while (*curr_grp)
    {
        const char *need_grp;

        need_grp = setup__is_cfg_group_must_panel_config (*curr_grp);
        if (need_grp != NULL)
        {
            mc_config_del_group (tmp_cfg, need_grp);
        }
        curr_grp++;
    }
    g_strfreev (groups);

    mc_config_save_file (tmp_cfg, NULL);
    mc_config_deinit (tmp_cfg);
}
コード例 #3
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
/**
  * Write history to the ${XDG_CACHE_HOME}/mc/history file
  */
void
dlg_save_history (WDialog * h)
{
    char *profile;
    int i;

    if (num_history_items_recorded == 0)        /* this is how to disable */
        return;

    profile = mc_config_get_full_path (MC_HISTORY_FILE);
    i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
    if (i != -1)
        close (i);

    /* Make sure the history is only readable by the user */
    if (chmod (profile, S_IRUSR | S_IWUSR) != -1 || errno == ENOENT)
    {
        ev_history_load_save_t event_data;

        event_data.cfg = mc_config_init (profile, FALSE);
        event_data.receiver = NULL;

        /* get all histories in dialog */
        mc_event_raise (h->event_group, MCEVENT_HISTORY_SAVE, &event_data);

        mc_config_save_file (event_data.cfg, NULL);
        mc_config_deinit (event_data.cfg);
    }

    g_free (profile);
}
コード例 #4
0
ファイル: common.c プロジェクト: sfionov/mc-dev
gboolean
mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path)
{
    mc_config_t *tmp_config;
    gchar **groups, **curr_grp;
    gchar **keys, **curr_key;
    gchar *value;

    if (mc_config == NULL) {
        return FALSE;
    }

    tmp_config = mc_config_init (ini_path);
    if (tmp_config == NULL)
        return FALSE;

    groups = mc_config_get_groups (tmp_config, NULL);

    for (curr_grp = groups; *curr_grp != NULL; curr_grp++) {
        keys = mc_config_get_keys (tmp_config, *curr_grp, NULL);
        for (curr_key = keys; *curr_key != NULL; curr_key++) {
            value = g_key_file_get_value (tmp_config->handle, *curr_grp, *curr_key, NULL);
            if (value == NULL)
                continue;

            g_key_file_set_value (mc_config->handle, *curr_grp, *curr_key, value);
            g_free (value);
        }
        g_strfreev (keys);
    }
    g_strfreev (groups);
    mc_config_deinit (tmp_config);
    return TRUE;
}
コード例 #5
0
ファイル: common.c プロジェクト: Chainie/mc
gboolean
mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
                     gboolean remove_empty)
{
    mc_config_t *tmp_config;
    gchar **groups, **curr_grp;
    gchar **keys, **curr_key;
    gchar *value;

    if (mc_config == NULL)
        return FALSE;

    tmp_config = mc_config_init (ini_path, read_only);
    if (tmp_config == NULL)
        return FALSE;

    groups = mc_config_get_groups (tmp_config, NULL);

    if (groups == NULL)
    {
        mc_config_deinit (tmp_config);
        return FALSE;
    }

    for (curr_grp = groups; *curr_grp != NULL; curr_grp++)
    {
        keys = mc_config_get_keys (tmp_config, *curr_grp, NULL);
        for (curr_key = keys; *curr_key != NULL; curr_key++)
        {
            value = g_key_file_get_value (tmp_config->handle, *curr_grp, *curr_key, NULL);
            if (value != NULL)
            {
                if (*value == '\0' && remove_empty)
                    g_key_file_remove_key (mc_config->handle, *curr_grp, *curr_key, NULL);
                else
                    g_key_file_set_value (mc_config->handle, *curr_grp, *curr_key, value);
                g_free (value);
            }
            else if (remove_empty)
                g_key_file_remove_key (mc_config->handle, *curr_grp, *curr_key, NULL);
        }
        g_strfreev (keys);
    }
    g_strfreev (groups);
    mc_config_deinit (tmp_config);
    return TRUE;
}
コード例 #6
0
ファイル: common.c プロジェクト: MidnightCommander/mc
void
mc_fhl_clear (mc_fhl_t * fhl)
{
    if (fhl != NULL)
    {
        mc_config_deinit (fhl->config);
        mc_fhl_array_free (fhl);
    }
}
コード例 #7
0
ファイル: config_string.c プロジェクト: 3333333/mc
END_TEST

/* --------------------------------------------------------------------------------------------- */

START_TEST (emulate__learn_save)
{
    mc_config_t *mc_config;
    char *actual_value, *esc_str;
    char *ini_filename = NULL;
    GError *error = NULL;

    ini_filename = g_build_filename(WORKDIR, "test-emulate__learn_save.ini",NULL);
    unlink(ini_filename);

    mc_config = mc_config_init (ini_filename, FALSE);
    if (mc_config == NULL)
    {
        fail("unable to create mc_congif_t object!");
        return;
    }

    esc_str = strutils_escape ("T;E\\X;T-FOR-\\T;E;S\\TI;N'G", -1, ";", TRUE);
    mc_config_set_string_raw (mc_config, "test-group1", "test-param1", esc_str);
    g_free (esc_str);

    if (!mc_config_save_file (mc_config, &error))
    {
        fail("Unable to save config file: %s",error->message);
        g_error_free(error);
    }

    mc_config_deinit (mc_config);
    mc_config = mc_config_init (ini_filename, FALSE);

    actual_value = mc_config_get_string_raw( mc_config, "test-group1", "test-param1", "not-exists");
    fail_unless_strcmp("T\\;E\\X\\;T-FOR-\\T\\;E\\;S\\TI\\;N'G");
    g_free(actual_value);

    mc_config_deinit (mc_config);
    g_free(ini_filename);
}
コード例 #8
0
ファイル: config_string.c プロジェクト: MidnightCommander/mc
static void
config_object__reopen (void)
{
    GError *error = NULL;

    if (!mc_config_save_file (mc_config, &error))
    {
        fail ("Unable to save config file: %s", error->message);
        g_error_free (error);
    }

    mc_config_deinit (mc_config);
    mc_config = mc_config_init (ini_filename, FALSE);
}
コード例 #9
0
ファイル: common.c プロジェクト: BpArCuCTeMbI/mc
void
mc_skin_deinit (void)
{
    tty_color_free_all_tmp ();
    tty_color_free_all_non_tmp ();

    MC_PTR_FREE (mc_skin__default.name);
    g_hash_table_destroy (mc_skin__default.colors);
    mc_skin__default.colors = NULL;

    MC_PTR_FREE (mc_skin__default.description);

    mc_config_deinit (mc_skin__default.config);
    mc_skin__default.config = NULL;

    mc_skin_is_init = FALSE;
}
コード例 #10
0
ファイル: serialize.c プロジェクト: LubkaB/mc
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST
/* *INDENT-ON* */

/* --------------------------------------------------------------------------------------------- */

/* *INDENT-OFF* */
START_TEST (test_deserialize_config)
/* *INDENT-ON* */
{
    /* given */
    mc_config_t *actual;
    char *actual_value;

    /* when */
    actual = mc_deserialize_config (deserialize_input_value1, &error);

    /* then */
    mctest_assert_not_null (actual);

    actual_value = mc_config_get_string_raw (actual, "group1", "param1", "");
    mctest_assert_str_eq (actual_value, "some value");
    g_free (actual_value);

    actual_value = mc_config_get_string (actual, "group1", "param2", "");
    mctest_assert_str_eq (actual_value, "some value ");
    g_free (actual_value);

    mctest_assert_int_eq (mc_config_get_bool (actual, "group2", "param1", FALSE), TRUE);

    mctest_assert_int_eq (mc_config_get_int (actual, "group2", "param2", 0), 123456);

    actual_value = mc_config_get_string_raw (actual, "group3", "param1", "");
    mctest_assert_str_eq (actual_value, "::bla-bla::");
    g_free (actual_value);

    actual_value = mc_config_get_string (actual, "group3", "param2", "");
    mctest_assert_str_eq (actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n");
    g_free (actual_value);

    mctest_assert_int_eq (mc_config_get_bool (actual, "group4", "param1", TRUE), FALSE);

    mctest_assert_int_eq (mc_config_get_int (actual, "group4", "param2", 0), 654321);

    mc_config_deinit (actual);
}
コード例 #11
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
/**
  * Read histories from the ${XDG_CACHE_HOME}/mc/history file
  */
static void
dlg_read_history (WDialog * h)
{
    char *profile;
    ev_history_load_save_t event_data;

    if (num_history_items_recorded == 0)        /* this is how to disable */
        return;

    profile = mc_config_get_full_path (MC_HISTORY_FILE);
    event_data.cfg = mc_config_init (profile, TRUE);
    event_data.receiver = NULL;

    /* create all histories in dialog */
    mc_event_raise (h->event_group, MCEVENT_HISTORY_LOAD, &event_data);

    mc_config_deinit (event_data.cfg);
    g_free (profile);
}
コード例 #12
0
ファイル: serialize.c プロジェクト: artzub/mc
END_TEST

/* --------------------------------------------------------------------------------------------- */

#define etalon_str "g6:group1p6:param1v10:some valuep6:param2v11:some value " \
   "g6:group2p6:param1v4:truep6:param2v6:123456" \
   "g6:group3p6:param1v11:::bla-bla::p6:param2v31:bla-:p1:w:v2:12:g3:123:bla-bla\n" \
   "g6:group4p6:param1v5:falsep6:param2v6:654321"

START_TEST (test_serialize_config)
{
    mc_config_t *test_data;
    GError *error = NULL;
    char *actual;

    test_data = mc_config_init (NULL);

    mc_config_set_string_raw (test_data, "group1", "param1", "some value");
    mc_config_set_string (test_data, "group1", "param2", "some value ");

    mc_config_set_bool (test_data, "group2", "param1", TRUE);
    mc_config_set_int (test_data, "group2", "param2", 123456);

    mc_config_set_string_raw (test_data, "group3", "param1", "::bla-bla::");
    mc_config_set_string (test_data, "group3", "param2", "bla-:p1:w:v2:12:g3:123:bla-bla\n");

    mc_config_set_bool (test_data, "group4", "param1", FALSE);
    mc_config_set_int (test_data, "group4", "param2", 654321);

    actual = mc_serialize_config (test_data, &error);
    mc_config_deinit (test_data);

    if (actual == NULL)
    {
        fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
        g_clear_error(&error);
        return;
    }

    fail_unless(strcmp(actual, etalon_str) == 0, "Not equal:\nactual (%s)\netalon (%s)", actual, etalon_str);
    g_free(actual);
}
コード例 #13
0
ファイル: setup.c プロジェクト: CyberShadow/mc
void
load_key_defs (void)
{
    /*
     * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
     * definitions override global settings.
     */
    mc_config_t *mc_global_config;

    mc_global_config = mc_config_init (global_profile_name, FALSE);
    if (mc_global_config != NULL)
    {
        load_keys_from_section ("general", mc_global_config);
        load_keys_from_section (getenv ("TERM"), mc_global_config);
        mc_config_deinit (mc_global_config);
    }

    load_keys_from_section ("general", mc_main_config);
    load_keys_from_section (getenv ("TERM"), mc_main_config);
}
コード例 #14
0
ファイル: serialize.c プロジェクト: LubkaB/mc
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST
/* *INDENT-ON* */

/* --------------------------------------------------------------------------------------------- */

/* *INDENT-OFF* */
START_TEST (test_serialize_config)
/* *INDENT-ON* */
{
    /* given */
    mc_config_t *test_data;
    char *actual;
    const char *expected_result = "g6:group1p6:param1v10:some valuep6:param2v11:some value "
        "g6:group2p6:param1v4:truep6:param2v6:123456"
        "g6:group3p6:param1v11:::bla-bla::p6:param2v31:bla-:p1:w:v2:12:g3:123:bla-bla\n"
        "g6:group4p6:param1v5:falsep6:param2v6:654321";

    test_data = mc_config_init (NULL, FALSE);

    mc_config_set_string_raw (test_data, "group1", "param1", "some value");
    mc_config_set_string (test_data, "group1", "param2", "some value ");

    mc_config_set_bool (test_data, "group2", "param1", TRUE);
    mc_config_set_int (test_data, "group2", "param2", 123456);

    mc_config_set_string_raw (test_data, "group3", "param1", "::bla-bla::");
    mc_config_set_string (test_data, "group3", "param2", "bla-:p1:w:v2:12:g3:123:bla-bla\n");

    mc_config_set_bool (test_data, "group4", "param1", FALSE);
    mc_config_set_int (test_data, "group4", "param2", 654321);

    /* when */
    actual = mc_serialize_config (test_data, &error);
    mc_config_deinit (test_data);

    /* then */
    mctest_assert_not_null (actual);
    mctest_assert_str_eq (actual, expected_result);

    g_free (actual);
}
コード例 #15
0
ファイル: history.c プロジェクト: BrEacK/mc
GList *
history_get (const char *input_name)
{
    GList *hist = NULL;
    char *profile;
    mc_config_t *cfg;

    if (num_history_items_recorded == 0)        /* this is how to disable */
        return NULL;
    if ((input_name == NULL) || (*input_name == '\0'))
        return NULL;

    profile = mc_config_get_full_path (MC_HISTORY_FILE);
    cfg = mc_config_init (profile);

    hist = history_load (cfg, input_name);

    mc_config_deinit (cfg);
    g_free (profile);

    return hist;
}
コード例 #16
0
ファイル: execute.c プロジェクト: LubkaB/mc
static char *
execute_get_opts_from_cfg (const char *command, const char *default_str)
{
    char *str_from_config;

    str_from_config =
        mc_config_get_string_raw (mc_main_config, CONFIG_EXT_EDITOR_VIEWER_SECTION, command, NULL);

    if (str_from_config == NULL)
    {
        mc_config_t *cfg;

        cfg = mc_config_init (global_profile_name, TRUE);
        if (cfg == NULL)
            return g_strdup (default_str);

        str_from_config =
            mc_config_get_string_raw (cfg, CONFIG_EXT_EDITOR_VIEWER_SECTION, command, default_str);

        mc_config_deinit (cfg);
    }

    return str_from_config;
}
コード例 #17
0
ファイル: setup.c プロジェクト: CyberShadow/mc
void
load_keymap_defs (gboolean load_from_file)
{
    /*
     * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
     * definitions override global settings.
     */
    mc_config_t *mc_global_keymap;

    mc_global_keymap = load_setup_get_keymap_profile_config (load_from_file);

    if (mc_global_keymap != NULL)
    {
        main_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_MAIN, main_keymap, mc_global_keymap);
        main_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_MAIN_EXT, main_x_keymap, mc_global_keymap);

        panel_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_PANEL, panel_keymap, mc_global_keymap);

        dialog_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_DIALOG, dialog_keymap, mc_global_keymap);

        input_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_INPUT, input_keymap, mc_global_keymap);

        listbox_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_LISTBOX, listbox_keymap, mc_global_keymap);

        tree_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_TREE, tree_keymap, mc_global_keymap);

        help_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_HELP, help_keymap, mc_global_keymap);

#ifdef USE_INTERNAL_EDIT
        editor_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_EDITOR, editor_keymap, mc_global_keymap);
        editor_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_EDITOR_EXT, editor_x_keymap, mc_global_keymap);
#endif

        viewer_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_VIEWER, viewer_keymap, mc_global_keymap);
        viewer_hex_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_VIEWER_HEX, viewer_hex_keymap, mc_global_keymap);

#ifdef USE_DIFF_VIEW
        diff_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section (KEYMAP_SECTION_DIFFVIEWER, diff_keymap, mc_global_keymap);
#endif

        mc_config_deinit (mc_global_keymap);
    }

    main_map = (global_keymap_t *) main_keymap->data;
    main_x_map = (global_keymap_t *) main_x_keymap->data;
    panel_map = (global_keymap_t *) panel_keymap->data;
    dialog_map = (global_keymap_t *) dialog_keymap->data;
    input_map = (global_keymap_t *) input_keymap->data;
    listbox_map = (global_keymap_t *) listbox_keymap->data;
    tree_map = (global_keymap_t *) tree_keymap->data;
    help_map = (global_keymap_t *) help_keymap->data;
#ifdef USE_INTERNAL_EDIT
    editor_map = (global_keymap_t *) editor_keymap->data;
    editor_x_map = (global_keymap_t *) editor_x_keymap->data;
#endif
    viewer_map = (global_keymap_t *) viewer_keymap->data;
    viewer_hex_map = (global_keymap_t *) viewer_hex_keymap->data;
#ifdef USE_DIFF_VIEW
    diff_map = (global_keymap_t *) diff_keymap->data;
#endif
}
コード例 #18
0
ファイル: config_string.c プロジェクト: MidnightCommander/mc
static void
config_object__deinit (void)
{
    mc_config_deinit (mc_config);
    g_free (ini_filename);
}
コード例 #19
0
ファイル: serialize.c プロジェクト: artzub/mc
END_TEST

/* --------------------------------------------------------------------------------------------- */

#undef deserialize_check_incorrect
#define deserialize_check_incorrect( etalon_code, etalon_str ) { \
    if (actual != NULL) \
    { \
        fail("actual value but should be NULL", actual); \
        mc_config_deinit(actual); \
    } \
    else \
    { \
        fail_unless (error->code == etalon_code && strcmp(error->message, etalon_str) == 0, \
            "\nerror code is %d (should be %d);\nerror message is '%s' (should be '%s')", \
            error->code, etalon_code, error->message, etalon_str); \
        g_clear_error(&error); \
    } \
}

START_TEST (test_deserialize_config)
{
    mc_config_t *actual;
    GError *error = NULL;
    char *actual_value;

    actual = mc_deserialize_config ("g123error in group name", &error);
    deserialize_check_incorrect( -3,
        "mc_deserialize_config() at 1: mc_serialize_str(): Length delimiter ':' doesn't exists");

    actual = mc_deserialize_config ("p6:param1v10:some valuep6:param2v11:some value ", &error);
    deserialize_check_incorrect( -2,
        "mc_deserialize_config() at 1: mc_serialize_str(): String prefix doesn't equal to 'g'");

    actual = mc_deserialize_config ("g6:group1v10:some valuep6:param2v11:some value ", &error);
    deserialize_check_incorrect( -2,
        "mc_deserialize_config() at 10: mc_serialize_str(): String prefix doesn't equal to 'p'");

    actual = mc_deserialize_config ("g6:group1p6000:param2v11:some value ", &error);
    deserialize_check_incorrect( -3,
        "mc_deserialize_config() at 10: mc_serialize_str(): Specified data length (6000) is greater than actual data length (21)");

    actual = mc_deserialize_config (etalon_str, &error);

    if (actual == NULL)
    {
        fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
        g_clear_error(&error);
        return;
    }

    actual_value = mc_config_get_string_raw(actual, "group1", "param1", "");
    fail_unless( strcmp(actual_value, "some value") == 0,
        "group1->param1(%s) should be equal to 'some value'", actual_value);
    g_free(actual_value);

    actual_value = mc_config_get_string(actual, "group1", "param2", "");
    fail_unless( strcmp(actual_value, "some value ") == 0,
        "group1->param2(%s) should be equal to 'some value '", actual_value);
    g_free(actual_value);

    fail_unless( mc_config_get_bool(actual, "group2", "param1", FALSE) == TRUE,
        "group2->param1(FALSE) should be equal to TRUE");

    fail_unless( mc_config_get_int(actual, "group2", "param2", 0) == 123456,
        "group2->param2(%d) should be equal to 123456", mc_config_get_int(actual, "group2", "param2", 0));

    actual_value = mc_config_get_string_raw(actual, "group3", "param1", "");
    fail_unless( strcmp(actual_value, "::bla-bla::") == 0,
        "group3->param1(%s) should be equal to '::bla-bla::'", actual_value);
    g_free(actual_value);

    actual_value = mc_config_get_string(actual, "group3", "param2", "");
    fail_unless( strcmp(actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n") == 0,
        "group3->param2(%s) should be equal to 'bla-:p1:w:v2:12:g3:123:bla-bla\n'", actual_value);
    g_free(actual_value);

    fail_unless( mc_config_get_bool(actual, "group4", "param1", TRUE) == FALSE,
        "group4->param1(TRUE) should be equal to FALSE");

    fail_unless( mc_config_get_int(actual, "group4", "param2", 0) == 654321,
        "group4->param2(%d) should be equal to 654321", mc_config_get_int(actual, "group4", "param2", 0));

    mc_config_deinit (actual);
}
コード例 #20
0
void
load_keymap_defs (void)
{
    /*
     * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_DATA_HOME}/mc/keymap, so that the user
     * definitions override global settings.
     */
    mc_config_t *mc_global_keymap;

    mc_global_keymap = load_setup_get_keymap_profile_config ();

    if (mc_global_keymap != NULL)
    {
#ifdef USE_INTERNAL_EDIT
        editor_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("editor", editor_keymap, mc_global_keymap);
        editor_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("editor:xmap", editor_x_keymap, mc_global_keymap);
#endif

        viewer_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("viewer", viewer_keymap, mc_global_keymap);
        viewer_hex_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("viewer:hex", viewer_hex_keymap, mc_global_keymap);

        main_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("main", main_keymap, mc_global_keymap);
        main_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("main:xmap", main_x_keymap, mc_global_keymap);

        panel_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("panel", panel_keymap, mc_global_keymap);

        input_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("input", input_keymap, mc_global_keymap);

        listbox_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("listbox", listbox_keymap, mc_global_keymap);

        tree_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("tree", tree_keymap, mc_global_keymap);

        help_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("help", help_keymap, mc_global_keymap);

        dialog_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("dialog", dialog_keymap, mc_global_keymap);

#ifdef USE_DIFF_VIEW
        diff_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
        load_keymap_from_section ("diffviewer", diff_keymap, mc_global_keymap);
#endif
        mc_config_deinit (mc_global_keymap);
    }

    main_map = default_main_map;
    if (main_keymap && main_keymap->len > 0)
        main_map = (global_keymap_t *) main_keymap->data;

    main_x_map = default_main_x_map;
    if (main_x_keymap && main_x_keymap->len > 0)
        main_x_map = (global_keymap_t *) main_x_keymap->data;

    panel_map = default_panel_keymap;
    if (panel_keymap && panel_keymap->len > 0)
        panel_map = (global_keymap_t *) panel_keymap->data;

    input_map = default_input_keymap;
    if (input_keymap && input_keymap->len > 0)
        input_map = (global_keymap_t *) input_keymap->data;

    listbox_map = default_listbox_keymap;
    if (listbox_keymap && listbox_keymap->len > 0)
        listbox_map = (global_keymap_t *) listbox_keymap->data;

    tree_map = default_tree_keymap;
    if (tree_keymap && tree_keymap->len > 0)
        tree_map = (global_keymap_t *) tree_keymap->data;

    help_map = default_help_keymap;
    if (help_keymap && help_keymap->len > 0)
        help_map = (global_keymap_t *) help_keymap->data;

    dialog_map = default_dialog_keymap;
    if (dialog_keymap && dialog_keymap->len > 0)
        dialog_map = (global_keymap_t *) dialog_keymap->data;

#ifdef USE_DIFF_VIEW
    diff_map = default_diff_keymap;
    if (diff_keymap && diff_keymap->len > 0)
        diff_map = (global_keymap_t *) diff_keymap->data;
#endif

}